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

Add named unions for all polymorphic types #1926

Merged
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
86 changes: 56 additions & 30 deletions test/resources/generated_examples_test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const expect = require('chai').expect;

describe('Accounts', function() {
it('listExternalAccounts method', async function() {
const externalAccount = await stripe.accounts.listExternalAccounts(
const externalAccounts = await stripe.accounts.listExternalAccounts(
'acct_xxxxxxxxxxxxx',
{
limit: 3,
}
);
expect(externalAccount).not.to.be.null;
expect(externalAccounts).not.to.be.null;
});

it('list method', async function() {
Expand Down Expand Up @@ -93,6 +93,28 @@ describe('Accounts', function() {
expect(capability).not.to.be.null;
});

it('listExternalAccounts method', async function() {
const externalAccounts = await stripe.accounts.listExternalAccounts(
'acct_xxxxxxxxxxxxx',
{
object: 'bank_account',
limit: 3,
}
);
expect(externalAccounts).not.to.be.null;
});

it('listExternalAccounts method', async function() {
const externalAccounts = await stripe.accounts.listExternalAccounts(
'acct_xxxxxxxxxxxxx',
{
object: 'card',
limit: 3,
}
);
expect(externalAccounts).not.to.be.null;
});

it('createExternalAccount method', async function() {
const externalAccount = await stripe.accounts.createExternalAccount(
'acct_xxxxxxxxxxxxx',
Expand All @@ -114,19 +136,19 @@ describe('Accounts', function() {
});

it('deleteExternalAccount method', async function() {
const deletedExternalAccount = await stripe.accounts.deleteExternalAccount(
const deleted = await stripe.accounts.deleteExternalAccount(
'acct_xxxxxxxxxxxxx',
'ba_xxxxxxxxxxxxx'
);
expect(deletedExternalAccount).not.to.be.null;
expect(deleted).not.to.be.null;
});

it('deleteExternalAccount method', async function() {
const deletedExternalAccount = await stripe.accounts.deleteExternalAccount(
const deleted = await stripe.accounts.deleteExternalAccount(
'acct_xxxxxxxxxxxxx',
'card_xxxxxxxxxxxxx'
);
expect(deletedExternalAccount).not.to.be.null;
expect(deleted).not.to.be.null;
});

it('retrieveExternalAccount method', async function() {
Expand Down Expand Up @@ -417,10 +439,14 @@ describe('Customers', function() {
});

it('updateSource method', async function() {
const card = await stripe.customers.updateSource('cus_123', 'card_123', {
account_holder_name: 'Kamil',
});
expect(card).not.to.be.null;
const customerSource = await stripe.customers.updateSource(
'cus_123',
'card_123',
{
account_holder_name: 'Kamil',
}
);
expect(customerSource).not.to.be.null;
});

it('list method', async function() {
Expand Down Expand Up @@ -517,81 +543,81 @@ describe('Customers', function() {
});

it('listSources method', async function() {
const paymentSource = await stripe.customers.listSources(
const customerSources = await stripe.customers.listSources(
'cus_xxxxxxxxxxxxx',
{
object: 'bank_account',
limit: 3,
}
);
expect(paymentSource).not.to.be.null;
expect(customerSources).not.to.be.null;
});

it('listSources method', async function() {
const paymentSource = await stripe.customers.listSources(
const customerSources = await stripe.customers.listSources(
'cus_xxxxxxxxxxxxx',
{
object: 'card',
limit: 3,
}
);
expect(paymentSource).not.to.be.null;
expect(customerSources).not.to.be.null;
});

it('createSource method', async function() {
const paymentSource = await stripe.customers.createSource(
const customerSource = await stripe.customers.createSource(
'cus_xxxxxxxxxxxxx',
{
source: 'btok_xxxxxxxxxxxxx',
}
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('createSource method', async function() {
const paymentSource = await stripe.customers.createSource(
const customerSource = await stripe.customers.createSource(
'cus_xxxxxxxxxxxxx',
{
source: 'tok_xxxx',
}
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('deleteSource method', async function() {
const paymentSource = await stripe.customers.deleteSource(
const customerSource = await stripe.customers.deleteSource(
'cus_xxxxxxxxxxxxx',
'ba_xxxxxxxxxxxxx'
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('deleteSource method', async function() {
const paymentSource = await stripe.customers.deleteSource(
const customerSource = await stripe.customers.deleteSource(
'cus_xxxxxxxxxxxxx',
'card_xxxxxxxxxxxxx'
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('retrieveSource method', async function() {
const paymentSource = await stripe.customers.retrieveSource(
const customerSource = await stripe.customers.retrieveSource(
'cus_xxxxxxxxxxxxx',
'ba_xxxxxxxxxxxxx'
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('retrieveSource method', async function() {
const paymentSource = await stripe.customers.retrieveSource(
const customerSource = await stripe.customers.retrieveSource(
'cus_xxxxxxxxxxxxx',
'card_xxxxxxxxxxxxx'
);
expect(paymentSource).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('updateSource method', async function() {
const card = await stripe.customers.updateSource(
const customerSource = await stripe.customers.updateSource(
'cus_xxxxxxxxxxxxx',
'ba_xxxxxxxxxxxxx',
{
Expand All @@ -600,18 +626,18 @@ describe('Customers', function() {
},
}
);
expect(card).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('updateSource method', async function() {
const card = await stripe.customers.updateSource(
const customerSource = await stripe.customers.updateSource(
'cus_xxxxxxxxxxxxx',
'card_xxxxxxxxxxxxx',
{
name: 'Jenny Rosen',
}
);
expect(card).not.to.be.null;
expect(customerSource).not.to.be.null;
});

it('verifySource method', async function() {
Expand Down
2 changes: 1 addition & 1 deletion types/Accounts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ declare module 'stripe' {
/**
* External accounts (bank accounts and debit cards) currently attached to this account
*/
external_accounts?: ApiList<Stripe.BankAccount | Stripe.Card>;
external_accounts?: ApiList<Stripe.ExternalAccount>;

future_requirements?: Account.FutureRequirements;

Expand Down
22 changes: 9 additions & 13 deletions types/AccountsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3410,7 +3410,7 @@ declare module 'stripe' {
id: string,
params: ExternalAccountCreateParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.BankAccount | Stripe.Card>>;
): Promise<Stripe.Response<Stripe.ExternalAccount>>;

/**
* Creates a single-use login link for an Express account to access their Stripe dashboard.
Expand Down Expand Up @@ -3448,16 +3448,12 @@ declare module 'stripe' {
id: string,
params?: ExternalAccountDeleteParams,
options?: RequestOptions
): Promise<
Stripe.Response<Stripe.DeletedBankAccount | Stripe.DeletedCard>
>;
): Promise<Stripe.Response<Stripe.DeletedExternalAccount>>;
deleteExternalAccount(
accountId: string,
id: string,
options?: RequestOptions
): Promise<
Stripe.Response<Stripe.DeletedBankAccount | Stripe.DeletedCard>
>;
): Promise<Stripe.Response<Stripe.DeletedExternalAccount>>;

/**
* Deletes an existing person's relationship to the account's legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.
Expand Down Expand Up @@ -3494,11 +3490,11 @@ declare module 'stripe' {
id: string,
params?: ExternalAccountListParams,
options?: RequestOptions
): ApiListPromise<Stripe.BankAccount | Stripe.Card>;
): ApiListPromise<Stripe.ExternalAccount>;
listExternalAccounts(
id: string,
options?: RequestOptions
): ApiListPromise<Stripe.BankAccount | Stripe.Card>;
): ApiListPromise<Stripe.ExternalAccount>;

/**
* Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first.
Expand Down Expand Up @@ -3547,12 +3543,12 @@ declare module 'stripe' {
id: string,
params?: ExternalAccountRetrieveParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.BankAccount | Stripe.Card>>;
): Promise<Stripe.Response<Stripe.ExternalAccount>>;
retrieveExternalAccount(
accountId: string,
id: string,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.BankAccount | Stripe.Card>>;
): Promise<Stripe.Response<Stripe.ExternalAccount>>;

/**
* Retrieves an existing person.
Expand Down Expand Up @@ -3594,12 +3590,12 @@ declare module 'stripe' {
id: string,
params?: ExternalAccountUpdateParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.BankAccount | Stripe.Card>>;
): Promise<Stripe.Response<Stripe.ExternalAccount>>;
updateExternalAccount(
accountId: string,
id: string,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.BankAccount | Stripe.Card>>;
): Promise<Stripe.Response<Stripe.ExternalAccount>>;

/**
* Updates an existing person.
Expand Down
24 changes: 24 additions & 0 deletions types/BalanceTransactionSources.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// File generated from our OpenAPI spec

declare module 'stripe' {
namespace Stripe {
type BalanceTransactionSource =
| ApplicationFee
| Charge
| ConnectCollectionTransfer
| CustomerCashBalanceTransaction
| Dispute
| FeeRefund
| Issuing.Authorization
| Issuing.Dispute
| Issuing.Transaction
| Payout
| PlatformTaxFee
| Refund
| ReserveTransaction
| TaxDeductedAtSource
| Topup
| Transfer
| TransferReversal;
}
}
21 changes: 1 addition & 20 deletions types/BalanceTransactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,7 @@ declare module 'stripe' {
/**
* This transaction relates to the Stripe object.
*/
source:
| string
| Stripe.ApplicationFee
| Stripe.Charge
| Stripe.ConnectCollectionTransfer
| Stripe.CustomerCashBalanceTransaction
| Stripe.Dispute
| Stripe.FeeRefund
| Stripe.Issuing.Authorization
| Stripe.Issuing.Dispute
| Stripe.Issuing.Transaction
| Stripe.Payout
| Stripe.PlatformTaxFee
| Stripe.Refund
| Stripe.ReserveTransaction
| Stripe.TaxDeductedAtSource
| Stripe.Topup
| Stripe.Transfer
| Stripe.TransferReversal
| null;
source: string | Stripe.BalanceTransactionSource | null;

/**
* The transaction's net funds status in the Stripe balance, which are either `available` or `pending`.
Expand Down
9 changes: 9 additions & 0 deletions types/CustomerSources.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// File generated from our OpenAPI spec

declare module 'stripe' {
namespace Stripe {
type CustomerSource = Account | BankAccount | Card | Source;

type DeletedCustomerSource = DeletedBankAccount | DeletedCard;
}
}
16 changes: 4 additions & 12 deletions types/CustomersResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,18 +1136,14 @@ declare module 'stripe' {
params?: CustomerSourceDeleteParams,
options?: RequestOptions
): Promise<
Stripe.Response<
Stripe.CustomerSource | Stripe.DeletedBankAccount | Stripe.DeletedCard
>
Stripe.Response<Stripe.CustomerSource | Stripe.DeletedCustomerSource>
>;
deleteSource(
customerId: string,
id: string,
options?: RequestOptions
): Promise<
Stripe.Response<
Stripe.CustomerSource | Stripe.DeletedBankAccount | Stripe.DeletedCard
>
Stripe.Response<Stripe.CustomerSource | Stripe.DeletedCustomerSource>
>;

/**
Expand Down Expand Up @@ -1365,16 +1361,12 @@ declare module 'stripe' {
id: string,
params?: CustomerSourceUpdateParams,
options?: RequestOptions
): Promise<
Stripe.Response<Stripe.Card | Stripe.BankAccount | Stripe.Source>
>;
): Promise<Stripe.Response<Stripe.CustomerSource>>;
updateSource(
customerId: string,
id: string,
options?: RequestOptions
): Promise<
Stripe.Response<Stripe.Card | Stripe.BankAccount | Stripe.Source>
>;
): Promise<Stripe.Response<Stripe.CustomerSource>>;

/**
* Verify a specified bank account for a given customer.
Expand Down
Loading
Loading