Class: PbAPI::Client
- Inherits:
-
Object
- Object
- PbAPI::Client
- Defined in:
- lib/pb_api/client.rb
Overview
main entry point for the gem see #balances. #transactions
Constant Summary collapse
- BASE_URL =
"https://acp.privatbank.ua/api/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
Instance Method Summary collapse
-
#balances ⇒ PbAPI::Resources::BalanceResource
Returns a new instance of PbAPI::Resources::BalanceResource for handling balance-related API operations.
- #connection ⇒ Object
-
#initialize(api_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
-
#transactions ⇒ PbAPI::Resources::TransactionResource
Returns a new instance of PbAPI::Resources::TransactionResource for handling transaction-related API operations.
Constructor Details
#initialize(api_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/pb_api/client.rb', line 10 def initialize(api_token:, adapter: Faraday.default_adapter, stubs: nil) @api_token = api_token @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/pb_api/client.rb', line 8 def adapter @adapter end |
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
8 9 10 |
# File 'lib/pb_api/client.rb', line 8 def api_token @api_token end |
Instance Method Details
#balances ⇒ PbAPI::Resources::BalanceResource
Returns a new instance of PbAPI::Resources::BalanceResource for handling balance-related API operations.
31 32 33 |
# File 'lib/pb_api/client.rb', line 31 def balances PbAPI::Resources::BalanceResource.new(self) end |
#connection ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pb_api/client.rb', line 18 def connection @connection ||= Faraday.new(BASE_URL) do |b| b.headers["token"] = @api_token b.headers["Content-Type"] = "application/json;charset=utf8" b.ssl.verify = true b.response :json b.response :logger, PbAPI.logger, { headers: false, bodies: false } b.adapter @adapter, @stubs end end |
#transactions ⇒ PbAPI::Resources::TransactionResource
Returns a new instance of PbAPI::Resources::TransactionResource for handling transaction-related API operations.
37 38 39 |
# File 'lib/pb_api/client.rb', line 37 def transactions PbAPI::Resources::TransactionResource.new(self) end |