Class: DMM::Client
- Inherits:
-
Object
- Object
- DMM::Client
- Includes:
- ItemList
- Defined in:
- lib/ruby-dmm/client.rb,
lib/ruby-dmm/client/item_list.rb
Defined Under Namespace
Modules: ItemList
Constant Summary
Constants included from ItemList
ItemList::ITEM_LIST_PARAMETERS
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
A new instance of Client.
- #last_response ⇒ Object
- #operation(value) ⇒ Object
Methods included from ItemList
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby-dmm/client.rb', line 24 def initialize(params={}) DMM..each do |key, value| # fall back to `DMM::Configuration` module defaults send("#{key}=", params[key] || value) end # Symbolize keys params = params.inject({}) do |hash, (key, value)| hash.merge(key.to_sym => value) end @params = { :api_id => ENV['DMM_API_ID'] || params[:api_id], # your own api_id :affiliate_id => ENV['DMM_AFFILIATE_ID'] || params[:affiliate_id], # your own affiliate_id :operation => nil, :version => DEFAULT_API_VERSION, :timestamp => Time.now.strftime("%F %T"), :site => DEFAULT_SITE, :result_only => false, # Set true to get response.result only. }.merge(params) end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
22 23 24 |
# File 'lib/ruby-dmm/client.rb', line 22 def params @params end |
Instance Method Details
#all ⇒ Object
50 51 52 |
# File 'lib/ruby-dmm/client.rb', line 50 def all @params[:operation] ? get('/', @params) : nil end |
#last_response ⇒ Object
54 55 56 |
# File 'lib/ruby-dmm/client.rb', line 54 def last_response @last_response end |
#operation(value) ⇒ Object
46 47 48 |
# File 'lib/ruby-dmm/client.rb', line 46 def operation(value) @params.update(:operation => value) end |