Skip to content

Commit

Permalink
feat(api): create financial account and retry microdeposits endpoints (
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and stainless-app[bot] committed Feb 21, 2024
1 parent c0bc04b commit 133bc25
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 109
configured_endpoints: 111
3 changes: 3 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Types:

Methods:

- <code title="post /financial_accounts">client.financialAccounts.<a href="./src/resources/financial-accounts/financial-accounts.ts">create</a>({ ...params }) -> FinancialAccount</code>
- <code title="get /financial_accounts/{financial_account_token}">client.financialAccounts.<a href="./src/resources/financial-accounts/financial-accounts.ts">retrieve</a>(financialAccountToken) -> FinancialAccount</code>
- <code title="patch /financial_accounts/{financial_account_token}">client.financialAccounts.<a href="./src/resources/financial-accounts/financial-accounts.ts">update</a>(financialAccountToken, { ...params }) -> FinancialAccount</code>
- <code title="get /financial_accounts">client.financialAccounts.<a href="./src/resources/financial-accounts/financial-accounts.ts">list</a>({ ...params }) -> FinancialAccountsSinglePage</code>
Expand Down Expand Up @@ -352,13 +353,15 @@ Types:
- <code><a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">ExternalBankAccountRetrieveResponse</a></code>
- <code><a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">ExternalBankAccountUpdateResponse</a></code>
- <code><a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">ExternalBankAccountListResponse</a></code>
- <code><a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">ExternalBankAccountRetryMicroDepositsResponse</a></code>

Methods:

- <code title="post /external_bank_accounts">client.externalBankAccounts.<a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">create</a>({ ...params }) -> ExternalBankAccountCreateResponse</code>
- <code title="get /external_bank_accounts/{external_bank_account_token}">client.externalBankAccounts.<a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">retrieve</a>(externalBankAccountToken) -> ExternalBankAccountRetrieveResponse</code>
- <code title="patch /external_bank_accounts/{external_bank_account_token}">client.externalBankAccounts.<a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">update</a>(externalBankAccountToken, { ...params }) -> ExternalBankAccountUpdateResponse</code>
- <code title="get /external_bank_accounts">client.externalBankAccounts.<a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">list</a>({ ...params }) -> ExternalBankAccountListResponsesCursorPage</code>
- <code title="post /external_bank_accounts/{external_bank_account_token}/retry_micro_deposits">client.externalBankAccounts.<a href="./src/resources/external-bank-accounts/external-bank-accounts.ts">retryMicroDeposits</a>(externalBankAccountToken) -> ExternalBankAccountRetryMicroDepositsResponse</code>

## MicroDeposits

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export namespace Lithic {
export import FinancialAccount = API.FinancialAccount;
export import FinancialTransaction = API.FinancialTransaction;
export import FinancialAccountsSinglePage = API.FinancialAccountsSinglePage;
export import FinancialAccountCreateParams = API.FinancialAccountCreateParams;
export import FinancialAccountUpdateParams = API.FinancialAccountUpdateParams;
export import FinancialAccountListParams = API.FinancialAccountListParams;

Expand Down Expand Up @@ -404,6 +405,7 @@ export namespace Lithic {
export import ExternalBankAccountRetrieveResponse = API.ExternalBankAccountRetrieveResponse;
export import ExternalBankAccountUpdateResponse = API.ExternalBankAccountUpdateResponse;
export import ExternalBankAccountListResponse = API.ExternalBankAccountListResponse;
export import ExternalBankAccountRetryMicroDepositsResponse = API.ExternalBankAccountRetryMicroDepositsResponse;
export import ExternalBankAccountListResponsesCursorPage = API.ExternalBankAccountListResponsesCursorPage;
export import ExternalBankAccountCreateParams = API.ExternalBankAccountCreateParams;
export import ExternalBankAccountUpdateParams = API.ExternalBankAccountUpdateParams;
Expand Down
129 changes: 119 additions & 10 deletions src/resources/external-bank-accounts/external-bank-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export class ExternalBankAccounts extends APIResource {
...options,
});
}

/**
* Retry external bank account micro deposit verification.
*/
retryMicroDeposits(
externalBankAccountToken: string,
options?: Core.RequestOptions,
): Core.APIPromise<ExternalBankAccountRetryMicroDepositsResponse> {
return this._client.post(
`/external_bank_accounts/${externalBankAccountToken}/retry_micro_deposits`,
options,
);
}
}

export class ExternalBankAccountListResponsesCursorPage extends CursorPage<ExternalBankAccountListResponse> {}
Expand All @@ -87,7 +100,7 @@ export interface ExternalBankAccountAddress {

export type OwnerType = 'BUSINESS' | 'INDIVIDUAL';

export type VerificationMethod = 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
export type VerificationMethod = 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

export interface ExternalBankAccountCreateResponse {
/**
Expand Down Expand Up @@ -140,9 +153,9 @@ export interface ExternalBankAccountCreateResponse {
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING';
verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
Expand Down Expand Up @@ -235,9 +248,9 @@ export interface ExternalBankAccountRetrieveResponse {
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING';
verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
Expand Down Expand Up @@ -330,9 +343,9 @@ export interface ExternalBankAccountUpdateResponse {
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING';
verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
Expand Down Expand Up @@ -425,9 +438,104 @@ export interface ExternalBankAccountListResponse {
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
* external accounts that are associated with the program, account_token field
* returned will be null
*/
account_token?: string;

/**
* Address used during Address Verification Service (AVS) checks during
* transactions if enabled via Auth Rules.
*/
address?: ExternalBankAccountAddress;

/**
* Optional field that helps identify bank accounts in receipts
*/
company_id?: string;

/**
* Date of Birth of the Individual that owns the external bank account
*/
dob?: string;

doing_business_as?: string;

/**
* The nickname given to this record of External Bank Account
*/
name?: string;

user_defined_id?: string;

/**
* Optional free text description of the reason for the failed verification. For
* ACH micro-deposits returned, this field will display the reason return code sent
* by the ACH network
*/
verification_failed_reason?: string;
}

export interface ExternalBankAccountRetryMicroDepositsResponse {
/**
* A globally unique identifier for this record of an external bank account
* association. If a program links an external bank account to more than one
* end-user or to both the program and the end-user, then Lithic will return each
* record of the association
*/
token: string;

/**
* The country that the bank account is located in using ISO 3166-1. We will only
* accept USA bank accounts e.g., USA
*/
country: string;

/**
* An ISO 8601 string representing when this funding source was added to the Lithic
* account.
*/
created: string;

/**
* currency of the external account 3-digit alphabetic ISO 4217 code
*/
currency: string;

/**
* The last 4 digits of the bank account. Derived by Lithic from the account number
* passed
*/
last_four: string;

/**
* Legal Name of the business or individual who owns the external account. This
* will appear in statements
*/
owner: string;

owner_type: 'BUSINESS' | 'INDIVIDUAL';

routing_number: string;

state: 'CLOSED' | 'ENABLED' | 'PAUSED';

type: 'CHECKING' | 'SAVINGS';

/**
* The number of attempts at verification
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING';
verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
Expand Down Expand Up @@ -581,7 +689,7 @@ export interface ExternalBankAccountListParams extends CursorPageParams {

states?: Array<'CLOSED' | 'ENABLED' | 'PAUSED'>;

verification_states?: Array<'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING'>;
verification_states?: Array<'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING'>;
}

export namespace ExternalBankAccounts {
Expand All @@ -592,6 +700,7 @@ export namespace ExternalBankAccounts {
export import ExternalBankAccountRetrieveResponse = ExternalBankAccountsAPI.ExternalBankAccountRetrieveResponse;
export import ExternalBankAccountUpdateResponse = ExternalBankAccountsAPI.ExternalBankAccountUpdateResponse;
export import ExternalBankAccountListResponse = ExternalBankAccountsAPI.ExternalBankAccountListResponse;
export import ExternalBankAccountRetryMicroDepositsResponse = ExternalBankAccountsAPI.ExternalBankAccountRetryMicroDepositsResponse;
export import ExternalBankAccountListResponsesCursorPage = ExternalBankAccountsAPI.ExternalBankAccountListResponsesCursorPage;
export import ExternalBankAccountCreateParams = ExternalBankAccountsAPI.ExternalBankAccountCreateParams;
export import ExternalBankAccountUpdateParams = ExternalBankAccountsAPI.ExternalBankAccountUpdateParams;
Expand Down
1 change: 1 addition & 0 deletions src/resources/external-bank-accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
ExternalBankAccountRetrieveResponse,
ExternalBankAccountUpdateResponse,
ExternalBankAccountListResponse,
ExternalBankAccountRetryMicroDepositsResponse,
ExternalBankAccountCreateParams,
ExternalBankAccountUpdateParams,
ExternalBankAccountListParams,
Expand Down
4 changes: 2 additions & 2 deletions src/resources/external-bank-accounts/micro-deposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export interface MicroDepositCreateResponse {
*/
verification_attempts: number;

verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID';
verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID' | 'PRENOTE';

verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'PENDING';
verification_state: 'ENABLED' | 'FAILED_VERIFICATION' | 'INSUFFICIENT_FUNDS' | 'PENDING';

/**
* Indicates which Lithic account the external account is associated with. For
Expand Down
38 changes: 38 additions & 0 deletions src/resources/financial-accounts/financial-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ export class FinancialAccounts extends APIResource {
new FinancialTransactionsAPI.FinancialTransactions(this._client);
statements: StatementsAPI.Statements = new StatementsAPI.Statements(this._client);

/**
* Create a new financial account
*/
create(
params: FinancialAccountCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<FinancialAccount> {
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
return this._client.post('/financial_accounts', {
body,
...options,
headers: { 'Idempotency-Key': idempotencyKey || '', ...options?.headers },
});
}

/**
* Get a financial account
*/
Expand Down Expand Up @@ -269,6 +284,28 @@ export namespace FinancialTransaction {
}
}

export interface FinancialAccountCreateParams {
/**
* Body param:
*/
nickname: string;

/**
* Body param:
*/
type: 'OPERATING';

/**
* Body param:
*/
account_token?: string;

/**
* Header param:
*/
'Idempotency-Key'?: string;
}

export interface FinancialAccountUpdateParams {
nickname?: string;
}
Expand All @@ -294,6 +331,7 @@ export namespace FinancialAccounts {
export import FinancialAccount = FinancialAccountsAPI.FinancialAccount;
export import FinancialTransaction = FinancialAccountsAPI.FinancialTransaction;
export import FinancialAccountsSinglePage = FinancialAccountsAPI.FinancialAccountsSinglePage;
export import FinancialAccountCreateParams = FinancialAccountsAPI.FinancialAccountCreateParams;
export import FinancialAccountUpdateParams = FinancialAccountsAPI.FinancialAccountUpdateParams;
export import FinancialAccountListParams = FinancialAccountsAPI.FinancialAccountListParams;
export import Balances = BalancesAPI.Balances;
Expand Down
1 change: 1 addition & 0 deletions src/resources/financial-accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { BalanceListParams, Balances } from './balances';
export {
FinancialAccount,
FinancialTransaction,
FinancialAccountCreateParams,
FinancialAccountUpdateParams,
FinancialAccountListParams,
FinancialTransactionsSinglePage,
Expand Down
2 changes: 2 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export {
ExternalBankAccountRetrieveResponse,
ExternalBankAccountUpdateResponse,
ExternalBankAccountListResponse,
ExternalBankAccountRetryMicroDepositsResponse,
ExternalBankAccountCreateParams,
ExternalBankAccountUpdateParams,
ExternalBankAccountListParams,
Expand All @@ -118,6 +119,7 @@ export {
export {
FinancialAccount,
FinancialTransaction,
FinancialAccountCreateParams,
FinancialAccountUpdateParams,
FinancialAccountListParams,
FinancialTransactionsSinglePage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,32 @@ describe('resource externalBankAccounts', () => {
page_size: 1,
starting_after: 'string',
states: ['CLOSED', 'ENABLED', 'PAUSED'],
verification_states: ['ENABLED', 'FAILED_VERIFICATION', 'PENDING'],
verification_states: ['ENABLED', 'FAILED_VERIFICATION', 'INSUFFICIENT_FUNDS'],
},
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Lithic.NotFoundError);
});

test('retryMicroDeposits', async () => {
const responsePromise = lithic.externalBankAccounts.retryMicroDeposits(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('retryMicroDeposits: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
lithic.externalBankAccounts.retryMicroDeposits('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
path: '/_stainless_unknown_path',
}),
).rejects.toThrow(Lithic.NotFoundError);
});
});
20 changes: 20 additions & 0 deletions tests/api-resources/financial-accounts/financial-accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ const lithic = new Lithic({
});

describe('resource financialAccounts', () => {
test('create: only required params', async () => {
const responsePromise = lithic.financialAccounts.create({ nickname: 'string', type: 'OPERATING' });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('create: required and optional params', async () => {
const response = await lithic.financialAccounts.create({
nickname: 'string',
type: 'OPERATING',
account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'Idempotency-Key': '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
});
});

test('retrieve', async () => {
const responsePromise = lithic.financialAccounts.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
const rawResponse = await responsePromise.asResponse();
Expand Down

0 comments on commit 133bc25

Please sign in to comment.