Class: Bakong::OpenApi::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#configObject (readonly)

Returns the value of attribute config.



16
17
18
# File 'lib/bakong/open_api/client.rb', line 16

def config
  @config
end

#connectionObject (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

#accountsObject



37
38
39
# File 'lib/bakong/open_api/client.rb', line 37

def accounts
  @accounts ||= Resources::Accounts.new(self)
end


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

#tokensObject



33
34
35
# File 'lib/bakong/open_api/client.rb', line 33

def tokens
  @tokens ||= Resources::Tokens.new(self)
end

#transactionsObject



45
46
47
# File 'lib/bakong/open_api/client.rb', line 45

def transactions
  @transactions ||= Resources::Transactions.new(self)
end