Skip to content

Commit

Permalink
Generate from spec version 1.71.0 - POST scheduled txns
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymholt committed Jul 9, 2024
1 parent a45c525 commit 6942584
Show file tree
Hide file tree
Showing 33 changed files with 570 additions and 139 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ The following methods are available in this library.
| | [transactions.importTransactions(budget_id)](https://github.com/ynab/ynab-sdk-js/blob/main/dist/apis/TransactionsApi.d.ts) | Imports transactions |
| **Scheduled Transactions** | [scheduled_transactions.getScheduledTransactions(budget_id)](https://github.com/ynab/ynab-sdk-js/blob/main/dist/apis/ScheduledTransactionsApi.d.ts) | Returns all scheduled transactions |
| | [scheduled_transactions.getScheduledTransactionById(budget_id, scheduled_transaction_id)](https://github.com/ynab/ynab-sdk-js/blob/main/dist/apis/ScheduledTransactionsApi.d.ts) | Returns a single scheduled transaction |
| | [scheduled_transactions.createScheduledTransaction(budget_id, data)](https://github.com/ynab/ynab-sdk-js/blob/main/dist/apis/ScheduledTransactionsApi.d.ts) | Creates a single scheduled transaction |

### Utilities

Expand Down
124 changes: 120 additions & 4 deletions open_api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.70.0
version: 1.71.0
servers:
- url: https://api.ynab.com/v1
security:
Expand Down Expand Up @@ -959,8 +959,8 @@ paths:
Creates a single transaction or multiple transactions. If you provide a
body containing a `transaction` object, a single transaction will be
created and if you provide a body containing a `transactions` array,
multiple transactions will be created. Scheduled transactions cannot be
created on this endpoint.
multiple transactions will be created. Scheduled transactions (transactions with a future date)
cannot be created on this endpoint.
operationId: createTransaction
parameters:
- name: budget_id
Expand Down Expand Up @@ -1469,6 +1469,47 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
post:
tags:
- Scheduled Transactions
summary: Create a single scheduled transaction
description: >-
Creates a single scheduled transaction.
operationId: createScheduledTransaction
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
requestBody:
description: >-
The scheduled transaction to create
content:
"application/json":
schema:
$ref: "#/components/schemas/PostScheduledTransactionWrapper"
required: true
responses:
"201":
description: The scheduled transaction was successfully created
content:
application/json:
schema:
$ref: "#/components/schemas/ScheduledTransactionResponse"
"400":
description: >-
The request could not be understood due to malformed syntax or
validation error(s).
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
x-codegen-request-body-name: data
/budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id}:
get:
tags:
Expand Down Expand Up @@ -2401,7 +2442,7 @@ components:
The payee for the transaction. To create a transfer between two
accounts, use the account transfer payee pointing to the target
account. Account transfer payees are specified as
`tranfer_payee_id` on the account resource.
`transfer_payee_id` on the account resource.
format: uuid
payee_name:
maxLength: 50
Expand Down Expand Up @@ -2875,6 +2916,64 @@ components:
properties:
scheduled_transaction:
$ref: "#/components/schemas/ScheduledTransactionDetail"
PostScheduledTransactionWrapper:
required:
- scheduled_transaction
type: object
properties:
scheduled_transaction:
$ref: "#/components/schemas/SaveScheduledTransaction"
SaveScheduledTransaction:
required:
- account_id
- date
type: object
properties:
account_id:
type: string
format: uuid
date:
type: string
description: >-
The scheduled transaction date in ISO format (e.g. 2016-12-01).
format: date
amount:
type: integer
description: >-
The scheduled transaction amount in milliunits format.
format: int64
payee_id:
type: string
nullable: true
description: >-
The payee for the scheduled transaction. To create a transfer between two
accounts, use the account transfer payee pointing to the target
account. Account transfer payees are specified as
`transfer_payee_id` on the account resource.
format: uuid
payee_name:
maxLength: 50
type: string
nullable: true
description: >-
The payee name for the the scheduled transaction. If a `payee_name` value is provided and `payee_id`
has a null value, the `payee_name` value will be used to resolve the
payee by either (1) a payee with the same name or (2) creation of a new payee.
category_id:
type: string
nullable: true
description: >-
The category for the scheduled transaction. Credit Card Payment categories are not permitted.
Creating a split scheduled transaction is not currently supported.
format: uuid
memo:
maxLength: 200
type: string
nullable: true
flag_color:
$ref: "#/components/schemas/TransactionFlagColor"
frequency:
$ref: "#/components/schemas/ScheduledTransactionFrequency"
ScheduledTransactionSummary:
required:
- account_id
Expand Down Expand Up @@ -3127,6 +3226,23 @@ components:
- cleared
- uncleared
- reconciled
ScheduledTransactionFrequency:
type: string
description: The scheduled transaction frequency
enum:
- never
- daily
- weekly
- everyOtherWeek
- twiceAMonth
- every4Weeks
- monthly
- everyOtherMonth
- every3Months
- every4Months
- twiceAYear
- yearly
- everyOtherYear
securitySchemes:
bearer:
type: http
Expand Down
3 changes: 3 additions & 0 deletions src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ models/PayeeResponseData.ts
models/PayeesResponse.ts
models/PayeesResponseData.ts
models/PostAccountWrapper.ts
models/PostScheduledTransactionWrapper.ts
models/PostTransactionsWrapper.ts
models/PutTransactionWrapper.ts
models/SaveAccount.ts
Expand All @@ -75,13 +76,15 @@ models/SaveMonthCategory.ts
models/SavePayee.ts
models/SavePayeeResponse.ts
models/SavePayeeResponseData.ts
models/SaveScheduledTransaction.ts
models/SaveSubTransaction.ts
models/SaveTransactionWithIdOrImportId.ts
models/SaveTransactionWithOptionalFields.ts
models/SaveTransactionsResponse.ts
models/SaveTransactionsResponseData.ts
models/ScheduledSubTransaction.ts
models/ScheduledTransactionDetail.ts
models/ScheduledTransactionFrequency.ts
models/ScheduledTransactionResponse.ts
models/ScheduledTransactionResponseData.ts
models/ScheduledTransactionSummary.ts
Expand Down
2 changes: 1 addition & 1 deletion src/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.6.0
7.7.0
56 changes: 56 additions & 0 deletions src/apis/ScheduledTransactionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@
import * as runtime from '../runtime';
import type {
ErrorResponse,
PostScheduledTransactionWrapper,
ScheduledTransactionResponse,
ScheduledTransactionsResponse,
} from '../models/index';
import {
ErrorResponseFromJSON,
ErrorResponseToJSON,
PostScheduledTransactionWrapperFromJSON,
PostScheduledTransactionWrapperToJSON,
ScheduledTransactionResponseFromJSON,
ScheduledTransactionResponseToJSON,
ScheduledTransactionsResponseFromJSON,
ScheduledTransactionsResponseToJSON,
} from '../models/index';

export interface CreateScheduledTransactionRequest {
budgetId: string;
data: PostScheduledTransactionWrapper;
}

export interface GetScheduledTransactionByIdRequest {
budgetId: string;
scheduledTransactionId: string;
Expand All @@ -38,6 +46,54 @@ export interface GetScheduledTransactionsRequest {
*/
export class ScheduledTransactionsApi extends runtime.BaseAPI {

/**
* Creates a single scheduled transaction.
* Create a single scheduled transaction
*/
async createScheduledTransactionRaw(requestParameters: CreateScheduledTransactionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ScheduledTransactionResponse>> {
if (requestParameters.budgetId === null || requestParameters.budgetId === undefined) {
throw new runtime.RequiredError('budgetId','Required parameter requestParameters.budgetId was null or undefined when calling createScheduledTransaction.');
}

if (requestParameters.data === null || requestParameters.data === undefined) {
throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling createScheduledTransaction.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Accept'] = 'application/json';

headerParameters['Content-Type'] = '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}/scheduled_transactions`.replace(`{${"budget_id"}}`, encodeURIComponent(String(requestParameters.budgetId))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: PostScheduledTransactionWrapperToJSON(requestParameters.data),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ScheduledTransactionResponseFromJSON(jsonValue));
}

/**
* Creates a single scheduled transaction.
* Create a single scheduled transaction
*/
async createScheduledTransaction(budgetId: string, data: PostScheduledTransactionWrapper, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ScheduledTransactionResponse> {
const response = await this.createScheduledTransactionRaw({ budgetId: budgetId, data: data }, initOverrides);
return await response.value();
}

/**
* Returns a single scheduled transaction
* Single scheduled transaction
Expand Down
4 changes: 2 additions & 2 deletions src/apis/TransactionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface UpdateTransactionsRequest {
export class TransactionsApi extends runtime.BaseAPI {

/**
* Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions cannot be created on this endpoint.
* Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions (transactions with a future date) cannot be created on this endpoint.
* Create a single transaction or multiple transactions
*/
async createTransactionRaw(requestParameters: CreateTransactionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SaveTransactionsResponse>> {
Expand Down Expand Up @@ -147,7 +147,7 @@ export class TransactionsApi extends runtime.BaseAPI {
}

/**
* Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions cannot be created on this endpoint.
* Creates a single transaction or multiple transactions. If you provide a body containing a `transaction` object, a single transaction will be created and if you provide a body containing a `transactions` array, multiple transactions will be created. Scheduled transactions (transactions with a future date) cannot be created on this endpoint.
* Create a single transaction or multiple transactions
*/
async createTransaction(budgetId: string, data: PostTransactionsWrapper, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SaveTransactionsResponse> {
Expand Down
12 changes: 6 additions & 6 deletions src/models/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface Account {
* @type {string}
* @memberof Account
*/
note?: string;
note?: string | null;
/**
* The current balance of the account in milliunits format
* @type {number}
Expand Down Expand Up @@ -98,31 +98,31 @@ export interface Account {
* @type {string}
* @memberof Account
*/
last_reconciled_at?: string;
last_reconciled_at?: string | null;
/**
* The original debt/loan account balance, specified in milliunits format.
* @type {number}
* @memberof Account
*/
debt_original_balance?: number;
debt_original_balance?: number | null;
/**
*
* @type {{ [key: string]: number; }}
* @memberof Account
*/
debt_interest_rates?: { [key: string]: number; };
debt_interest_rates?: { [key: string]: number; } | null;
/**
*
* @type {{ [key: string]: number; }}
* @memberof Account
*/
debt_minimum_payments?: { [key: string]: number; };
debt_minimum_payments?: { [key: string]: number; } | null;
/**
*
* @type {{ [key: string]: number; }}
* @memberof Account
*/
debt_escrow_amounts?: { [key: string]: number; };
debt_escrow_amounts?: { [key: string]: number; } | null;
/**
* Whether or not the account has been deleted. Deleted accounts will only be included in delta requests.
* @type {boolean}
Expand Down
2 changes: 1 addition & 1 deletion src/models/AccountType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type AccountType = typeof AccountType[keyof typeof AccountType];
export function instanceOfAccountType(value: any): boolean {
for (const key in AccountType) {
if (Object.prototype.hasOwnProperty.call(AccountType, key)) {
if (AccountType[key as keyof typeof AccountType] === value) {
if ((AccountType as Record<string, AccountType>)[key] === value) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/BudgetDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ export interface BudgetDetail {
* @type {DateFormat}
* @memberof BudgetDetail
*/
date_format?: DateFormat;
date_format?: DateFormat | null;
/**
*
* @type {CurrencyFormat}
* @memberof BudgetDetail
*/
currency_format?: CurrencyFormat;
currency_format?: CurrencyFormat | null;
/**
*
* @type {Array<Account>}
Expand Down
4 changes: 2 additions & 2 deletions src/models/BudgetSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export interface BudgetSummary {
* @type {DateFormat}
* @memberof BudgetSummary
*/
date_format?: DateFormat;
date_format?: DateFormat | null;
/**
*
* @type {CurrencyFormat}
* @memberof BudgetSummary
*/
currency_format?: CurrencyFormat;
currency_format?: CurrencyFormat | null;
/**
* The budget accounts (only included if `include_accounts=true` specified as query parameter)
* @type {Array<Account>}
Expand Down
Loading

0 comments on commit 6942584

Please sign in to comment.