-
Notifications
You must be signed in to change notification settings - Fork 548
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 TaxId resource and APIs
- Loading branch information
1 parent
5416f02
commit b5cd9e3
Showing
8 changed files
with
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class TaxId < APIResource | ||
extend Stripe::APIOperations::List | ||
include Stripe::APIOperations::Delete | ||
|
||
OBJECT_NAME = "tax_id".freeze | ||
|
||
def resource_url | ||
if !respond_to?(:customer) || customer.nil? | ||
raise NotImplementedError, | ||
"Tax Ids cannot be accessed without a customer ID." | ||
end | ||
"#{Customer.resource_url}/#{CGI.escape(customer)}/tax_ids/#{CGI.escape(id)}" | ||
end | ||
|
||
def self.retrieve(_id, _opts = {}) | ||
raise NotImplementedError, "Tax Ids cannot be retrieved without a customer ID. Retrieve a tax id using Customer.retrieve_tax_id('tax_id')" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
class TaxIdTest < Test::Unit::TestCase | ||
context "#resource_url" do | ||
should "return a resource URL" do | ||
tax_id = Stripe::TaxId.construct_from( | ||
id: "txi_123", | ||
customer: "cus_123" | ||
) | ||
assert_equal "/v1/customers/cus_123/tax_ids/txi_123", | ||
tax_id.resource_url | ||
end | ||
|
||
should "raise without a customer" do | ||
tax_id = Stripe::TaxId.construct_from(id: "txi_123") | ||
assert_raises NotImplementedError do | ||
tax_id.resource_url | ||
end | ||
end | ||
end | ||
|
||
should "raise on #retrieve" do | ||
assert_raises NotImplementedError do | ||
Stripe::TaxId.retrieve("txi_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