Skip to content

Commit

Permalink
fix(api): add response body to virtualAccounts.retrieve() and updat…
Browse files Browse the repository at this point in the history
…e resources (#155)

- Fix `virtualAccounts.retrieve()` to return a response instead of `void`
- Change `Documents.create()` and `PaymentOrderCreateParams.Document` to accept `documentable_id` and `documentable_type` body params instead of query params
- Add `as_of_lock_version` to `LedgerAccountListParams` and `LedgerAccountRetrieveParams`
- Remove `entity_id` from `InternalAccountCreateParams`
- Add `vendor_attributes` to `InternalAccountCreateParams`
- Change `effective_at` to accept `date-time` instead of `date`
  • Loading branch information
stainless-bot authored and chen-annie committed Jul 24, 2023
1 parent 0965670 commit b5464dd
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 44 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ Types:
Methods:

- <code title="post /api/virtual_accounts">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">create</a>({ ...params }) -> VirtualAccount</code>
- <code title="get /api/virtual_accounts/{id}">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">retrieve</a>(id) -> void</code>
- <code title="get /api/virtual_accounts/{id}">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">retrieve</a>(id) -> VirtualAccount</code>
- <code title="patch /api/virtual_accounts/{id}">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">update</a>(id, { ...params }) -> VirtualAccount</code>
- <code title="get /api/virtual_accounts">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">list</a>({ ...params }) -> VirtualAccountsPage</code>
- <code title="delete /api/virtual_accounts/{id}">client.virtualAccounts.<a href="./src/resources/virtual-accounts.ts">del</a>(id) -> VirtualAccount</code>
15 changes: 3 additions & 12 deletions src/resources/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ export class Documents extends APIResource {
params: DocumentCreateParams,
options?: Core.RequestOptions,
): Promise<Core.APIResponse<Document>> {
const {
documentable_id: documentableId,
documentable_type: documentableType,
'Idempotency-Key': idempotencyKey,
...body
} = params;
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
return this.post(
'/api/documents',
await multipartFormRequestOptions({
query: { documentable_id: documentableId, documentable_type: documentableType },
body,
...options,
headers: { 'Idempotency-Key': idempotencyKey || '', ...options?.headers },
Expand Down Expand Up @@ -157,15 +151,12 @@ export namespace Document {

export interface DocumentCreateParams {
/**
* Query param: The unique identifier for the associated object.
* Body param: The unique identifier for the associated object.
*/
documentable_id: string;

/**
* Query param: The type of the associated object. Currently can be one of
* `payment_order`, `transaction`, `paper_item`, `expected_payment`,
* `counterparty`, `organization`, `case`, `internal_account`, `decision`, or
* `external_account`.
* Body param:
*/
documentable_type:
| 'cases'
Expand Down
11 changes: 6 additions & 5 deletions src/resources/internal-accounts/internal-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ export interface InternalAccountCreateParams {
*/
counterparty_id?: string;

/**
* Body param: The identifier of the entity at Increase which owns the account.
*/
entity_id?: string;

/**
* Body param: The parent internal account of this new account.
*/
Expand All @@ -249,6 +244,12 @@ export interface InternalAccountCreateParams {
*/
party_address?: InternalAccountCreateParams.PartyAddress;

/**
* Body param: A hash of vendor specific attributes that will be used when creating
* the account at the vendor specified by the given connection.
*/
vendor_attributes?: Record<string, string>;

/**
* Header param: This key should be something unique, preferably something like an
* UUID.
Expand Down
40 changes: 24 additions & 16 deletions src/resources/ledger-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,30 @@ export interface LedgerAccountCreateParams {

export interface LedgerAccountRetrieveParams {
/**
* Use balances[effective_at_lower_bound] and balances[effective_at_upper_bound] to
* get the balances change between the two timestamps. The lower bound is inclusive
* while the upper bound is exclusive of the provided timestamps. If no value is
* supplied the balances will be retrieved not including that bound.
* Use `balances[effective_at_lower_bound]` and
* `balances[effective_at_upper_bound]` to get the balances change between the two
* timestamps. The lower bound is inclusive while the upper bound is exclusive of
* the provided timestamps. If no value is supplied the balances will be retrieved
* not including that bound. Use `balances[as_of_lock_version]` to retrieve a
* balance as of a specific Ledger Account `lock_version`.
*/
balances?: LedgerAccountRetrieveParams.Balances;
}

export namespace LedgerAccountRetrieveParams {
/**
* Use balances[effective_at_lower_bound] and balances[effective_at_upper_bound] to
* get the balances change between the two timestamps. The lower bound is inclusive
* while the upper bound is exclusive of the provided timestamps. If no value is
* supplied the balances will be retrieved not including that bound.
* Use `balances[effective_at_lower_bound]` and
* `balances[effective_at_upper_bound]` to get the balances change between the two
* timestamps. The lower bound is inclusive while the upper bound is exclusive of
* the provided timestamps. If no value is supplied the balances will be retrieved
* not including that bound. Use `balances[as_of_lock_version]` to retrieve a
* balance as of a specific Ledger Account `lock_version`.
*/
export interface Balances {
as_of_date?: string;

as_of_lock_version?: number;

effective_at?: string;

effective_at_lower_bound?: string;
Expand Down Expand Up @@ -376,10 +382,11 @@ export interface LedgerAccountListParams extends PageParams {
id?: string;

/**
* Use balances[effective_at_lower_bound] and balances[effective_at_upper_bound] to
* get the balances change between the two timestamps. The lower bound is inclusive
* while the upper bound is exclusive of the provided timestamps. If no value is
* supplied the balances will be retrieved not including that bound.
* Use `balances[effective_at_lower_bound]` and
* `balances[effective_at_upper_bound]` to get the balances change between the two
* timestamps. The lower bound is inclusive while the upper bound is exclusive of
* the provided timestamps. If no value is supplied the balances will be retrieved
* not including that bound.
*/
balances?: LedgerAccountListParams.Balances;

Expand Down Expand Up @@ -413,10 +420,11 @@ export interface LedgerAccountListParams extends PageParams {

export namespace LedgerAccountListParams {
/**
* Use balances[effective_at_lower_bound] and balances[effective_at_upper_bound] to
* get the balances change between the two timestamps. The lower bound is inclusive
* while the upper bound is exclusive of the provided timestamps. If no value is
* supplied the balances will be retrieved not including that bound.
* Use `balances[effective_at_lower_bound]` and
* `balances[effective_at_upper_bound]` to get the balances change between the two
* timestamps. The lower bound is inclusive while the upper bound is exclusive of
* the provided timestamps. If no value is supplied the balances will be retrieved
* not including that bound.
*/
export interface Balances {
as_of_date?: string;
Expand Down
18 changes: 18 additions & 0 deletions src/resources/payment-orders/payment-orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,24 @@ export namespace PaymentOrderCreateParams {
}

export interface Document {
/**
* The unique identifier for the associated object.
*/
documentable_id: string;

documentable_type:
| 'cases'
| 'counterparties'
| 'expected_payments'
| 'external_accounts'
| 'internal_accounts'
| 'organizations'
| 'paper_items'
| 'payment_orders'
| 'transactions'
| 'decisions'
| 'connections';

file: Uploadable;

/**
Expand Down
7 changes: 2 additions & 5 deletions src/resources/virtual-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ export class VirtualAccounts extends APIResource {
/**
* get virtual_account
*/
retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<void>> {
return this.get(`/api/virtual_accounts/${id}`, {
...options,
headers: { Accept: '', ...options?.headers },
});
retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<VirtualAccount>> {
return this.get(`/api/virtual_accounts/${id}`, options);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('resource internalAccounts', () => {
name: 'string',
party_name: 'string',
counterparty_id: 'string',
entity_id: 'string',
parent_account_id: 'string',
party_address: {
line1: 'string',
Expand All @@ -35,6 +34,7 @@ describe('resource internalAccounts', () => {
postal_code: 'string',
country: 'string',
},
vendor_attributes: { key: 'value', foo: 'bar', modern: 'treasury' },
'Idempotency-Key': 'string',
});
});
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/ledger-accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('resource ledgerAccounts', () => {
effective_at: '2019-12-27T18:11:19.117Z',
effective_at_lower_bound: '2019-12-27T18:11:19.117Z',
effective_at_upper_bound: '2019-12-27T18:11:19.117Z',
as_of_lock_version: 0,
},
},
{ path: '/_stainless_unknown_path' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('resource ledgerTransactions', () => {
'string',
{
description: 'string',
effective_at: '2019-12-27',
effective_at: '2019-12-27T18:11:19.117Z',
external_id: 'string',
ledgerable_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
ledgerable_type: 'counterparty',
Expand Down
21 changes: 18 additions & 3 deletions tests/api-resources/payment-orders/payment-orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,24 @@ describe('resource paymentOrders', () => {
currency: 'AED',
description: 'string',
documents: [
{ document_type: 'string', file: await toFile(Buffer.from('# my file contents'), 'README.md') },
{ document_type: 'string', file: await toFile(Buffer.from('# my file contents'), 'README.md') },
{ document_type: 'string', file: await toFile(Buffer.from('# my file contents'), 'README.md') },
{
documentable_id: 'string',
documentable_type: 'cases',
document_type: 'string',
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
},
{
documentable_id: 'string',
documentable_type: 'cases',
document_type: 'string',
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
},
{
documentable_id: 'string',
documentable_type: 'cases',
document_type: 'string',
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
},
],
effective_date: '2019-12-27',
expires_at: '2019-12-27T18:11:19.117Z',
Expand Down

0 comments on commit b5464dd

Please sign in to comment.