Class: Yookassa::Client
- Inherits:
-
Object
- Object
- Yookassa::Client
- Defined in:
- lib/yookassa/client.rb
Overview
API client that holds configuration and provides access to resource endpoints.
You can use the global client via default_client or create an isolated instance for multi-shop setups.
Instance Attribute Summary collapse
-
#config ⇒ Configuration
readonly
The client's configuration.
Instance Method Summary collapse
-
#deals ⇒ Resources::Deal
Deal resource endpoint.
-
#initialize(shop_id: nil, api_key: nil, auth_token: nil, **options) ⇒ Client
constructor
Creates a new API client.
-
#invoices ⇒ Resources::Invoice
Invoice resource endpoint.
-
#payments ⇒ Resources::Payment
Payment resource endpoint.
-
#payouts ⇒ Resources::Payout
Payout resource endpoint.
-
#receipts ⇒ Resources::Receipt
Receipt resource endpoint.
-
#refunds ⇒ Resources::Refund
Refund resource endpoint.
-
#settings ⇒ Resources::Settings
Shop settings resource endpoint.
-
#webhooks ⇒ Resources::Webhook
Webhook resource endpoint.
Constructor Details
#initialize(shop_id: nil, api_key: nil, auth_token: nil, **options) ⇒ Client
Creates a new API client.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yookassa/client.rb', line 22 def initialize(shop_id: nil, api_key: nil, auth_token: nil, **) @config = Configuration.new @config.shop_id = shop_id @config.api_key = api_key @config.auth_token = auth_token @config.timeout = [:timeout] if .key?(:timeout) @config.max_retries = [:max_retries] if .key?(:max_retries) @config.retry_delay = [:retry_delay] if .key?(:retry_delay) @config.logger = [:logger] if .key?(:logger) end |
Instance Attribute Details
#config ⇒ Configuration (readonly)
Returns the client's configuration.
14 15 16 |
# File 'lib/yookassa/client.rb', line 14 def config @config end |
Instance Method Details
#deals ⇒ Resources::Deal
Returns deal resource endpoint.
54 55 56 |
# File 'lib/yookassa/client.rb', line 54 def deals @deals ||= Resources::Deal.new(self) end |
#invoices ⇒ Resources::Invoice
Returns invoice resource endpoint.
64 65 66 |
# File 'lib/yookassa/client.rb', line 64 def invoices @invoices ||= Resources::Invoice.new(self) end |
#payments ⇒ Resources::Payment
Returns payment resource endpoint.
34 35 36 |
# File 'lib/yookassa/client.rb', line 34 def payments @payments ||= Resources::Payment.new(self) end |
#payouts ⇒ Resources::Payout
Returns payout resource endpoint.
49 50 51 |
# File 'lib/yookassa/client.rb', line 49 def payouts @payouts ||= Resources::Payout.new(self) end |
#receipts ⇒ Resources::Receipt
Returns receipt resource endpoint.
44 45 46 |
# File 'lib/yookassa/client.rb', line 44 def receipts @receipts ||= Resources::Receipt.new(self) end |
#refunds ⇒ Resources::Refund
Returns refund resource endpoint.
39 40 41 |
# File 'lib/yookassa/client.rb', line 39 def refunds @refunds ||= Resources::Refund.new(self) end |
#settings ⇒ Resources::Settings
Returns shop settings resource endpoint.
69 70 71 |
# File 'lib/yookassa/client.rb', line 69 def settings @settings ||= Resources::Settings.new(self) end |
#webhooks ⇒ Resources::Webhook
Returns webhook resource endpoint.
59 60 61 |
# File 'lib/yookassa/client.rb', line 59 def webhooks @webhooks ||= Resources::Webhook.new(self) end |