rakuten_web_service 1.10.0 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/workflows/ci.yml +30 -0
  4. data/CHANGELOG.md +103 -48
  5. data/Gemfile +3 -3
  6. data/README.ja.md +118 -48
  7. data/README.md +35 -10
  8. data/examples/ichiba_item_search.rb +1 -1
  9. data/examples/recipe_search.rb +16 -0
  10. data/lib/rakuten_web_service/all_proxy.rb +2 -1
  11. data/lib/rakuten_web_service/books/genre.rb +1 -1
  12. data/lib/rakuten_web_service/books/resource.rb +1 -1
  13. data/lib/rakuten_web_service/books/total.rb +1 -1
  14. data/lib/rakuten_web_service/client.rb +9 -9
  15. data/lib/rakuten_web_service/configuration.rb +0 -16
  16. data/lib/rakuten_web_service/error.rb +5 -0
  17. data/lib/rakuten_web_service/genre.rb +1 -1
  18. data/lib/rakuten_web_service/gora/course.rb +1 -1
  19. data/lib/rakuten_web_service/gora/course_detail.rb +1 -1
  20. data/lib/rakuten_web_service/gora/plan.rb +1 -1
  21. data/lib/rakuten_web_service/ichiba/item.rb +3 -3
  22. data/lib/rakuten_web_service/ichiba/product.rb +1 -1
  23. data/lib/rakuten_web_service/ichiba/ranking.rb +1 -1
  24. data/lib/rakuten_web_service/ichiba/tag.rb +16 -0
  25. data/lib/rakuten_web_service/ichiba/tag_group.rb +23 -0
  26. data/lib/rakuten_web_service/ichiba.rb +2 -0
  27. data/lib/rakuten_web_service/kobo/ebook.rb +1 -1
  28. data/lib/rakuten_web_service/kobo/genre.rb +1 -1
  29. data/lib/rakuten_web_service/recipe/category.rb +3 -1
  30. data/lib/rakuten_web_service/recipe.rb +1 -1
  31. data/lib/rakuten_web_service/resource.rb +29 -20
  32. data/lib/rakuten_web_service/response.rb +5 -4
  33. data/lib/rakuten_web_service/search_result.rb +14 -15
  34. data/lib/rakuten_web_service/travel/area_class.rb +30 -29
  35. data/lib/rakuten_web_service/travel/hotel.rb +3 -1
  36. data/lib/rakuten_web_service/travel/search_result.rb +1 -1
  37. data/lib/rakuten_web_service/version.rb +1 -1
  38. data/lib/rakuten_web_service.rb +17 -1
  39. data/rakuten_web_service.gemspec +6 -4
  40. data/spec/fixtures/ichiba/item_search_with_no_items.json +8 -0
  41. data/spec/fixtures/ichiba/tag_search.json +15 -0
  42. data/spec/rakuten_web_service/configuration_spec.rb +0 -52
  43. data/spec/rakuten_web_service/genre_spec.rb +1 -1
  44. data/spec/rakuten_web_service/ichiba/item_spec.rb +13 -0
  45. data/spec/rakuten_web_service/ichiba/tag_group_spec.rb +68 -0
  46. data/spec/rakuten_web_service/ichiba/tag_spec.rb +35 -0
  47. data/spec/rakuten_web_service/resource_spec.rb +2 -2
  48. data/spec/rakuten_web_service/response_spec.rb +7 -7
  49. data/spec/rakuten_web_service/travel/search_result_spec.rb +4 -4
  50. data/spec/rakuten_web_service_spec.rb +48 -0
  51. metadata +56 -16
  52. data/.travis.yml +0 -46
  53. data/spec/integration/integration_spec.rb +0 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 415917a50517faaba6319b58c399fa8b52685d3116725e32152592a87f6e89ea
4
- data.tar.gz: c6fd00ef38214d6008dd2db3417dccf066cdf4ae1f1243a9249413e4d3dac1e0
3
+ metadata.gz: 77a989e998fd6a3271a5f1e999a0a42f6858ea20cacd06ebd05753212d97aee3
4
+ data.tar.gz: 90ceb9449c4aeb5c3bf01b46f7660d3f76a603fd8a28bd102f1fa33d66d45bae
5
5
  SHA512:
6
- metadata.gz: 070ae2ea7f6ca3c0877d4ec36d4f13012ba0c7b990dfd4591694d5e278f83352be927966e91714378da1140b8538eadcdcf9e8b1ebfc8aefb32456849f397780
7
- data.tar.gz: 7911a4ca4d7927477e683290948316e49290de31cc7fd02380437564f38ebbe7af3c05d47b92316e5fb91e5ff3f0488ad6f4d71d1dfbfd2c5ae2f08b7145928f
6
+ metadata.gz: f083fede7c88df4046d4ca2c2f41429b1f37c9b4a814dace5e7b8b7ace92636a06cc3ce72ab06808dfc1fbf8758a89a167cd70ad276a0a826e5e139a1fe2307c
7
+ data.tar.gz: c97f6fcd7762134d830743fc92e77e26c66057a9f86671c338d1a5d95e0fc835d923419e8f593d8e1f7d68ca336e053eb684080b2eab60ea026f45c582c818ad
@@ -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']
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby-version:
16
+ - 2.5
17
+ - 2.6
18
+ - 2.7
19
+ - "3.0"
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - uses: ruby/setup-ruby@v1
24
+ env:
25
+ BUNDLE_WITHOUT: vscode
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+ bundler-cache: true
29
+ - name: Run test
30
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,168 +1,223 @@
1
- # v1.10.0
1
+ # CHANGELOG
2
2
 
3
- ## Enhancements
3
+ ## v1.13.1 (2021/09/02)
4
+
5
+ ### Improvements
6
+
7
+ - Fixed the issue when item can't be found by specifying elements [#132](https://github.com/rakuten-ws/rws-ruby-sdk/pull/132)
8
+ - Removed abolished methods from sample codes in README [#131](https://github.com/rakuten-ws/rws-ruby-sdk/pull/131)
9
+ - Migrated CI for this repo from Travis CI to GitHub Actions [#130](https://github.com/rakuten-ws/rws-ruby-sdk/pull/130)
10
+ - Add ruby 3.0 support [#129](https://github.com/rakuten-ws/rws-ruby-sdk/pull/129)
11
+
12
+ ## v1.13.0 (2020/10/15)
13
+
14
+ ### Enhancements
15
+
16
+ - Adds `RakutenWebService::Ichiba::Tab.search` [#112](https://github.com/rakuten-ws/rws-ruby-sdk/pull/112)
17
+
18
+ ### Improvements
19
+
20
+ - Adds `rexml` to development dependencies to run tests in ruby 3.0 [#127](https://github.com/rakuten-ws/rws-ruby-sdk/pull/127)
21
+ - Abolishes integration spec [#126](https://github.com/rakuten-ws/rws-ruby-sdk/pull/126)
22
+ - Suppresses deprecation warning for bundle install's option [#125](https://github.com/rakuten-ws/rws-ruby-sdk/pull/125)
23
+ - Updates README.ja.md by fuyuton [#124](https://github.com/rakuten-ws/rws-ruby-sdk/pull/124)
24
+ - Removes comment out by 4geru [#123](https://github.com/rakuten-ws/rws-ruby-sdk/pull/123)
25
+ - Use instance variable in ichiba item example code by 4geru [#122](https://github.com/rakuten-ws/rws-ruby-sdk/pull/122)
26
+ - Updates .travis.yml by 4geru [#121](https://github.com/rakuten-ws/rws-ruby-sdk/pull/121)
27
+ - 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)
28
+ - Drop v2.4 from supported ruby versions [#118](https://github.com/rakuten-ws/rws-ruby-sdk/pull/118)
29
+ - Update supported ruby versions: welcome ruby 2.7 [#117](https://github.com/rakuten-ws/rws-ruby-sdk/pull/117)
30
+ - Inserts frozen string literal comments to travel api codes [#113](https://github.com/rakuten-ws/rws-ruby-sdk/pull/113)
31
+ - Refactoring: Extract process from `Travel::Areaclass::Base` constructor [#114](https://github.com/rakuten-ws/rws-ruby-sdk/pull/114)
32
+ - Refactoring: decompose `RakutenWebService::Resource.attribute` to reduce its complexity [#115](https://github.com/rakuten-ws/rws-ruby-sdk/pull/115)
33
+ - Refactoring: fix some style issues [#116](https://github.com/rakuten-ws/rws-ruby-sdk/pull/116)
34
+
35
+ ### Thanks
36
+
37
+ We are pleased to say thanks to @4geru and @fuyuton. This release includes their seminal works.
38
+ Thanks :tada:
39
+
40
+ ## v1.12.0 (2019/09/09)
41
+
42
+ ### Enhancements
43
+
44
+ - Starts Support Ichiba Tag API. [#110](https://github.com/rakuten-ws/rws-ruby-sdk/pull/110)
45
+
46
+ ### Thanks
47
+
48
+ We are pleased to say thanks to @keisukeponpoko. This release is made by their seminal work.
49
+
50
+ ## v1.11.0 (2019/07/11)
51
+
52
+ ### Improvements
53
+
54
+ * Drop ruby 2.3 from supported ruby versions. [#104](https://github.com/rakuten-ws/rws-ruby-sdk/pull/104)
55
+ * Fixes some issues reported by CoceClimate [#108](https://github.com/rakuten-ws/rws-ruby-sdk/pull/108)
56
+ * `RWS.configuration` no longer accepsts block [#107](https://github.com/rakuten-ws/rws-ruby-sdk/pull/107)
57
+
58
+ ## v1.10.0 (2019/03/11)
59
+
60
+ ### Enhancements
4
61
 
5
62
  * Starts Support of two Travel APIs: SimpleHotelSearch and GetAreaClass. [#91](https://github.com/rakuten-ws/rws-ruby-sdk/pull/91)
6
63
 
7
- # v1.9.2 (2018/12/28)
64
+ ## v1.9.2 (2018/12/28)
8
65
 
9
- ## Enhancements
66
+ ### Enhancements
10
67
 
11
68
  * Ruby 2.6 has been released :tada: this version joined the supported versions! [#100](https://github.com/rakuten-ws/rws-ruby-sdk/pull/100)
12
69
 
13
- # v1.9.1 (2018/03/30)
70
+ ## v1.9.1 (2018/03/30)
14
71
 
15
- ## Improvements
72
+ ### Improvements
16
73
 
17
74
  * Use the magic comment to frozen all string literals.[#93](https://github.com/rakuten-ws/rws-ruby-sdk/pull/93)
18
75
  * Drop ruby 2.2 from supported ruby versions since it goes to the EOL. [#95](https://github.com/rakuten-ws/rws-ruby-sdk/pull/95)
19
76
 
20
- # v1.9.0 (2018/01/04)
77
+ ## v1.9.0 (2018/01/04)
21
78
 
22
- ## Enhancements
79
+ ### Enhancements
23
80
 
24
81
  * Update supported API versions. [#87](https://github.com/rakuten-ws/rws-ruby-sdk/pull/87)
25
82
 
26
- # v1.8.0 (2017/12/30)
83
+ ## v1.8.0 (2017/12/30)
27
84
 
28
- ## Enhancements
85
+ ### Enhancements
29
86
 
30
87
  * Add `RWS::Resource#attributes` method. [#85](https://github.com/rakuten-ws/rws-ruby-sdk/pull/85)
31
88
 
32
- ## Improvements
89
+ ### Improvements
33
90
 
34
91
  * Start supporting Ruby 2.5 and drop 2.1 from supported versions. [#83](https://github.com/rakuten-ws/rws-ruby-sdk/pull/83)
35
92
  * Update outdated gems. [#84](https://github.com/rakuten-ws/rws-ruby-sdk/pull/84)
36
93
 
37
- # v1.7.0 (2017/09/17)
94
+ ## v1.7.0 (2017/09/17)
38
95
 
39
- ## Enhancements
96
+ ### Enhancements
40
97
 
41
98
  * Add Helpers for pagination. [#78](https://github.com/rakuten-ws/rws-ruby-sdk/pull/78)
42
99
 
43
- ## Improvements
100
+ ### Improvements
44
101
 
45
102
  * Minor fix for README.ja.md [#77](https://github.com/rakuten-ws/rws-ruby-sdk/pull/77)
46
103
  * Suppressing installing gems required for debugging with VSCode in CI. [#79](https://github.com/rakuten-ws/rws-ruby-sdk/pull/79)
47
104
 
48
- ## Thanks
105
+ ### Thanks
49
106
 
50
107
  I'm pleasured to say thanks to @jinco13. He fixed wrong method names and links in README.ja.md.
51
108
 
52
- # v1.6.1 (2017/08/21)
109
+ ## v1.6.1 (2017/08/21)
53
110
 
54
- ## Bug Fix
111
+ ### Bug Fix
55
112
 
56
113
  * `RakutenWebService::Ichiba::Genre#brothers` always returns an empty array. [#75](https://github.com/rakuten-ws/rws-ruby-sdk/pull/75)
57
114
 
58
- # v1.6.0 (2017/08/16)
115
+ ## v1.6.0 (2017/08/16)
59
116
 
60
- ## Improvements
117
+ ### Improvements
61
118
 
62
119
  * Added `RakutenWebService::BaseGenre#brothers`. [#74](https://github.com/rakuten-ws/rws-ruby-sdk/pull/74)
63
120
 
64
- # v1.5.0 (2017/03/31)
121
+ ## v1.5.0 (2017/03/31)
65
122
 
66
- ## Improvements
123
+ ### Improvements
67
124
 
68
125
  * Allows to call `RakutenWebService::Recipe.ranking` without `category_id`. [#70](https://github.com/rakuten-ws/rws-ruby-sdk/pull/70)
69
126
 
70
- ## Thanks
127
+ ### Thanks
71
128
 
72
129
  I'm pleasured to say thanks to @kakakakakku. His work has made the usage of `RWS::Recipe.raning` easy to get the ranking in all genres.
73
130
  Thanks!
74
131
 
75
- # v1.4.2 (2017/01/22)
132
+ ## v1.4.2 (2017/01/22)
76
133
 
77
- ## Bug Fixes
134
+ ### Bug Fixes
78
135
 
79
136
  * `Net::HTTP` is NOT `reuquire`d anywhere in the codebase. [#67](https://github.com/rakuten-ws/rws-ruby-sdk/pull/67)
80
137
 
81
138
  The version 1.4.1 or earlier of this gem doesn't `require 'net/http'` by itself.
82
139
  @gouf found the bug report in [teratail](https://teratail.com/questions/62804) and made a pull-request to fix it. Thanks!
83
140
 
84
- ## Improvements
141
+ ### Improvements
85
142
 
86
143
  * `debug_mode` has come again! if you want to see responses from Rakuten Web Service APIs, you can see the ones by set `debug_mode` `true`. [#56](https://github.com/rakuten-ws/rws-ruby-sdk/pull/56)
87
144
  * Refactoring: use new Hash syntax as supporting ruby 1.9 series has been stopped already. [#60](https://github.com/rakuten-ws/rws-ruby-sdk/pull/60)
88
145
 
89
- # v1.4.1 (2016/11/22)
146
+ ## v1.4.1 (2016/11/22)
90
147
 
91
- ## Bug Fix
148
+ ### Bug Fix
92
149
 
93
150
  * Fixed: `WrongParameter` raises when giving any `sort` option to `RakutenWebService::Resource.serch`. [#54](https://github.com/rakuten-ws/rws-ruby-sdk/pull/54)
94
151
 
95
- ## Thanks
152
+ ### Thanks
96
153
 
97
154
  I'm pleased to say thanks to @sho-yamane since he reported the bug #53. If he didn't do it, I would find the bug much later.
98
155
  Thanks, @sho-yamane.
99
156
 
157
+ ## v1.4.0 (2016/11/11)
100
158
 
101
- # v1.4.0 (2016/11/11)
102
-
103
- ## Enhancements
159
+ ### Enhancements
104
160
 
105
161
  * Raise RuntimeError if required option `application_id` is not set when generating parameters. [#51](https://github.com/rakuten-ws/rws-ruby-sdk/pull/51)
106
162
 
163
+ ## v1.3.0 (2016/11/08)
107
164
 
108
- # v1.3.0 (2016/11/08)
109
-
110
- ## Enhancements
165
+ ### Enhancements
111
166
 
112
167
  * Loads Application ID and Affiliate ID from environment varaibles `RWS_APPLICATION_ID` and `RWS_AFFILIATE_ID` respectively. [#47](https://github.com/rakuten-ws/rws-ruby-sdk/pull/47)
113
168
 
114
- ## Improvements
169
+ ### Improvements
115
170
 
116
171
  * Upgraded `codeclimate-test-reporter`. [#48](https://github.com/rakuten-ws/rws-ruby-sdk/pull/48)
117
172
 
118
- # v1.2.0 (2016/10/25)
173
+ ## v1.2.0 (2016/10/25)
119
174
 
120
- ## Ehancements
175
+ ### Ehancements
121
176
 
122
177
  * Started supporting GenreInformation. [#45](https://github.com/rakuten-ws/rws-ruby-sdk/pull/45)
123
178
  * `RakutenWebService::BaseGenre#parent` returns Genre object of the parent genre. [#44](https://github.com/rakuten-ws/rws-ruby-sdk/pull/44)
124
179
 
125
- # v1.1.1 (2016/09/12)
180
+ ## v1.1.1 (2016/09/12)
126
181
 
127
- ## Bug Fix
182
+ ### Bug Fix
128
183
 
129
184
  * Fixed `RakutenWebService::Ichiba::Genre#ranking` ignores given options to be passed to Ichiba Ranking API. [#43](https://github.com/rakuten-ws/rws-ruby-sdk/pull/43)
130
185
 
131
- # v1.1.0 (2016/09/12)
186
+ ## v1.1.0 (2016/09/12)
132
187
 
133
- ## Enhancements
188
+ ### Enhancements
134
189
 
135
190
  * Remove the dependency on faraday, using `Net::HTTP`. [#39](https://github.com/rakuten-ws/rws-ruby-sdk/pull/39)
136
191
  * Allows users to rescue any exception with `RakutenWebService::Error` which is a superclass of all the error class like `RakutenWebService::NotFound`. [#41](https://github.com/rakuten-ws/rws-ruby-sdk/pull/41)
137
192
 
138
- # v1.0.0 (2016/07/29)
193
+ ## v1.0.0 (2016/07/29)
139
194
 
140
- ## Enhancements
195
+ ### Enhancements
141
196
 
142
197
  * Upgrade the version of RSpec and refactoring the configuration. [#36](https://github.com/rakuten-ws/rws-ruby-sdk/pull/36) and [#37](https://github.com/rakuten-ws/rws-ruby-sdk/pull/36)
143
198
 
144
- # v1.0.0.rc1
199
+ ## v1.0.0.rc1
145
200
 
146
- ## Enhancements
201
+ ### Enhancements
147
202
 
148
203
  * Started supporting Gora APIs by @kamatama41 .[#29](https://github.com/rakuten-ws/rws-ruby-sdk/pull/29)
149
204
  * Started supporting Recipe APIs. [#31](https://github.com/rakuten-ws/rws-ruby-sdk/pull/31)
150
205
  * Updated versions of supported Rakuten Web Service APIs.
151
206
 
152
- ## Compatibility Changes
207
+ ### Compatibility Changes
153
208
 
154
209
  * Updated supported Ruby versions to 2.1.0 or later
155
210
  * Any resource's `search` such as `RakutenWebService::Ichiba::Item` returns Enumerator which provides resources fetched at one page.
156
211
  It used to provide all resources by auto-pagerize. From this version provides methods for pagerizing. Please refer to [the sample in README](https://github.com/rakuten-ws/rws-ruby-sdk/blob/master/README.md#pagerizing).
157
212
  * Deprecated calling `RakutenWebService.configuration` with a block, recommending to use `RakutenWebService.configure`.
158
213
 
159
- ## Thanks
214
+ ### Thanks
160
215
 
161
216
  At first, I should appreciate all users of the gems.
162
217
  One of the enhancements, supporting Gora APIs, is realized by @kamatama41 's seminal work.
163
218
  Thank you for your contribution!
164
219
 
165
- # v0.6.3 (2015/07/03)
220
+ ## v0.6.3 (2015/07/03)
166
221
 
167
222
  * Update a gem dependency by @45deg
168
223
  * Fix typo by @45deg
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.15.1', require: false
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.6.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
- gem 'rakuten_web_service'
20
+ gem 'rakuten_web_service'
17
21
  ```
18
22
 
19
23
  そして`bundle`コマンドでインストール。
20
24
 
21
- $ bundle
25
+ ```sh
26
+ bundle
27
+ ```
22
28
 
23
29
  もしくは、`gem`コマンドにより
24
30
 
25
- $ gem install rakuten_web_service
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
- c.affiliate_id = 'YOUR_AFFILIATE_ID'
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(:keyword => 'Ruby') # This returns Enumerable object
79
+ items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby') # Enumerable オブジェクトが返ってくる
91
80
  items.first(10).each do |item|
92
- puts "#{item['itemName']}, #{item.price} yen" # You can refer to values as well as Hash.
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.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 # root genre
102
- # children returns sub genres
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
- # Use genre id to fetch genre object
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 ranking['itemName']
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 ranking['itemName']
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