stripe 1.25.0 → 1.26.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: 1e35419ace88d4f0aec2f7e5227a02dd5d9c4338
4
- data.tar.gz: 223e592ef5558c048bff2825d31ed6842197b874
3
+ metadata.gz: 3dee603f6988c8f35b2deeadcf5edcea8ebdc114
4
+ data.tar.gz: e038126f33119dd877578663534f490baab820b7
5
5
  SHA512:
6
- metadata.gz: a0056b8bff477a1a2c5e7f2d25876af0aec97002ff4383bd4e4bab53c8e0c2018a18e1f95a50a85465b7baf2309d2cbb26b97abc121e7d90aa4945f6e77df0b3
7
- data.tar.gz: e5126b06634a7c2062bbf60f1761eded6773dddb63d45d8a67302bbfcc3b60456f4db40ffbc398d5b6a24cd1f8d00a1b2fe6e37812b94a24717054be7506816f
6
+ metadata.gz: 8d86d6e937aa2ef7510b94c1a83e91ee72e8a088d940976642333487c5e20358ed29ec8b564f0cacd45903fb1ab8c41463d4c586e09179df58e6b4984e8c6f4e
7
+ data.tar.gz: a1fb40b9c610afc152fd6cface2438939b3853194b5568cbaa3b314315b973a394e5664bde1228c5945ffd1b1d7ef177b1c4eb4ad2145140958aa02e2984c52d
@@ -1,3 +1,7 @@
1
+ === 1.26.0 2015-09-11
2
+
3
+ * Add support for 429 Rate Limited response
4
+
1
5
  === 1.25.0 2015-08-17
2
6
 
3
7
  * Added support for refund listing and retrieval without an associated charge
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.25.0
1
+ 1.26.0
@@ -57,6 +57,7 @@ require 'stripe/errors/api_connection_error'
57
57
  require 'stripe/errors/card_error'
58
58
  require 'stripe/errors/invalid_request_error'
59
59
  require 'stripe/errors/authentication_error'
60
+ require 'stripe/errors/rate_limit_error'
60
61
 
61
62
  module Stripe
62
63
  DEFAULT_CA_BUNDLE_PATH = File.dirname(__FILE__) + '/data/ca-certificates.crt'
@@ -262,6 +263,8 @@ module Stripe
262
263
  raise authentication_error(error, resp, error_obj)
263
264
  when 402
264
265
  raise card_error(error, resp, error_obj)
266
+ when 429
267
+ raise rate_limit_error(error, resp, error_obj)
265
268
  else
266
269
  raise api_error(error, resp, error_obj)
267
270
  end
@@ -278,6 +281,11 @@ module Stripe
278
281
  resp.headers)
279
282
  end
280
283
 
284
+ def self.rate_limit_error(error, resp, error_obj)
285
+ RateLimitError.new(error[:message], resp.code, resp.body, error_obj,
286
+ resp.headers)
287
+ end
288
+
281
289
  def self.card_error(error, resp, error_obj)
282
290
  CardError.new(error[:message], error[:param], error[:code],
283
291
  resp.code, resp.body, error_obj, resp.headers)
@@ -10,20 +10,24 @@ module Stripe
10
10
  InvoiceItem.create(params.merge(:customer => id), opts)
11
11
  end
12
12
 
13
- def invoices
14
- Invoice.all({ :customer => id }, @opts)
13
+ def invoices(params={}, opts={})
14
+ opts = @opts.merge(Util.normalize_opts(opts))
15
+ Invoice.all(params.merge(:customer => id), opts)
15
16
  end
16
17
 
17
- def invoice_items
18
- InvoiceItem.all({ :customer => id }, @opts)
18
+ def invoice_items(params={}, opts={})
19
+ opts = @opts.merge(Util.normalize_opts(opts))
20
+ InvoiceItem.all(params.merge(:customer => id), opts)
19
21
  end
20
22
 
21
- def upcoming_invoice
22
- Invoice.upcoming({ :customer => id }, @opts)
23
+ def upcoming_invoice(params={}, opts={})
24
+ opts = @opts.merge(Util.normalize_opts(opts))
25
+ Invoice.upcoming(params.merge(:customer => id), opts)
23
26
  end
24
27
 
25
- def charges
26
- Charge.all({ :customer => id }, @opts)
28
+ def charges(params={}, opts={})
29
+ opts = @opts.merge(Util.normalize_opts(opts))
30
+ Charge.all(params.merge(:customer => id), opts)
27
31
  end
28
32
 
29
33
  def create_upcoming_invoice(params={}, opts={})
@@ -0,0 +1,4 @@
1
+ module Stripe
2
+ class RateLimitError < StripeError
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.25.0'
2
+ VERSION = '1.26.0'
3
3
  end
@@ -270,6 +270,18 @@ module Stripe
270
270
  end
271
271
  end
272
272
 
273
+ should "a 429 should give a RateLimitError with http status, body, and JSON body" do
274
+ response = make_response(make_rate_limit_error, 429)
275
+ @mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 429))
276
+ begin
277
+ Stripe::Customer.retrieve("foo")
278
+ rescue Stripe::RateLimitError => e
279
+ assert_equal(429, e.http_status)
280
+ assert_equal(true, !!e.http_body)
281
+ assert_equal(true, e.json_body.kind_of?(Hash))
282
+ end
283
+ end
284
+
273
285
  should "setting a nil value for a param should exclude that param from the request" do
274
286
  @mock.expects(:get).with do |url, api_key, params|
275
287
  uri = URI(url)
@@ -510,6 +510,15 @@ module Stripe
510
510
  }
511
511
  end
512
512
 
513
+ def make_rate_limit_error
514
+ {
515
+ :error => {
516
+ :type => "invalid_request_error",
517
+ :message => "Too many requests in a period of time."
518
+ }
519
+ }
520
+ end
521
+
513
522
  def make_api_error
514
523
  {
515
524
  :error => {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.25.0
4
+ version: 1.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Boucher
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-17 00:00:00.000000000 Z
12
+ date: 2015-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -144,6 +144,7 @@ files:
144
144
  - lib/stripe/errors/authentication_error.rb
145
145
  - lib/stripe/errors/card_error.rb
146
146
  - lib/stripe/errors/invalid_request_error.rb
147
+ - lib/stripe/errors/rate_limit_error.rb
147
148
  - lib/stripe/errors/stripe_error.rb
148
149
  - lib/stripe/event.rb
149
150
  - lib/stripe/file_upload.rb