Class: Instamojo::API

Inherits:
Object
  • Object
show all
Defined in:
lib/base.rb,
lib/API/api.rb

Constant Summary collapse

WHITELISTED_API_PARAMS =
[:api_key, :auth_token, :endpoint]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil, auth_token = nil, endpoint = nil, options = {}, &block) ⇒ API

Returns a new instance of API.



15
16
17
18
19
20
21
# File 'lib/API/api.rb', line 15

def initialize(api_key = nil, auth_token = nil, endpoint = nil, options = {}, &block)
  options = find_params(api_key, auth_token, endpoint, options, block)

  options.select { |k, _| WHITELISTED_API_PARAMS.include? k.to_sym }.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



13
14
15
# File 'lib/API/api.rb', line 13

def client
  @client
end

Instance Method Details

#to_sObject



27
28
29
# File 'lib/API/api.rb', line 27

def to_s
  @endpoint ? sprintf("Instamojo API(key: %s, endpoint: %s)", @api_key, @endpoint): sprintf("Instamojo API(key: %s)", @api_key)
end