rakuten_web_service 1.9.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +6 -9
  3. data/.github/FUNDING.yml +12 -0
  4. data/.travis.yml +10 -22
  5. data/CHANGELOG.md +102 -44
  6. data/Gemfile +3 -4
  7. data/README.ja.md +118 -48
  8. data/README.md +44 -17
  9. data/Rakefile +13 -0
  10. data/examples/ichiba_item_search.rb +1 -1
  11. data/examples/recipe_search.rb +16 -0
  12. data/examples/travel_apis.rb +19 -0
  13. data/lib/rakuten_web_service.rb +18 -1
  14. data/lib/rakuten_web_service/all_proxy.rb +2 -1
  15. data/lib/rakuten_web_service/books/genre.rb +1 -1
  16. data/lib/rakuten_web_service/books/resource.rb +1 -1
  17. data/lib/rakuten_web_service/books/total.rb +1 -1
  18. data/lib/rakuten_web_service/client.rb +9 -9
  19. data/lib/rakuten_web_service/configuration.rb +5 -17
  20. data/lib/rakuten_web_service/error.rb +5 -0
  21. data/lib/rakuten_web_service/genre.rb +3 -1
  22. data/lib/rakuten_web_service/gora/course.rb +1 -1
  23. data/lib/rakuten_web_service/gora/course_detail.rb +1 -1
  24. data/lib/rakuten_web_service/gora/plan.rb +1 -1
  25. data/lib/rakuten_web_service/ichiba.rb +2 -0
  26. data/lib/rakuten_web_service/ichiba/item.rb +2 -2
  27. data/lib/rakuten_web_service/ichiba/product.rb +1 -1
  28. data/lib/rakuten_web_service/ichiba/ranking.rb +1 -1
  29. data/lib/rakuten_web_service/ichiba/tag.rb +16 -0
  30. data/lib/rakuten_web_service/ichiba/tag_group.rb +23 -0
  31. data/lib/rakuten_web_service/kobo/ebook.rb +1 -1
  32. data/lib/rakuten_web_service/kobo/genre.rb +1 -1
  33. data/lib/rakuten_web_service/recipe.rb +1 -1
  34. data/lib/rakuten_web_service/recipe/category.rb +3 -1
  35. data/lib/rakuten_web_service/resource.rb +46 -26
  36. data/lib/rakuten_web_service/response.rb +10 -5
  37. data/lib/rakuten_web_service/search_result.rb +22 -23
  38. data/lib/rakuten_web_service/string_support.rb +18 -0
  39. data/lib/rakuten_web_service/travel.rb +2 -0
  40. data/lib/rakuten_web_service/travel/area_class.rb +129 -0
  41. data/lib/rakuten_web_service/travel/hotel.rb +30 -0
  42. data/lib/rakuten_web_service/travel/open_struct.rb +19 -0
  43. data/lib/rakuten_web_service/travel/resource.rb +12 -0
  44. data/lib/rakuten_web_service/travel/search_result.rb +34 -0
  45. data/lib/rakuten_web_service/version.rb +1 -1
  46. data/rakuten_web_service.gemspec +8 -5
  47. data/spec/fixtures/ichiba/tag_search.json +15 -0
  48. data/spec/fixtures/travel/area_class.json +1 -0
  49. data/spec/fixtures/travel/simple_hotel_search.json +1 -0
  50. data/spec/rakuten_web_service/configuration_spec.rb +0 -52
  51. data/spec/rakuten_web_service/genre_spec.rb +1 -1
  52. data/spec/rakuten_web_service/ichiba/tag_group_spec.rb +68 -0
  53. data/spec/rakuten_web_service/ichiba/tag_spec.rb +35 -0
  54. data/spec/rakuten_web_service/resource_spec.rb +31 -1
  55. data/spec/rakuten_web_service/response_spec.rb +7 -7
  56. data/spec/rakuten_web_service/travel/area_class_spec.rb +117 -0
  57. data/spec/rakuten_web_service/travel/open_struct_spec.rb +53 -0
  58. data/spec/rakuten_web_service/travel/search_result_spec.rb +71 -0
  59. data/spec/rakuten_web_service/travel/simple_hotel_search_spec.rb +65 -0
  60. data/spec/rakuten_web_service_spec.rb +48 -0
  61. metadata +90 -19
  62. data/spec/integration/integration_spec.rb +0 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd60bf746130b97cac7b59e6a529457183b6eae42f3eb595b64c4aa820b2bbcd
4
- data.tar.gz: e773d058c29619d931bda28e656f7fe7cea63816905c56e20fa55c7a84662d49
3
+ metadata.gz: bdb4eed0f6b4075f460d74c30218551f0345c9bc12cda1a433bdcf9525e4ff64
4
+ data.tar.gz: ce188517ae7113a4322b35b271c9c5fccda23f0bb5694a8047bea1afdbf25a0c
5
5
  SHA512:
6
- metadata.gz: a68b23e18568d9e7cc60213b2fc881d02085966f809f7dd7e3e503e8c7404096ee46ea5120b2740ad896f4699a915cd57cf53af892ee17cb47aafc7944bb8031
7
- data.tar.gz: ce2b779f0eddebd1c9246dc041bc277b84a3047e3428f7150ccfd2c60ecc204fa73b89817f31380e80d5c393e09a382cbf765569871912387f2153e2ba6cbf95
6
+ metadata.gz: 8b996cb29aa1fc0dd7634ee33dced0386e0d320711a42e98a20af695815df35709778d2150327551fa2dffe27a69407eb04f0aa4a3c72d01ba485e8e6ac172b7
7
+ data.tar.gz: 265354c69faacb14e9fe3aa3565b44d9813a8011562b913a3fe4ee017ea3e18bc4cf4df0e1f97295a5eb5c235a3beecc75e9efa37ecb89543fee5543c8e49307
@@ -1,4 +1,5 @@
1
- engines:
1
+ version: "2"
2
+ plugins:
2
3
  rubocop:
3
4
  enabled: true
4
5
  duplication:
@@ -6,11 +7,7 @@ engines:
6
7
  config:
7
8
  languages:
8
9
  - ruby
9
-
10
- ratings:
11
- paths:
12
- - lib/**/*.rb
13
-
14
- exclude_paths:
15
- - spec/**/*
16
- - examples/*.rb
10
+ exclude_patterns:
11
+ - "bin/"
12
+ - "spec/"
13
+ - "examples/"
@@ -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']
@@ -1,42 +1,30 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.6
4
- - 2.4.3
5
- - 2.5.0
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
15
11
 
16
12
  before_install:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
17
16
  - gem install bundler
18
-
19
- bundler_args: --without vscode
17
+ - bundle config set without 'vscode'
20
18
 
21
19
  script:
22
20
  - bundle exec rake
23
- - bundle exec codeclimate-test-reporter
21
+
22
+ after_script:
23
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
24
24
 
25
25
  matrix:
26
26
  allow_failures:
27
27
  - rvm: ruby-head
28
- exclude:
29
- - rvm: 2.3.6
30
- env: INTEGRATION=yes
31
- - rvm: 2.4.3
32
- env: INTEGRATION=yes
33
- - rvm: ruby-head
34
- env: INTEGRATION=yes
35
-
36
- addons:
37
- code_climate:
38
- repo_token:
39
- secure: Z23O936LoCDGJ/OyYsLzxTUI+CMWyrfeN1PtQdCNMdF4vxwaCsAHr3ulTdudGhKMrVZGENSEK6fq0Xal3o3oPaH9aGM9sUQ/ibRM+J94Lx6Owu4okTsIHoEy4vFeW+A/62aiwxPcoi7PFrvC8FOfaZg+b+vvYAQcitVe6qwBHiE=
40
28
 
41
29
  notifications:
42
30
  email: false
@@ -1,156 +1,214 @@
1
- # v1.9.1 (2018/03/30)
1
+ # CHANGELOG
2
2
 
3
- ## Improvements
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
+
31
+ ## v1.12.0 (2019/09/09)
32
+
33
+ ### Enhancements
34
+
35
+ - Starts Support Ichiba Tag API. [#110](https://github.com/rakuten-ws/rws-ruby-sdk/pull/110)
36
+
37
+ ### Thanks
38
+
39
+ We are pleased to say thanks to @keisukeponpoko. This release is made by their seminal work.
40
+
41
+ ## v1.11.0 (2019/07/11)
42
+
43
+ ### Improvements
44
+
45
+ * Drop ruby 2.3 from supported ruby versions. [#104](https://github.com/rakuten-ws/rws-ruby-sdk/pull/104)
46
+ * Fixes some issues reported by CoceClimate [#108](https://github.com/rakuten-ws/rws-ruby-sdk/pull/108)
47
+ * `RWS.configuration` no longer accepsts block [#107](https://github.com/rakuten-ws/rws-ruby-sdk/pull/107)
48
+
49
+ ## v1.10.0 (2019/03/11)
50
+
51
+ ### Enhancements
52
+
53
+ * Starts Support of two Travel APIs: SimpleHotelSearch and GetAreaClass. [#91](https://github.com/rakuten-ws/rws-ruby-sdk/pull/91)
54
+
55
+ ## v1.9.2 (2018/12/28)
56
+
57
+ ### Enhancements
58
+
59
+ * Ruby 2.6 has been released :tada: this version joined the supported versions! [#100](https://github.com/rakuten-ws/rws-ruby-sdk/pull/100)
60
+
61
+ ## v1.9.1 (2018/03/30)
62
+
63
+ ### Improvements
4
64
 
5
65
  * Use the magic comment to frozen all string literals.[#93](https://github.com/rakuten-ws/rws-ruby-sdk/pull/93)
6
66
  * 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)
7
67
 
8
- # v1.9.0 (2018/01/04)
68
+ ## v1.9.0 (2018/01/04)
9
69
 
10
- ## Enhancements
70
+ ### Enhancements
11
71
 
12
72
  * Update supported API versions. [#87](https://github.com/rakuten-ws/rws-ruby-sdk/pull/87)
13
73
 
14
- # v1.8.0 (2017/12/30)
74
+ ## v1.8.0 (2017/12/30)
15
75
 
16
- ## Enhancements
76
+ ### Enhancements
17
77
 
18
78
  * Add `RWS::Resource#attributes` method. [#85](https://github.com/rakuten-ws/rws-ruby-sdk/pull/85)
19
79
 
20
- ## Improvements
80
+ ### Improvements
21
81
 
22
82
  * Start supporting Ruby 2.5 and drop 2.1 from supported versions. [#83](https://github.com/rakuten-ws/rws-ruby-sdk/pull/83)
23
83
  * Update outdated gems. [#84](https://github.com/rakuten-ws/rws-ruby-sdk/pull/84)
24
84
 
25
- # v1.7.0 (2017/09/17)
85
+ ## v1.7.0 (2017/09/17)
26
86
 
27
- ## Enhancements
87
+ ### Enhancements
28
88
 
29
89
  * Add Helpers for pagination. [#78](https://github.com/rakuten-ws/rws-ruby-sdk/pull/78)
30
90
 
31
- ## Improvements
91
+ ### Improvements
32
92
 
33
93
  * Minor fix for README.ja.md [#77](https://github.com/rakuten-ws/rws-ruby-sdk/pull/77)
34
94
  * Suppressing installing gems required for debugging with VSCode in CI. [#79](https://github.com/rakuten-ws/rws-ruby-sdk/pull/79)
35
95
 
36
- ## Thanks
96
+ ### Thanks
37
97
 
38
98
  I'm pleasured to say thanks to @jinco13. He fixed wrong method names and links in README.ja.md.
39
99
 
40
- # v1.6.1 (2017/08/21)
100
+ ## v1.6.1 (2017/08/21)
41
101
 
42
- ## Bug Fix
102
+ ### Bug Fix
43
103
 
44
104
  * `RakutenWebService::Ichiba::Genre#brothers` always returns an empty array. [#75](https://github.com/rakuten-ws/rws-ruby-sdk/pull/75)
45
105
 
46
- # v1.6.0 (2017/08/16)
106
+ ## v1.6.0 (2017/08/16)
47
107
 
48
- ## Improvements
108
+ ### Improvements
49
109
 
50
110
  * Added `RakutenWebService::BaseGenre#brothers`. [#74](https://github.com/rakuten-ws/rws-ruby-sdk/pull/74)
51
111
 
52
- # v1.5.0 (2017/03/31)
112
+ ## v1.5.0 (2017/03/31)
53
113
 
54
- ## Improvements
114
+ ### Improvements
55
115
 
56
116
  * Allows to call `RakutenWebService::Recipe.ranking` without `category_id`. [#70](https://github.com/rakuten-ws/rws-ruby-sdk/pull/70)
57
117
 
58
- ## Thanks
118
+ ### Thanks
59
119
 
60
120
  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.
61
121
  Thanks!
62
122
 
63
- # v1.4.2 (2017/01/22)
123
+ ## v1.4.2 (2017/01/22)
64
124
 
65
- ## Bug Fixes
125
+ ### Bug Fixes
66
126
 
67
127
  * `Net::HTTP` is NOT `reuquire`d anywhere in the codebase. [#67](https://github.com/rakuten-ws/rws-ruby-sdk/pull/67)
68
128
 
69
129
  The version 1.4.1 or earlier of this gem doesn't `require 'net/http'` by itself.
70
130
  @gouf found the bug report in [teratail](https://teratail.com/questions/62804) and made a pull-request to fix it. Thanks!
71
131
 
72
- ## Improvements
132
+ ### Improvements
73
133
 
74
134
  * `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)
75
135
  * 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)
76
136
 
77
- # v1.4.1 (2016/11/22)
137
+ ## v1.4.1 (2016/11/22)
78
138
 
79
- ## Bug Fix
139
+ ### Bug Fix
80
140
 
81
141
  * Fixed: `WrongParameter` raises when giving any `sort` option to `RakutenWebService::Resource.serch`. [#54](https://github.com/rakuten-ws/rws-ruby-sdk/pull/54)
82
142
 
83
- ## Thanks
143
+ ### Thanks
84
144
 
85
145
  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.
86
146
  Thanks, @sho-yamane.
87
147
 
148
+ ## v1.4.0 (2016/11/11)
88
149
 
89
- # v1.4.0 (2016/11/11)
90
-
91
- ## Enhancements
150
+ ### Enhancements
92
151
 
93
152
  * Raise RuntimeError if required option `application_id` is not set when generating parameters. [#51](https://github.com/rakuten-ws/rws-ruby-sdk/pull/51)
94
153
 
154
+ ## v1.3.0 (2016/11/08)
95
155
 
96
- # v1.3.0 (2016/11/08)
97
-
98
- ## Enhancements
156
+ ### Enhancements
99
157
 
100
158
  * 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)
101
159
 
102
- ## Improvements
160
+ ### Improvements
103
161
 
104
162
  * Upgraded `codeclimate-test-reporter`. [#48](https://github.com/rakuten-ws/rws-ruby-sdk/pull/48)
105
163
 
106
- # v1.2.0 (2016/10/25)
164
+ ## v1.2.0 (2016/10/25)
107
165
 
108
- ## Ehancements
166
+ ### Ehancements
109
167
 
110
168
  * Started supporting GenreInformation. [#45](https://github.com/rakuten-ws/rws-ruby-sdk/pull/45)
111
169
  * `RakutenWebService::BaseGenre#parent` returns Genre object of the parent genre. [#44](https://github.com/rakuten-ws/rws-ruby-sdk/pull/44)
112
170
 
113
- # v1.1.1 (2016/09/12)
171
+ ## v1.1.1 (2016/09/12)
114
172
 
115
- ## Bug Fix
173
+ ### Bug Fix
116
174
 
117
175
  * 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)
118
176
 
119
- # v1.1.0 (2016/09/12)
177
+ ## v1.1.0 (2016/09/12)
120
178
 
121
- ## Enhancements
179
+ ### Enhancements
122
180
 
123
181
  * Remove the dependency on faraday, using `Net::HTTP`. [#39](https://github.com/rakuten-ws/rws-ruby-sdk/pull/39)
124
182
  * 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)
125
183
 
126
- # v1.0.0 (2016/07/29)
184
+ ## v1.0.0 (2016/07/29)
127
185
 
128
- ## Enhancements
186
+ ### Enhancements
129
187
 
130
188
  * 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)
131
189
 
132
- # v1.0.0.rc1
190
+ ## v1.0.0.rc1
133
191
 
134
- ## Enhancements
192
+ ### Enhancements
135
193
 
136
194
  * Started supporting Gora APIs by @kamatama41 .[#29](https://github.com/rakuten-ws/rws-ruby-sdk/pull/29)
137
195
  * Started supporting Recipe APIs. [#31](https://github.com/rakuten-ws/rws-ruby-sdk/pull/31)
138
196
  * Updated versions of supported Rakuten Web Service APIs.
139
197
 
140
- ## Compatibility Changes
198
+ ### Compatibility Changes
141
199
 
142
200
  * Updated supported Ruby versions to 2.1.0 or later
143
201
  * Any resource's `search` such as `RakutenWebService::Ichiba::Item` returns Enumerator which provides resources fetched at one page.
144
202
  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).
145
203
  * Deprecated calling `RakutenWebService.configuration` with a block, recommending to use `RakutenWebService.configure`.
146
204
 
147
- ## Thanks
205
+ ### Thanks
148
206
 
149
207
  At first, I should appreciate all users of the gems.
150
208
  One of the enhancements, supporting Gora APIs, is realized by @kamatama41 's seminal work.
151
209
  Thank you for your contribution!
152
210
 
153
- # v0.6.3 (2015/07/03)
211
+ ## v0.6.3 (2015/07/03)
154
212
 
155
213
  * Update a gem dependency by @45deg
156
214
  * Fix typo by @45deg
data/Gemfile CHANGED
@@ -4,11 +4,10 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'codeclimate-test-reporter', '~> 1.0.0'
8
- gem 'simplecov', '~> 0.15.1', require: false
7
+ gem 'simplecov', '~> 0.17.1', require: false
9
8
  end
10
9
 
11
10
  group :vscode do
12
- gem 'debase', '0.2.2.beta14'
13
- gem 'ruby-debug-ide', '~> 0.6.0'
11
+ gem 'debase', '~> 0.2', '>= 0.2.4.1'
12
+ gem 'ruby-debug-ide', '~> 0.7'
14
13
  end
@@ -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.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 # 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