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
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
A new instance of Client.
- #operation(value) ⇒ Object
Methods included from ItemList
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby-dmm/client.rb', line 23 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 @result_only = !!params.delete(:result_only) # Set true to get response.result only. @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, }.merge(params) @encode_options = params[:encode_options] || {} end |
Instance Attribute Details
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
21 22 23 |
# File 'lib/ruby-dmm/client.rb', line 21 def last_response @last_response end |
#params ⇒ Object
Returns the value of attribute params.
20 21 22 |
# File 'lib/ruby-dmm/client.rb', line 20 def params @params end |
Instance Method Details
#all ⇒ Object
51 52 53 |
# File 'lib/ruby-dmm/client.rb', line 51 def all @params[:operation] ? get('/', @params) : nil end |
#operation(value) ⇒ Object
47 48 49 |
# File 'lib/ruby-dmm/client.rb', line 47 def operation(value) @params.update(:operation => value) end |