class Affirm::Client

Attributes

connection[R]
url_prefix[R]

Public Class Methods

new() click to toggle source
# File lib/affirm/client.rb, line 14
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
request(method, path, **data) click to toggle source
# File lib/affirm/client.rb, line 9
def request(method, path, **data)
  new.public_send(method, path, data)
end

Public Instance Methods

get(path, **data) click to toggle source
# File lib/affirm/client.rb, line 24
def get(path, **data)
  connection.get(normalized_path(path), data)
end
post(path, **data) click to toggle source
# File lib/affirm/client.rb, line 28
def post(path, **data)
  connection.post(normalized_path(path), data)
end

Private Instance Methods

basic_auth_password() click to toggle source
# File lib/affirm/client.rb, line 38
def basic_auth_password
  Affirm.configuration.private_api_key
end
basic_auth_user() click to toggle source
# File lib/affirm/client.rb, line 34
def basic_auth_user
  Affirm.configuration.public_api_key
end
normalize_path(path) click to toggle source
# File lib/affirm/client.rb, line 46
def normalize_path(path)
  Faraday::Utils.normalize_path(path)
end
normalized_path(path) click to toggle source
# File lib/affirm/client.rb, line 42
def normalized_path(path)
  url_prefix + normalize_path(path)
end