stripe 1.51.1 → 1.52.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: 5d4b487a7f1742c56ebfafadb07b0a4ee7a352a4
4
- data.tar.gz: ca0ab770ffc1e382f75b33c30a667d9fccd2af26
3
+ metadata.gz: 51a173fc4e60e562a7a4b0e56ac97b8fdb6d9cec
4
+ data.tar.gz: 0ca3a5dd2f33d2dca97ab0fb868f89defe9ac119
5
5
  SHA512:
6
- metadata.gz: 0fb66566f5cddad11f7fcdae7bd5ab6f50daf4366475da0da6bf8e2394063720b08c761bbc7f7afac446af907e2ecb5a8ea93b88d8e6aa9f5110c3afd44f00eb
7
- data.tar.gz: 73c72693910b62975a67035cceca3ba5a3029c988eda0abeb268fd6d96dd2754bf93cb5198799c5f6903f06c2fe8dd031a85382047c24c6b90215fe1038707c6
6
+ metadata.gz: 7c7e39888631f88be74385814a7bedc046744636ac352ad727c726d54c90efaa8ba95b5480f56212d144396524bb563f744a26ee196a029d3e03dc7af9bd71b7
7
+ data.tar.gz: 7c572f28527faebf622fca923814ff926b320ff764539f18905dd75faf4b9a2dd04fcaa33ada0a8b639a57438652a760379a7ceb8da1847f4c2c8483e38bca22
@@ -1,3 +1,7 @@
1
+ === 1.52.0 2016-08-30
2
+
3
+ * Make sure `Subscription`'s `source` is saved with its parent
4
+
1
5
  === 1.51.1 2016-08-30
2
6
 
3
7
  * Make sure `Account`'s `external_account` is saved with its parent
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.51.1
1
+ 1.52.0
@@ -1,10 +1,17 @@
1
1
  module Stripe
2
2
  class Account < APIResource
3
+ extend Gem::Deprecate
3
4
  extend Stripe::APIOperations::Create
4
5
  extend Stripe::APIOperations::List
5
6
  include Stripe::APIOperations::Delete
6
7
  include Stripe::APIOperations::Save
7
8
 
9
+ save_nested_resource :external_account
10
+
11
+ # This method is deprecated. Please use `#external_account=` instead.
12
+ save_nested_resource :bank_account
13
+ deprecate :bank_account=, "#external_account=", 2017, 8
14
+
8
15
  def resource_url
9
16
  if self['id']
10
17
  super
@@ -28,23 +35,6 @@ module Stripe
28
35
  super(id, opts)
29
36
  end
30
37
 
31
- # Set or replace an account's external account.
32
- def external_account=(value)
33
- super
34
-
35
- # The parent setter will perform certain useful operations like
36
- # converting to an APIResource if appropriate.
37
- value = self.external_account
38
-
39
- # Note that external_account may be a card, but could also be a tokenized
40
- # card's ID (which is a string), and so we check its type here.
41
- if value.is_a?(APIResource)
42
- value.save_with_parent = true
43
- end
44
-
45
- value
46
- end
47
-
48
38
  def reject(params={}, opts={})
49
39
  opts = Util.normalize_opts(opts)
50
40
  response, opts = request(:post, resource_url + '/reject', params, opts)
@@ -110,22 +100,6 @@ module Stripe
110
100
 
111
101
  ARGUMENT_NOT_PROVIDED = Object.new
112
102
 
113
- # Set or replace an account's bank account.
114
- #
115
- # This method is deprecated. Please use #external_account instead.
116
- def bank_account=(value)
117
- super
118
- value = self.bank_account
119
-
120
- if value.is_a?(APIResource)
121
- value.save_with_parent = true
122
- end
123
-
124
- value
125
- end
126
- extend Gem::Deprecate
127
- deprecate :bank_account=, "#external_account=", 2017, 8
128
-
129
103
  private
130
104
 
131
105
  def serialize_additional_owners(legal_entity, additional_owners)
@@ -20,6 +20,32 @@ module Stripe
20
20
  "/v1/#{CGI.escape(class_name.downcase)}s"
21
21
  end
22
22
 
23
+ # A metaprogramming call that specifies that a field of a resource can be
24
+ # its own type of API resource (say a nested card under an account for
25
+ # example), and if that resource is set, it should be transmitted to the
26
+ # API on a create or update. Doing so is not the default behavior because
27
+ # API resources should normally be persisted on their own RESTful
28
+ # endpoints.
29
+ def self.save_nested_resource(name)
30
+ define_method(:"#{name}=") do |value|
31
+ super(value)
32
+
33
+ # The parent setter will perform certain useful operations like
34
+ # converting to an APIResource if appropriate. Refresh our argument
35
+ # value to whatever it mutated to.
36
+ value = send(name)
37
+
38
+ # Note that the value may be subresource, but could also be a scalar
39
+ # (like a tokenized card's ID for example), so we check the type before
40
+ # setting #save_with_parent here.
41
+ if value.is_a?(APIResource)
42
+ value.save_with_parent = true
43
+ end
44
+
45
+ value
46
+ end
47
+ end
48
+
23
49
  def resource_url
24
50
  unless id = self['id']
25
51
  raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
@@ -5,22 +5,7 @@ module Stripe
5
5
  include Stripe::APIOperations::Save
6
6
  extend Stripe::APIOperations::List
7
7
 
8
- # Set or replace a customer's default source.
9
- def source=(value)
10
- super
11
-
12
- # The parent setter will perform certain useful operations like
13
- # converting to an APIResource if appropriate.
14
- value = self.source
15
-
16
- # Note that source may be a card, but could also be a tokenized card's ID
17
- # (which is a string), and so we check its type here.
18
- if value.is_a?(APIResource)
19
- value.save_with_parent = true
20
- end
21
-
22
- value
23
- end
8
+ save_nested_resource :source
24
9
 
25
10
  def add_invoice_item(params, opts={})
26
11
  opts = @opts.merge(Util.normalize_opts(opts))
@@ -5,6 +5,8 @@ module Stripe
5
5
  include Stripe::APIOperations::Save
6
6
  include Stripe::APIOperations::Delete
7
7
 
8
+ save_nested_resource :source
9
+
8
10
  def delete_discount
9
11
  _, opts = request(:delete, discount_url)
10
12
  initialize_from({ :discount => nil }, opts, true)
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.51.1'
2
+ VERSION = '1.52.0'
3
3
  end
@@ -290,49 +290,7 @@ module Stripe
290
290
  assert_equal(expected, obj.serialize_params)
291
291
  end
292
292
 
293
- context "#external_account=" do
294
- should "can have a token source set" do
295
- a = Stripe::Account.new("test_account")
296
- a.external_account = "tok_123"
297
- assert_equal "tok_123", a.external_account
298
- end
299
-
300
- should "set a flag if given an object source" do
301
- a = Stripe::Account.new("test_account")
302
- a.external_account = {
303
- :object => 'card'
304
- }
305
- assert_equal true, a.external_account.save_with_parent
306
- end
307
- end
308
-
309
293
  context "#bank_account=" do
310
- should "can have a token source set" do
311
- old_stderr = $stderr
312
- $stderr = StringIO.new
313
- begin
314
- a = Stripe::Account.new("test_account")
315
- a.bank_account = "tok_123"
316
- assert_equal "tok_123", a.bank_account
317
- ensure
318
- $stderr = old_stderr
319
- end
320
- end
321
-
322
- should "set a flag if given an object source" do
323
- old_stderr = $stderr
324
- $stderr = StringIO.new
325
- begin
326
- a = Stripe::Account.new("test_account")
327
- a.bank_account = {
328
- :object => 'bank_account'
329
- }
330
- assert_equal true, a.bank_account.save_with_parent
331
- ensure
332
- $stderr = old_stderr
333
- end
334
- end
335
-
336
294
  should "warn that #bank_account= is deprecated" do
337
295
  old_stderr = $stderr
338
296
  $stderr = StringIO.new
@@ -3,6 +3,26 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
 
4
4
  module Stripe
5
5
  class ApiResourceTest < Test::Unit::TestCase
6
+ class NestedTestAPIResource < Stripe::APIResource
7
+ save_nested_resource :external_account
8
+ end
9
+
10
+ context ".save_nested_resource" do
11
+ should "can have a scalar set" do
12
+ r = NestedTestAPIResource.new("test_resource")
13
+ r.external_account = "tok_123"
14
+ assert_equal "tok_123", r.external_account
15
+ end
16
+
17
+ should "set a flag if given an object source" do
18
+ r = NestedTestAPIResource.new("test_resource")
19
+ r.external_account = {
20
+ :object => 'card'
21
+ }
22
+ assert_equal true, r.external_account.save_with_parent
23
+ end
24
+ end
25
+
6
26
  should "creating a new APIResource should not fetch over the network" do
7
27
  @mock.expects(:get).never
8
28
  Stripe::Customer.new("someid")
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.51.1
4
+ version: 1.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe