-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Customer Balance Transaction resource and APIs
- Loading branch information
1 parent
1ed21bc
commit 8df3b74
Showing
6 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class CustomerBalanceTransaction < APIResource | ||
OBJECT_NAME = "customer_balance_transaction".freeze | ||
|
||
def resource_url | ||
if !respond_to?(:customer) || customer.nil? | ||
raise NotImplementedError, | ||
"Customer Balance Transactions cannot be accessed without a customer ID." | ||
end | ||
"#{Customer.resource_url}/#{CGI.escape(customer)}/balance_transactions/#{CGI.escape(id)}" | ||
end | ||
|
||
def self.retrieve(_id, _opts = {}) | ||
raise NotImplementedError, | ||
"Customer Balance Transactions cannot be retrieved without a customer ID. " \ | ||
"Retrieve a Customer Balance Transaction using Customer.retrieve_customer_balance_transaction('cus_123', 'cbtxn_123')" | ||
end | ||
|
||
def self.update(_id, _params = nil, _opts = nil) | ||
raise NotImplementedError, | ||
"Customer Balance Transactions cannot be retrieved without a customer ID. " \ | ||
"Update a Customer Balance Transaction using Customer.update_balance_transaction('cus_123', 'cbtxn_123', params)" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
class CustomerBalanceTransactionTest < Test::Unit::TestCase | ||
context "#resource_url" do | ||
should "return a resource URL" do | ||
transaction = Stripe::CustomerBalanceTransaction.construct_from( | ||
id: "cbtxn_123", | ||
customer: "cus_123" | ||
) | ||
assert_equal "/v1/customers/cus_123/balance_transactions/cbtxn_123", | ||
transaction.resource_url | ||
end | ||
|
||
should "raise without a customer" do | ||
transaction = Stripe::CustomerBalanceTransaction.construct_from(id: "cbtxn_123") | ||
assert_raises NotImplementedError do | ||
transaction.resource_url | ||
end | ||
end | ||
end | ||
|
||
should "raise on #retrieve" do | ||
assert_raises NotImplementedError do | ||
Stripe::CustomerBalanceTransaction.retrieve("cbtxn_123") | ||
end | ||
end | ||
|
||
should "raise on #update" do | ||
assert_raises NotImplementedError do | ||
Stripe::CustomerBalanceTransaction.update("cbtxn_123") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters