Class: Affirm::Client
- Inherits:
-
Object
- Object
- Affirm::Client
- Defined in:
- lib/affirm/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Class Method Summary collapse
Instance Method Summary collapse
- #get(path, **data) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #post(path, **data) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/affirm/client.rb', line 3 def connection @connection end |
Class Method Details
.request(method, path, **data) ⇒ Object
9 10 11 |
# File 'lib/affirm/client.rb', line 9 def request(method, path, **data) new.public_send(method, path, data) end |
Instance Method Details
#get(path, **data) ⇒ Object
24 25 26 |
# File 'lib/affirm/client.rb', line 24 def get(path, **data) connection.get(normalized_path(path), data) end |
#post(path, **data) ⇒ Object
28 29 30 |
# File 'lib/affirm/client.rb', line 28 def post(path, **data) connection.post(normalized_path(path), data) end |