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

Update generated code for beta #1313

Merged
merged 13 commits into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v756
v794
6 changes: 5 additions & 1 deletion lib/stripe/api_operations/search.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

# TODO: (major) Deprecated, Remove along with extends
module Stripe
module APIOperations
# The _search method via API Operations is deprecated.
# Please use the search method from within the resource instead.
module Search
def _search(search_url, filters = {}, opts = {})
request_stripe_object(
Expand All @@ -12,6 +13,9 @@ def _search(search_url, filters = {}, opts = {})
opts: opts
)
end

extend Gem::Deprecate
deprecate :_search, "request_stripe_object", 2024, 1
end
end
end
2 changes: 1 addition & 1 deletion lib/stripe/object_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def self.object_names_to_classes
SearchResultObject::OBJECT_NAME => SearchResultObject,

# business objects
File::OBJECT_NAME_ALT => File,
Account::OBJECT_NAME => Account,
AccountLink::OBJECT_NAME => AccountLink,
AccountNotice::OBJECT_NAME => AccountNotice,
Expand Down Expand Up @@ -51,7 +52,6 @@ def self.object_names_to_classes
Event::OBJECT_NAME => Event,
ExchangeRate::OBJECT_NAME => ExchangeRate,
File::OBJECT_NAME => File,
File::OBJECT_NAME_ALT => File,
FileLink::OBJECT_NAME => FileLink,
FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
FinancialConnections::AccountInferredBalance::OBJECT_NAME =>
Expand Down
5 changes: 2 additions & 3 deletions lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ module Stripe
# enabled to make live charges or receive payouts.
#
# For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that
# account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links)
# for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express**
# below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
# account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions),
# some properties are only returned for Custom accounts. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
class Account < APIResource
extend Gem::Deprecate
extend Stripe::APIOperations::Create
Expand Down
14 changes: 14 additions & 0 deletions lib/stripe/resources/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ def self.attach_payment_intent(invoice, params = {}, opts = {})
)
end

# At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.
#
# Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.
#
# You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource.
def self.create_preview(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/invoices/create_preview",
params: params,
opts: opts
)
end

# Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method.
def self.finalize_invoice(invoice, params = {}, opts = {})
request_stripe_object(
Expand Down
8 changes: 4 additions & 4 deletions lib/stripe/resources/payout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Payout < APIResource

OBJECT_NAME = "payout"

# You can cancel a previously created payout if it hasn't been paid out yet. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts.
# You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts.
def cancel(params = {}, opts = {})
request_stripe_object(
method: :post,
Expand All @@ -27,7 +27,7 @@ def cancel(params = {}, opts = {})
)
end

# Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is in the pending status, use /v1/payouts/:id/cancel instead.
# Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead.
#
# By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required.
def reverse(params = {}, opts = {})
Expand All @@ -39,7 +39,7 @@ def reverse(params = {}, opts = {})
)
end

# You can cancel a previously created payout if it hasn't been paid out yet. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts.
# You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts.
def self.cancel(payout, params = {}, opts = {})
request_stripe_object(
method: :post,
Expand All @@ -49,7 +49,7 @@ def self.cancel(payout, params = {}, opts = {})
)
end

# Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is in the pending status, use /v1/payouts/:id/cancel instead.
# Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead.
#
# By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required.
def self.reverse(payout, params = {}, opts = {})
Expand Down
20 changes: 20 additions & 0 deletions test/stripe/api_operations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ def self.protected_fields
end
end

context ".search" do
should "warn that ._search is deprecated" do
old_stderr = $stderr
$stderr = StringIO.new
begin
stub_request(:post, "#{Stripe.api_base}/v1/customers/search?query=foo:bar")
.to_return(body: JSON.generate(object: "customer"))

client = StripeClient.new
client.request { Customer._search("/v1/customers/search", query: "foo:bar") }

message = "NOTE: Stripe::Customer._search is deprecated; use request_stripe_object " \
"instead. It will be removed on or after 2024-01."
assert_match Regexp.new(message), $stderr.string
ensure
$stderr = old_stderr
end
end
end

context ".nested_resource_class_methods" do
class MainResource < APIResource # rubocop:todo Lint/ConstantDefinitionInBlock
extend Stripe::APIOperations::NestedResource
Expand Down
Loading