rakuten_web_service 0.6.3 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +19 -3
- data/CHANGELOG.md +14 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +5 -0
- data/README.ja.md +133 -0
- data/README.md +129 -48
- data/examples/books_item_search.rb +24 -0
- data/examples/gora_search.rb +48 -0
- data/examples/ichiba_item_search.rb +1 -3
- data/lib/rakuten_web_service.rb +2 -0
- data/lib/rakuten_web_service/all_proxy.rb +20 -0
- data/lib/rakuten_web_service/client.rb +6 -13
- data/lib/rakuten_web_service/configuration.rb +28 -4
- data/lib/rakuten_web_service/gora.rb +3 -0
- data/lib/rakuten_web_service/gora/course.rb +17 -0
- data/lib/rakuten_web_service/gora/course_detail.rb +55 -0
- data/lib/rakuten_web_service/gora/plan.rb +47 -0
- data/lib/rakuten_web_service/ichiba/item.rb +5 -4
- data/lib/rakuten_web_service/ichiba/shop.rb +1 -1
- data/lib/rakuten_web_service/kobo/ebook.rb +2 -2
- data/lib/rakuten_web_service/recipe.rb +28 -0
- data/lib/rakuten_web_service/recipe/category.rb +60 -0
- data/lib/rakuten_web_service/resource.rb +9 -1
- data/lib/rakuten_web_service/search_result.rb +43 -19
- data/lib/rakuten_web_service/version.rb +1 -1
- data/rakuten_web_service.gemspec +2 -2
- data/spec/fixtures/gora/course_detail_search.json +1 -0
- data/spec/fixtures/gora/course_search_with_Karuizawa.json +1 -0
- data/spec/fixtures/gora/plan_search_with_area_code.json +1 -0
- data/spec/fixtures/recipe/category.json +1 -0
- data/spec/fixtures/recipe/ranking.json +1 -0
- data/spec/rakuten_web_service/books/book_spec.rb +1 -2
- data/spec/rakuten_web_service/books/cd_spec.rb +1 -2
- data/spec/rakuten_web_service/books/dvd_spec.rb +1 -2
- data/spec/rakuten_web_service/books/foreign_book_spec.rb +1 -2
- data/spec/rakuten_web_service/books/game_spec.rb +1 -2
- data/spec/rakuten_web_service/books/genre_spec.rb +1 -2
- data/spec/rakuten_web_service/books/magazine_spec.rb +1 -2
- data/spec/rakuten_web_service/books/software_spec.rb +1 -2
- data/spec/rakuten_web_service/books/total_spec.rb +1 -2
- data/spec/rakuten_web_service/client_spec.rb +3 -3
- data/spec/rakuten_web_service/configuration_spec.rb +45 -4
- data/spec/rakuten_web_service/gora/course_detail_spec.rb +60 -0
- data/spec/rakuten_web_service/gora/course_spec.rb +108 -0
- data/spec/rakuten_web_service/gora/plan_spec.rb +62 -0
- data/spec/rakuten_web_service/ichiba/genre_spec.rb +1 -2
- data/spec/rakuten_web_service/ichiba/item_spec.rb +53 -8
- data/spec/rakuten_web_service/ichiba/product_search_spec.rb +2 -3
- data/spec/rakuten_web_service/ichiba/ranking_spec.rb +1 -1
- data/spec/rakuten_web_service/ichiba/shop_spec.rb +2 -3
- data/spec/rakuten_web_service/kobo/ebook_spec.rb +2 -3
- data/spec/rakuten_web_service/kobo/genre_spec.rb +1 -2
- data/spec/rakuten_web_service/recipe/category_spec.rb +185 -0
- data/spec/rakuten_web_service/recipe_spec.rb +50 -0
- data/spec/spec_helper.rb +16 -6
- metadata +42 -11
- data/README.en.md +0 -108
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakutenWebService::Recipe do
|
4
|
+
let(:endpoint) { 'https://app.rakuten.co.jp/services/api/Recipe/CategoryRanking/20121121' }
|
5
|
+
let(:affiliate_id) { 'dummy_affiliate_id' }
|
6
|
+
let(:application_id) { 'dummy_application_id' }
|
7
|
+
let(:expected_query) do
|
8
|
+
{
|
9
|
+
:affiliateId => affiliate_id,
|
10
|
+
:applicationId => application_id,
|
11
|
+
:categoryId => category_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
RakutenWebService.configure do |c|
|
17
|
+
c.affiliate_id = affiliate_id
|
18
|
+
c.application_id = application_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.search' do
|
23
|
+
it 'should not be called' do
|
24
|
+
expect { RWS::Recipe.search(category_id: '10') }.to raise_error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.ranking' do
|
29
|
+
let(:category_id) { '30' }
|
30
|
+
|
31
|
+
before do
|
32
|
+
response = JSON.parse(fixture('recipe/ranking.json'))
|
33
|
+
|
34
|
+
@expected_request = stub_request(:get, endpoint).
|
35
|
+
with(query: expected_query).
|
36
|
+
to_return(body: response.to_json)
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { RakutenWebService::Recipe.ranking(category_id) }
|
40
|
+
|
41
|
+
it 'should call search with category id' do
|
42
|
+
subject.first
|
43
|
+
|
44
|
+
expect(@expected_request).to have_been_made.once
|
45
|
+
end
|
46
|
+
it 'shoudl return an array of Reciep' do
|
47
|
+
expect(subject).to be_all { |r| r.is_a?(RWS::Recipe) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,26 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
1
|
+
if ENV['CI']
|
2
|
+
require 'codeclimate-test-reporter'
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
|
5
|
+
require 'coveralls'
|
6
|
+
Coveralls.wear!
|
7
|
+
end
|
4
8
|
|
5
|
-
|
9
|
+
require File.expand_path(File.join(__dir__, '..', 'lib', 'rakuten_web_service'))
|
10
|
+
|
11
|
+
require 'webmock/rspec'
|
6
12
|
|
7
13
|
Dir[File.expand_path(File.join(File.dirname(__FILE__), "support/**/*.rb"))].each { |f| require f }
|
8
14
|
|
9
15
|
RSpec.configure do |c|
|
10
16
|
c.mock_with :rspec
|
11
17
|
|
12
|
-
c.before :
|
13
|
-
WebMock.disable_net_connect!
|
18
|
+
c.before :suite do
|
19
|
+
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
20
|
+
end
|
21
|
+
|
22
|
+
c.before :suite, integration: true do
|
23
|
+
WebMock.allow_net_connect!
|
14
24
|
end
|
15
25
|
|
16
26
|
c.after :each do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakuten_web_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.20.4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.20.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,16 +115,21 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- .coveralls.yml
|
118
119
|
- .gitignore
|
119
120
|
- .travis.yml
|
120
121
|
- CHANGELOG.md
|
122
|
+
- CODE_OF_CONDUCT.md
|
121
123
|
- Gemfile
|
122
124
|
- LICENSE.txt
|
123
|
-
- README.
|
125
|
+
- README.ja.md
|
124
126
|
- README.md
|
125
127
|
- Rakefile
|
128
|
+
- examples/books_item_search.rb
|
129
|
+
- examples/gora_search.rb
|
126
130
|
- examples/ichiba_item_search.rb
|
127
131
|
- lib/rakuten_web_service.rb
|
132
|
+
- lib/rakuten_web_service/all_proxy.rb
|
128
133
|
- lib/rakuten_web_service/books.rb
|
129
134
|
- lib/rakuten_web_service/books/book.rb
|
130
135
|
- lib/rakuten_web_service/books/cd.rb
|
@@ -139,6 +144,10 @@ files:
|
|
139
144
|
- lib/rakuten_web_service/client.rb
|
140
145
|
- lib/rakuten_web_service/configuration.rb
|
141
146
|
- lib/rakuten_web_service/genre.rb
|
147
|
+
- lib/rakuten_web_service/gora.rb
|
148
|
+
- lib/rakuten_web_service/gora/course.rb
|
149
|
+
- lib/rakuten_web_service/gora/course_detail.rb
|
150
|
+
- lib/rakuten_web_service/gora/plan.rb
|
142
151
|
- lib/rakuten_web_service/ichiba.rb
|
143
152
|
- lib/rakuten_web_service/ichiba/genre.rb
|
144
153
|
- lib/rakuten_web_service/ichiba/item.rb
|
@@ -148,6 +157,8 @@ files:
|
|
148
157
|
- lib/rakuten_web_service/kobo.rb
|
149
158
|
- lib/rakuten_web_service/kobo/ebook.rb
|
150
159
|
- lib/rakuten_web_service/kobo/genre.rb
|
160
|
+
- lib/rakuten_web_service/recipe.rb
|
161
|
+
- lib/rakuten_web_service/recipe/category.rb
|
151
162
|
- lib/rakuten_web_service/resource.rb
|
152
163
|
- lib/rakuten_web_service/response.rb
|
153
164
|
- lib/rakuten_web_service/search_result.rb
|
@@ -162,12 +173,17 @@ files:
|
|
162
173
|
- spec/fixtures/books/magazine_search_with_keyword_Ruby.json
|
163
174
|
- spec/fixtures/books/software_search_with_keyword_Ruby.json
|
164
175
|
- spec/fixtures/books/total_search_with_keyword_Ruby.json
|
176
|
+
- spec/fixtures/gora/course_detail_search.json
|
177
|
+
- spec/fixtures/gora/course_search_with_Karuizawa.json
|
178
|
+
- spec/fixtures/gora/plan_search_with_area_code.json
|
165
179
|
- spec/fixtures/ichiba/genre_search.json
|
166
180
|
- spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
|
167
181
|
- spec/fixtures/ichiba/product_search.json
|
168
182
|
- spec/fixtures/ichiba/ranking_search.json
|
169
183
|
- spec/fixtures/kobo/ebook_search_with_Ruby.json
|
170
184
|
- spec/fixtures/kobo/genre_search.json
|
185
|
+
- spec/fixtures/recipe/category.json
|
186
|
+
- spec/fixtures/recipe/ranking.json
|
171
187
|
- spec/rakuten_web_service/books/book_spec.rb
|
172
188
|
- spec/rakuten_web_service/books/cd_spec.rb
|
173
189
|
- spec/rakuten_web_service/books/dvd_spec.rb
|
@@ -179,6 +195,9 @@ files:
|
|
179
195
|
- spec/rakuten_web_service/books/total_spec.rb
|
180
196
|
- spec/rakuten_web_service/client_spec.rb
|
181
197
|
- spec/rakuten_web_service/configuration_spec.rb
|
198
|
+
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
199
|
+
- spec/rakuten_web_service/gora/course_spec.rb
|
200
|
+
- spec/rakuten_web_service/gora/plan_spec.rb
|
182
201
|
- spec/rakuten_web_service/ichiba/genre_spec.rb
|
183
202
|
- spec/rakuten_web_service/ichiba/item_spec.rb
|
184
203
|
- spec/rakuten_web_service/ichiba/product_search_spec.rb
|
@@ -186,6 +205,8 @@ files:
|
|
186
205
|
- spec/rakuten_web_service/ichiba/shop_spec.rb
|
187
206
|
- spec/rakuten_web_service/kobo/ebook_spec.rb
|
188
207
|
- spec/rakuten_web_service/kobo/genre_spec.rb
|
208
|
+
- spec/rakuten_web_service/recipe/category_spec.rb
|
209
|
+
- spec/rakuten_web_service/recipe_spec.rb
|
189
210
|
- spec/spec_helper.rb
|
190
211
|
- spec/support/fixture_suppot.rb
|
191
212
|
homepage: http://webservice.rakuten.co.jp/
|
@@ -198,14 +219,14 @@ require_paths:
|
|
198
219
|
- lib
|
199
220
|
required_ruby_version: !ruby/object:Gem::Requirement
|
200
221
|
requirements:
|
201
|
-
- - '
|
222
|
+
- - '>='
|
202
223
|
- !ruby/object:Gem::Version
|
203
|
-
version: 1.
|
224
|
+
version: 2.1.0
|
204
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
226
|
requirements:
|
206
|
-
- - '
|
227
|
+
- - '>'
|
207
228
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
229
|
+
version: 1.3.1
|
209
230
|
requirements: []
|
210
231
|
rubyforge_project:
|
211
232
|
rubygems_version: 2.0.3
|
@@ -222,12 +243,17 @@ test_files:
|
|
222
243
|
- spec/fixtures/books/magazine_search_with_keyword_Ruby.json
|
223
244
|
- spec/fixtures/books/software_search_with_keyword_Ruby.json
|
224
245
|
- spec/fixtures/books/total_search_with_keyword_Ruby.json
|
246
|
+
- spec/fixtures/gora/course_detail_search.json
|
247
|
+
- spec/fixtures/gora/course_search_with_Karuizawa.json
|
248
|
+
- spec/fixtures/gora/plan_search_with_area_code.json
|
225
249
|
- spec/fixtures/ichiba/genre_search.json
|
226
250
|
- spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
|
227
251
|
- spec/fixtures/ichiba/product_search.json
|
228
252
|
- spec/fixtures/ichiba/ranking_search.json
|
229
253
|
- spec/fixtures/kobo/ebook_search_with_Ruby.json
|
230
254
|
- spec/fixtures/kobo/genre_search.json
|
255
|
+
- spec/fixtures/recipe/category.json
|
256
|
+
- spec/fixtures/recipe/ranking.json
|
231
257
|
- spec/rakuten_web_service/books/book_spec.rb
|
232
258
|
- spec/rakuten_web_service/books/cd_spec.rb
|
233
259
|
- spec/rakuten_web_service/books/dvd_spec.rb
|
@@ -239,6 +265,9 @@ test_files:
|
|
239
265
|
- spec/rakuten_web_service/books/total_spec.rb
|
240
266
|
- spec/rakuten_web_service/client_spec.rb
|
241
267
|
- spec/rakuten_web_service/configuration_spec.rb
|
268
|
+
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
269
|
+
- spec/rakuten_web_service/gora/course_spec.rb
|
270
|
+
- spec/rakuten_web_service/gora/plan_spec.rb
|
242
271
|
- spec/rakuten_web_service/ichiba/genre_spec.rb
|
243
272
|
- spec/rakuten_web_service/ichiba/item_spec.rb
|
244
273
|
- spec/rakuten_web_service/ichiba/product_search_spec.rb
|
@@ -246,5 +275,7 @@ test_files:
|
|
246
275
|
- spec/rakuten_web_service/ichiba/shop_spec.rb
|
247
276
|
- spec/rakuten_web_service/kobo/ebook_spec.rb
|
248
277
|
- spec/rakuten_web_service/kobo/genre_spec.rb
|
278
|
+
- spec/rakuten_web_service/recipe/category_spec.rb
|
279
|
+
- spec/rakuten_web_service/recipe_spec.rb
|
249
280
|
- spec/spec_helper.rb
|
250
281
|
- spec/support/fixture_suppot.rb
|
data/README.en.md
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
# RakutenWebService
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/rakuten-ws/rws-ruby-sdk.png?branch=master)](https://travis-ci.org/rakuten-ws/rws-ruby-sdk) [![Gem Version](https://badge.fury.io/rb/rakuten_web_service.png)](http://badge.fury.io/rb/rakuten_web_service)
|
4
|
-
|
5
|
-
|
6
|
-
## Installation
|
7
|
-
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
gem 'rakuten_web_service'
|
12
|
-
```
|
13
|
-
|
14
|
-
And then execute:
|
15
|
-
|
16
|
-
$ bundle
|
17
|
-
|
18
|
-
Or install it yourself as:
|
19
|
-
|
20
|
-
$ gem install rakuten_web_service
|
21
|
-
|
22
|
-
|
23
|
-
Now rakuten\_web\_service is supporting the following APIs:
|
24
|
-
|
25
|
-
### Rakuten Ichiba APIs
|
26
|
-
|
27
|
-
* [Rakuten Ichiba Item Search API](http://webservice.rakuten.co.jp/api/ichibaitemsearch/)
|
28
|
-
* [Rakuten Ichiba Genre Search API](http://webservice.rakuten.co.jp/api/ichibagenresearch/)
|
29
|
-
* [Rakuten Ichiba Ranking API](http://webservice.rakuten.co.jp/api/ichibaitemranking/)
|
30
|
-
* [Rakuten Product API](http://webservice.rakuten.co.jp/api/productsearch/)
|
31
|
-
|
32
|
-
|
33
|
-
### Rakuten Books APIs
|
34
|
-
|
35
|
-
* [Rakuten Books Total Search API](http://webservice.rakuten.co.jp/api/bookstotalsearch/)
|
36
|
-
* [Rakuten Books Book Search API](http://webservice.rakuten.co.jp/api/booksbooksearch/)
|
37
|
-
* [Rakuten Books CD Search API](http://webservice.rakuten.co.jp/api/bookscdsearch/)
|
38
|
-
* [Rakuten Books DVD/Blu-ray Search API](http://webservice.rakuten.co.jp/api/booksdvdsearch/)
|
39
|
-
* [Rakuten Books ForeignBook Search API](http://webservice.rakuten.co.jp/api/booksforeignbooksearch/)
|
40
|
-
* [Rakuten Books Magazine Search API](http://webservice.rakuten.co.jp/api/booksmagazinesearch/)
|
41
|
-
* [Rakuten Books Game Search API](http://webservice.rakuten.co.jp/api/booksgamesearch/)
|
42
|
-
* [Rakuten Books Software Search API](http://webservice.rakuten.co.jp/api/bookssoftwaresearch/)
|
43
|
-
* [Rakuten Books Genre Search API](http://webservice.rakuten.co.jp/api/booksgenresearch/)
|
44
|
-
|
45
|
-
### Rakuten Kobo APIs
|
46
|
-
|
47
|
-
* [Rakuten Kobo Ebook Search API](http://webservice.rakuten.co.jp/api/koboebooksearch/)
|
48
|
-
* [Rakuten Kobo Genre Search API](http://webservice.rakuten.co.jp/api/kobogenresearch/)
|
49
|
-
|
50
|
-
## Usage
|
51
|
-
|
52
|
-
### Prerequisite: Getting Application ID
|
53
|
-
|
54
|
-
You need to get Application ID for your application to access to Rakuten Web Service APIs.
|
55
|
-
If you have not got it, register your appplication [here](https://webservice.rakuten.co.jp/app/create).
|
56
|
-
|
57
|
-
### Configuration
|
58
|
-
|
59
|
-
`RakutenWebService.configuration` allows you to specify your application's key called application\_id and your affiliate id(optional).
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
RakutenWebService.configuration do |c|
|
63
|
-
c.application_id = 'YOUR_APPLICATION_ID'
|
64
|
-
c.affiliate_id = 'YOUR_AFFILIATE_ID'
|
65
|
-
end
|
66
|
-
```
|
67
|
-
|
68
|
-
Please note that you neet to replace `'YOUR_APPLICATION_ID'` and `'YOUR_AFFILIATE_ID'` with actual ones you have.
|
69
|
-
|
70
|
-
### Search Ichiba Items
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
items = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby') # This returns Enumerable object
|
74
|
-
items.first(10).each do |item|
|
75
|
-
puts "#{item['itemName']}, #{item.price} yen" # You can refer to values as well as Hash.
|
76
|
-
end
|
77
|
-
```
|
78
|
-
|
79
|
-
### Genre
|
80
|
-
|
81
|
-
Genre class provides an interface to traverse sub genres.
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
root = RakutenWebService::Ichiba::Genre.root # root genre
|
85
|
-
# children returns sub genres
|
86
|
-
root.children.each do |child|
|
87
|
-
puts "[#{child.id}] #{child.name}"
|
88
|
-
end
|
89
|
-
|
90
|
-
# Use genre id to fetch genre object
|
91
|
-
RakutenWebService::Ichiba::Genre[100316].name # => "水・ソフトドリンク"
|
92
|
-
```
|
93
|
-
|
94
|
-
|
95
|
-
### Ichiba Item Ranking
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
RakutenWebService::Ichiba::Item.ranking(:age => 30, :sex => 0) # returns the TOP 30 items for Male in 30s
|
99
|
-
RakutenWebService::Ichiba::Genre[100316].ranking # the TOP 30 items in "水・ソフトドリンク" genre
|
100
|
-
```
|
101
|
-
|
102
|
-
## Contributing
|
103
|
-
|
104
|
-
1. Fork it
|
105
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
106
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
107
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
108
|
-
5. Create new Pull Request
|