From b8931e71c0045f89ea2c63b5843a7cf81ecd305f Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 1 Mar 2022 11:21:53 -0800 Subject: [PATCH] Codegen for openapi 1707cb8 --- lib/resources.js | 3 + lib/resources/TestHelpers/TestClocks.js | 36 ++++ .../resources/generated_examples_test.spec.js | 32 ++++ types/2020-08-27/Customers.d.ts | 10 + types/2020-08-27/InvoiceItems.d.ts | 5 + types/2020-08-27/Invoices.d.ts | 15 ++ types/2020-08-27/Products.d.ts | 2 +- types/2020-08-27/Quotes.d.ts | 10 + types/2020-08-27/Refunds.d.ts | 39 ++++ types/2020-08-27/SubscriptionSchedules.d.ts | 5 + types/2020-08-27/Subscriptions.d.ts | 5 + types/2020-08-27/Terminal/Locations.d.ts | 18 +- types/2020-08-27/TestHelpers/TestClocks.d.ts | 174 ++++++++++++++++++ types/2020-08-27/index.d.ts | 4 + 14 files changed, 354 insertions(+), 4 deletions(-) create mode 100644 lib/resources/TestHelpers/TestClocks.js create mode 100644 types/2020-08-27/TestHelpers/TestClocks.d.ts diff --git a/lib/resources.js b/lib/resources.js index f5ba52b795..fbe202a5e3 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -91,4 +91,7 @@ module.exports = { Locations: require('./resources/Terminal/Locations'), Readers: require('./resources/Terminal/Readers'), }), + TestHelpers: resourceNamespace('testHelpers', { + TestClocks: require('./resources/TestHelpers/TestClocks'), + }), }; diff --git a/lib/resources/TestHelpers/TestClocks.js b/lib/resources/TestHelpers/TestClocks.js new file mode 100644 index 0000000000..adae9ae446 --- /dev/null +++ b/lib/resources/TestHelpers/TestClocks.js @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec + +'use strict'; + +const StripeResource = require('../../StripeResource'); +const stripeMethod = StripeResource.method; + +module.exports = StripeResource.extend({ + path: 'test_helpers/test_clocks', + + create: stripeMethod({ + method: 'POST', + path: '', + }), + + retrieve: stripeMethod({ + method: 'GET', + path: '/{testClock}', + }), + + list: stripeMethod({ + method: 'GET', + path: '', + methodType: 'list', + }), + + del: stripeMethod({ + method: 'DELETE', + path: '/{testClock}', + }), + + advance: stripeMethod({ + method: 'POST', + path: '/{testClock}/advance', + }), +}); diff --git a/test/resources/generated_examples_test.spec.js b/test/resources/generated_examples_test.spec.js index f6c5278ae2..03b6f2c694 100644 --- a/test/resources/generated_examples_test.spec.js +++ b/test/resources/generated_examples_test.spec.js @@ -2043,3 +2043,35 @@ describe('PaymentLink', function() { expect(paymentLink).not.to.be.null; }); }); + +describe('TestHelpers.TestClock', function() { + it('create method', async function() { + const testClock = await stripe.testHelpers.testClocks.create({ + frozen_time: 123, + name: 'cogsworth', + }); + expect(testClock).not.to.be.null; + }); + + it('retrieve method', async function() { + const testClock = await stripe.testHelpers.testClocks.retrieve('clock_xyz'); + expect(testClock).not.to.be.null; + }); + + it('list method', async function() { + const testClocks = await stripe.testHelpers.testClocks.list(); + expect(testClocks).not.to.be.null; + }); + + it('del method', async function() { + const deleted = await stripe.testHelpers.testClocks.del('clock_xyz'); + expect(deleted).not.to.be.null; + }); + + it('advance method', async function() { + const testClock = await stripe.testHelpers.testClocks.advance('clock_xyz', { + frozen_time: 142, + }); + expect(testClock).not.to.be.null; + }); +}); diff --git a/types/2020-08-27/Customers.d.ts b/types/2020-08-27/Customers.d.ts index cef1b44a74..47af6abb78 100644 --- a/types/2020-08-27/Customers.d.ts +++ b/types/2020-08-27/Customers.d.ts @@ -130,6 +130,11 @@ declare module 'stripe' { * The customer's tax IDs. */ tax_ids?: ApiList; + + /** + * ID of the test clock this customer belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; } namespace Customer { @@ -352,6 +357,11 @@ declare module 'stripe' { * The customer's tax IDs. */ tax_id_data?: Array; + + /** + * ID of the test clock to attach to the customer. + */ + test_clock?: string; } namespace CustomerCreateParams { diff --git a/types/2020-08-27/InvoiceItems.d.ts b/types/2020-08-27/InvoiceItems.d.ts index 94fa754adc..bf340b957f 100644 --- a/types/2020-08-27/InvoiceItems.d.ts +++ b/types/2020-08-27/InvoiceItems.d.ts @@ -105,6 +105,11 @@ declare module 'stripe' { */ tax_rates: Array | null; + /** + * ID of the test clock this invoice item belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; + /** * Unit amount (in the `currency` specified) of the invoice item. */ diff --git a/types/2020-08-27/Invoices.d.ts b/types/2020-08-27/Invoices.d.ts index 8630f32ccf..4a30bb04b8 100644 --- a/types/2020-08-27/Invoices.d.ts +++ b/types/2020-08-27/Invoices.d.ts @@ -318,6 +318,11 @@ declare module 'stripe' { */ tax: number | null; + /** + * ID of the test clock this invoice belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; + threshold_reason?: Invoice.ThresholdReason; /** @@ -894,6 +899,11 @@ declare module 'stripe' { */ payment_settings?: InvoiceCreateParams.PaymentSettings; + /** + * How to handle pending invoice items on invoice creation. One of `include`, `include_and_require`, or `exclude`. `include` will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. `include_and_require` will include any pending invoice items, if no pending invoice items exist then the request will fail. `exclude` will always create an empty invoice draft regardless if there are pending invoice items or not. Defaults to `include_and_require` if the parameter is omitted. + */ + pending_invoice_items_behavior?: InvoiceCreateParams.PendingInvoiceItemsBehavior; + /** * Extra information about a charge for the customer's credit card statement. It must contain at least one letter. If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item's product's `statement_descriptor`. */ @@ -1054,6 +1064,11 @@ declare module 'stripe' { | 'wechat_pay'; } + type PendingInvoiceItemsBehavior = + | 'exclude' + | 'include' + | 'include_and_require'; + interface TransferData { /** * The amount that will be transferred automatically when the invoice is paid. If no amount is set, the full amount is transferred. diff --git a/types/2020-08-27/Products.d.ts b/types/2020-08-27/Products.d.ts index 9a51dc0aea..35e67dbeee 100644 --- a/types/2020-08-27/Products.d.ts +++ b/types/2020-08-27/Products.d.ts @@ -357,7 +357,7 @@ declare module 'stripe' { /** * A URL of a publicly-accessible webpage for this product. */ - url?: string; + url?: Stripe.Emptyable; } namespace ProductUpdateParams { diff --git a/types/2020-08-27/Quotes.d.ts b/types/2020-08-27/Quotes.d.ts index 374aa61007..18864f2faf 100644 --- a/types/2020-08-27/Quotes.d.ts +++ b/types/2020-08-27/Quotes.d.ts @@ -149,6 +149,11 @@ declare module 'stripe' { */ subscription_schedule: string | Stripe.SubscriptionSchedule | null; + /** + * ID of the test clock this quote belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; + total_details: Quote.TotalDetails; /** @@ -590,6 +595,11 @@ declare module 'stripe' { */ subscription_data?: QuoteCreateParams.SubscriptionData; + /** + * ID of the test clock to attach to the quote. + */ + test_clock?: string; + /** * The data with which to automatically create a Transfer for each of the invoices. */ diff --git a/types/2020-08-27/Refunds.d.ts b/types/2020-08-27/Refunds.d.ts index b6016e300b..a9b4f095e0 100644 --- a/types/2020-08-27/Refunds.d.ts +++ b/types/2020-08-27/Refunds.d.ts @@ -61,6 +61,8 @@ declare module 'stripe' { */ metadata: Stripe.Metadata | null; + next_action?: Refund.NextAction; + /** * ID of the PaymentIntent that was refunded. */ @@ -93,6 +95,43 @@ declare module 'stripe' { } namespace Refund { + interface NextAction { + /** + * Contains the refund details. + */ + display_details: NextAction.DisplayDetails | null; + + /** + * Type of the next action to perform. + */ + type: string; + } + + namespace NextAction { + interface DisplayDetails { + email_sent: DisplayDetails.EmailSent; + + /** + * The expiry timestamp. + */ + expires_at: number; + } + + namespace DisplayDetails { + interface EmailSent { + /** + * The timestamp when the email was sent. + */ + email_sent_at: number; + + /** + * The recipient's email address. + */ + email_sent_to: string; + } + } + } + type Reason = | 'duplicate' | 'expired_uncaptured_charge' diff --git a/types/2020-08-27/SubscriptionSchedules.d.ts b/types/2020-08-27/SubscriptionSchedules.d.ts index c9f8e7b3bb..757d17d59f 100644 --- a/types/2020-08-27/SubscriptionSchedules.d.ts +++ b/types/2020-08-27/SubscriptionSchedules.d.ts @@ -82,6 +82,11 @@ declare module 'stripe' { * ID of the subscription managed by the subscription schedule. */ subscription: string | Stripe.Subscription | null; + + /** + * ID of the test clock this subscription schedule belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; } namespace SubscriptionSchedule { diff --git a/types/2020-08-27/Subscriptions.d.ts b/types/2020-08-27/Subscriptions.d.ts index 71af485446..5d8ae6b506 100644 --- a/types/2020-08-27/Subscriptions.d.ts +++ b/types/2020-08-27/Subscriptions.d.ts @@ -176,6 +176,11 @@ declare module 'stripe' { */ status: Subscription.Status; + /** + * ID of the test clock this subscription belongs to. + */ + test_clock?: string | Stripe.TestHelpers.TestClock | null; + /** * The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices. */ diff --git a/types/2020-08-27/Terminal/Locations.d.ts b/types/2020-08-27/Terminal/Locations.d.ts index e5d78e7abb..e58062d21c 100644 --- a/types/2020-08-27/Terminal/Locations.d.ts +++ b/types/2020-08-27/Terminal/Locations.d.ts @@ -174,11 +174,19 @@ declare module 'stripe' { id: string, params?: LocationRetrieveParams, options?: RequestOptions - ): Promise>; + ): Promise< + Stripe.Response< + Stripe.Terminal.Location | Stripe.Terminal.DeletedLocation + > + >; retrieve( id: string, options?: RequestOptions - ): Promise>; + ): Promise< + Stripe.Response< + Stripe.Terminal.Location | Stripe.Terminal.DeletedLocation + > + >; /** * Updates a Location object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. @@ -187,7 +195,11 @@ declare module 'stripe' { id: string, params?: LocationUpdateParams, options?: RequestOptions - ): Promise>; + ): Promise< + Stripe.Response< + Stripe.Terminal.Location | Stripe.Terminal.DeletedLocation + > + >; /** * Returns a list of Location objects. diff --git a/types/2020-08-27/TestHelpers/TestClocks.d.ts b/types/2020-08-27/TestHelpers/TestClocks.d.ts new file mode 100644 index 0000000000..8773f532ec --- /dev/null +++ b/types/2020-08-27/TestHelpers/TestClocks.d.ts @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec + +declare module 'stripe' { + namespace Stripe { + namespace TestHelpers { + /** + * The TestClock object. + */ + interface TestClock { + /** + * Unique identifier for the object. + */ + id: string; + + /** + * String representing the object's type. Objects of the same type share the same value. + */ + object: 'test_helpers.test_clock'; + + /** + * Time at which the object was created. Measured in seconds since the Unix epoch. + */ + created: number; + + deleted?: void; + + /** + * Time at which all objects belonging to this clock are frozen. + */ + frozen_time: number; + + /** + * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + */ + livemode: boolean; + + /** + * The custom name supplied at creation. + */ + name: string | null; + + /** + * The status of the Test Clock. + */ + status: TestClock.Status; + } + + namespace TestClock { + type Status = 'advancing' | 'internal_failure' | 'ready'; + } + + /** + * The DeletedTestClock object. + */ + interface DeletedTestClock { + /** + * Unique identifier for the object. + */ + id: string; + + /** + * String representing the object's type. Objects of the same type share the same value. + */ + object: 'test_helpers.test_clock'; + + /** + * Always true for a deleted object + */ + deleted: true; + } + + interface TestClockCreateParams { + /** + * The initial frozen time for this test clock. + */ + frozen_time: number; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + + /** + * The name for this test clock. + */ + name?: string; + } + + interface TestClockRetrieveParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + interface TestClockListParams extends PaginationParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + interface TestClockDeleteParams {} + + interface TestClockAdvanceParams { + /** + * The time to advance the test clock. Must be after the test clock's current frozen time. Cannot be more than two intervals in the future from the shortest subscription in this test clock. If there are no subscriptions in this test clock, it cannot be more than two years in the future. + */ + frozen_time: number; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + class TestClocksResource { + /** + * Creates a new test clock that can be attached to new customers and quotes. + */ + create( + params: TestClockCreateParams, + options?: RequestOptions + ): Promise>; + + /** + * Retrieves a test clock. + */ + retrieve( + id: string, + params?: TestClockRetrieveParams, + options?: RequestOptions + ): Promise>; + retrieve( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Returns a list of your test clocks. + */ + list( + params?: TestClockListParams, + options?: RequestOptions + ): ApiListPromise; + list( + options?: RequestOptions + ): ApiListPromise; + + /** + * Deletes a test clock. + */ + del( + id: string, + params?: TestClockDeleteParams, + options?: RequestOptions + ): Promise>; + del( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready. + */ + advance( + id: string, + params: TestClockAdvanceParams, + options?: RequestOptions + ): Promise>; + } + } + } +} diff --git a/types/2020-08-27/index.d.ts b/types/2020-08-27/index.d.ts index 708b8725d0..b943c01e04 100644 --- a/types/2020-08-27/index.d.ts +++ b/types/2020-08-27/index.d.ts @@ -97,6 +97,7 @@ /// /// /// +/// /// /// /// @@ -210,6 +211,9 @@ declare module 'stripe' { locations: Stripe.Terminal.LocationsResource; readers: Stripe.Terminal.ReadersResource; }; + testHelpers: { + testClocks: Stripe.TestHelpers.TestClocksResource; + }; /** * API Errors */