stripe 1.25.0 → 1.26.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/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +8 -0
- data/lib/stripe/customer.rb +12 -8
- data/lib/stripe/errors/rate_limit_error.rb +4 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +12 -0
- data/test/test_data.rb +9 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dee603f6988c8f35b2deeadcf5edcea8ebdc114
|
4
|
+
data.tar.gz: e038126f33119dd877578663534f490baab820b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d86d6e937aa2ef7510b94c1a83e91ee72e8a088d940976642333487c5e20358ed29ec8b564f0cacd45903fb1ab8c41463d4c586e09179df58e6b4984e8c6f4e
|
7
|
+
data.tar.gz: a1fb40b9c610afc152fd6cface2438939b3853194b5568cbaa3b314315b973a394e5664bde1228c5945ffd1b1d7ef177b1c4eb4ad2145140958aa02e2984c52d
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.26.0
|
data/lib/stripe.rb
CHANGED
@@ -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)
|
data/lib/stripe/customer.rb
CHANGED
@@ -10,20 +10,24 @@ module Stripe
|
|
10
10
|
InvoiceItem.create(params.merge(:customer => id), opts)
|
11
11
|
end
|
12
12
|
|
13
|
-
def invoices
|
14
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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={})
|
data/lib/stripe/version.rb
CHANGED
@@ -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)
|
data/test/test_data.rb
CHANGED
@@ -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.
|
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-
|
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
|