stripe 4.21.2 → 4.21.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/stripe/api_resource.rb +5 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9231fd56adca6e557e0e6956a115e7f969096402747e143ff7d433442146f0ac
|
4
|
+
data.tar.gz: 6f2a3c7a973e5f004518a83ccac1164f7eb354fe26816aa2f39bfa67b4b661e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66416730e242f3e1de13937d46143cfd3c2a2f97ac6cbdf908b9a01a1f12b158a3ee983e3f1d888bfccc734b518382889ef57dff9e215e448cd3572268883b99
|
7
|
+
data.tar.gz: c6ac92bcbe56e3d19cb642677f5cbcaf89afe45f5321e6016931b9fc8a86b5e203efc10f9de5db9b5df4ac443a3f539d8e4374e547f1e1f24f65d3730dbe9e91
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.21.3 - 2019-07-15
|
4
|
+
* [#810](https://github.com/stripe/stripe-ruby/pull/810) Better error message when passing non-string to custom method
|
5
|
+
|
3
6
|
## 4.21.2 - 2019-07-05
|
4
7
|
* [#806](https://github.com/stripe/stripe-ruby/pull/806) Revert back to `initialize_from` from `Util.convert_to_stripe_object`
|
5
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.21.
|
1
|
+
4.21.3
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -70,6 +70,11 @@ module Stripe
|
|
70
70
|
end
|
71
71
|
http_path ||= name.to_s
|
72
72
|
define_singleton_method(name) do |id, params = {}, opts = {}|
|
73
|
+
unless id.is_a?(String)
|
74
|
+
raise ArgumentError,
|
75
|
+
"id should be a string representing the ID of an API resource"
|
76
|
+
end
|
77
|
+
|
73
78
|
url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
|
74
79
|
resp, opts = request(http_verb, url, params, opts)
|
75
80
|
Util.convert_to_stripe_object(resp.data, opts)
|
data/lib/stripe/version.rb
CHANGED
@@ -4,10 +4,31 @@ require ::File.expand_path("../test_helper", __dir__)
|
|
4
4
|
|
5
5
|
module Stripe
|
6
6
|
class ApiResourceTest < Test::Unit::TestCase
|
7
|
+
class CustomMethodAPIResource < APIResource
|
8
|
+
OBJECT_NAME = "custom_method".freeze
|
9
|
+
custom_method :my_method, http_verb: :post
|
10
|
+
end
|
11
|
+
|
7
12
|
class NestedTestAPIResource < APIResource
|
8
13
|
save_nested_resource :external_account
|
9
14
|
end
|
10
15
|
|
16
|
+
context ".custom_method" do
|
17
|
+
should "call to an RPC-style method" do
|
18
|
+
stub_request(:post, "#{Stripe.api_base}/v1/custom_methods/ch_123/my_method")
|
19
|
+
.to_return(body: JSON.generate({}))
|
20
|
+
CustomMethodAPIResource.my_method("ch_123")
|
21
|
+
end
|
22
|
+
|
23
|
+
should "raise an error if a non-ID is passed" do
|
24
|
+
e = assert_raises ArgumentError do
|
25
|
+
CustomMethodAPIResource.my_method(id: "ch_123")
|
26
|
+
end
|
27
|
+
assert_equal "id should be a string representing the ID of an API resource",
|
28
|
+
e.message
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
11
32
|
context ".save_nested_resource" do
|
12
33
|
should "can have a scalar set" do
|
13
34
|
r = NestedTestAPIResource.new("test_resource")
|
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: 4.21.
|
4
|
+
version: 4.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|