rakuten_web_service 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -2
- data/README.md +3 -2
- data/lib/rakuten_web_service/client.rb +19 -36
- data/lib/rakuten_web_service/error.rb +26 -0
- data/lib/rakuten_web_service/version.rb +1 -1
- data/rakuten_web_service.gemspec +0 -5
- data/spec/rakuten_web_service/client_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixture_suppot.rb +0 -2
- metadata +19 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7f33b3d1527b11476b4da96985d7be2806a46af
|
4
|
+
data.tar.gz: a1968049850a302e5f66f6e3dc53233be5565287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0695e2c151da45d995de251b2db22af6ed087d90f3c65345c768214107e5bcf7a58cb33bb5a3a609ac88a6857d14dbff913fe71d3b5742910db1f25835010ba9
|
7
|
+
data.tar.gz: 60612ca32c7f9b5cdac8133869d4a38674cf78f2af5c6e04d75932675ef08fad92e9e65eb25a45f74a7fee1027c9585cf2b9f1dd947f59164290406db93fdddf
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
# v1.
|
1
|
+
# v1.1.0 (2016/09/12)
|
2
|
+
|
3
|
+
## Enhancements
|
4
|
+
|
5
|
+
* Remove the dependency on faraday, using `Net::HTTP`. [#39](https://github.com/rakuten-ws/rws-ruby-sdk/pull/39)
|
6
|
+
* 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)
|
7
|
+
|
8
|
+
# v1.0.0 (2016/07/29)
|
2
9
|
|
3
10
|
## Enhancements
|
4
11
|
|
@@ -25,7 +32,7 @@ At first, I should appreciate all users of the gems.
|
|
25
32
|
One of the enhancements, supporting Gora APIs, is realized by @kamatama41 's seminal work.
|
26
33
|
Thank you for your contribution!
|
27
34
|
|
28
|
-
# v0.6.3
|
35
|
+
# v0.6.3 (2015/07/03)
|
29
36
|
|
30
37
|
* Update a gem dependency by @45deg
|
31
38
|
* Fix typo by @45deg
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# RakutenWebService
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/rakuten-ws/rws-ruby-sdk.
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/rakuten_web_service.
|
3
|
+
[![Build Status](https://travis-ci.org/rakuten-ws/rws-ruby-sdk.svg?branch=master)](https://travis-ci.org/rakuten-ws/rws-ruby-sdk)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rakuten_web_service.svg)](https://badge.fury.io/rb/rakuten_web_service)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/rakuten-ws/rws-ruby-sdk/badge.svg?branch=master)](https://coveralls.io/github/rakuten-ws/rws-ruby-sdk?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/rakuten-ws/rws-ruby-sdk/badges/gpa.svg)](https://codeclimate.com/github/rakuten-ws/rws-ruby-sdk)
|
6
7
|
|
7
8
|
This gem provides a client for easily accessing [Rakuten Web Service APIs](https://webservice.rakuten.co.jp/).
|
8
9
|
|
@@ -1,55 +1,38 @@
|
|
1
1
|
require 'uri'
|
2
|
-
require '
|
3
|
-
require 'faraday_middleware'
|
4
|
-
|
2
|
+
require 'json'
|
5
3
|
require 'rakuten_web_service/response'
|
4
|
+
require 'rakuten_web_service/error'
|
6
5
|
|
7
6
|
module RakutenWebService
|
8
|
-
class WrongParameter < StandardError; end
|
9
|
-
class NotFound < StandardError; end
|
10
|
-
class TooManyRequests < StandardError; end
|
11
|
-
class SystemError < StandardError; end
|
12
|
-
class ServiceUnavailable < StandardError; end
|
13
|
-
|
14
7
|
class Client
|
15
|
-
attr_reader :url
|
8
|
+
attr_reader :url
|
16
9
|
|
17
10
|
def initialize(resource_class)
|
18
11
|
@resource_class = resource_class
|
19
|
-
url = URI.parse(@resource_class.endpoint)
|
20
|
-
@url = "#{url.scheme}://#{url.host}"
|
21
|
-
@path = url.path
|
12
|
+
@url = URI.parse(@resource_class.endpoint)
|
22
13
|
end
|
23
14
|
|
24
15
|
def get(params)
|
25
16
|
params = RakutenWebService.configuration.generate_parameters(params)
|
26
|
-
response =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
raise NotFound, response.body['error_description']
|
34
|
-
when 429
|
35
|
-
raise TooManyRequests, response.body['error_description']
|
36
|
-
when 500
|
37
|
-
raise SystemError, response.body['error_description']
|
38
|
-
when 503
|
39
|
-
raise ServiceUnavailable, response.body['error_description']
|
17
|
+
response = request(url.path, params)
|
18
|
+
body = JSON.parse(response.body)
|
19
|
+
|
20
|
+
if Net::HTTPSuccess === response
|
21
|
+
return RakutenWebService::Response.new(@resource_class, body)
|
22
|
+
else
|
23
|
+
raise RakutenWebService::Error.repository[response.code.to_i], body['error_description']
|
40
24
|
end
|
41
25
|
end
|
42
26
|
|
43
27
|
private
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
28
|
+
def request(path, params)
|
29
|
+
http = Net::HTTP.new(@url.host, @url.port)
|
30
|
+
http.use_ssl = true
|
31
|
+
path = "#{path}?#{params.map { |k, v| "#{k}=#{URI.encode(v.to_s)}" }.join('&')}"
|
32
|
+
header = {
|
33
|
+
'User-Agent' => "RakutenWebService SDK for Ruby v#{RWS::VERSION}(ruby-#{RUBY_VERSION} [#{RUBY_PLATFORM}])"
|
34
|
+
}
|
35
|
+
http.get(path, header)
|
53
36
|
end
|
54
37
|
end
|
55
38
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RakutenWebService
|
2
|
+
class Error < StandardError
|
3
|
+
def self.register(status_code, error)
|
4
|
+
repository[status_code] = error
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.repository
|
8
|
+
@repository ||= {}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class WrongParameter < Error; end
|
13
|
+
Error.register(400, WrongParameter)
|
14
|
+
|
15
|
+
class NotFound < Error; end
|
16
|
+
Error.register(404, NotFound)
|
17
|
+
|
18
|
+
class TooManyRequests < Error; end
|
19
|
+
Error.register(429, TooManyRequests)
|
20
|
+
|
21
|
+
class SystemError < Error; end
|
22
|
+
Error.register(500, SystemError)
|
23
|
+
|
24
|
+
class ServiceUnavailable < Error; end
|
25
|
+
Error.register(503, ServiceUnavailable)
|
26
|
+
end
|
data/rakuten_web_service.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'rakuten_web_service/version'
|
@@ -14,14 +13,10 @@ Gem::Specification.new do |spec|
|
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
17
|
spec.require_paths = ["lib"]
|
20
18
|
spec.required_ruby_version = '>= 2.1.0'
|
21
19
|
|
22
|
-
spec.add_dependency 'faraday', '~> 0.9.0'
|
23
|
-
spec.add_dependency 'faraday_middleware'
|
24
|
-
|
25
20
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
21
|
spec.add_development_dependency "rake"
|
27
22
|
spec.add_development_dependency "webmock", "~> 1.20.4"
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,111 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakuten_web_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: faraday
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: faraday_middleware
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: bundler
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
|
-
- - ~>
|
17
|
+
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
19
|
version: '1.3'
|
48
20
|
type: :development
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
|
-
- - ~>
|
24
|
+
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
26
|
version: '1.3'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: rake
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
|
-
- -
|
31
|
+
- - ">="
|
60
32
|
- !ruby/object:Gem::Version
|
61
33
|
version: '0'
|
62
34
|
type: :development
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
|
-
- -
|
38
|
+
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
40
|
version: '0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: webmock
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- - ~>
|
45
|
+
- - "~>"
|
74
46
|
- !ruby/object:Gem::Version
|
75
47
|
version: 1.20.4
|
76
48
|
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
|
-
- - ~>
|
52
|
+
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: 1.20.4
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: rspec
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
|
-
- - ~>
|
59
|
+
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
61
|
version: 3.5.0
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
|
-
- - ~>
|
66
|
+
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
68
|
version: 3.5.0
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: tapp
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
|
-
- -
|
73
|
+
- - ">="
|
102
74
|
- !ruby/object:Gem::Version
|
103
75
|
version: '0'
|
104
76
|
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
|
-
- -
|
80
|
+
- - ">="
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
83
|
description: Ruby Client for Rakuten Web Service
|
@@ -115,9 +87,9 @@ executables: []
|
|
115
87
|
extensions: []
|
116
88
|
extra_rdoc_files: []
|
117
89
|
files:
|
118
|
-
- .coveralls.yml
|
119
|
-
- .gitignore
|
120
|
-
- .travis.yml
|
90
|
+
- ".coveralls.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
121
93
|
- CHANGELOG.md
|
122
94
|
- CODE_OF_CONDUCT.md
|
123
95
|
- Gemfile
|
@@ -143,6 +115,7 @@ files:
|
|
143
115
|
- lib/rakuten_web_service/books/total.rb
|
144
116
|
- lib/rakuten_web_service/client.rb
|
145
117
|
- lib/rakuten_web_service/configuration.rb
|
118
|
+
- lib/rakuten_web_service/error.rb
|
146
119
|
- lib/rakuten_web_service/genre.rb
|
147
120
|
- lib/rakuten_web_service/gora.rb
|
148
121
|
- lib/rakuten_web_service/gora/course.rb
|
@@ -219,17 +192,17 @@ require_paths:
|
|
219
192
|
- lib
|
220
193
|
required_ruby_version: !ruby/object:Gem::Requirement
|
221
194
|
requirements:
|
222
|
-
- -
|
195
|
+
- - ">="
|
223
196
|
- !ruby/object:Gem::Version
|
224
197
|
version: 2.1.0
|
225
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
199
|
requirements:
|
227
|
-
- -
|
200
|
+
- - ">="
|
228
201
|
- !ruby/object:Gem::Version
|
229
202
|
version: '0'
|
230
203
|
requirements: []
|
231
204
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.5.1
|
233
206
|
signing_key:
|
234
207
|
specification_version: 4
|
235
208
|
summary: Ruby Client for Rakuten Web Service
|