Skip to content

Commit

Permalink
feat(api): updates (#180)
Browse files Browse the repository at this point in the history
- Remove `balances` query param from `update/delete ledger account categories`
- add `metadata` query param to `list/retrieve ledger account payouts`
- add `currency` query param to `list ledger accounts/ledger entries`
- add `ledger account payout id` query param to `list ledger entries/ledger transactions`
- rename `ledger transaction id` path param to `id` in `create ledger transaction reversal`
- add `skip payout ledger transaction` property to `ledger account payout create request`
- make `effective at` property optional in `ledger transaction create request`
  • Loading branch information
stainless-bot authored and cleb11 committed Aug 15, 2023
1 parent 639f25b commit 24c193d
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 131 deletions.
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Methods:
- <code title="get /api/ledger_account_categories/{id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">retrieve</a>(id, { ...params }) -> LedgerAccountCategory</code>
- <code title="patch /api/ledger_account_categories/{id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">update</a>(id, { ...params }) -> LedgerAccountCategory</code>
- <code title="get /api/ledger_account_categories">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">list</a>({ ...params }) -> LedgerAccountCategoriesPage</code>
- <code title="delete /api/ledger_account_categories/{id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">del</a>(id, { ...params }) -> LedgerAccountCategory</code>
- <code title="delete /api/ledger_account_categories/{id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">del</a>(id) -> LedgerAccountCategory</code>
- <code title="put /api/ledger_account_categories/{id}/ledger_accounts/{ledger_account_id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">addLedgerAccount</a>(id, ledgerAccountId) -> void</code>
- <code title="put /api/ledger_account_categories/{id}/ledger_account_categories/{sub_category_id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">addNestedCategory</a>(id, subCategoryId) -> void</code>
- <code title="delete /api/ledger_account_categories/{id}/ledger_accounts/{ledger_account_id}">client.ledgerAccountCategories.<a href="./src/resources/ledger-account-categories.ts">removeLedgerAccount</a>(id, ledgerAccountId) -> void</code>
Expand Down Expand Up @@ -313,7 +313,7 @@ Methods:
- <code title="get /api/ledger_transactions/{id}">client.ledgerTransactions.<a href="./src/resources/ledger-transactions/ledger-transactions.ts">retrieve</a>(id) -> LedgerTransaction</code>
- <code title="patch /api/ledger_transactions/{id}">client.ledgerTransactions.<a href="./src/resources/ledger-transactions/ledger-transactions.ts">update</a>(id, { ...params }) -> LedgerTransaction</code>
- <code title="get /api/ledger_transactions">client.ledgerTransactions.<a href="./src/resources/ledger-transactions/ledger-transactions.ts">list</a>({ ...params }) -> LedgerTransactionsPage</code>
- <code title="post /api/ledger_transactions/{ledger_transaction_id}/reversal">client.ledgerTransactions.<a href="./src/resources/ledger-transactions/ledger-transactions.ts">createReversal</a>(ledgerTransactionId, { ...params }) -> LedgerTransaction</code>
- <code title="post /api/ledger_transactions/{id}/reversal">client.ledgerTransactions.<a href="./src/resources/ledger-transactions/ledger-transactions.ts">createReversal</a>(id, { ...params }) -> LedgerTransaction</code>

## Versions

Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ export namespace ModernTreasury {
export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams;
export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams;
export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams;
export import LedgerAccountCategoryDeleteParams = API.LedgerAccountCategoryDeleteParams;

export import LedgerAccounts = API.LedgerAccounts;
export import LedgerAccount = API.LedgerAccount;
Expand Down
1 change: 0 additions & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export {
LedgerAccountCategoryRetrieveParams,
LedgerAccountCategoryUpdateParams,
LedgerAccountCategoryListParams,
LedgerAccountCategoryDeleteParams,
LedgerAccountCategoriesPage,
LedgerAccountCategories,
} from './ledger-account-categories';
Expand Down
102 changes: 28 additions & 74 deletions src/resources/ledger-account-categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ export class LedgerAccountCategories extends APIResource {
*/
update(
id: string,
params?: LedgerAccountCategoryUpdateParams,
body?: LedgerAccountCategoryUpdateParams,
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerAccountCategory>>;
update(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<LedgerAccountCategory>>;
update(
id: string,
params: LedgerAccountCategoryUpdateParams | Core.RequestOptions = {},
body: LedgerAccountCategoryUpdateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerAccountCategory>> {
if (isRequestOptions(params)) {
return this.update(id, {}, params);
if (isRequestOptions(body)) {
return this.update(id, {}, body);
}
const { balances, ...body } = params;
return this.patch(`/api/ledger_account_categories/${id}`, { query: { balances }, body, ...options });
return this.patch(`/api/ledger_account_categories/${id}`, { body, ...options });
}

/**
Expand All @@ -87,26 +86,12 @@ export class LedgerAccountCategories extends APIResource {
/**
* Delete a ledger account category.
*/
del(
id: string,
body?: LedgerAccountCategoryDeleteParams,
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerAccountCategory>>;
del(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<LedgerAccountCategory>>;
del(
id: string,
body: LedgerAccountCategoryDeleteParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerAccountCategory>> {
if (isRequestOptions(body)) {
return this.del(id, {}, body);
}
const { balances } = body;
return this.delete(`/api/ledger_account_categories/${id}`, { query: { balances }, ...options });
del(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<LedgerAccountCategory>> {
return this.delete(`/api/ledger_account_categories/${id}`, options);
}

/**
* Add a ledger account category to an account.
* Add a ledger account to a ledger account category.
*/
addLedgerAccount(
id: string,
Expand Down Expand Up @@ -134,7 +119,7 @@ export class LedgerAccountCategories extends APIResource {
}

/**
* Delete a ledger account category from an account.
* Remove a ledger account from a ledger account category.
*/
removeLedgerAccount(
id: string,
Expand Down Expand Up @@ -362,20 +347,18 @@ export interface LedgerAccountCategoryCreateParams {

export interface LedgerAccountCategoryRetrieveParams {
/**
* For example, if you want the balances as of a particular effective date
* (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
* For example, if you want the balances as of a particular time (ISO8601), the
* encoded query string would be `balances%5Beffective_at%5D=2000-12-31T12:00:00Z`.
* The balances as of a time are inclusive of entries with that exact time.
*/
balances?: LedgerAccountCategoryRetrieveParams.Balances;
}

export namespace LedgerAccountCategoryRetrieveParams {
/**
* For example, if you want the balances as of a particular effective date
* (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
* For example, if you want the balances as of a particular time (ISO8601), the
* encoded query string would be `balances%5Beffective_at%5D=2000-12-31T12:00:00Z`.
* The balances as of a time are inclusive of entries with that exact time.
*/
export interface Balances {
as_of_date?: string;
Expand All @@ -386,45 +369,30 @@ export namespace LedgerAccountCategoryRetrieveParams {

export interface LedgerAccountCategoryUpdateParams {
/**
* Query param: For example, if you want the balances as of a particular effective
* date (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
*/
balances?: LedgerAccountCategoryUpdateParams.Balances;

/**
* Body param: The description of the ledger account category.
* The description of the ledger account category.
*/
description?: string | null;

/**
* Body param: Additional data represented as key-value pairs. Both the key and
* value must be strings.
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;

/**
* Body param: The name of the ledger account category.
* The name of the ledger account category.
*/
name?: string;
}

export namespace LedgerAccountCategoryUpdateParams {
export interface LedgerAccountCategoryListParams extends PageParams {
/**
* For example, if you want the balances as of a particular effective date
* (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
* For example, if you want the balances as of a particular time (ISO8601), the
* encoded query string would be `balances%5Beffective_at%5D=2000-12-31T12:00:00Z`.
* The balances as of a time are inclusive of entries with that exact time.
*/
export interface Balances {
as_of_date?: string;
balances?: LedgerAccountCategoryListParams.Balances;

effective_at?: string;
}
}

export interface LedgerAccountCategoryListParams extends PageParams {
/**
* Query categories which contain a ledger account directly or through child
* categories.
Expand All @@ -448,26 +416,13 @@ export interface LedgerAccountCategoryListParams extends PageParams {
parent_ledger_account_category_id?: string;
}

export interface LedgerAccountCategoryDeleteParams {
/**
* For example, if you want the balances as of a particular effective date
* (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
*/
balances?: LedgerAccountCategoryDeleteParams.Balances;
}

export namespace LedgerAccountCategoryDeleteParams {
export namespace LedgerAccountCategoryListParams {
/**
* For example, if you want the balances as of a particular effective date
* (YYYY-MM-DD), the encoded query string would be
* balances%5Bas_of_date%5D=2000-12-31. The balances as of a date are exclusive of
* entries with that exact date.
* For example, if you want the balances as of a particular time (ISO8601), the
* encoded query string would be `balances%5Beffective_at%5D=2000-12-31T12:00:00Z`.
* The balances as of a time are inclusive of entries with that exact time.
*/
export interface Balances {
as_of_date?: string;

effective_at?: string;
}
}
Expand All @@ -479,5 +434,4 @@ export namespace LedgerAccountCategories {
export import LedgerAccountCategoryRetrieveParams = API.LedgerAccountCategoryRetrieveParams;
export import LedgerAccountCategoryUpdateParams = API.LedgerAccountCategoryUpdateParams;
export import LedgerAccountCategoryListParams = API.LedgerAccountCategoryListParams;
export import LedgerAccountCategoryDeleteParams = API.LedgerAccountCategoryDeleteParams;
}
13 changes: 13 additions & 0 deletions src/resources/ledger-account-payouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ export interface LedgerAccountPayoutCreateParams {
*/
metadata?: Record<string, string>;

/**
* Body param: It is set to `false` by default. It should be set to `true` when
* migrating existing payouts.
*/
skip_payout_ledger_transaction?: boolean | null;

/**
* Body param: The status of the ledger account payout. It is set to `pending` by
* default. To post a ledger account payout at creation, use `posted`.
Expand Down Expand Up @@ -213,6 +219,13 @@ export interface LedgerAccountPayoutUpdateParams {
}

export interface LedgerAccountPayoutListParams extends PageParams {
/**
* For example, if you want to query for records with metadata key `Type` and value
* `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query
* parameters.
*/
metadata?: Record<string, string>;

payout_ledger_account_id?: string;
}

Expand Down
2 changes: 2 additions & 0 deletions src/resources/ledger-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ export interface LedgerAccountListParams extends PageParams {
*/
created_at?: Record<string, string>;

currency?: string;

ledger_account_category_id?: string;

ledger_id?: string;
Expand Down
4 changes: 3 additions & 1 deletion src/resources/ledger-entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export interface LedgerEntryListParams extends PageParams {
direction?: 'credit' | 'debit';

/**
* Use "gt" (>), "gte" (>=), "lt" (<), "lte" (<=), or "eq" (=) to filter by the
* Use `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to filter by the
* transaction's effective time. Format ISO8601
*/
effective_at?: Record<string, string>;
Expand All @@ -281,6 +281,8 @@ export interface LedgerEntryListParams extends PageParams {
*/
ledger_account_lock_version?: Record<string, number>;

ledger_account_payout_id?: string;

/**
* Get all ledger entries that are included in the ledger account statement.
*/
Expand Down
33 changes: 19 additions & 14 deletions src/resources/ledger-transactions/ledger-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,20 @@ export class LedgerTransactions extends APIResource {
* Create a ledger transaction reversal.
*/
createReversal(
ledgerTransactionId: string,
id: string,
body?: LedgerTransactionCreateReversalParams,
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerTransaction>>;
createReversal(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<LedgerTransaction>>;
createReversal(
ledgerTransactionId: string,
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerTransaction>>;
createReversal(
ledgerTransactionId: string,
id: string,
body: LedgerTransactionCreateReversalParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Promise<Core.APIResponse<LedgerTransaction>> {
if (isRequestOptions(body)) {
return this.createReversal(ledgerTransactionId, {}, body);
return this.createReversal(id, {}, body);
}
return this.post(`/api/ledger_transactions/${ledgerTransactionId}/reversal`, { body, ...options });
return this.post(`/api/ledger_transactions/${id}/reversal`, { body, ...options });
}
}

Expand Down Expand Up @@ -195,12 +192,6 @@ export interface LedgerTransaction {
}

export interface LedgerTransactionCreateParams {
/**
* Body param: The timestamp (ISO8601 format) at which the ledger transaction
* happened for reporting purposes.
*/
effective_at: string;

/**
* Body param: An array of ledger entry objects.
*/
Expand All @@ -211,6 +202,12 @@ export interface LedgerTransactionCreateParams {
*/
description?: string | null;

/**
* Body param: The timestamp (ISO8601 format) at which the ledger transaction
* happened for reporting purposes.
*/
effective_at?: string;

/**
* Body param: The date (YYYY-MM-DD) on which the ledger transaction happened for
* reporting purposes.
Expand Down Expand Up @@ -335,6 +332,12 @@ export interface LedgerTransactionUpdateParams {
*/
description?: string | null;

/**
* The timestamp (ISO8601 format) at which the ledger transaction happened for
* reporting purposes.
*/
effective_at?: string;

/**
* An array of ledger entry objects.
*/
Expand Down Expand Up @@ -439,6 +442,8 @@ export interface LedgerTransactionListParams extends PageParams {

ledger_account_id?: string;

ledger_account_payout_id?: string;

ledger_id?: string;

ledgerable_id?: string;
Expand Down
Loading

0 comments on commit 24c193d

Please sign in to comment.