Class: UkrsibAPI::Client
- Inherits:
-
Object
- Object
- UkrsibAPI::Client
- Defined in:
- lib/ukrsib_api/client.rb
Overview
main entry point for the gem see #balances, #transactions
Constant Summary collapse
- BASE_URL =
"https://business.ukrsibbank.com/morpheus/"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
Instance Method Summary collapse
-
#balances ⇒ UkrsibAPI::Resources::BalanceResource
Returns a new instance of UkrsibAPI::Resources::BalanceResource for handling balance-related API operations.
- #connection ⇒ Object
-
#initialize(authentication: nil, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
Expects UkrsibAPI::Authentication tp be already authorized see documentation for UkrsibAPI::Authentication.
-
#statements_v3 ⇒ UkrsibAPI::Resources::TransactionResource
Returns a new instance of UkrsibAPI::Resources::TransactionResource for handling transaction-related API operations.
Constructor Details
#initialize(authentication: nil, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Expects UkrsibAPI::Authentication tp be already authorized see documentation for UkrsibAPI::Authentication
13 14 15 16 17 |
# File 'lib/ukrsib_api/client.rb', line 13 def initialize(authentication: nil, adapter: Faraday.default_adapter, stubs: nil) @auth = authentication || UkrsibAPI::Authentication.new @adapter = adapter @stubs = stubs end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/ukrsib_api/client.rb', line 8 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/ukrsib_api/client.rb', line 8 def adapter @adapter end |
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
8 9 10 |
# File 'lib/ukrsib_api/client.rb', line 8 def auth @auth end |
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
8 9 10 |
# File 'lib/ukrsib_api/client.rb', line 8 def stubs @stubs end |
Instance Method Details
#balances ⇒ UkrsibAPI::Resources::BalanceResource
Returns a new instance of UkrsibAPI::Resources::BalanceResource for handling balance-related API operations.
35 36 37 |
# File 'lib/ukrsib_api/client.rb', line 35 def balances UkrsibAPI::Resources::BalanceResource.new(self) end |
#connection ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ukrsib_api/client.rb', line 19 def connection @auth.refresh_token_if_needed @connection ||= Faraday.new(BASE_URL) do |b| b.headers["Authorization"] = "Bearer #{@auth.access_token}" b.headers["Content-Type"] = "application/json;charset=utf8" b.ssl.verify = true b.request :json b.response :json b.response :logger, UkrsibAPI.logger, { headers: false, bodies: false } b.adapter @adapter, @stubs end end |
#statements_v3 ⇒ UkrsibAPI::Resources::TransactionResource
Returns a new instance of UkrsibAPI::Resources::TransactionResource for handling transaction-related API operations.
41 42 43 |
# File 'lib/ukrsib_api/client.rb', line 41 def statements_v3 UkrsibAPI::Resources::StatementsV3Resource.new(self) end |