From efa8f3b215332f04fbacb7cf733c85b52cc59859 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Mon, 11 May 2020 14:45:16 -0700 Subject: [PATCH] Codegen for openapi 72527e3 --- lib/resources/Checkout/Sessions.js | 7 ++ test/resources/Checkout/Sessions.spec.js | 13 ++++ types/2020-03-02/Accounts.d.ts | 3 - types/2020-03-02/Checkout/Sessions.d.ts | 77 ++++++++++++++++++++++ types/2020-03-02/Coupons.d.ts | 2 +- types/2020-03-02/Invoices.d.ts | 2 +- types/2020-03-02/LineItems.d.ts | 81 ++++++++++++++++++++++++ types/2020-03-02/Plans.d.ts | 4 +- types/2020-03-02/Prices.d.ts | 4 +- types/2020-03-02/Subscriptions.d.ts | 2 +- types/2020-03-02/index.d.ts | 1 + 11 files changed, 186 insertions(+), 10 deletions(-) create mode 100644 types/2020-03-02/LineItems.d.ts diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index 57e601eba9..f68a79c5eb 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -1,9 +1,16 @@ 'use strict'; const StripeResource = require('../../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'checkout/sessions', includeBasic: ['create', 'list', 'retrieve'], + + listLineItems: stripeMethod({ + method: 'GET', + path: '/{session}/line_items', + methodType: 'list', + }), }); diff --git a/test/resources/Checkout/Sessions.spec.js b/test/resources/Checkout/Sessions.spec.js index a8dab65700..9b7c35b5b7 100644 --- a/test/resources/Checkout/Sessions.spec.js +++ b/test/resources/Checkout/Sessions.spec.js @@ -51,5 +51,18 @@ describe('Checkout', () => { }); }); }); + + describe('listLineItems', () => { + it('Sends the correct request', () => { + stripe.checkout.sessions.listLineItems('cs_123'); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/checkout/sessions/cs_123/line_items', + headers: {}, + data: {}, + settings: {}, + }); + }); + }); }); }); diff --git a/types/2020-03-02/Accounts.d.ts b/types/2020-03-02/Accounts.d.ts index 02613b5f17..99ed9b8dfa 100644 --- a/types/2020-03-02/Accounts.d.ts +++ b/types/2020-03-02/Accounts.d.ts @@ -2024,9 +2024,6 @@ declare module 'stripe' { /** * With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. * To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). - * - * For Standard accounts, parameters other than country, email, and type - * are used to prefill the account application that we ask the account holder to complete. */ create( params?: AccountCreateParams, diff --git a/types/2020-03-02/Checkout/Sessions.d.ts b/types/2020-03-02/Checkout/Sessions.d.ts index b25aaad878..b0685e11ac 100644 --- a/types/2020-03-02/Checkout/Sessions.d.ts +++ b/types/2020-03-02/Checkout/Sessions.d.ts @@ -57,6 +57,11 @@ declare module 'stripe' { */ display_items?: Array; + /** + * The line items purchased by the customer. [Expand](https://stripe.com/docs/api/expanding_objects) this field to include it in the response. + */ + line_items?: ApiList | null; + /** * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. */ @@ -547,6 +552,8 @@ declare module 'stripe' { * A list of items the customer is purchasing. Use this parameter for * one-time payments or adding invoice line items to a subscription (used * in conjunction with `subscription_data`). + * There is a maximum of 100 line items, however it is recommended to + * consolidate line items if there are more than a few dozen. */ line_items?: Array; @@ -623,6 +630,16 @@ declare module 'stripe' { */ name?: string; + /** + * The ID of the price object. + */ + price?: string; + + /** + * Data used to generate a new price object inline. + */ + price_data?: LineItem.PriceData; + /** * The quantity of the line item being purchased. */ @@ -634,6 +651,53 @@ declare module 'stripe' { tax_rates?: Array; } + namespace LineItem { + interface PriceData { + /** + * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + */ + currency: string; + + /** + * The ID of the product that this price will belong to. + */ + product: string; + + /** + * The recurring components of a price such as `interval` and `usage_type`. + */ + recurring?: PriceData.Recurring; + + /** + * A positive integer in %s (or 0 for a free price) representing how much to charge. + */ + unit_amount?: number; + + /** + * Same as `unit_amount`, but accepts a decimal value with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. + */ + unit_amount_decimal?: string; + } + + namespace PriceData { + interface Recurring { + /** + * Specifies billing frequency. Either `day`, `week`, `month` or `year`. + */ + interval: Recurring.Interval; + + /** + * The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). + */ + interval_count?: number; + } + + namespace Recurring { + type Interval = 'day' | 'month' | 'week' | 'year'; + } + } + } + type Locale = | 'auto' | 'da' @@ -1167,6 +1231,19 @@ declare module 'stripe' { options?: RequestOptions ): ApiListPromise; list(options?: RequestOptions): ApiListPromise; + + /** + * When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + */ + listLineItems( + id: string, + params?: LineItemListParams, + options?: RequestOptions + ): ApiListPromise; + listLineItems( + id: string, + options?: RequestOptions + ): ApiListPromise; } } } diff --git a/types/2020-03-02/Coupons.d.ts b/types/2020-03-02/Coupons.d.ts index 0b3f24cfa6..97b199f090 100644 --- a/types/2020-03-02/Coupons.d.ts +++ b/types/2020-03-02/Coupons.d.ts @@ -133,7 +133,7 @@ declare module 'stripe' { expand?: Array; /** - * Unique string of your choice that will be used to identify this coupon when applying it to a customer. This is often a specific code you'll give to your customer to use when signing up (e.g., `FALL25OFF`). If you don't want to specify a particular code, you can leave the ID blank and we'll generate a random code for you. + * Unique string of your choice that will be used to identify this coupon when applying it to a customer. If you don't want to specify a particular code, you can leave the ID blank and we'll generate a random code for you. */ id?: string; diff --git a/types/2020-03-02/Invoices.d.ts b/types/2020-03-02/Invoices.d.ts index 69624f4bf6..6d47037aaf 100644 --- a/types/2020-03-02/Invoices.d.ts +++ b/types/2020-03-02/Invoices.d.ts @@ -296,7 +296,7 @@ declare module 'stripe' { total_tax_amounts: Array | null; /** - * If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. + * The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice. */ transfer_data?: Invoice.TransferData | null; diff --git a/types/2020-03-02/LineItems.d.ts b/types/2020-03-02/LineItems.d.ts new file mode 100644 index 0000000000..ec342f39b6 --- /dev/null +++ b/types/2020-03-02/LineItems.d.ts @@ -0,0 +1,81 @@ +declare module 'stripe' { + namespace Stripe { + /** + * The LineItem object. + */ + interface LineItem { + /** + * Unique identifier for the object. + */ + id: string; + + /** + * String representing the object's type. Objects of the same type share the same value. + */ + object: 'item'; + + /** + * Total before any discounts or taxes is applied. + */ + amount_subtotal: number | null; + + /** + * Total after discounts and taxes. + */ + amount_total: number | null; + + /** + * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + */ + currency: string; + + /** + * An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name. + */ + description: string; + + /** + * Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products. + * Products help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme. + * + * For example, you might have a single "gold" product that has prices for $10/month, $100/year, and €9 once. + * + * Related guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](https://stripe.com/docs/billing/invoices/create), and more about [products and prices](https://stripe.com/docs/billing/prices-guide). + */ + price: Stripe.Price; + + /** + * The quantity of products being purchased. + */ + quantity: number | null; + + /** + * The taxes applied to the line item. + */ + taxes: Array | null; + } + + namespace LineItem { + interface Tax { + /** + * Amount of tax for this line item. + */ + amount: number; + + /** + * Tax rates can be applied to invoices and subscriptions to collect tax. + * + * Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates). + */ + rate: Stripe.TaxRate; + } + } + + interface LineItemListParams extends PaginationParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + } +} diff --git a/types/2020-03-02/Plans.d.ts b/types/2020-03-02/Plans.d.ts index 1e0425c7ed..96fc48161a 100644 --- a/types/2020-03-02/Plans.d.ts +++ b/types/2020-03-02/Plans.d.ts @@ -25,12 +25,12 @@ declare module 'stripe' { aggregate_usage: Plan.AggregateUsage | null; /** - * The amount in %s to be charged on the interval specified. + * The unit amount in %s to be charged, represented as a whole integer if possible. */ amount: number | null; /** - * Same as `amount`, but contains a decimal value with at most 12 decimal places. + * The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. */ amount_decimal: string | null; diff --git a/types/2020-03-02/Prices.d.ts b/types/2020-03-02/Prices.d.ts index 0ce4d81b5a..0a19b41d87 100644 --- a/types/2020-03-02/Prices.d.ts +++ b/types/2020-03-02/Prices.d.ts @@ -87,12 +87,12 @@ declare module 'stripe' { type: Price.Type; /** - * The unit amount in %s to be charged. + * The unit amount in %s to be charged, represented as a whole integer if possible. */ unit_amount: number | null; /** - * Same as `amount`, but contains a decimal value with at most 12 decimal places. + * The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. */ unit_amount_decimal: string | null; } diff --git a/types/2020-03-02/Subscriptions.d.ts b/types/2020-03-02/Subscriptions.d.ts index 28db25ad0b..8b27bd3552 100644 --- a/types/2020-03-02/Subscriptions.d.ts +++ b/types/2020-03-02/Subscriptions.d.ts @@ -183,7 +183,7 @@ declare module 'stripe' { tax_percent: number | null; /** - * If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. + * 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. */ transfer_data?: Subscription.TransferData | null; diff --git a/types/2020-03-02/index.d.ts b/types/2020-03-02/index.d.ts index 03e7dda6b5..c69b962120 100644 --- a/types/2020-03-02/index.d.ts +++ b/types/2020-03-02/index.d.ts @@ -46,6 +46,7 @@ /// /// /// +/// /// /// ///