klarna-checkout 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f200d016d1077f2b5b3ebc5f0c86d159026bba2
4
- data.tar.gz: e67d945dd337c79bc009dc81f567eb019cd6824f
3
+ metadata.gz: dcb82bc6f8a86362065616c56980e994b713efb3
4
+ data.tar.gz: a05179022c7476475a1409dbd31b3468390393c4
5
5
  SHA512:
6
- metadata.gz: b761e05e33fc91e2535a89b9c9eb9913873e50ed65d99fe38388bd90677b608f77249b2e1651b4a343bc27683495d9e4ab7dd6bc833163e28de637c6131cd1bd
7
- data.tar.gz: d482de6c343129e429961d8876be3ab3fadc07988892c373ba1c49901e3754ce728ab447e26e23214cca6baf77d2213f162767d877639ccb4c42686f3bd303de
6
+ metadata.gz: 6bb0c40683e1a162d2dfd712dee6488017681a593f2cd13754f8231a62093e1cdca6d295acf6f334a15329398fd9101c3f0645296b4e03a4f99d9e8b214eac72
7
+ data.tar.gz: d461df1a7064310aaac34df4b95be343121bd6f34c44933b4d1735c89aab69dbd21cbb4044c9fbfe6770fccea4fb656f4dae62e99bb9c44107357a6401f66ab3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://magnum.travis-ci.com/Skalar/klarna-checkout-ruby.png?token=e2yW3RUEf8aqmbRkK1DS)](https://magnum.travis-ci.com/Skalar/klarna-checkout-ruby) [![Code Climate](https://codeclimate.com/github/Skalar/klarna-checkout-ruby.png)](https://codeclimate.com/github/Skalar/klarna-checkout-ruby)
1
+ [ ![Codeship Status for Skalar/klarna-checkout-ruby](https://www.codeship.io/projects/c01f6250-8b2d-0131-29ef-223e3dbeac7e/status?branch=master)](https://www.codeship.io/projects/15721) [![Code Climate](https://codeclimate.com/github/Skalar/klarna-checkout-ruby.png)](https://codeclimate.com/github/Skalar/klarna-checkout-ruby) [![Gem Version](https://badge.fury.io/rb/klarna-checkout.png)](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
 
@@ -1,5 +1,5 @@
1
1
  module Klarna
2
2
  module Checkout
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  require 'klarna/checkout/version'
2
2
 
3
3
  describe Klarna::Checkout::VERSION do
4
- it { should eq '1.0.1' }
4
+ it { should eq '1.1.0' }
5
5
  end
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.1
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 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday