diff --git a/open_api_spec.yaml b/open_api_spec.yaml index 5f9c44b..a17097e 100644 --- a/open_api_spec.yaml +++ b/open_api_spec.yaml @@ -6,7 +6,7 @@ info: upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.ynab.com - version: 1.71.0 + version: 1.72.0 servers: - url: https://api.ynab.com/v1 security: @@ -1425,6 +1425,76 @@ paths: application/json: schema: $ref: "#/components/schemas/ErrorResponse" + /budgets/{budget_id}/months/{month}/transactions: + get: + tags: + - Transactions + summary: List transactions in month, excluding any pending transactions + description: Returns all transactions for a specified month + operationId: getTransactionsByMonth + parameters: + - name: budget_id + in: path + description: >- + The id of the budget. "last-used" can be used to specify the last + used budget and "default" can be used if default budget selection is + enabled (see: https://api.ynab.com/#oauth-default-budget). + required: true + schema: + type: string + - name: month + in: path + description: >- + The budget month in ISO format (e.g. 2016-12-01) ("current" can also + be used to specify the current calendar month (UTC)) + required: true + schema: + type: string + - name: since_date + in: query + description: >- + If specified, only transactions on or after this date will be + included. The date should be ISO formatted (e.g. 2016-12-30). + schema: + type: string + format: date + - name: type + in: query + description: >- + If specified, only transactions of the specified type will be + included. "uncategorized" and "unapproved" are currently supported. + schema: + type: string + enum: + - uncategorized + - unapproved + - name: last_knowledge_of_server + in: query + description: >- + The starting server knowledge. If provided, only entities that have + changed since `last_knowledge_of_server` will be included. + schema: + type: integer + format: int64 + responses: + "200": + description: The list of requested transactions + content: + application/json: + schema: + $ref: "#/components/schemas/HybridTransactionsResponse" + "404": + description: No transactions were found + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" + default: + description: An error occurred + content: + application/json: + schema: + $ref: "#/components/schemas/ErrorResponse" /budgets/{budget_id}/scheduled_transactions: get: tags: diff --git a/src/apis/TransactionsApi.ts b/src/apis/TransactionsApi.ts index 4f68af8..495778c 100644 --- a/src/apis/TransactionsApi.ts +++ b/src/apis/TransactionsApi.ts @@ -79,6 +79,14 @@ export interface GetTransactionsByCategoryRequest { lastKnowledgeOfServer?: number; } +export interface GetTransactionsByMonthRequest { + budgetId: string; + month: string; + sinceDate?: string; + type?: GetTransactionsByMonthTypeEnum; + lastKnowledgeOfServer?: number; +} + export interface GetTransactionsByPayeeRequest { budgetId: string; payeeId: string; @@ -412,6 +420,63 @@ export class TransactionsApi extends runtime.BaseAPI { return await response.value(); } + /** + * Returns all transactions for a specified month + * List transactions in month, excluding any pending transactions + */ + async getTransactionsByMonthRaw(requestParameters: GetTransactionsByMonthRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.budgetId === null || requestParameters.budgetId === undefined) { + throw new runtime.RequiredError('budgetId','Required parameter requestParameters.budgetId was null or undefined when calling getTransactionsByMonth.'); + } + + if (requestParameters.month === null || requestParameters.month === undefined) { + throw new runtime.RequiredError('month','Required parameter requestParameters.month was null or undefined when calling getTransactionsByMonth.'); + } + + const queryParameters: any = {}; + + if (requestParameters.sinceDate !== undefined) { + queryParameters['since_date'] = requestParameters.sinceDate; + } + + if (requestParameters.type !== undefined) { + queryParameters['type'] = requestParameters.type; + } + + if (requestParameters.lastKnowledgeOfServer !== undefined) { + queryParameters['last_knowledge_of_server'] = requestParameters.lastKnowledgeOfServer; + } + + const headerParameters: runtime.HTTPHeaders = {}; + headerParameters['Accept'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token("bearer", []); + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/budgets/{budget_id}/months/{month}/transactions`.replace(`{${"budget_id"}}`, encodeURIComponent(String(requestParameters.budgetId))).replace(`{${"month"}}`, encodeURIComponent(String(requestParameters.month))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => HybridTransactionsResponseFromJSON(jsonValue)); + } + + /** + * Returns all transactions for a specified month + * List transactions in month, excluding any pending transactions + */ + async getTransactionsByMonth(budgetId: string, month: string, sinceDate?: string, type?: GetTransactionsByMonthTypeEnum, lastKnowledgeOfServer?: number, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getTransactionsByMonthRaw({ budgetId: budgetId, month: month, sinceDate: sinceDate, type: type, lastKnowledgeOfServer: lastKnowledgeOfServer }, initOverrides); + return await response.value(); + } + /** * Returns all transactions for a specified payee * List payee transactions, excluding any pending transactions @@ -636,6 +701,14 @@ export const GetTransactionsByCategoryTypeEnum = { Unapproved: 'unapproved' } as const; export type GetTransactionsByCategoryTypeEnum = typeof GetTransactionsByCategoryTypeEnum[keyof typeof GetTransactionsByCategoryTypeEnum]; +/** + * @export + */ +export const GetTransactionsByMonthTypeEnum = { + Uncategorized: 'uncategorized', + Unapproved: 'unapproved' +} as const; +export type GetTransactionsByMonthTypeEnum = typeof GetTransactionsByMonthTypeEnum[keyof typeof GetTransactionsByMonthTypeEnum]; /** * @export */