rakuten_web_service 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.travis.yml +4 -16
- data/CHANGELOG.md +28 -0
- data/Gemfile +3 -3
- data/README.ja.md +118 -48
- data/README.md +30 -6
- data/examples/ichiba_item_search.rb +1 -1
- data/examples/recipe_search.rb +16 -0
- data/lib/rakuten_web_service/all_proxy.rb +2 -1
- data/lib/rakuten_web_service/books/genre.rb +1 -1
- data/lib/rakuten_web_service/books/resource.rb +1 -1
- data/lib/rakuten_web_service/books/total.rb +1 -1
- data/lib/rakuten_web_service/client.rb +9 -9
- data/lib/rakuten_web_service/error.rb +5 -0
- data/lib/rakuten_web_service/genre.rb +1 -1
- data/lib/rakuten_web_service/gora/course.rb +1 -1
- data/lib/rakuten_web_service/gora/course_detail.rb +1 -1
- data/lib/rakuten_web_service/gora/plan.rb +1 -1
- data/lib/rakuten_web_service/ichiba/item.rb +1 -1
- data/lib/rakuten_web_service/ichiba/product.rb +1 -1
- data/lib/rakuten_web_service/ichiba/ranking.rb +1 -1
- data/lib/rakuten_web_service/ichiba/tag.rb +5 -0
- data/lib/rakuten_web_service/ichiba/tag_group.rb +2 -6
- data/lib/rakuten_web_service/kobo/ebook.rb +1 -1
- data/lib/rakuten_web_service/kobo/genre.rb +1 -1
- data/lib/rakuten_web_service/recipe.rb +1 -1
- data/lib/rakuten_web_service/recipe/category.rb +3 -1
- data/lib/rakuten_web_service/resource.rb +29 -20
- data/lib/rakuten_web_service/response.rb +5 -4
- data/lib/rakuten_web_service/search_result.rb +14 -15
- data/lib/rakuten_web_service/travel/area_class.rb +28 -22
- data/lib/rakuten_web_service/travel/hotel.rb +3 -1
- data/lib/rakuten_web_service/travel/search_result.rb +1 -1
- data/lib/rakuten_web_service/version.rb +1 -1
- data/rakuten_web_service.gemspec +6 -4
- data/spec/rakuten_web_service/genre_spec.rb +1 -1
- data/spec/rakuten_web_service/ichiba/tag_spec.rb +17 -0
- data/spec/rakuten_web_service/resource_spec.rb +2 -2
- data/spec/rakuten_web_service/response_spec.rb +7 -7
- data/spec/rakuten_web_service/travel/search_result_spec.rb +4 -4
- metadata +43 -15
- data/spec/integration/integration_spec.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb4eed0f6b4075f460d74c30218551f0345c9bc12cda1a433bdcf9525e4ff64
|
4
|
+
data.tar.gz: ce188517ae7113a4322b35b271c9c5fccda23f0bb5694a8047bea1afdbf25a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b996cb29aa1fc0dd7634ee33dced0386e0d320711a42e98a20af695815df35709778d2150327551fa2dffe27a69407eb04f0aa4a3c72d01ba485e8e6ac172b7
|
7
|
+
data.tar.gz: 265354c69faacb14e9fe3aa3565b44d9813a8011562b913a3fe4ee017ea3e18bc4cf4df0e1f97295a5eb5c235a3beecc75e9efa37ecb89543fee5543c8e49307
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: [satoryu] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
|
+
patreon: # Replace with a single Patreon username
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
11
|
+
otechie: # Replace with a single Otechie username
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
data/.travis.yml
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
3
|
+
- 2.5
|
4
|
+
- 2.6
|
5
|
+
- 2.7
|
6
6
|
- ruby-head
|
7
7
|
|
8
|
-
env:
|
9
|
-
- INTEGRATION=yes
|
10
|
-
- INTEGRATION=no
|
11
|
-
|
12
8
|
group: travis_lts
|
13
9
|
|
14
10
|
cache: bundler
|
@@ -18,8 +14,7 @@ before_install:
|
|
18
14
|
- chmod +x ./cc-test-reporter
|
19
15
|
- ./cc-test-reporter before-build
|
20
16
|
- gem install bundler
|
21
|
-
|
22
|
-
bundler_args: --without vscode
|
17
|
+
- bundle config set without 'vscode'
|
23
18
|
|
24
19
|
script:
|
25
20
|
- bundle exec rake
|
@@ -30,13 +25,6 @@ after_script:
|
|
30
25
|
matrix:
|
31
26
|
allow_failures:
|
32
27
|
- rvm: ruby-head
|
33
|
-
exclude:
|
34
|
-
- rvm: 2.4.3
|
35
|
-
env: INTEGRATION=yes
|
36
|
-
- rvm: 2.5.0
|
37
|
-
env: INTEGRATION=yes
|
38
|
-
- rvm: ruby-head
|
39
|
-
env: INTEGRATION=yes
|
40
28
|
|
41
29
|
notifications:
|
42
30
|
email: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v1.13.0 (2020/10/15)
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
|
7
|
+
- Adds `RakutenWebService::Ichiba::Tab.search` [#112](https://github.com/rakuten-ws/rws-ruby-sdk/pull/112)
|
8
|
+
|
9
|
+
### Improvements
|
10
|
+
|
11
|
+
- Adds `rexml` to development dependencies to run tests in ruby 3.0 [#127](https://github.com/rakuten-ws/rws-ruby-sdk/pull/127)
|
12
|
+
- Abolishes integration spec [#126](https://github.com/rakuten-ws/rws-ruby-sdk/pull/126)
|
13
|
+
- Suppresses deprecation warning for bundle install's option [#125](https://github.com/rakuten-ws/rws-ruby-sdk/pull/125)
|
14
|
+
- Updates README.ja.md by fuyuton [#124](https://github.com/rakuten-ws/rws-ruby-sdk/pull/124)
|
15
|
+
- Removes comment out by 4geru [#123](https://github.com/rakuten-ws/rws-ruby-sdk/pull/123)
|
16
|
+
- Use instance variable in ichiba item example code by 4geru [#122](https://github.com/rakuten-ws/rws-ruby-sdk/pull/122)
|
17
|
+
- Updates .travis.yml by 4geru [#121](https://github.com/rakuten-ws/rws-ruby-sdk/pull/121)
|
18
|
+
- Adds recipe example code by @4geru [#119](https://github.com/rakuten-ws/rws-ruby-sdk/pull/119) [#120](https://github.com/rakuten-ws/rws-ruby-sdk/pull/120)
|
19
|
+
- Drop v2.4 from supported ruby versions [#118](https://github.com/rakuten-ws/rws-ruby-sdk/pull/118)
|
20
|
+
- Update supported ruby versions: welcome ruby 2.7 [#117](https://github.com/rakuten-ws/rws-ruby-sdk/pull/117)
|
21
|
+
- Inserts frozen string literal comments to travel api codes [#113](https://github.com/rakuten-ws/rws-ruby-sdk/pull/113)
|
22
|
+
- Refactoring: Extract process from `Travel::Areaclass::Base` constructor [#114](https://github.com/rakuten-ws/rws-ruby-sdk/pull/114)
|
23
|
+
- Refactoring: decompose `RakutenWebService::Resource.attribute` to reduce its complexity [#115](https://github.com/rakuten-ws/rws-ruby-sdk/pull/115)
|
24
|
+
- Refactoring: fix some style issues [#116](https://github.com/rakuten-ws/rws-ruby-sdk/pull/116)
|
25
|
+
|
26
|
+
### Thanks
|
27
|
+
|
28
|
+
We are pleased to say thanks to @4geru and @fuyuton. This release includes their seminal works.
|
29
|
+
Thanks :tada:
|
30
|
+
|
3
31
|
## v1.12.0 (2019/09/09)
|
4
32
|
|
5
33
|
### Enhancements
|
data/Gemfile
CHANGED
@@ -4,10 +4,10 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :test do
|
7
|
-
gem 'simplecov', '~> 0.
|
7
|
+
gem 'simplecov', '~> 0.17.1', require: false
|
8
8
|
end
|
9
9
|
|
10
10
|
group :vscode do
|
11
|
-
gem 'debase', '0.2.2'
|
12
|
-
gem 'ruby-debug-ide', '~> 0.
|
11
|
+
gem 'debase', '~> 0.2', '>= 0.2.4.1'
|
12
|
+
gem 'ruby-debug-ide', '~> 0.7'
|
13
13
|
end
|
data/README.ja.md
CHANGED
@@ -8,62 +8,34 @@ rakuten\_web\_serviceは、 Rubyから楽天が提供しているAPIに簡単に
|
|
8
8
|
|
9
9
|
English version is [here](http://github.com/rakuten-ws/rws-ruby-sdk/blob/master/README.md).
|
10
10
|
|
11
|
+
## 前提条件
|
12
|
+
|
13
|
+
* Ruby 2.5 またはそれ以上のバージョンであること
|
14
|
+
|
11
15
|
## インストール方法
|
12
16
|
|
13
17
|
bundlerを利用したアプリケーションの場合、Gemfileに以下の1行を追加します。
|
14
18
|
|
15
19
|
```ruby
|
16
|
-
|
20
|
+
gem 'rakuten_web_service'
|
17
21
|
```
|
18
22
|
|
19
23
|
そして`bundle`コマンドでインストール。
|
20
24
|
|
21
|
-
|
25
|
+
```sh
|
26
|
+
bundle
|
27
|
+
```
|
22
28
|
|
23
29
|
もしくは、`gem`コマンドにより
|
24
30
|
|
25
|
-
|
31
|
+
```sh
|
32
|
+
gem install rakuten_web_service
|
33
|
+
```
|
26
34
|
|
27
35
|
とすることでインストールできます。
|
28
36
|
|
29
37
|
現在rakuten\_web\_serviceは下記のAPIをサポートしています。
|
30
38
|
|
31
|
-
### 楽天市場API
|
32
|
-
|
33
|
-
* [Rakuten Ichiba Item Search API](http://webservice.rakuten.co.jp/api/ichibaitemsearch/)
|
34
|
-
* [Rakuten Ichiba Genre Search API](http://webservice.rakuten.co.jp/api/ichibagenresearch/)
|
35
|
-
* [Rakuten Ichiba Ranking API](http://webservice.rakuten.co.jp/api/ichibaitemranking/)
|
36
|
-
* [Rakuten Product API](http://webservice.rakuten.co.jp/api/productsearch/)
|
37
|
-
|
38
|
-
|
39
|
-
### 楽天ブックス系API
|
40
|
-
|
41
|
-
* [Rakuten Books Total Search API](http://webservice.rakuten.co.jp/api/bookstotalsearch/)
|
42
|
-
* [Rakuten Books Book Search API](http://webservice.rakuten.co.jp/api/booksbooksearch/)
|
43
|
-
* [Rakuten Books CD Search API](http://webservice.rakuten.co.jp/api/bookscdsearch/)
|
44
|
-
* [Rakuten Books DVD/Blu-ray Search API](http://webservice.rakuten.co.jp/api/booksdvdsearch/)
|
45
|
-
* [Rakuten Books ForeignBook Search API](http://webservice.rakuten.co.jp/api/booksforeignbooksearch/)
|
46
|
-
* [Rakuten Books Magazine Search API](http://webservice.rakuten.co.jp/api/booksmagazinesearch/)
|
47
|
-
* [Rakuten Books Game Search API](http://webservice.rakuten.co.jp/api/booksgamesearch/)
|
48
|
-
* [Rakuten Books Software Search API](http://webservice.rakuten.co.jp/api/bookssoftwaresearch/)
|
49
|
-
* [Rakuten Books Genre Search API](http://webservice.rakuten.co.jp/api/booksgenresearch/)
|
50
|
-
|
51
|
-
### 楽天Kobo系API
|
52
|
-
|
53
|
-
* [楽天Kobo電子書籍検索API](http://webservice.rakuten.co.jp/api/koboebooksearch/)
|
54
|
-
* [楽天Koboジャンル検索API](http://webservice.rakuten.co.jp/api/kobogenresearch/)
|
55
|
-
|
56
|
-
### 楽天レシピ系API
|
57
|
-
|
58
|
-
* [楽天レシピカテゴリ一覧API](https://webservice.rakuten.co.jp/api/recipecategorylist/)
|
59
|
-
* [楽天レシピカテゴリ別ランキングAPI](https://webservice.rakuten.co.jp/api/recipecategoryranking/)
|
60
|
-
|
61
|
-
### 楽天GORA系API
|
62
|
-
|
63
|
-
* [楽天GORAゴルフ場検索API](https://webservice.rakuten.co.jp/api/goragolfcoursesearch/)
|
64
|
-
* [楽天GORAゴルフ場詳細API](https://webservice.rakuten.co.jp/api/goragolfcoursedetail/)
|
65
|
-
* [楽天GORAプラン検索API](https://webservice.rakuten.co.jp/api/goraplansearch/)
|
66
|
-
|
67
39
|
## 使用方法
|
68
40
|
|
69
41
|
### 事前準備: アプリケーションIDの取得
|
@@ -77,19 +49,62 @@ bundlerを利用したアプリケーションの場合、Gemfileに以下の1
|
|
77
49
|
|
78
50
|
```ruby
|
79
51
|
RakutenWebService.configure do |c|
|
52
|
+
# (必須) アプリケーションID
|
80
53
|
c.application_id = 'YOUR_APPLICATION_ID'
|
81
|
-
|
54
|
+
|
55
|
+
# (任意) 楽天アフィリエイトID
|
56
|
+
c.affiliate_id = 'YOUR_AFFILIATE_ID' # default: nil
|
57
|
+
|
58
|
+
# (任意) リクエストのリトライ回数
|
59
|
+
# 一定期間の間のリクエスト数が制限を超えた時、APIはリクエスト過多のエラーを返す。
|
60
|
+
# その後、クライアントは少し間を空けた後に同じリクエストを再度送る。
|
61
|
+
c.max_retries = 3 # default: 5
|
62
|
+
|
63
|
+
# (任意) デバッグモード
|
64
|
+
# trueの時、クライアントはすべてのHTTPリクエストとレスポンスを
|
65
|
+
# 標準エラー出力に流す。
|
66
|
+
c.debug = true # default: false
|
82
67
|
end
|
83
68
|
```
|
84
69
|
|
85
70
|
`'YOUR_APPLICATION_ID'` と `'YOUR_AFFILIATE_ID'` は、実際のアプリケーションIDとアフィリエイトIDに置き換えてください。
|
86
71
|
|
72
|
+
#### 環境変数
|
73
|
+
|
74
|
+
`application_id` と `affiliate_id` はそれぞれ、環境変数`RWS_APPLICATION_ID`と`RWS_AFFILIATION_ID`を定義することでも設定できる。
|
75
|
+
|
87
76
|
### 市場商品の検索
|
88
77
|
|
89
78
|
```ruby
|
90
|
-
items = RakutenWebService::Ichiba::Item.search(:
|
79
|
+
items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby') # Enumerable オブジェクトが返ってくる
|
91
80
|
items.first(10).each do |item|
|
92
|
-
puts "#{item['itemName']}, #{item.price} yen" #
|
81
|
+
puts "#{item['itemName']}, #{item.price} yen" # Hashのように値を参照できる
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
### ページング
|
86
|
+
|
87
|
+
`RakutenWebService::Ichiba::Item.search` など`search`メソッドはページングのためのメソッドを持ったオブジェクトを返します。
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby')
|
91
|
+
items.count #=> 30. デフォルトで1度のリクエストで30件の商品情報が返ってくる
|
92
|
+
|
93
|
+
last_items = items.page(3) # 3ページ目の情報を取る
|
94
|
+
|
95
|
+
# 最後のページまでスキップする
|
96
|
+
while last_items.has_next_page?
|
97
|
+
last_items = last_items.next_page
|
98
|
+
end
|
99
|
+
|
100
|
+
# 最後のページの商品名を表示
|
101
|
+
last_items.each do |item|
|
102
|
+
puts item.name
|
103
|
+
end
|
104
|
+
|
105
|
+
# 上記の処理をより簡潔に書くと以下のようになる
|
106
|
+
items.page(3).all do |item|
|
107
|
+
puts item.name
|
93
108
|
end
|
94
109
|
```
|
95
110
|
|
@@ -98,32 +113,87 @@ bundlerを利用したアプリケーションの場合、Gemfileに以下の1
|
|
98
113
|
Genreクラスは、`children`や`parent`といったジャンル階層を辿るインターフェースを持っています。
|
99
114
|
|
100
115
|
```ruby
|
101
|
-
root = RakutenWebService::Ichiba::Genre.root #
|
102
|
-
# children
|
116
|
+
root = RakutenWebService::Ichiba::Genre.root # ジャンルのルート
|
117
|
+
# children はそのジャンルの直下のサブジャンルを返す
|
103
118
|
root.children.each do |child|
|
104
119
|
puts "[#{child.id}] #{child.name}"
|
105
120
|
end
|
106
121
|
|
107
|
-
#
|
122
|
+
# ジャンルの情報を引くため、ジャンルIDを用る
|
108
123
|
RakutenWebService::Ichiba::Genre[100316].name # => "水・ソフトドリンク"
|
109
124
|
```
|
110
125
|
|
111
|
-
|
112
126
|
### 市場商品ランキング
|
113
127
|
|
114
128
|
```ruby
|
115
129
|
ranking_by_age = RakutenWebService::Ichiba::Item.ranking(:age => 30, :sex => 1) # 30代男性 のランキングTOP 30
|
116
130
|
ranking_by_age.each do |ranking|
|
117
131
|
# 'itemName'以外の属性については右記を参照 http://webservice.rakuten.co.jp/api/ichibaitemsearch/#outputParameter
|
118
|
-
puts
|
132
|
+
puts item.name
|
119
133
|
end
|
120
134
|
|
121
135
|
ranking_by_genre = RakutenWebService::Ichiba::Genre[200162].ranking # "水・ソフトドリンク" ジャンルのTOP 30
|
122
136
|
ranking_by_genre.each do |ranking|
|
123
|
-
puts
|
137
|
+
puts item.name
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
### レシピ
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
categories = RakutenWebService::Recipe.small_categories
|
145
|
+
|
146
|
+
# 全種類の小カテゴリーを表示
|
147
|
+
categories.each do |category|
|
148
|
+
category.name
|
149
|
+
end
|
150
|
+
|
151
|
+
recipes = categories.first.ranking
|
152
|
+
|
153
|
+
# カテゴリーに対応するレシピを表示
|
154
|
+
recipes.each do |recipe|
|
155
|
+
recipe.title
|
124
156
|
end
|
125
157
|
```
|
126
158
|
|
159
|
+
## サポートしているAPI
|
160
|
+
|
161
|
+
### 楽天市場API
|
162
|
+
|
163
|
+
* [Rakuten Ichiba Item Search API](http://webservice.rakuten.co.jp/api/ichibaitemsearch/)
|
164
|
+
* [Rakuten Ichiba Genre Search API](http://webservice.rakuten.co.jp/api/ichibagenresearch/)
|
165
|
+
* [Rakuten Ichiba Ranking API](http://webservice.rakuten.co.jp/api/ichibaitemranking/)
|
166
|
+
* [Rakuten Product API](http://webservice.rakuten.co.jp/api/productsearch/)
|
167
|
+
* [Rakuten Ichiba Tag Search API](https://webservice.rakuten.co.jp/api/ichibatagsearch/)
|
168
|
+
|
169
|
+
### 楽天ブックス系API
|
170
|
+
|
171
|
+
* [Rakuten Books Total Search API](http://webservice.rakuten.co.jp/api/bookstotalsearch/)
|
172
|
+
* [Rakuten Books Book Search API](http://webservice.rakuten.co.jp/api/booksbooksearch/)
|
173
|
+
* [Rakuten Books CD Search API](http://webservice.rakuten.co.jp/api/bookscdsearch/)
|
174
|
+
* [Rakuten Books DVD/Blu-ray Search API](http://webservice.rakuten.co.jp/api/booksdvdsearch/)
|
175
|
+
* [Rakuten Books ForeignBook Search API](http://webservice.rakuten.co.jp/api/booksforeignbooksearch/)
|
176
|
+
* [Rakuten Books Magazine Search API](http://webservice.rakuten.co.jp/api/booksmagazinesearch/)
|
177
|
+
* [Rakuten Books Game Search API](http://webservice.rakuten.co.jp/api/booksgamesearch/)
|
178
|
+
* [Rakuten Books Software Search API](http://webservice.rakuten.co.jp/api/bookssoftwaresearch/)
|
179
|
+
* [Rakuten Books Genre Search API](http://webservice.rakuten.co.jp/api/booksgenresearch/)
|
180
|
+
|
181
|
+
### 楽天Kobo系API
|
182
|
+
|
183
|
+
* [楽天Kobo電子書籍検索API](http://webservice.rakuten.co.jp/api/koboebooksearch/)
|
184
|
+
* [楽天Koboジャンル検索API](http://webservice.rakuten.co.jp/api/kobogenresearch/)
|
185
|
+
|
186
|
+
### 楽天レシピ系API
|
187
|
+
|
188
|
+
* [楽天レシピカテゴリ一覧API](https://webservice.rakuten.co.jp/api/recipecategorylist/)
|
189
|
+
* [楽天レシピカテゴリ別ランキングAPI](https://webservice.rakuten.co.jp/api/recipecategoryranking/)
|
190
|
+
|
191
|
+
### 楽天GORA系API
|
192
|
+
|
193
|
+
* [楽天GORAゴルフ場検索API](https://webservice.rakuten.co.jp/api/goragolfcoursesearch/)
|
194
|
+
* [楽天GORAゴルフ場詳細API](https://webservice.rakuten.co.jp/api/goragolfcoursedetail/)
|
195
|
+
* [楽天GORAプラン検索API](https://webservice.rakuten.co.jp/api/goraplansearch/)
|
196
|
+
|
127
197
|
## Contributing
|
128
198
|
|
129
199
|
1. Fork it
|
data/README.md
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
This gem provides a client for easily accessing [Rakuten Web Service APIs](https://webservice.rakuten.co.jp/).
|
10
10
|
|
11
|
+
日本語のドキュメントは[こちら](http://github.com/rakuten-ws/rws-ruby-sdk/blob/master/README.ja.md)。
|
12
|
+
|
11
13
|
## Table of Contents
|
12
14
|
|
13
15
|
* [Prerequisite](#prerequisite)
|
@@ -30,23 +32,27 @@ This gem provides a client for easily accessing [Rakuten Web Service APIs](https
|
|
30
32
|
|
31
33
|
## Prerequisite
|
32
34
|
|
33
|
-
* Ruby 2.
|
35
|
+
* Ruby 2.5 or later
|
34
36
|
|
35
37
|
## Installation
|
36
38
|
|
37
39
|
Add this line to your application's Gemfile:
|
38
40
|
|
39
41
|
```ruby
|
40
|
-
|
42
|
+
gem 'rakuten_web_service'
|
41
43
|
```
|
42
44
|
|
43
45
|
And then execute:
|
44
46
|
|
45
|
-
|
47
|
+
```sh
|
48
|
+
bundle
|
49
|
+
```
|
46
50
|
|
47
51
|
Or install it yourself as:
|
48
52
|
|
49
|
-
|
53
|
+
```sh
|
54
|
+
gem install rakuten_web_service
|
55
|
+
```
|
50
56
|
|
51
57
|
## Usage
|
52
58
|
|
@@ -143,12 +149,30 @@ Genre class provides an interface to traverse sub genres.
|
|
143
149
|
ranking_by_age = RakutenWebService::Ichiba::Item.ranking(age: 30, sex: 1) # returns the TOP 30 items for Male in 30s
|
144
150
|
# For attributes other than 'itemName', see: http://webservice.rakuten.co.jp/api/ichibaitemsearch/#outputParameter
|
145
151
|
ranking_by_age.each do |ranking|
|
146
|
-
puts
|
152
|
+
puts item.name
|
147
153
|
end
|
148
154
|
|
149
155
|
ranking_by_genre = RakutenWebService::Ichiba::Genre[200162].ranking # the TOP 30 items in "水・ソフトドリンク" genre
|
150
156
|
ranking_by_genre.each do |ranking|
|
151
|
-
puts
|
157
|
+
puts item.name
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
161
|
+
### Recipe
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
categories = RakutenWebService::Recipe.small_categories
|
165
|
+
|
166
|
+
# Search all small recipe categories.
|
167
|
+
categories.each do |category|
|
168
|
+
category.name
|
169
|
+
end
|
170
|
+
|
171
|
+
recipes = categories.first.ranking
|
172
|
+
|
173
|
+
# Search category recipes.
|
174
|
+
recipes.each do |recipe|
|
175
|
+
recipe.title
|
152
176
|
end
|
153
177
|
```
|
154
178
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rakuten_web_service'
|
2
|
+
|
3
|
+
application_id = ARGV.shift
|
4
|
+
keyword = ARGV[0..-1].join(' ')
|
5
|
+
|
6
|
+
RakutenWebService.configure do |c|
|
7
|
+
c.application_id = application_id
|
8
|
+
end
|
9
|
+
|
10
|
+
category = RakutenWebService::Recipe.small_categories.find { |c| c.name.match(keyword) }
|
11
|
+
|
12
|
+
recipes = category.ranking
|
13
|
+
|
14
|
+
recipes.first(10).each do |recipe|
|
15
|
+
puts "#{recipe.title} is made by #{recipe.nickname}"
|
16
|
+
end
|