-
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 TaxRate resource and APIs
- Loading branch information
1 parent
5416f02
commit 9c3ddaa
Showing
6 changed files
with
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module Stripe | ||
class TaxRate < APIResource | ||
extend Stripe::APIOperations::Create | ||
include Stripe::APIOperations::Save | ||
extend Stripe::APIOperations::List | ||
|
||
OBJECT_NAME = "tax_rate".freeze | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require ::File.expand_path("../../test_helper", __FILE__) | ||
|
||
module Stripe | ||
class TaxRateTest < Test::Unit::TestCase | ||
should "be listable" do | ||
tax_rates = Stripe::TaxRate.list | ||
assert_requested :get, "#{Stripe.api_base}/v1/tax_rates" | ||
assert tax_rates.data.is_a?(Array) | ||
assert tax_rates.first.is_a?(Stripe::TaxRate) | ||
end | ||
|
||
should "be retrievable" do | ||
tax_rate = Stripe::TaxRate.retrieve("txr_123") | ||
assert_requested :get, "#{Stripe.api_base}/v1/tax_rates/txr_123" | ||
assert tax_rate.is_a?(Stripe::TaxRate) | ||
end | ||
|
||
should "be creatable" do | ||
tax_rate = Stripe::TaxRate.create( | ||
display_name: "name", | ||
inclusive: false, | ||
percentage: 10.15 | ||
) | ||
assert_requested :post, "#{Stripe.api_base}/v1/tax_rates" | ||
assert tax_rate.is_a?(Stripe::TaxRate) | ||
end | ||
|
||
should "be saveable" do | ||
tax_rate = Stripe::TaxRate.retrieve("txr_123") | ||
tax_rate.metadata["key"] = "value" | ||
tax_rate.save | ||
assert_requested :post, "#{Stripe.api_base}/v1/tax_rates/#{tax_rate.id}" | ||
end | ||
|
||
should "be updateable" do | ||
tax_rate = Stripe::TaxRate.update("txr_123", metadata: { key: "value" }) | ||
assert_requested :post, "#{Stripe.api_base}/v1/tax_rates/txr_123" | ||
assert tax_rate.is_a?(Stripe::TaxRate) | ||
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