Sha256: c113d61626d5c4cbadd5106c1fb49f8494c00fdd2eb382db143aa1572d6c144b

Contents?: true

Size: 548 Bytes

Versions: 5

Compression:

Stored size: 548 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

5 entries across 5 versions & 1 rubygems

Version Path
perfect_audit-0.2.2 lib/perfect_audit/connection.rb
perfect_audit-0.2.1 lib/perfect_audit/connection.rb
perfect_audit-0.2.0 lib/perfect_audit/connection.rb
perfect_audit-0.1.5 lib/perfect_audit/connection.rb
perfect_audit-0.1.4 lib/perfect_audit/connection.rb