Class: Multicard::Client
- Inherits:
-
Object
- Object
- Multicard::Client
- Defined in:
- lib/multicard/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#authenticated_request(method, path, body: nil, params: nil) ⇒ Response
Execute an authenticated API request.
- #cards ⇒ Object
- #holds ⇒ Object
-
#initialize(**options) ⇒ Client
constructor
A new instance of Client.
-
#invoices ⇒ Object
Resource accessors (lazy-initialized).
- #payments ⇒ Object
- #payouts ⇒ Object
- #registry ⇒ Object
Constructor Details
#initialize(**options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/multicard/client.rb', line 7 def initialize(**) @config = if Multicard.configuration Multicard.configuration.merge() else Configuration.new(**) end @config.validate! @http_client = HttpClient.new(@config) @token_manager = TokenManager.new(@http_client, @config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/multicard/client.rb', line 5 def config @config end |
Instance Method Details
#authenticated_request(method, path, body: nil, params: nil) ⇒ Response
Execute an authenticated API request. Automatically retries once on 401.
33 34 35 36 37 38 |
# File 'lib/multicard/client.rb', line 33 def authenticated_request(method, path, body: nil, params: nil) execute_authenticated(method, path, body: body, params: params) rescue AuthenticationError @token_manager.reset! execute_authenticated(method, path, body: body, params: params) end |
#cards ⇒ Object
21 |
# File 'lib/multicard/client.rb', line 21 def cards = @cards ||= Resources::Cards.new(self) |
#holds ⇒ Object
22 |
# File 'lib/multicard/client.rb', line 22 def holds = @holds ||= Resources::Holds.new(self) |
#invoices ⇒ Object
Resource accessors (lazy-initialized)
19 |
# File 'lib/multicard/client.rb', line 19 def invoices = @invoices ||= Resources::Invoices.new(self) |
#payments ⇒ Object
20 |
# File 'lib/multicard/client.rb', line 20 def payments = @payments ||= Resources::Payments.new(self) |