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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9565603560cfb5f63405f2ac5a1fbbab363d736c81bb7d06858a06530e9fb5b9
4
- data.tar.gz: cc69afe87e63b28d38b1fcd5482cc947b24e0f13414e2c8abc4a2267b27ba373
3
+ metadata.gz: 9231fd56adca6e557e0e6956a115e7f969096402747e143ff7d433442146f0ac
4
+ data.tar.gz: 6f2a3c7a973e5f004518a83ccac1164f7eb354fe26816aa2f39bfa67b4b661e0
5
5
  SHA512:
6
- metadata.gz: 6fdbf78bb9cce8463cedb3859755607b5c4b5e9eeea2125aee9079e3ea9ed00c623d8ce5dd249b4ee042c05552b80be8b7848a831c1a73d1e14cc72bcbd11e97
7
- data.tar.gz: 539d01633f5ced964669bd7611aaeb64534b54a2125ea8e0480867e9d94a5af8d9563450e6ac9e2bdedf3e72d0f25fca77ca8c2d3c08a6049b804a72340bc237
6
+ metadata.gz: 66416730e242f3e1de13937d46143cfd3c2a2f97ac6cbdf908b9a01a1f12b158a3ee983e3f1d888bfccc734b518382889ef57dff9e215e448cd3572268883b99
7
+ data.tar.gz: c6ac92bcbe56e3d19cb642677f5cbcaf89afe45f5321e6016931b9fc8a86b5e203efc10f9de5db9b5df4ac443a3f539d8e4374e547f1e1f24f65d3730dbe9e91
@@ -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.2
1
+ 4.21.3
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "4.21.2".freeze
4
+ VERSION = "4.21.3".freeze
5
5
  end
@@ -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.2
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-05 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday