rakuten-de 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +60 -0
- data/LICENSE +22 -0
- data/README.md +52 -0
- data/Rakefile +7 -0
- data/lib/rakuten-de.rb +1 -0
- data/lib/rakuten.rb +13 -0
- data/lib/rakuten/api_error.rb +28 -0
- data/lib/rakuten/client.rb +22 -0
- data/lib/rakuten/error.rb +4 -0
- data/lib/rakuten/request.rb +34 -0
- data/lib/rakuten/response.rb +57 -0
- data/lib/rakuten/version.rb +3 -0
- data/rakuten-de.gemspec +31 -0
- data/spec/integration/client_spec.rb +23 -0
- data/spec/integration/request_spec.rb +21 -0
- data/spec/responses/failed_with_an_error.json +14 -0
- data/spec/responses/misc_getKeyInfo_success.json +16 -0
- data/spec/responses/simple_empty.json +5 -0
- data/spec/responses/simple_failed.json +5 -0
- data/spec/responses/simple_success.json +5 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/unit/api_error_spec.rb +29 -0
- data/spec/unit/request_spec.rb +42 -0
- data/spec/unit/response_spec.rb +68 -0
- metadata +212 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rakuten-de (0.0.1)
|
5
|
+
activesupport (>= 3.1.0)
|
6
|
+
rest-client (~> 1.6.7)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ZenTest (4.8.2)
|
12
|
+
activesupport (3.2.8)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.2)
|
16
|
+
autotest (4.4.6)
|
17
|
+
ZenTest (>= 4.4.1)
|
18
|
+
autotest-fsevent (0.2.8)
|
19
|
+
sys-uname
|
20
|
+
autotest-growl (0.2.16)
|
21
|
+
crack (0.3.1)
|
22
|
+
diff-lcs (1.1.3)
|
23
|
+
ffi (1.1.5)
|
24
|
+
i18n (0.6.1)
|
25
|
+
mime-types (1.19)
|
26
|
+
multi_json (1.3.6)
|
27
|
+
rake (0.9.2.2)
|
28
|
+
rest-client (1.6.7)
|
29
|
+
mime-types (>= 1.16)
|
30
|
+
rspec (2.11.0)
|
31
|
+
rspec-core (~> 2.11.0)
|
32
|
+
rspec-expectations (~> 2.11.0)
|
33
|
+
rspec-mocks (~> 2.11.0)
|
34
|
+
rspec-core (2.11.1)
|
35
|
+
rspec-expectations (2.11.2)
|
36
|
+
diff-lcs (~> 1.1.3)
|
37
|
+
rspec-mocks (2.11.2)
|
38
|
+
sys-uname (0.9.0)
|
39
|
+
ffi (>= 1.0.0)
|
40
|
+
webmock (1.8.9)
|
41
|
+
addressable (>= 2.2.7)
|
42
|
+
crack (>= 0.1.7)
|
43
|
+
yard (0.8.2.1)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
autotest
|
50
|
+
autotest-fsevent
|
51
|
+
autotest-growl
|
52
|
+
bundler
|
53
|
+
jruby-openssl
|
54
|
+
rake
|
55
|
+
rakuten-de!
|
56
|
+
rspec
|
57
|
+
rspec-expectations
|
58
|
+
rspec-mocks
|
59
|
+
webmock
|
60
|
+
yard
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 ['Marian Theisen']
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
rakuten-de
|
2
|
+
==========
|
3
|
+
[![Build Status](https://secure.travis-ci.org/kayoom/rakuten-de.png)](http://travis-ci.org/kayoom/rakuten-de)
|
4
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ryanb/cancan)
|
5
|
+
|
6
|
+
This is a simple gem to access the _rakuten.de_ REST-Api. You can find
|
7
|
+
the documentation for the Api itself
|
8
|
+
[here](http://webservice.rakuten.de/documentation/overview).
|
9
|
+
|
10
|
+
Get Started
|
11
|
+
-----------
|
12
|
+
|
13
|
+
Install _rakuten-de_ with `gem install rakuten-de` or add it to your
|
14
|
+
_Gemfile_: `gem 'rakuten-de'`. Fire up _IRB_, a rails console (`rails
|
15
|
+
c`) or a simple test file and do:
|
16
|
+
|
17
|
+
require 'rakuten-de'
|
18
|
+
client = Rakuten::Client.new '123456789a123456789a123456789a12' # Sandbox API-Key, replace with your API-Key for production use
|
19
|
+
|
20
|
+
client.get :misc, :get_key_info
|
21
|
+
# => {"key"=>{"active"=>"1", "calls_today"=>"20", "last_call_datetimestamp"=>"2010-01-01 20:15:00", "daily_calls_limit"=>"10000", "permissions"=>{"products"=>"write", "orders"=>"read", "categories"=>"forbidden"}}}
|
22
|
+
|
23
|
+
# or via post
|
24
|
+
client.post :misc, :get_key_info
|
25
|
+
# => {"key"=>{"active"=>"1", "calls_today"=>"20", "last_call_datetimestamp"=>"2010-01-01 20:15:00", "daily_calls_limit"=>"10000", "permissions"=>{"products"=>"write", "orders"=>"read", "categories"=>"forbidden"}}}
|
26
|
+
|
27
|
+
You can find a list of possible methods, parameters and response formats [here](http://webservice.rakuten.de/documentation/overview).
|
28
|
+
|
29
|
+
Handling Errors
|
30
|
+
---------------
|
31
|
+
|
32
|
+
_rakuten-de_ will raise the first returned error if the API response
|
33
|
+
indicates an error. You can rescue generic API-Errors or only specified.
|
34
|
+
|
35
|
+
begin
|
36
|
+
client = Rakuten::Client.new 'some_bogus_key'
|
37
|
+
client.get :misc, :get_key_info
|
38
|
+
|
39
|
+
rescue Rakuten::ApiError[15] => e # 15 is the error code for invalid key
|
40
|
+
puts "Wrong key"
|
41
|
+
rescue Rakuten::ApiError # catch any other errors
|
42
|
+
# ...
|
43
|
+
end
|
44
|
+
|
45
|
+
More to come ...
|
46
|
+
----------------
|
47
|
+
|
48
|
+
Disclaimer
|
49
|
+
----------
|
50
|
+
Please note that "Rakuten" is a registered trademark of "Rakuten
|
51
|
+
Deutschland GmbH". We are not associated with Rakuten Deutschland GmbH
|
52
|
+
and provide this gem under a MIT license.
|
data/Rakefile
ADDED
data/lib/rakuten-de.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rakuten'
|
data/lib/rakuten.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_support/core_ext/class'
|
2
|
+
|
3
|
+
module Rakuten
|
4
|
+
class ApiError < Error
|
5
|
+
class_attribute :code
|
6
|
+
self.code = 0
|
7
|
+
|
8
|
+
attr_reader :help
|
9
|
+
|
10
|
+
def initialize message, help = nil
|
11
|
+
@help = help
|
12
|
+
super message
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def [] code
|
17
|
+
code = code.to_i
|
18
|
+
return self if code == 0
|
19
|
+
|
20
|
+
@errors_by_code ||= Hash.new do |hash, key|
|
21
|
+
hash[key] = Class.new(self).tap { |c| c.code = key }
|
22
|
+
end
|
23
|
+
|
24
|
+
@errors_by_code[code]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rakuten
|
2
|
+
class Client
|
3
|
+
attr_reader :api_key
|
4
|
+
|
5
|
+
def initialize api_key
|
6
|
+
@api_key = api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def get group, method, params = {}
|
10
|
+
Response.new(request_for(group, method, params).get).result
|
11
|
+
end
|
12
|
+
|
13
|
+
def post group, method, params = {}
|
14
|
+
Response.new(request_for(group, method, params).post).result
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
def request_for group, method, params
|
19
|
+
Request.new group, method, params.merge(key: @api_key)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'active_support/core_ext/array'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
module Rakuten
|
5
|
+
class Request
|
6
|
+
URL = "http://webservice.rakuten.de/merchants"
|
7
|
+
FORMAT = "json"
|
8
|
+
|
9
|
+
attr_reader :group, :method, :version
|
10
|
+
|
11
|
+
def initialize *args
|
12
|
+
@params = args.extract_options!
|
13
|
+
@group, @method, @version = args.map(&:to_s)
|
14
|
+
|
15
|
+
@method = @method.camelize(:lower)
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
@url ||= [URL, group, method, version].compact * '/'
|
20
|
+
end
|
21
|
+
|
22
|
+
def get
|
23
|
+
RestClient.get url, params: params
|
24
|
+
end
|
25
|
+
|
26
|
+
def post
|
27
|
+
RestClient.post url, params
|
28
|
+
end
|
29
|
+
|
30
|
+
def params
|
31
|
+
@params.merge format: FORMAT
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'active_support/json'
|
2
|
+
|
3
|
+
module Rakuten
|
4
|
+
class Response
|
5
|
+
JSON = ActiveSupport::JSON
|
6
|
+
attr_reader :raw
|
7
|
+
|
8
|
+
def initialize body
|
9
|
+
@raw = JSON.decode body
|
10
|
+
end
|
11
|
+
|
12
|
+
def success?
|
13
|
+
status_code != -1
|
14
|
+
end
|
15
|
+
|
16
|
+
def failed?
|
17
|
+
status_code == -1
|
18
|
+
end
|
19
|
+
|
20
|
+
def empty?
|
21
|
+
status_code == 0
|
22
|
+
end
|
23
|
+
|
24
|
+
def errors
|
25
|
+
@errors ||= _errors.map do |error|
|
26
|
+
Rakuten::ApiError[error['code']].new *error.values_at('message', 'help')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def error
|
31
|
+
errors.first or Rakuten::ApiError.new("Request failed without errors returned")
|
32
|
+
end
|
33
|
+
|
34
|
+
def result
|
35
|
+
if success?
|
36
|
+
fetch(:result, {}).except('success')
|
37
|
+
else
|
38
|
+
raise error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
def status_code
|
44
|
+
@status_code ||= fetch(:result, :success, -1).to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
def _errors
|
48
|
+
fetch :result, :errors, :error, []
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch *keys, default
|
52
|
+
keys[0...-1].inject(@raw) do |hash, key|
|
53
|
+
hash.fetch(key.to_s, {})
|
54
|
+
end.fetch(keys.last.to_s, default)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/rakuten-de.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "rakuten/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rakuten-de"
|
8
|
+
s.version = Rakuten::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
11
|
+
s.authors = ["Marian Theisen"]
|
12
|
+
s.email = 'dev@kayoom.com'
|
13
|
+
s.summary = "Rakuten API client"
|
14
|
+
s.homepage = "http://github.com/kayoom/rakuten-de"
|
15
|
+
s.description = "Rakuten API client"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "activesupport", ">= 3.1.0"
|
23
|
+
s.add_dependency "rest-client", "~> 1.6.7"
|
24
|
+
|
25
|
+
s.add_development_dependency "yard"
|
26
|
+
s.add_development_dependency "rspec"
|
27
|
+
s.add_development_dependency 'rspec-mocks'
|
28
|
+
s.add_development_dependency 'rspec-expectations'
|
29
|
+
s.add_development_dependency "bundler"
|
30
|
+
s.add_development_dependency "webmock"
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rakuten::Client do
|
4
|
+
let(:client) { described_class.new(sandbox_key) }
|
5
|
+
|
6
|
+
describe 'a simple get call' do
|
7
|
+
before do
|
8
|
+
stub_get 'misc', 'getKeyInfo', 'misc_getKeyInfo_success'
|
9
|
+
end
|
10
|
+
subject { client.get(:misc, :get_key_info) }
|
11
|
+
|
12
|
+
it { should have_key 'key' }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'a simple post call' do
|
16
|
+
before do
|
17
|
+
stub_post 'misc', 'getKeyInfo', 'misc_getKeyInfo_success'
|
18
|
+
end
|
19
|
+
subject { client.post(:misc, :get_key_info) }
|
20
|
+
|
21
|
+
it { should have_key 'key' }
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rakuten::Request do
|
4
|
+
subject { described_class.new('misc', 'getKeyInfo', key: '123456789a123456789a123456789a12')}
|
5
|
+
|
6
|
+
describe 'a simple get request' do
|
7
|
+
before do
|
8
|
+
stub_get 'misc', 'getKeyInfo', 'simple_success'
|
9
|
+
end
|
10
|
+
|
11
|
+
its(:get) { should be_a String }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'a simple post request' do
|
15
|
+
before do
|
16
|
+
stub_post 'misc', 'getKeyInfo', 'simple_success'
|
17
|
+
end
|
18
|
+
|
19
|
+
its(:post) { should be_a String }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"result": {
|
3
|
+
"success": "1",
|
4
|
+
"key": {
|
5
|
+
"active": "1",
|
6
|
+
"calls_today": "20",
|
7
|
+
"last_call_datetimestamp": "2010-01-01 20:15:00",
|
8
|
+
"daily_calls_limit": "10000",
|
9
|
+
"permissions": {
|
10
|
+
"products": "write",
|
11
|
+
"orders": "read",
|
12
|
+
"categories": "forbidden"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'rakuten-de'
|
5
|
+
|
6
|
+
require 'rspec'
|
7
|
+
require 'rspec/mocks'
|
8
|
+
require 'rspec/mocks/standalone'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
|
11
|
+
module Helpers
|
12
|
+
def sandbox_key
|
13
|
+
'123456789a123456789a123456789a12'
|
14
|
+
end
|
15
|
+
|
16
|
+
def stub_response name
|
17
|
+
File.read File.join(File.dirname(__FILE__), 'responses', "#{name}.json")
|
18
|
+
end
|
19
|
+
|
20
|
+
def stub_get group, name, response
|
21
|
+
stub_http_request(:get, "webservice.rakuten.de/merchants/#{group}/#{name}").
|
22
|
+
with(query: hash_including( key: sandbox_key, format: "json")).
|
23
|
+
to_return(body: stub_response(response), status: 200)
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_post group, name, response
|
27
|
+
stub_request(:post, "webservice.rakuten.de/merchants/#{group}/#{name}").
|
28
|
+
with(body: hash_including( key: sandbox_key, format: "json")).
|
29
|
+
to_return(body: stub_response(response), status: 200)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.include Helpers
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rakuten::ApiError do
|
4
|
+
describe 'class' do
|
5
|
+
subject { described_class }
|
6
|
+
|
7
|
+
describe '#[code]' do
|
8
|
+
let(:code) { 10 }
|
9
|
+
subject { described_class[code] }
|
10
|
+
|
11
|
+
its(:superclass) { should == described_class }
|
12
|
+
its(:code) { should == 10 }
|
13
|
+
|
14
|
+
context "code: 0" do
|
15
|
+
let(:code) { 0 }
|
16
|
+
|
17
|
+
it { should == described_class }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'instance' do
|
23
|
+
subject { described_class.new "this is an error", "http://foo.com" }
|
24
|
+
|
25
|
+
its(:code) { should == 0 }
|
26
|
+
its(:message) { should == "this is an error" }
|
27
|
+
its(:help) { should == "http://foo.com" }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rakuten::Request do
|
4
|
+
describe '#initialize' do
|
5
|
+
context "(group, method, params)" do
|
6
|
+
subject { described_class.new('misc', 'getKeyInfo', key: sandbox_key) }
|
7
|
+
|
8
|
+
its(:group) { should == 'misc' }
|
9
|
+
its(:method) { should == 'getKeyInfo' }
|
10
|
+
its(:params) { should == { key: sandbox_key, format: 'json' } }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "(group, method, version, params)" do
|
14
|
+
subject { described_class.new('misc', 'getKeyInfo', 'v2.0', key: sandbox_key) }
|
15
|
+
|
16
|
+
its(:group) { should == 'misc' }
|
17
|
+
its(:method) { should == 'getKeyInfo' }
|
18
|
+
its(:version) { should == 'v2.0' }
|
19
|
+
its(:params) { should == { key: sandbox_key, format: 'json' } }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'camelize method' do
|
23
|
+
subject { described_class.new('misc', 'get_key_info') }
|
24
|
+
|
25
|
+
its(:method) { should == 'getKeyInfo' }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#url' do
|
30
|
+
context "without version" do
|
31
|
+
subject { described_class.new('misc', 'getKeyInfo') }
|
32
|
+
|
33
|
+
its(:url) { should == 'http://webservice.rakuten.de/merchants/misc/getKeyInfo' }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with version" do
|
37
|
+
subject { described_class.new('misc', 'getKeyInfo', 'v2.0') }
|
38
|
+
|
39
|
+
its(:url) { should == 'http://webservice.rakuten.de/merchants/misc/getKeyInfo/v2.0' }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rakuten::Response do
|
4
|
+
let(:response) { 'simple_success' }
|
5
|
+
let(:json_encoded_body) { stub_response(response) }
|
6
|
+
subject { described_class.new(json_encoded_body) }
|
7
|
+
|
8
|
+
describe '#initialize(json_encoded_body)' do
|
9
|
+
its(:raw) { should == { 'result' => { 'success' => "1" }}}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#success?' do
|
13
|
+
it { should be_success }
|
14
|
+
|
15
|
+
context "empty response" do
|
16
|
+
let(:response) { 'simple_empty' }
|
17
|
+
it { should be_success }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#empty?' do
|
22
|
+
let(:response) { 'simple_empty' }
|
23
|
+
it { should be_empty }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#failed?' do
|
27
|
+
let(:response) { 'simple_failed' }
|
28
|
+
it { should be_failed }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#errors' do
|
32
|
+
let(:response) { 'failed_with_an_error' }
|
33
|
+
|
34
|
+
its(:errors) { should be_an Array }
|
35
|
+
its(:'errors.first') { should be_a Rakuten::ApiError }
|
36
|
+
its(:'errors.first') { should be_a Rakuten::ApiError[10] }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#error' do
|
40
|
+
let(:response) { 'failed_with_an_error' }
|
41
|
+
|
42
|
+
its(:error) { should be_a Rakuten::ApiError[10] }
|
43
|
+
|
44
|
+
context 'without errors' do
|
45
|
+
let(:response) { 'simple_failed' }
|
46
|
+
|
47
|
+
its(:error) { should be_a Rakuten::ApiError }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#result' do
|
52
|
+
context 'on success' do
|
53
|
+
let(:response) { 'misc_getKeyInfo_success' }
|
54
|
+
|
55
|
+
its(:result) { should be_a Hash }
|
56
|
+
its(:result) { should have_key 'key' }
|
57
|
+
its(:result) { should_not have_key 'success' }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'on failure' do
|
61
|
+
let(:response) { 'simple_failed' }
|
62
|
+
|
63
|
+
it 'should raise an error' do
|
64
|
+
expect { subject.result }.to raise_error(Rakuten::ApiError)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rakuten-de
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marian Theisen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.6.7
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.6.7
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-mocks
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-expectations
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: bundler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: webmock
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: Rakuten API client
|
143
|
+
email: dev@kayoom.com
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files: []
|
147
|
+
files:
|
148
|
+
- .gitignore
|
149
|
+
- .rspec
|
150
|
+
- .travis.yml
|
151
|
+
- Gemfile
|
152
|
+
- Gemfile.lock
|
153
|
+
- LICENSE
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- lib/rakuten-de.rb
|
157
|
+
- lib/rakuten.rb
|
158
|
+
- lib/rakuten/api_error.rb
|
159
|
+
- lib/rakuten/client.rb
|
160
|
+
- lib/rakuten/error.rb
|
161
|
+
- lib/rakuten/request.rb
|
162
|
+
- lib/rakuten/response.rb
|
163
|
+
- lib/rakuten/version.rb
|
164
|
+
- rakuten-de.gemspec
|
165
|
+
- spec/integration/client_spec.rb
|
166
|
+
- spec/integration/request_spec.rb
|
167
|
+
- spec/responses/failed_with_an_error.json
|
168
|
+
- spec/responses/misc_getKeyInfo_success.json
|
169
|
+
- spec/responses/simple_empty.json
|
170
|
+
- spec/responses/simple_failed.json
|
171
|
+
- spec/responses/simple_success.json
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- spec/unit/api_error_spec.rb
|
174
|
+
- spec/unit/request_spec.rb
|
175
|
+
- spec/unit/response_spec.rb
|
176
|
+
homepage: http://github.com/kayoom/rakuten-de
|
177
|
+
licenses: []
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
none: false
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 1.8.24
|
197
|
+
signing_key:
|
198
|
+
specification_version: 3
|
199
|
+
summary: Rakuten API client
|
200
|
+
test_files:
|
201
|
+
- spec/integration/client_spec.rb
|
202
|
+
- spec/integration/request_spec.rb
|
203
|
+
- spec/responses/failed_with_an_error.json
|
204
|
+
- spec/responses/misc_getKeyInfo_success.json
|
205
|
+
- spec/responses/simple_empty.json
|
206
|
+
- spec/responses/simple_failed.json
|
207
|
+
- spec/responses/simple_success.json
|
208
|
+
- spec/spec_helper.rb
|
209
|
+
- spec/unit/api_error_spec.rb
|
210
|
+
- spec/unit/request_spec.rb
|
211
|
+
- spec/unit/response_spec.rb
|
212
|
+
has_rdoc:
|