klarna-checkout 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/klarna/checkout/client.rb +10 -10
- data/lib/klarna/checkout/version.rb +1 -1
- data/spec/lib/klarna/checkout/client_spec.rb +13 -3
- data/spec/lib/klarna/checkout/version_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcb82bc6f8a86362065616c56980e994b713efb3
|
4
|
+
data.tar.gz: a05179022c7476475a1409dbd31b3468390393c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bb0c40683e1a162d2dfd712dee6488017681a593f2cd13754f8231a62093e1cdca6d295acf6f334a15329398fd9101c3f0645296b4e03a4f99d9e8b214eac72
|
7
|
+
data.tar.gz: d461df1a7064310aaac34df4b95be343121bd6f34c44933b4d1735c89aab69dbd21cbb4044c9fbfe6770fccea4fb656f4dae62e99bb9c44107357a6401f66ab3
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://www.codeship.io/projects/15721) [](https://codeclimate.com/github/Skalar/klarna-checkout-ruby) [](http://badge.fury.io/rb/klarna-checkout)
|
2
2
|
|
3
3
|
# Klarna Checkout
|
4
4
|
|
@@ -108,6 +108,13 @@ order.purchase_country
|
|
108
108
|
* Validation of objects according to documentation
|
109
109
|
* Respect readonly attributes
|
110
110
|
|
111
|
+
## Supported Rubies
|
112
|
+
|
113
|
+
* 1.9.2
|
114
|
+
* 1.9.3
|
115
|
+
* 2.0.0
|
116
|
+
* 2.1.0
|
117
|
+
|
111
118
|
## Contributing
|
112
119
|
|
113
120
|
1. Fork it
|
@@ -55,7 +55,7 @@ module Klarna
|
|
55
55
|
req.headers['Accept'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json'
|
56
56
|
req.headers['Accept-Encoding'] = ''
|
57
57
|
end
|
58
|
-
handle_status_code(response.status)
|
58
|
+
handle_status_code(response.status, response.body)
|
59
59
|
|
60
60
|
Order.new(JSON.parse(response.body))
|
61
61
|
end
|
@@ -74,24 +74,24 @@ module Klarna
|
|
74
74
|
Digest::SHA256.base64digest(payload)
|
75
75
|
end
|
76
76
|
|
77
|
-
def handle_status_code(code, &blk)
|
77
|
+
def handle_status_code(code, msg = nil, &blk)
|
78
78
|
case Integer(code)
|
79
79
|
when 200, 201
|
80
80
|
yield if block_given?
|
81
81
|
when 401
|
82
|
-
raise Klarna::Checkout::UnauthorizedException.new
|
82
|
+
raise Klarna::Checkout::UnauthorizedException.new(msg)
|
83
83
|
when 403
|
84
|
-
raise Klarna::Checkout::ForbiddenException.new
|
84
|
+
raise Klarna::Checkout::ForbiddenException.new(msg)
|
85
85
|
when 404
|
86
|
-
raise Klarna::Checkout::NotFoundException.new
|
86
|
+
raise Klarna::Checkout::NotFoundException.new(msg)
|
87
87
|
when 405
|
88
|
-
raise Klarna::Checkout::MethodNotAllowedException.new
|
88
|
+
raise Klarna::Checkout::MethodNotAllowedException.new(msg)
|
89
89
|
when 406
|
90
|
-
raise Klarna::Checkout::NotAcceptableException.new
|
90
|
+
raise Klarna::Checkout::NotAcceptableException.new(msg)
|
91
91
|
when 415
|
92
|
-
raise Klarna::Checkout::UnsupportedMediaTypeException.new
|
92
|
+
raise Klarna::Checkout::UnsupportedMediaTypeException.new(msg)
|
93
93
|
when 500
|
94
|
-
raise Klarna::Checkout::InternalServerErrorException.new
|
94
|
+
raise Klarna::Checkout::InternalServerErrorException.new(msg)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -112,7 +112,7 @@ module Klarna
|
|
112
112
|
|
113
113
|
req.body = request_body
|
114
114
|
end
|
115
|
-
handle_status_code(response.status)
|
115
|
+
handle_status_code(response.status, response.body)
|
116
116
|
response
|
117
117
|
end
|
118
118
|
|
@@ -87,7 +87,7 @@ describe Klarna::Checkout::Client do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "checks the response" do
|
90
|
-
subject.should receive(:handle_status_code).with(201)
|
90
|
+
subject.should receive(:handle_status_code).with(201, '')
|
91
91
|
subject.create_order(order)
|
92
92
|
end
|
93
93
|
|
@@ -151,6 +151,16 @@ describe Klarna::Checkout::Client do
|
|
151
151
|
subject.handle_status_code(401)
|
152
152
|
}.to raise_error(Klarna::Checkout::UnauthorizedException)
|
153
153
|
end
|
154
|
+
|
155
|
+
describe "handling status code with a message" do
|
156
|
+
it "has a message" do
|
157
|
+
begin
|
158
|
+
subject.handle_status_code(401, 'foobar')
|
159
|
+
rescue => e
|
160
|
+
e.message.should eq('foobar')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
154
164
|
end
|
155
165
|
|
156
166
|
context "with 403" do
|
@@ -223,7 +233,7 @@ describe Klarna::Checkout::Client do
|
|
223
233
|
end
|
224
234
|
|
225
235
|
it "checks the response" do
|
226
|
-
subject.should receive(:handle_status_code).with(200)
|
236
|
+
subject.should receive(:handle_status_code).with(200, JSON.generate({ id: "143F7BC0A1090B11C39E7220000" }))
|
227
237
|
subject.read_order('143F7BC0A1090B11C39E7220000')
|
228
238
|
end
|
229
239
|
end
|
@@ -251,7 +261,7 @@ describe Klarna::Checkout::Client do
|
|
251
261
|
end
|
252
262
|
|
253
263
|
it "checks the response" do
|
254
|
-
subject.should receive(:handle_status_code).with(200)
|
264
|
+
subject.should receive(:handle_status_code).with(200, JSON.generate({ id: "143F7BC0A1090B11C39E7220000" }))
|
255
265
|
subject.update_order(order)
|
256
266
|
end
|
257
267
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klarna-checkout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theodor Tonum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|