Class: Binking::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/binking/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token: Binking.config.api_token, host: Binking.config.host, sandbox: Binking.config.sandbox, cache: Binking.config.cache, logger: Binking.config.logger) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/binking/client.rb', line 9

def initialize(api_token: Binking.config.api_token,
               host: Binking.config.host,
               sandbox: Binking.config.sandbox,
               cache: Binking.config.cache,
               logger: Binking.config.logger)
  @api_token = api_token
  @host = host
  @sandbox = sandbox
  @cache = cache
  @logger = logger
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



7
8
9
# File 'lib/binking/client.rb', line 7

def api_token
  @api_token
end

#cacheObject

Returns the value of attribute cache.



7
8
9
# File 'lib/binking/client.rb', line 7

def cache
  @cache
end

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/binking/client.rb', line 7

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/binking/client.rb', line 7

def logger
  @logger
end

#sandboxObject

Returns the value of attribute sandbox.



7
8
9
# File 'lib/binking/client.rb', line 7

def sandbox
  @sandbox
end

Instance Method Details

#get(path, params = nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/binking/client.rb', line 21

def get(path, params = nil)
  connection.get(path.gsub(%r{^/}, ""), params) do |req|
    req.params["apiKey"] = api_token if api_token
    req.params["sandbox"] = 1 if sandbox
  end
end