Sha256: 0066f270cde62a648362e3f07101218f28bf5323f07067f7e69f28247f56f6df

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 Bytes

Contents

require 'dry-initializer'
require 'http'

module PerfectAudit
  class Connection
    extend Dry::Initializer

    BASE_PATH = 'https://www.perfectaudit.com/api/v1/'.freeze

    option :api_key
    option :api_secret

    def post(path, params)
      HTTP.basic_auth(:user => api_key, :pass => api_secret).post(url(path), params)
    end

    def get(path, params = {})
      HTTP.basic_auth(:user => api_key, :pass => api_secret).get(url(path), params)
    end

    private

    def url(path)
      URI.join(BASE_PATH, path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perfect_audit-0.1.3 lib/perfect_audit/connection.rb
perfect_audit-0.1.2 lib/perfect_audit/connection.rb
perfect_audit-0.1.1 lib/perfect_audit/connection.rb