stripe 3.10.0 → 3.11.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
- SHA1:
3
- metadata.gz: 2e7b5bea101451f3c7a05b79a5b7dbad7e02d2a7
4
- data.tar.gz: efc7af8e83a025865095472b00130d9720ad5575
2
+ SHA256:
3
+ metadata.gz: 981d54e75ed0dc6a6c6e9134cbf338a2d8ed02e7169afc93f37c5c65d1e23955
4
+ data.tar.gz: 844de1199f90a2e1eb32f2a011fda913b0ee3c799cd670c8dd42d441d0135805
5
5
  SHA512:
6
- metadata.gz: 826e1e1a0883d6a103da74ea2b3221ab55d786772e616038d05f2c7a38981ba45e2a9b14885358fef978cdf9aca0da8187f5c6da09d4c416e212e3c38c9b742f
7
- data.tar.gz: 5a79ab66f87303e6ff5b06dc7999b6ede34ef2ee23126f47c318d25e37f51ba10551e09d3efe54d9811b5d8dfdc52d37c75b58024eb1d3c8979f8f85a8fe7371
6
+ metadata.gz: 7890d0984cb8d83aec246a5fe745f2e57343e1b1c256343e79c49f35479de9cbafd90046dd00b537339a6b08257eb9dd39a1aa96f420059d5596584f7f2b7bd5
7
+ data.tar.gz: 371d48d97dedf110422c91e70b25be7aa092576f55e87d5b1cf3e3d336b847ff9e0000fa18bd5f234459f33dd9b5826a7400fc53c7ac8939ac42de3c831220f3
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2017-10-30 14:39:50 +0100 using RuboCop version 0.50.0.
3
+ # on 2018-02-23 14:17:07 +0100 using RuboCop version 0.50.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -8,23 +8,23 @@
8
8
 
9
9
  # Offense count: 19
10
10
  Metrics/AbcSize:
11
- Max: 49
11
+ Max: 45
12
12
 
13
13
  # Offense count: 27
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
15
  Metrics/BlockLength:
16
- Max: 467
16
+ Max: 469
17
17
 
18
18
  # Offense count: 8
19
19
  # Configuration parameters: CountComments.
20
20
  Metrics/ClassLength:
21
- Max: 595
21
+ Max: 597
22
22
 
23
- # Offense count: 10
23
+ # Offense count: 11
24
24
  Metrics/CyclomaticComplexity:
25
25
  Max: 13
26
26
 
27
- # Offense count: 257
27
+ # Offense count: 259
28
28
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
29
29
  # URISchemes: http, https
30
30
  Metrics/LineLength:
@@ -33,14 +33,14 @@ Metrics/LineLength:
33
33
  # Offense count: 32
34
34
  # Configuration parameters: CountComments.
35
35
  Metrics/MethodLength:
36
- Max: 47
36
+ Max: 45
37
37
 
38
38
  # Offense count: 1
39
39
  # Configuration parameters: CountComments.
40
40
  Metrics/ModuleLength:
41
41
  Max: 305
42
42
 
43
- # Offense count: 5
43
+ # Offense count: 6
44
44
  # Configuration parameters: CountKeywordArgs.
45
45
  Metrics/ParameterLists:
46
46
  Max: 7
@@ -55,6 +55,6 @@ Style/ClassVars:
55
55
  - 'lib/stripe/stripe_object.rb'
56
56
  - 'test/stripe/api_resource_test.rb'
57
57
 
58
- # Offense count: 52
58
+ # Offense count: 53
59
59
  Style/Documentation:
60
60
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.11.0 - 2018-02-26
4
+ * [#628](https://github.com/stripe/stripe-ruby/pull/628) Add support for `code` attribute on all Stripe exceptions
5
+
3
6
  ## 3.10.0 - 2018-02-21
4
7
  * [#627](https://github.com/stripe/stripe-ruby/pull/627) Add support for topups
5
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.10.0
1
+ 3.11.0
data/lib/stripe/errors.rb CHANGED
@@ -8,8 +8,7 @@ module Stripe
8
8
  # about the response that conveyed the error.
9
9
  attr_accessor :response
10
10
 
11
- # These fields are now available as part of #response and that usage should
12
- # be preferred.
11
+ attr_reader :code
13
12
  attr_reader :http_body
14
13
  attr_reader :http_headers
15
14
  attr_reader :http_status
@@ -18,12 +17,13 @@ module Stripe
18
17
 
19
18
  # Initializes a StripeError.
20
19
  def initialize(message = nil, http_status: nil, http_body: nil, json_body: nil,
21
- http_headers: nil)
20
+ http_headers: nil, code: nil)
22
21
  @message = message
23
22
  @http_status = http_status
24
23
  @http_body = http_body
25
24
  @http_headers = http_headers || {}
26
25
  @json_body = json_body
26
+ @code = code
27
27
  @request_id = @http_headers[:request_id]
28
28
  end
29
29
 
@@ -55,14 +55,15 @@ module Stripe
55
55
  # CardError is raised when a user enters a card that can't be charged for
56
56
  # some reason.
57
57
  class CardError < StripeError
58
- attr_reader :param, :code
58
+ attr_reader :param
59
59
 
60
+ # TODO: make code a keyword arg in next major release
60
61
  def initialize(message, param, code, http_status: nil, http_body: nil, json_body: nil,
61
62
  http_headers: nil)
62
63
  super(message, http_status: http_status, http_body: http_body,
63
- json_body: json_body, http_headers: http_headers)
64
+ json_body: json_body, http_headers: http_headers,
65
+ code: code)
64
66
  @param = param
65
- @code = code
66
67
  end
67
68
  end
68
69
 
@@ -77,9 +78,10 @@ module Stripe
77
78
  attr_accessor :param
78
79
 
79
80
  def initialize(message, param, http_status: nil, http_body: nil, json_body: nil,
80
- http_headers: nil)
81
+ http_headers: nil, code: nil)
81
82
  super(message, http_status: http_status, http_body: http_body,
82
- json_body: json_body, http_headers: http_headers)
83
+ json_body: json_body, http_headers: http_headers,
84
+ code: code)
83
85
  @param = param
84
86
  end
85
87
  end
@@ -109,13 +111,11 @@ module Stripe
109
111
  module OAuth
110
112
  # OAuthError is raised when the OAuth API returns an error.
111
113
  class OAuthError < StripeError
112
- attr_accessor :code
113
-
114
114
  def initialize(code, description, http_status: nil, http_body: nil, json_body: nil,
115
115
  http_headers: nil)
116
116
  super(description, http_status: http_status, http_body: http_body,
117
- json_body: json_body, http_headers: http_headers)
118
- @code = code
117
+ json_body: json_body, http_headers: http_headers,
118
+ code: code)
119
119
  end
120
120
  end
121
121
 
@@ -294,6 +294,7 @@ module Stripe
294
294
  http_headers: resp.http_headers,
295
295
  http_status: resp.http_status,
296
296
  json_body: resp.data,
297
+ code: error_data[:code],
297
298
  }
298
299
 
299
300
  case resp.http_status
@@ -310,6 +311,9 @@ module Stripe
310
311
  when 401
311
312
  AuthenticationError.new(error_data[:message], opts)
312
313
  when 402
314
+ # TODO: modify CardError constructor to make code a keyword argument
315
+ # so we don't have to delete it from opts
316
+ opts.delete(:code)
313
317
  CardError.new(
314
318
  error_data[:message], error_data[:param], error_data[:code],
315
319
  opts
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = "3.10.0".freeze
2
+ VERSION = "3.11.0".freeze
3
3
  end
@@ -452,13 +452,15 @@ module Stripe
452
452
 
453
453
  should "raise CardError on 402" do
454
454
  stub_request(:post, "#{Stripe.api_base}/v1/charges")
455
- .to_return(body: JSON.generate(make_missing_id_error), status: 402)
455
+ .to_return(body: JSON.generate(make_invalid_exp_year_error), status: 402)
456
456
  client = StripeClient.new
457
457
  begin
458
458
  client.execute_request(:post, "/v1/charges")
459
459
  rescue Stripe::CardError => e
460
460
  assert_equal(402, e.http_status)
461
461
  assert_equal(true, e.json_body.is_a?(Hash))
462
+ assert_equal("invalid_expiry_year", e.code)
463
+ assert_equal("exp_year", e.param)
462
464
  end
463
465
  end
464
466
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.14
187
+ rubygems_version: 2.7.6
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Ruby bindings for the Stripe API