Sha256: 7f08c43c027f3e3703961324a1f820291069156e0b4978613498d11269dc3149

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

require 'dry-initializer'
require 'http'

module PerfectAudit
  class Connection
    extend Dry::Initializer

    BASE_PATH = 'https://api.ocrolus.com/v1/'

    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.3.2 lib/perfect_audit/connection.rb
perfect_audit-0.3.1 lib/perfect_audit/connection.rb
perfect_audit-0.3.0 lib/perfect_audit/connection.rb