Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TaxRate resource and APIs #760

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
require "stripe/subscription_schedule"
require "stripe/subscription_schedule_revision"
require "stripe/tax_id"
require "stripe/tax_rate"
require "stripe/terminal/connection_token"
require "stripe/terminal/location"
require "stripe/terminal/reader"
Expand Down
11 changes: 11 additions & 0 deletions lib/stripe/tax_rate.rb
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
1 change: 1 addition & 0 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def self.object_classes # rubocop:disable Metrics/MethodLength
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
SubscriptionScheduleRevision::OBJECT_NAME => SubscriptionScheduleRevision,
TaxId::OBJECT_NAME => TaxId,
TaxRate::OBJECT_NAME => TaxRate,
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
Terminal::Location::OBJECT_NAME => Terminal::Location,
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
Expand Down
43 changes: 43 additions & 0 deletions test/stripe/tax_rate_test.rb
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