Class: ApiBucket::Yahooauction::Client
- Inherits:
-
Object
- Object
- ApiBucket::Yahooauction::Client
- Includes:
- Http
- Defined in:
- lib/api_bucket/yahooauction/client.rb,
lib/api_bucket/yahooauction/client/http.rb
Defined Under Namespace
Modules: Http
Constant Summary collapse
- REQUEST_URL =
'http://auctions.yahooapis.jp/AuctionWebService/V2/json/search'
- REQUEST_URL_ITEM =
'http://auctions.yahooapis.jp/AuctionWebService/V2/json/auctionItem'
Instance Attribute Summary collapse
-
#appid ⇒ Object
Returns the value of attribute appid.
-
#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 Http
Methods included from Base::Client::Http
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 |
# File 'lib/api_bucket/yahooauction/client.rb', line 28 def initialize(={}) = ApiBucket::Yahooauction..merge() self.page = [:page] || 1 self.limit = [:limit] || 20 self.appid = [:appid] end |
Instance Attribute Details
#appid ⇒ Object
Returns the value of attribute appid.
8 9 10 |
# File 'lib/api_bucket/yahooauction/client.rb', line 8 def appid @appid end |
#limit ⇒ Object
Returns the value of attribute limit.
8 9 10 |
# File 'lib/api_bucket/yahooauction/client.rb', line 8 def limit @limit end |
#page ⇒ Object
Returns the value of attribute page.
8 9 10 |
# File 'lib/api_bucket/yahooauction/client.rb', line 8 def page @page end |
Instance Method Details
#categories ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/api_bucket/yahooauction/client.rb', line 13 def categories { :'----' => 'ALL', :'25464' => 'おもちゃ、ゲーム', :'24242' => 'ホビー、カルチャー', :'20000' => 'アンティーク、コレクション', :'23000' => 'ファッション', :'42177' => 'ビューティー、ヘルスケア', :'24198' => '住まい、インテリア', :'23140' => 'アクセサリー、時計', :'2084032594' => 'タレントグッズ', :'2084043920' => 'チケット、金券、宿泊予約', } end |
#lookup(id, params = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/api_bucket/yahooauction/client.rb', line 55 def lookup(id, params={}) = { auctionID: id, appid: self.appid } .merge!(params) ApiBucket::Yahooauction::Response.new(send_request(, REQUEST_URL_ITEM)) end |
#search(keywords, params = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/api_bucket/yahooauction/client.rb', line 36 def search(keywords, params={}) = { hits: self.limit, page: self.page, category: params[:search_index], query: keywords, appid: self.appid, } .merge!(params) # delete no needed keys .delete(:keywords) .delete(:search_index) [:category] = 'ALL' if [:category].nil? ApiBucket::Yahooauction::Response.new(send_request(, REQUEST_URL)) end |