Class: Bakong::OpenApi::Client
- Inherits:
-
Object
- Object
- Bakong::OpenApi::Client
- Defined in:
- lib/bakong/open_api/client.rb
Overview
Primary entry-point. Holds configuration and a Connection. Resource modules (tokens, accounts, deeplinks, transactions) are lazily instantiated on first access.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #accounts ⇒ Object
- #deeplinks ⇒ Object
-
#initialize(token: nil, base_url: nil, open_timeout: nil, read_timeout: nil, user_agent: nil) ⇒ Client
constructor
A new instance of Client.
-
#token=(new_token) ⇒ Object
Mutate the active token after construction (e.g. after renew_token).
- #tokens ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(token: nil, base_url: nil, open_timeout: nil, read_timeout: nil, user_agent: nil) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 |
# File 'lib/bakong/open_api/client.rb', line 18 def initialize(token: nil, base_url: nil, open_timeout: nil, read_timeout: nil, user_agent: nil) @config = Configuration.new @config.token = token if token @config.base_url = base_url if base_url @config.open_timeout = open_timeout if open_timeout @config.read_timeout = read_timeout if read_timeout @config.user_agent = user_agent if user_agent @connection = Connection.new(@config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/bakong/open_api/client.rb', line 16 def config @config end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
16 17 18 |
# File 'lib/bakong/open_api/client.rb', line 16 def connection @connection end |
Instance Method Details
#accounts ⇒ Object
37 38 39 |
# File 'lib/bakong/open_api/client.rb', line 37 def accounts @accounts ||= Resources::Accounts.new(self) end |
#deeplinks ⇒ Object
41 42 43 |
# File 'lib/bakong/open_api/client.rb', line 41 def deeplinks @deeplinks ||= Resources::Deeplinks.new(self) end |
#token=(new_token) ⇒ Object
Mutate the active token after construction (e.g. after renew_token).
29 30 31 |
# File 'lib/bakong/open_api/client.rb', line 29 def token=(new_token) @config.token = new_token end |
#tokens ⇒ Object
33 34 35 |
# File 'lib/bakong/open_api/client.rb', line 33 def tokens @tokens ||= Resources::Tokens.new(self) end |
#transactions ⇒ Object
45 46 47 |
# File 'lib/bakong/open_api/client.rb', line 45 def transactions @transactions ||= Resources::Transactions.new(self) end |