Skip to content

Commit

Permalink
Add billing portal configuration (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Feb 20, 2021
1 parent 512f546 commit f59ba8c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Expand Up @@ -27,6 +27,7 @@ Layout/HeredocIndentation:

Layout/LineLength:
Exclude:
- "lib/stripe/object_types.rb"
- "lib/stripe/resources/**/*.rb"
- "test/**/*.rb"

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -15,7 +15,7 @@ notifications:
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.101.0
- STRIPE_MOCK_VERSION=0.103.0

cache:
directories:
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/object_types.rb
Expand Up @@ -19,6 +19,7 @@ def self.object_names_to_classes
Balance::OBJECT_NAME => Balance,
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
BankAccount::OBJECT_NAME => BankAccount,
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
Expand Down
1 change: 1 addition & 0 deletions lib/stripe/resources.rb
Expand Up @@ -9,6 +9,7 @@
require "stripe/resources/balance"
require "stripe/resources/balance_transaction"
require "stripe/resources/bank_account"
require "stripe/resources/billing_portal/configuration"
require "stripe/resources/billing_portal/session"
require "stripe/resources/bitcoin_receiver"
require "stripe/resources/bitcoin_transaction"
Expand Down
14 changes: 14 additions & 0 deletions lib/stripe/resources/billing_portal/configuration.rb
@@ -0,0 +1,14 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
module BillingPortal
class Configuration < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "billing_portal.configuration"
end
end
end
37 changes: 37 additions & 0 deletions test/stripe/billing_portal/configuration_test.rb
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __dir__)

module Stripe
module BillingPortal
class ConfigurationTest < Test::Unit::TestCase
should "be creatable" do
session = Stripe::BillingPortal::Configuration.create({
business_profile: {
privacy_policy_url: "https://example.com/privacy",
terms_of_service_url: "https://example.com/tos",
},
features: { customer_update: { allowed_updates: ["address"], enabled: true } },
})
assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/configurations"
assert session.is_a?(Stripe::BillingPortal::Configuration)
end
should "be retrievable" do
session = Stripe::BillingPortal::Configuration.retrieve("bpc_xyz")
assert_requested :get, "#{Stripe.api_base}/v1/billing_portal/configurations/bpc_xyz"
assert session.is_a?(Stripe::BillingPortal::Configuration)
end

should "be updateable" do
session = Stripe::BillingPortal::Configuration.update("bpc_xyz", { active: false })
assert_requested :post, "#{Stripe.api_base}/v1/billing_portal/configurations/bpc_xyz"
assert session.is_a?(Stripe::BillingPortal::Configuration)
end
should "be listable" do
sessions = Stripe::BillingPortal::Configuration.list
assert_requested :get, "#{Stripe.api_base}/v1/billing_portal/configurations"
assert sessions.data[0].is_a?(Stripe::BillingPortal::Configuration)
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -16,7 +16,7 @@
require ::File.expand_path("stripe_mock", __dir__)

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

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

0 comments on commit f59ba8c

Please sign in to comment.