Skip to content

Commit

Permalink
Add support for TaxRate resource and APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Apr 19, 2019
1 parent 5416f02 commit 9c3ddaa
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.52.0
- STRIPE_MOCK_VERSION=0.54.0

cache:
directories:
Expand Down
1 change: 1 addition & 0 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
require "stripe/subscription_item"
require "stripe/subscription_schedule"
require "stripe/subscription_schedule_revision"
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 @@ -107,6 +107,7 @@ def self.object_classes # rubocop:disable Metrics/MethodLength
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
SubscriptionScheduleRevision::OBJECT_NAME => SubscriptionScheduleRevision,
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
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require ::File.expand_path("../stripe_mock", __FILE__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.52.0".freeze
MOCK_MINIMUM_VERSION = "0.54.0".freeze
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down

0 comments on commit 9c3ddaa

Please sign in to comment.