Skip to content

Commit

Permalink
Update retrieve_cash_balance method to have params. (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcr-stripe authored Aug 1, 2022
1 parent 5a4d6fc commit a40fda3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
search(params, opts).auto_paging_each(&blk)
end

def self.retrieve_cash_balance(customer, opts = {})
def self.retrieve_cash_balance(customer, params = {}, opts = {})
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
params: {},
params: params,
opts: opts
)
end
Expand Down
20 changes: 6 additions & 14 deletions test/stripe/customer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,38 +230,30 @@ class CustomerTest < Test::Unit::TestCase
# compatibility for existing users.

context "#retrieve_cash_balance" do
should "legacy call pattern - retrieve_cash_balance(customer_id, nil)" do
should "retrieve with just ID" do
Stripe::Customer.retrieve_cash_balance("cus_123")
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance"
end

should "legacy call pattern - retrieve_cash_balance(customer_id, opts)" do
should "retrieve with custom opts" do
# Assert that we're actually making a change by swapping out the API base.
assert Stripe.api_base != Stripe.connect_base

Stripe::Customer.retrieve_cash_balance("cus_123", { api_base: Stripe.connect_base })
assert_requested :get, "#{Stripe.connect_base}/v1/customers/cus_123/cash_balance"
end

should "modern call pattern - retrieve_cash_balance(customer_id, opts)" do
# Assert that we're actually making a change by swapping out the API base.
assert Stripe.api_base != Stripe.connect_base

Stripe::Customer.retrieve_cash_balance("cus_123", { api_base: Stripe.connect_base })
Stripe::Customer.retrieve_cash_balance("cus_123", {}, { api_base: Stripe.connect_base })
assert_requested :get, "#{Stripe.connect_base}/v1/customers/cus_123/cash_balance"
end
end

context "#update_cash_balance" do
should "legacy call pattern - update_cash_balance(customer, params)" do
should "update with ID, params" do
Stripe::Customer.update_cash_balance("cus_123", { settings: { reconciliation_mode: "manual" } })

assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance" do |req|
req.body == "settings[reconciliation_mode]=manual"
end
end

should "legacy call pattern - update_cash_balance(customer, params, opts)" do
should "update with ID, params and opts" do
# Assert that we're actually making a change by swapping out the API base.
assert Stripe.api_base != Stripe.connect_base

Expand All @@ -276,7 +268,7 @@ class CustomerTest < Test::Unit::TestCase
end
end

should "modern call pattern - update_cash_balance(customer)" do
should "update with just ID" do
Stripe::Customer.update_cash_balance("cus_123")

assert_requested :post, "#{Stripe.api_base}/v1/customers/cus_123/cash_balance"
Expand Down

0 comments on commit a40fda3

Please sign in to comment.