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
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.
- #operation(value) ⇒ Object
Methods included from ItemList
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-dmm/client.rb', line 20 def initialize(params={}) params = params.inject({}) {|hash, (key, value)| hash.merge({key.to_sym => value})} @params = { :api_id => params[:api_id], # your own api_id :affiliate_id => params[:affiliate_id], # your own api_id :operation => nil, # "ItemList" is only available now. :version => DEFAULT_API_VERSION, :timestamp => Time.now.strftime("%F %T"), :site => DEFAULT_SITE, :result_only => false, # Set true to get only response.result. }.merge(params) DMM..each {|key, value| send("#{key}=", value) } end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
18 19 20 |
# File 'lib/ruby-dmm/client.rb', line 18 def params @params end |
Instance Method Details
#all ⇒ Object
39 40 41 |
# File 'lib/ruby-dmm/client.rb', line 39 def all @params[:operation] ? get('/', @params) : nil end |
#operation(value) ⇒ Object
35 36 37 |
# File 'lib/ruby-dmm/client.rb', line 35 def operation(value) self.tap {|o| o.params.update(:operation => value) } end |