Skip to content

Commit

Permalink
Merge branch 'stripe:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Slsadler14 authored Feb 19, 2024
2 parents 5e898b3 + 6664641 commit deffb61
Show file tree
Hide file tree
Showing 186 changed files with 226,047 additions and 139 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Changelog
## 10.9.0 - 2024-02-15
* [#1329](https://github.com/stripe/stripe-ruby/pull/1329) Update generated code
* Fixed bug where `TaxId` resource `delete` method sent request to wrong URL (https://github.com/stripe/stripe-ruby/issues/1333)
* [#1324](https://github.com/stripe/stripe-ruby/pull/1324) Start running Sorbet in CI
* [#1327](https://github.com/stripe/stripe-ruby/pull/1327) Add methods for dynamically referenced constants

## 10.8.0 - 2024-02-08
* [#1322](https://github.com/stripe/stripe-ruby/pull/1322) Update generated code
* [#1323](https://github.com/stripe/stripe-ruby/pull/1323) Extract other CRUDL api operations from mixins
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ group :development do
# don't install on truffleruby
gem "jaro_winkler", "1.5.4" unless RUBY_ENGINE == "truffleruby"

gem "sorbet-static"
gem "tapioca"

platforms :mri do
gem "byebug"
gem "pry"
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ codegen-format:

ci-test:
bundle install && bundle exec rake test
@version=$$(ruby -e "puts RUBY_VERSION.split('.')[0..1].join.to_i"); \
if [ $$version -ge 27 ]; then \
echo "Ruby version >= 2.7, continue with srb tc"; \
bundle exec srb tc; \
else \
echo "Ruby version < 2.7, skipping srb tc"; \
fi

test: ci-test
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v810
v829
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.8.0
10.9.0
27 changes: 27 additions & 0 deletions bin/tapioca
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("tapioca", "tapioca")
11 changes: 10 additions & 1 deletion lib/stripe/api_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class APIResource < StripeObject
# for example, where this is allowed.
attr_accessor :save_with_parent

# TODO: (major) Remove OBJECT_NAME and stop using const_get here
# This is a workaround to avoid breaking users who have defined their own
# APIResource subclasses with a custom OBJECT_NAME. We should never fallback
# on this case otherwise.
OBJECT_NAME = ""
def self.object_name
const_get(:OBJECT_NAME)
end

def self.class_name
name.split("::")[-1]
end
Expand All @@ -23,7 +32,7 @@ def self.resource_url
end
# Namespaces are separated in object names with periods (.) and in URLs
# with forward slashes (/), so replace the former with the latter.
"/v1/#{self::OBJECT_NAME.downcase.tr('.', '/')}s"
"/v1/#{object_name.downcase.tr('.', '/')}s"
end

# A metaprogramming call that specifies that a field of a resource can be
Expand Down
8 changes: 6 additions & 2 deletions lib/stripe/api_resource_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def initialize(resource)
@resource = resource
end

def self.resource_class
nil
end

# Adds a custom method to a test helper. This is used to add support for
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
# following parameters:
Expand All @@ -27,12 +31,12 @@ def initialize(resource)
# adds a `capture` class method to the resource class that, when called,
# will send a POST request to `/v1/<object_name>/capture`.
def self.custom_method(name, http_verb:, http_path: nil)
Util.custom_method self::RESOURCE_CLASS, self, name, http_verb, http_path
Util.custom_method resource_class, self, name, http_verb, http_path
end

def self.resource_url
"/v1/test_helpers/" \
"#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
"#{resource_class.object_name.downcase.tr('.', '/')}s"
end

def resource_url
Expand Down
3 changes: 3 additions & 0 deletions lib/stripe/list_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class ListObject < StripeObject
include Stripe::APIOperations::Create

OBJECT_NAME = "list"
def self.object_name
"list"
end

# This accessor allows a `ListObject` to inherit various filters that were
# given to a predecessor. This allows for things like consistent limits,
Expand Down
238 changes: 120 additions & 118 deletions lib/stripe/object_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,136 +2,138 @@
# frozen_string_literal: true

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize

module Stripe
module ObjectTypes
def self.object_names_to_classes
{
# data structures
ListObject::OBJECT_NAME => ListObject,
SearchResultObject::OBJECT_NAME => SearchResultObject,
ListObject.object_name => ListObject,
SearchResultObject.object_name => SearchResultObject,

# business objects
File::OBJECT_NAME_ALT => File,
Account::OBJECT_NAME => Account,
AccountLink::OBJECT_NAME => AccountLink,
AccountSession::OBJECT_NAME => AccountSession,
ApplePayDomain::OBJECT_NAME => ApplePayDomain,
ApplicationFee::OBJECT_NAME => ApplicationFee,
ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
Apps::Secret::OBJECT_NAME => Apps::Secret,
Balance::OBJECT_NAME => Balance,
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
BankAccount::OBJECT_NAME => BankAccount,
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
Capability::OBJECT_NAME => Capability,
Card::OBJECT_NAME => Card,
CashBalance::OBJECT_NAME => CashBalance,
Charge::OBJECT_NAME => Charge,
Checkout::Session::OBJECT_NAME => Checkout::Session,
Climate::Order::OBJECT_NAME => Climate::Order,
Climate::Product::OBJECT_NAME => Climate::Product,
Climate::Supplier::OBJECT_NAME => Climate::Supplier,
CountrySpec::OBJECT_NAME => CountrySpec,
Coupon::OBJECT_NAME => Coupon,
CreditNote::OBJECT_NAME => CreditNote,
CreditNoteLineItem::OBJECT_NAME => CreditNoteLineItem,
Customer::OBJECT_NAME => Customer,
CustomerBalanceTransaction::OBJECT_NAME => CustomerBalanceTransaction,
CustomerCashBalanceTransaction::OBJECT_NAME => CustomerCashBalanceTransaction,
CustomerSession::OBJECT_NAME => CustomerSession,
Discount::OBJECT_NAME => Discount,
Dispute::OBJECT_NAME => Dispute,
EphemeralKey::OBJECT_NAME => EphemeralKey,
Event::OBJECT_NAME => Event,
ExchangeRate::OBJECT_NAME => ExchangeRate,
File::OBJECT_NAME => File,
FileLink::OBJECT_NAME => FileLink,
FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
FinancialConnections::AccountOwner::OBJECT_NAME => FinancialConnections::AccountOwner,
FinancialConnections::AccountOwnership::OBJECT_NAME =>
File.object_name_alt => File,
Account.object_name => Account,
AccountLink.object_name => AccountLink,
AccountSession.object_name => AccountSession,
ApplePayDomain.object_name => ApplePayDomain,
ApplicationFee.object_name => ApplicationFee,
ApplicationFeeRefund.object_name => ApplicationFeeRefund,
Apps::Secret.object_name => Apps::Secret,
Balance.object_name => Balance,
BalanceTransaction.object_name => BalanceTransaction,
BankAccount.object_name => BankAccount,
BillingPortal::Configuration.object_name => BillingPortal::Configuration,
BillingPortal::Session.object_name => BillingPortal::Session,
Capability.object_name => Capability,
Card.object_name => Card,
CashBalance.object_name => CashBalance,
Charge.object_name => Charge,
Checkout::Session.object_name => Checkout::Session,
Climate::Order.object_name => Climate::Order,
Climate::Product.object_name => Climate::Product,
Climate::Supplier.object_name => Climate::Supplier,
CountrySpec.object_name => CountrySpec,
Coupon.object_name => Coupon,
CreditNote.object_name => CreditNote,
CreditNoteLineItem.object_name => CreditNoteLineItem,
Customer.object_name => Customer,
CustomerBalanceTransaction.object_name => CustomerBalanceTransaction,
CustomerCashBalanceTransaction.object_name => CustomerCashBalanceTransaction,
CustomerSession.object_name => CustomerSession,
Discount.object_name => Discount,
Dispute.object_name => Dispute,
EphemeralKey.object_name => EphemeralKey,
Event.object_name => Event,
ExchangeRate.object_name => ExchangeRate,
File.object_name => File,
FileLink.object_name => FileLink,
FinancialConnections::Account.object_name => FinancialConnections::Account,
FinancialConnections::AccountOwner.object_name => FinancialConnections::AccountOwner,
FinancialConnections::AccountOwnership.object_name =>
FinancialConnections::AccountOwnership,
FinancialConnections::Session::OBJECT_NAME => FinancialConnections::Session,
FinancialConnections::Transaction::OBJECT_NAME => FinancialConnections::Transaction,
FundingInstructions::OBJECT_NAME => FundingInstructions,
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
Issuing::Card::OBJECT_NAME => Issuing::Card,
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
Issuing::Token::OBJECT_NAME => Issuing::Token,
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
LineItem::OBJECT_NAME => LineItem,
LoginLink::OBJECT_NAME => LoginLink,
Mandate::OBJECT_NAME => Mandate,
PaymentIntent::OBJECT_NAME => PaymentIntent,
PaymentLink::OBJECT_NAME => PaymentLink,
PaymentMethod::OBJECT_NAME => PaymentMethod,
PaymentMethodConfiguration::OBJECT_NAME => PaymentMethodConfiguration,
PaymentMethodDomain::OBJECT_NAME => PaymentMethodDomain,
Payout::OBJECT_NAME => Payout,
Person::OBJECT_NAME => Person,
Plan::OBJECT_NAME => Plan,
Price::OBJECT_NAME => Price,
Product::OBJECT_NAME => Product,
PromotionCode::OBJECT_NAME => PromotionCode,
Quote::OBJECT_NAME => Quote,
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
Refund::OBJECT_NAME => Refund,
Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
Reversal::OBJECT_NAME => Reversal,
Review::OBJECT_NAME => Review,
SetupAttempt::OBJECT_NAME => SetupAttempt,
SetupIntent::OBJECT_NAME => SetupIntent,
ShippingRate::OBJECT_NAME => ShippingRate,
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
Source::OBJECT_NAME => Source,
SourceTransaction::OBJECT_NAME => SourceTransaction,
Subscription::OBJECT_NAME => Subscription,
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
Tax::Calculation::OBJECT_NAME => Tax::Calculation,
Tax::CalculationLineItem::OBJECT_NAME => Tax::CalculationLineItem,
Tax::Registration::OBJECT_NAME => Tax::Registration,
Tax::Settings::OBJECT_NAME => Tax::Settings,
Tax::Transaction::OBJECT_NAME => Tax::Transaction,
Tax::TransactionLineItem::OBJECT_NAME => Tax::TransactionLineItem,
TaxCode::OBJECT_NAME => TaxCode,
TaxId::OBJECT_NAME => TaxId,
TaxRate::OBJECT_NAME => TaxRate,
Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
Terminal::Location::OBJECT_NAME => Terminal::Location,
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
Token::OBJECT_NAME => Token,
Topup::OBJECT_NAME => Topup,
Transfer::OBJECT_NAME => Transfer,
Treasury::CreditReversal::OBJECT_NAME => Treasury::CreditReversal,
Treasury::DebitReversal::OBJECT_NAME => Treasury::DebitReversal,
Treasury::FinancialAccount::OBJECT_NAME => Treasury::FinancialAccount,
Treasury::FinancialAccountFeatures::OBJECT_NAME => Treasury::FinancialAccountFeatures,
Treasury::InboundTransfer::OBJECT_NAME => Treasury::InboundTransfer,
Treasury::OutboundPayment::OBJECT_NAME => Treasury::OutboundPayment,
Treasury::OutboundTransfer::OBJECT_NAME => Treasury::OutboundTransfer,
Treasury::ReceivedCredit::OBJECT_NAME => Treasury::ReceivedCredit,
Treasury::ReceivedDebit::OBJECT_NAME => Treasury::ReceivedDebit,
Treasury::Transaction::OBJECT_NAME => Treasury::Transaction,
Treasury::TransactionEntry::OBJECT_NAME => Treasury::TransactionEntry,
UsageRecord::OBJECT_NAME => UsageRecord,
UsageRecordSummary::OBJECT_NAME => UsageRecordSummary,
WebhookEndpoint::OBJECT_NAME => WebhookEndpoint,
FinancialConnections::Session.object_name => FinancialConnections::Session,
FinancialConnections::Transaction.object_name => FinancialConnections::Transaction,
FundingInstructions.object_name => FundingInstructions,
Identity::VerificationReport.object_name => Identity::VerificationReport,
Identity::VerificationSession.object_name => Identity::VerificationSession,
Invoice.object_name => Invoice,
InvoiceItem.object_name => InvoiceItem,
InvoiceLineItem.object_name => InvoiceLineItem,
Issuing::Authorization.object_name => Issuing::Authorization,
Issuing::Card.object_name => Issuing::Card,
Issuing::Cardholder.object_name => Issuing::Cardholder,
Issuing::Dispute.object_name => Issuing::Dispute,
Issuing::Token.object_name => Issuing::Token,
Issuing::Transaction.object_name => Issuing::Transaction,
LineItem.object_name => LineItem,
LoginLink.object_name => LoginLink,
Mandate.object_name => Mandate,
PaymentIntent.object_name => PaymentIntent,
PaymentLink.object_name => PaymentLink,
PaymentMethod.object_name => PaymentMethod,
PaymentMethodConfiguration.object_name => PaymentMethodConfiguration,
PaymentMethodDomain.object_name => PaymentMethodDomain,
Payout.object_name => Payout,
Person.object_name => Person,
Plan.object_name => Plan,
Price.object_name => Price,
Product.object_name => Product,
PromotionCode.object_name => PromotionCode,
Quote.object_name => Quote,
Radar::EarlyFraudWarning.object_name => Radar::EarlyFraudWarning,
Radar::ValueList.object_name => Radar::ValueList,
Radar::ValueListItem.object_name => Radar::ValueListItem,
Refund.object_name => Refund,
Reporting::ReportRun.object_name => Reporting::ReportRun,
Reporting::ReportType.object_name => Reporting::ReportType,
Reversal.object_name => Reversal,
Review.object_name => Review,
SetupAttempt.object_name => SetupAttempt,
SetupIntent.object_name => SetupIntent,
ShippingRate.object_name => ShippingRate,
Sigma::ScheduledQueryRun.object_name => Sigma::ScheduledQueryRun,
Source.object_name => Source,
SourceTransaction.object_name => SourceTransaction,
Subscription.object_name => Subscription,
SubscriptionItem.object_name => SubscriptionItem,
SubscriptionSchedule.object_name => SubscriptionSchedule,
Tax::Calculation.object_name => Tax::Calculation,
Tax::CalculationLineItem.object_name => Tax::CalculationLineItem,
Tax::Registration.object_name => Tax::Registration,
Tax::Settings.object_name => Tax::Settings,
Tax::Transaction.object_name => Tax::Transaction,
Tax::TransactionLineItem.object_name => Tax::TransactionLineItem,
TaxCode.object_name => TaxCode,
TaxId.object_name => TaxId,
TaxRate.object_name => TaxRate,
Terminal::Configuration.object_name => Terminal::Configuration,
Terminal::ConnectionToken.object_name => Terminal::ConnectionToken,
Terminal::Location.object_name => Terminal::Location,
Terminal::Reader.object_name => Terminal::Reader,
TestHelpers::TestClock.object_name => TestHelpers::TestClock,
Token.object_name => Token,
Topup.object_name => Topup,
Transfer.object_name => Transfer,
Treasury::CreditReversal.object_name => Treasury::CreditReversal,
Treasury::DebitReversal.object_name => Treasury::DebitReversal,
Treasury::FinancialAccount.object_name => Treasury::FinancialAccount,
Treasury::FinancialAccountFeatures.object_name => Treasury::FinancialAccountFeatures,
Treasury::InboundTransfer.object_name => Treasury::InboundTransfer,
Treasury::OutboundPayment.object_name => Treasury::OutboundPayment,
Treasury::OutboundTransfer.object_name => Treasury::OutboundTransfer,
Treasury::ReceivedCredit.object_name => Treasury::ReceivedCredit,
Treasury::ReceivedDebit.object_name => Treasury::ReceivedDebit,
Treasury::Transaction.object_name => Treasury::Transaction,
Treasury::TransactionEntry.object_name => Treasury::TransactionEntry,
UsageRecord.object_name => UsageRecord,
UsageRecordSummary.object_name => UsageRecordSummary,
WebhookEndpoint.object_name => WebhookEndpoint,
}
end
end
end

# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
Loading

0 comments on commit deffb61

Please sign in to comment.