Class: ApiBucket::Rakuten::Client
- Inherits:
-
Object
- Object
- ApiBucket::Rakuten::Client
- Includes:
- Http
- Defined in:
- lib/api_bucket/rakuten/client.rb,
lib/api_bucket/rakuten/client/http.rb
Defined Under Namespace
Modules: Http
Constant Summary collapse
- REQUEST_URL =
'https://app.rakuten.co.jp/services/api/IchibaItem/Search/20120723'
Instance Attribute Summary collapse
-
#affiliate_id ⇒ Object
Returns the value of attribute affiliate_id.
-
#application_id ⇒ Object
Returns the value of attribute application_id.
-
#format ⇒ Object
Returns the value of attribute format.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#page ⇒ Object
Returns the value of attribute page.
Instance Method Summary collapse
- #categories ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #lookup(id, params = {}) ⇒ Object
- #search(keywords, params = {}) ⇒ Object
Methods included from Base::Client::Http
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
35 36 37 38 39 40 41 42 43 |
# File 'lib/api_bucket/rakuten/client.rb', line 35 def initialize(={}) = ApiBucket::Rakuten..merge() self.page = [:page] || 1 self.limit = [:limit] || 20 self.format = [:format] || 'json' self.application_id = [:application_id] self.affiliate_id = [:affiliate_id] end |
Instance Attribute Details
#affiliate_id ⇒ Object
Returns the value of attribute affiliate_id.
9 10 11 |
# File 'lib/api_bucket/rakuten/client.rb', line 9 def affiliate_id @affiliate_id end |
#application_id ⇒ Object
Returns the value of attribute application_id.
9 10 11 |
# File 'lib/api_bucket/rakuten/client.rb', line 9 def application_id @application_id end |
#format ⇒ Object
Returns the value of attribute format.
9 10 11 |
# File 'lib/api_bucket/rakuten/client.rb', line 9 def format @format end |
#limit ⇒ Object
Returns the value of attribute limit.
9 10 11 |
# File 'lib/api_bucket/rakuten/client.rb', line 9 def limit @limit end |
#page ⇒ Object
Returns the value of attribute page.
9 10 11 |
# File 'lib/api_bucket/rakuten/client.rb', line 9 def page @page end |
Instance Method Details
#categories ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/api_bucket/rakuten/client.rb', line 13 def categories { :ALL => 'ALL', :'101240' => 'CD・DVD/BD・楽器', :'100371' => 'レディースファッション', :'551177' => 'メンズファッション', :'558885' => '靴', :'216131' => 'バッグ・小物・ブランド雑貨', :'100804' => 'インテリア・寝具・収納', :'211742' => '家電・AV・カメラ', :'402853' => 'デジタルコンテンツ', :'100227' => '食品', :'100000' => '百貨店・総合通販・ギフト', :'101381' => '旅行・出張・チケット', :'100939' => '美容・コスメ・香水', } end |
#lookup(id, params = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/api_bucket/rakuten/client.rb', line 66 def lookup(id, params={}) = { itemCode: id, operation: 'ItemCodeSearch', version: '2010-08-05', applicationId: self.application_id, affiliateId: self.affiliate_id, } .merge!(params) ApiBucket::Rakuten::Response.new(send_request(, REQUEST_URL)) end |
#search(keywords, params = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/api_bucket/rakuten/client.rb', line 45 def search(keywords, params={}) = { hits: self.limit, page: self.page, genreId: params[:search_index], keyword: keywords, applicationId: self.application_id, affiliateId: self.affiliate_id, } .merge!(params) # delete no needed keys .delete(:keywords) .delete(:search_index) [:genreId] = '0' if [:genreId] == 'ALL' ApiBucket::Rakuten::Response.new(send_request(, REQUEST_URL)) end |