-
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 CustomerBalanceTransaction resource and APIs
- Loading branch information
1 parent
b667280
commit abef09e
Showing
8 changed files
with
117 additions
and
2 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
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class CustomerBalanceTransaction < APIResource | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Save | ||
|
||
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_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
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
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