Sha256: 967a17861425f96e5eed23085156b685cd9bcf4b8696d091a79cde4f5213692d
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Affirm class Client attr_reader :connection attr_reader :url_prefix private :url_prefix class << self def request(method, path, data={}) new.public_send(method, path, data) end end def initialize @url_prefix = "/api/v2" @connection = Faraday.new(Affirm.configuration.endpoint) do |conn| conn.basic_auth(basic_auth_user, basic_auth_password) conn.request :json conn.response :json, content_type: /\bjson$/ conn.adapter Faraday.default_adapter end end def get(path, data={}) connection.get(normalized_path(path), data) end def post(path, data={}) connection.post(normalized_path(path), data) end private def basic_auth_user Affirm.configuration.public_api_key end def basic_auth_password Affirm.configuration.private_api_key end def normalized_path(path) url_prefix + normalize_path(path) end def normalize_path(path) Faraday::Utils.normalize_path(path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
affirm-ruby-1.1.3 | lib/affirm/client.rb |