Skip to content

Commit

Permalink
Merge pull request #802 from stripe/richardm-autogen-fixes
Browse files Browse the repository at this point in the history
Typescript Fixes

* Consistently use `| null` vs `| ''`
* Properly type Array<CustomField>
  • Loading branch information
richardm-stripe authored Feb 14, 2020
2 parents ae22537 + b5213c6 commit a40ff56
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 74 deletions.
2 changes: 1 addition & 1 deletion types/2019-12-03/CreditNoteLineItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ declare module 'stripe' {
/**
* The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item`.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
Expand Down
4 changes: 2 additions & 2 deletions types/2019-12-03/CreditNotes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ declare module 'stripe' {
/**
* The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item`.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
Expand Down Expand Up @@ -391,7 +391,7 @@ declare module 'stripe' {
/**
* The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item`.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
Expand Down
12 changes: 6 additions & 6 deletions types/2019-12-03/Customers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ declare module 'stripe' {
/**
* The customer's address.
*/
address?: AddressParam | '';
address?: AddressParam | null;

/**
* An integer amount in %s that represents the customer's current balance, which affect the customer's future invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.
Expand Down Expand Up @@ -283,7 +283,7 @@ declare module 'stripe' {
/**
* Default custom fields to be displayed on invoices for this customer. When updating, pass an empty string to remove previously-defined fields.
*/
custom_fields?: InvoiceSettings.CustomFields | null;
custom_fields?: Array<InvoiceSettings.CustomField> | null;

/**
* ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices.
Expand All @@ -297,7 +297,7 @@ declare module 'stripe' {
}

namespace InvoiceSettings {
interface CustomFields {
interface CustomField {
/**
* The name of the custom field. This may be up to 30 characters.
*/
Expand Down Expand Up @@ -378,7 +378,7 @@ declare module 'stripe' {
/**
* The customer's address.
*/
address?: AddressParam | '';
address?: AddressParam | null;

/**
* An integer amount in %s that represents the customer's current balance, which affect the customer's future invoices. A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.
Expand Down Expand Up @@ -464,7 +464,7 @@ declare module 'stripe' {
/**
* Default custom fields to be displayed on invoices for this customer. When updating, pass an empty string to remove previously-defined fields.
*/
custom_fields?: InvoiceSettings.CustomFields | null;
custom_fields?: Array<InvoiceSettings.CustomField> | null;

/**
* ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices.
Expand All @@ -478,7 +478,7 @@ declare module 'stripe' {
}

namespace InvoiceSettings {
interface CustomFields {
interface CustomField {
/**
* The name of the custom field. This may be up to 30 characters.
*/
Expand Down
2 changes: 1 addition & 1 deletion types/2019-12-03/InvoiceItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ declare module 'stripe' {
/**
* The tax rates which apply to the invoice item. When set, the `default_tax_rates` on the invoice do not apply to this invoice item. Pass an empty string to remove previously-defined tax rates.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* The integer unit amount in **%s** of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
Expand Down
12 changes: 6 additions & 6 deletions types/2019-12-03/InvoiceLineItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ declare module 'stripe' {
* For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.
*/
subscription_billing_cycle_anchor?:
| number
| InvoiceLineItemListUpcomingParams.SubscriptionBillingCycleAnchor;
| InvoiceLineItemListUpcomingParams.SubscriptionBillingCycleAnchor
| number;

/**
* Timestamp indicating when the subscription should be scheduled to cancel. Will prorate if within the current period and prorations have been enabled using `proration_behavior`.`
*/
subscription_cancel_at?: number | '';
subscription_cancel_at?: number | null;

/**
* Boolean indicating whether this subscription should cancel at the end of the current period.
Expand All @@ -193,7 +193,7 @@ declare module 'stripe' {
/**
* If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set.
*/
subscription_default_tax_rates?: Array<string> | '';
subscription_default_tax_rates?: Array<string> | null;

/**
* List of subscription items, each with an attached plan.
Expand Down Expand Up @@ -284,7 +284,7 @@ declare module 'stripe' {
*/
quantity?: number;

tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* The integer unit amount in **%s** of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
Expand Down Expand Up @@ -352,7 +352,7 @@ declare module 'stripe' {
/**
* A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;
}

namespace SubscriptionItem {
Expand Down
48 changes: 24 additions & 24 deletions types/2019-12-03/Invoices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,6 @@ declare module 'stripe' {

type CollectionMethod = 'charge_automatically' | 'send_invoice';

interface CustomField {
/**
* The name of the custom field.
*/
name: string;

/**
* The value of the custom field.
*/
value: string;
}

interface CustomerShipping {
address?: Address;

Expand Down Expand Up @@ -395,6 +383,18 @@ declare module 'stripe' {
| 'za_vat';
}

interface CustomField {
/**
* The name of the custom field.
*/
name: string;

/**
* The value of the custom field.
*/
value: string;
}

type Status =
| 'deleted'
| 'draft'
Expand Down Expand Up @@ -520,7 +520,7 @@ declare module 'stripe' {
/**
* A list of up to 4 custom fields to be displayed on the invoice.
*/
custom_fields?: InvoiceCreateParams.CustomFields | null;
custom_fields?: Array<InvoiceCreateParams.CustomField> | null;

/**
* The number of days from when the invoice is created until it is due. Valid only for invoices where `collection_method=send_invoice`.
Expand Down Expand Up @@ -591,7 +591,7 @@ declare module 'stripe' {
namespace InvoiceCreateParams {
type CollectionMethod = 'charge_automatically' | 'send_invoice';

interface CustomFields {
interface CustomField {
/**
* The name of the custom field. This may be up to 30 characters.
*/
Expand Down Expand Up @@ -637,7 +637,7 @@ declare module 'stripe' {
/**
* A list of up to 4 custom fields to be displayed on the invoice. If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. Pass an empty string to remove previously-defined fields.
*/
custom_fields?: InvoiceUpdateParams.CustomFields | null;
custom_fields?: Array<InvoiceUpdateParams.CustomField> | null;

/**
* The number of days from which the invoice is created until it is due. Only valid for invoices where `collection_method=send_invoice`. This field can only be updated on `draft` invoices.
Expand All @@ -657,7 +657,7 @@ declare module 'stripe' {
/**
* The tax rates that will apply to any line item that does not have `tax_rates` set. Pass an empty string to remove previously-defined tax rates.
*/
default_tax_rates?: Array<string> | '';
default_tax_rates?: Array<string> | null;

/**
* An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.
Expand Down Expand Up @@ -692,7 +692,7 @@ declare module 'stripe' {
/**
* The percent tax rate applied to the invoice, represented as a non-negative decimal number (with at most four decimal places) between 0 and 100. To unset a previously-set value, pass an empty string. This field can be updated only on `draft` invoices. This field has been deprecated and will be removed in a future API version, for further information view the [migration docs](https://stripe.com/docs/billing/migration/taxes) for `tax_rates`.
*/
tax_percent?: number | '';
tax_percent?: number | 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. This will be unset if you POST an empty value.
Expand All @@ -703,7 +703,7 @@ declare module 'stripe' {
namespace InvoiceUpdateParams {
type CollectionMethod = 'charge_automatically' | 'send_invoice';

interface CustomFields {
interface CustomField {
/**
* The name of the custom field. This may be up to 30 characters.
*/
Expand Down Expand Up @@ -850,13 +850,13 @@ declare module 'stripe' {
* For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`.
*/
subscription_billing_cycle_anchor?:
| number
| InvoiceRetrieveUpcomingParams.SubscriptionBillingCycleAnchor;
| InvoiceRetrieveUpcomingParams.SubscriptionBillingCycleAnchor
| number;

/**
* Timestamp indicating when the subscription should be scheduled to cancel. Will prorate if within the current period and prorations have been enabled using `proration_behavior`.`
*/
subscription_cancel_at?: number | '';
subscription_cancel_at?: number | null;

/**
* Boolean indicating whether this subscription should cancel at the end of the current period.
Expand All @@ -871,7 +871,7 @@ declare module 'stripe' {
/**
* If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set.
*/
subscription_default_tax_rates?: Array<string> | '';
subscription_default_tax_rates?: Array<string> | null;

/**
* List of subscription items, each with an attached plan.
Expand Down Expand Up @@ -962,7 +962,7 @@ declare module 'stripe' {
*/
quantity?: number;

tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;

/**
* The integer unit amount in **%s** of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount.
Expand Down Expand Up @@ -1030,7 +1030,7 @@ declare module 'stripe' {
/**
* A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
*/
tax_rates?: Array<string> | '';
tax_rates?: Array<string> | null;
}

namespace SubscriptionItem {
Expand Down
6 changes: 3 additions & 3 deletions types/2019-12-03/Issuing/Authorizations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ declare module 'stripe' {
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam | '';
metadata?: MetadataParam | null;
}

interface AuthorizationListParams extends PaginationParams {
Expand Down Expand Up @@ -346,7 +346,7 @@ declare module 'stripe' {
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam | '';
metadata?: MetadataParam | null;
}

interface AuthorizationDeclineParams {
Expand All @@ -358,7 +358,7 @@ declare module 'stripe' {
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam | '';
metadata?: MetadataParam | null;
}

class AuthorizationsResource {
Expand Down
2 changes: 1 addition & 1 deletion types/2019-12-03/Issuing/Cards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ declare module 'stripe' {
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam | '';
metadata?: MetadataParam | null;

/**
* Whether authorizations can be approved on this card.
Expand Down
2 changes: 1 addition & 1 deletion types/2019-12-03/Issuing/Transactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ declare module 'stripe' {
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
*/
metadata?: MetadataParam | '';
metadata?: MetadataParam | null;
}

interface TransactionListParams extends PaginationParams {
Expand Down
8 changes: 4 additions & 4 deletions types/2019-12-03/Orders.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ declare module 'stripe' {
/**
* List of items to return.
*/
items?: OrderReturnOrderParams.Items | null;
items?: Array<OrderReturnOrderParams.Item> | null;
}

namespace OrderReturnOrderParams {
interface Items {
interface Item {
/**
* The amount (price) for this order item to return.
*/
Expand All @@ -489,10 +489,10 @@ declare module 'stripe' {
/**
* The type of this order item. Must be `sku`, `tax`, or `shipping`.
*/
type?: Items.Type;
type?: Item.Type;
}

namespace Items {
namespace Item {
type Type = 'discount' | 'shipping' | 'sku' | 'tax';
}
}
Expand Down
7 changes: 4 additions & 3 deletions types/2019-12-03/PaymentIntents.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ declare module 'stripe' {
/**
* The amount of the application fee (if any) for the resulting payment. See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts) for details.
*/
application_fee_amount?: number | '';
application_fee_amount?: 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).
Expand Down Expand Up @@ -835,7 +835,7 @@ declare module 'stripe' {
/**
* Email address that the receipt for the resulting payment will be sent to.
*/
receipt_email?: string | '';
receipt_email?: string | null;

/**
* If the PaymentIntent has a `payment_method` and a `customer` or if you're attaching a payment method to the PaymentIntent in this request, you can pass `save_payment_method=true` to save the payment method to the customer. Defaults to `false`.
Expand Down Expand Up @@ -1119,7 +1119,7 @@ declare module 'stripe' {
/**
* Email address that the receipt for the resulting payment will be sent to.
*/
receipt_email?: string | '';
receipt_email?: string | null;

/**
* The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site.
Expand Down Expand Up @@ -1215,6 +1215,7 @@ declare module 'stripe' {
type Type = 'offline' | 'online';
}
}

interface MandateData2 {
/**
* This hash contains details about the customer acceptance of the Mandate.
Expand Down
1 change: 1 addition & 0 deletions types/2019-12-03/PaymentMethods.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ declare module 'stripe' {
*/
number: string;
}

interface Card2 {
token: string;
}
Expand Down
Loading

0 comments on commit a40ff56

Please sign in to comment.