mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-01 00:00:30 -04:00
Flag Account#external_account into save_with_parent system
In #433, we built a framework under which subresources are usually not persisted, but in certain cases they can be. At the time, `Customer#source` was the only field that I knew about that had to be flagged into it. Issue #456 has raised that we also be doing `Account#external_account`. This patch adds support for that. Fixes #456.
This commit is contained in:
parent
5573cc73fc
commit
d6514ef633
@ -28,6 +28,23 @@ module Stripe
|
||||
super(id, opts)
|
||||
end
|
||||
|
||||
# Set or replace an account's external account.
|
||||
def external_account=(value)
|
||||
super
|
||||
|
||||
# The parent setter will perform certain useful operations like
|
||||
# converting to an APIResource if appropriate.
|
||||
value = self.external_account
|
||||
|
||||
# Note that external_account may be a card, but could also be a tokenized
|
||||
# card's ID (which is a string), and so we check its type here.
|
||||
if value.is_a?(APIResource)
|
||||
value.save_with_parent = true
|
||||
end
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def reject(params={}, opts={})
|
||||
opts = Util.normalize_opts(opts)
|
||||
response, opts = request(:post, resource_url + '/reject', params, opts)
|
||||
|
@ -289,5 +289,19 @@ module Stripe
|
||||
}
|
||||
assert_equal(expected, obj.serialize_params)
|
||||
end
|
||||
|
||||
should "can have a token source set" do
|
||||
a = Stripe::Account.new("test_account")
|
||||
a.external_account = "tok_123"
|
||||
assert_equal "tok_123", a.external_account
|
||||
end
|
||||
|
||||
should "set a flag if given an object source" do
|
||||
a = Stripe::Account.new("test_account")
|
||||
a.external_account = {
|
||||
:object => 'card'
|
||||
}
|
||||
assert_equal true, a.external_account.save_with_parent
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user