From 057912a0bac78d57e6c95ccecd865f27476e5006 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 9 Aug 2019 03:55:27 -0400 Subject: fix the provided openapi spec a lot of things marked required actually aren't --- data/spec-v1-swagger.json | 30 ++----------- ynab-api/docs/Account.md | 2 +- ynab-api/docs/BudgetSummaryResponseData.md | 2 +- ynab-api/docs/Category.md | 10 ++--- ynab-api/docs/HybridTransaction.md | 16 +++---- ynab-api/docs/MonthDetail.md | 4 +- ynab-api/docs/MonthSummary.md | 4 +- ynab-api/docs/Payee.md | 2 +- ynab-api/docs/ScheduledSubTransaction.md | 6 +-- ynab-api/docs/ScheduledTransactionDetail.md | 6 +-- ynab-api/docs/ScheduledTransactionSummary.md | 6 +-- ynab-api/docs/SubTransaction.md | 8 ++-- ynab-api/docs/TransactionDetail.md | 16 +++---- ynab-api/docs/TransactionSummary.md | 16 +++---- ynab-api/src/models/account.rs | 8 ++-- .../src/models/budget_summary_response_data.rs | 8 ++-- ynab-api/src/models/category.rs | 32 +++++++------- ynab-api/src/models/hybrid_transaction.rs | 50 +++++++++++----------- ynab-api/src/models/month_detail.rs | 14 +++--- ynab-api/src/models/month_summary.rs | 14 +++--- ynab-api/src/models/payee.rs | 8 ++-- ynab-api/src/models/scheduled_sub_transaction.rs | 20 ++++----- .../src/models/scheduled_transaction_detail.rs | 20 ++++----- .../src/models/scheduled_transaction_summary.rs | 20 ++++----- ynab-api/src/models/sub_transaction.rs | 26 +++++------ ynab-api/src/models/transaction_detail.rs | 50 +++++++++++----------- ynab-api/src/models/transaction_summary.rs | 50 +++++++++++----------- 27 files changed, 212 insertions(+), 236 deletions(-) diff --git a/data/spec-v1-swagger.json b/data/spec-v1-swagger.json index 6b11782..fea1c53 100644 --- a/data/spec-v1-swagger.json +++ b/data/spec-v1-swagger.json @@ -1479,7 +1479,7 @@ "properties": { "data": { "type": "object", - "required": ["budgets", "default_budget"], + "required": ["budgets"], "properties": { "budgets": { "type": "array", @@ -1694,7 +1694,6 @@ "type", "on_budget", "closed", - "note", "balance", "cleared_balance", "uncleared_balance", @@ -1849,15 +1848,10 @@ "category_group_id", "name", "hidden", - "note", "budgeted", "activity", "balance", - "goal_type", - "goal_creation_month", "goal_target", - "goal_target_month", - "goal_percentage_complete", "deleted" ], "properties": { @@ -1990,7 +1984,7 @@ }, "Payee": { "type": "object", - "required": ["id", "name", "transfer_account_id", "deleted"], + "required": ["id", "name", "deleted"], "properties": { "id": { "type": "string", @@ -2251,17 +2245,9 @@ "id", "date", "amount", - "memo", "cleared", "approved", - "flag_color", "account_id", - "payee_id", - "category_id", - "transfer_account_id", - "transfer_transaction_id", - "matched_transaction_id", - "import_id", "deleted" ], "properties": { @@ -2460,10 +2446,6 @@ "id", "transaction_id", "amount", - "memo", - "payee_id", - "category_id", - "transfer_account_id", "deleted" ], "properties": { @@ -2546,12 +2528,9 @@ "date_next", "frequency", "amount", - "memo", "flag_color", "account_id", - "payee_id", "category_id", - "transfer_account_id", "deleted" ], "properties": { @@ -2658,10 +2637,7 @@ "id", "scheduled_transaction_id", "amount", - "memo", - "payee_id", "category_id", - "transfer_account_id", "deleted" ], "properties": { @@ -2740,7 +2716,7 @@ }, "MonthSummary": { "type": "object", - "required": ["month", "note", "income", "budgeted", "activity", "to_be_budgeted", "age_of_money", "deleted"], + "required": ["month", "income", "budgeted", "activity", "to_be_budgeted", "deleted"], "properties": { "month": { "type": "string", diff --git a/ynab-api/docs/Account.md b/ynab-api/docs/Account.md index adeab71..265294b 100644 --- a/ynab-api/docs/Account.md +++ b/ynab-api/docs/Account.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **_type** | **String** | The type of account. Note: payPal, merchantAccount, investmentAccount, and mortgage types have been deprecated and will be removed in the future. | **on_budget** | **bool** | Whether this account is on budget or not | **closed** | **bool** | Whether this account is closed or not | -**note** | **String** | | +**note** | **String** | | [optional] **balance** | **i64** | The current balance of the account in milliunits format | **cleared_balance** | **i64** | The current cleared balance of the account in milliunits format | **uncleared_balance** | **i64** | The current uncleared balance of the account in milliunits format | diff --git a/ynab-api/docs/BudgetSummaryResponseData.md b/ynab-api/docs/BudgetSummaryResponseData.md index 6adce43..2836bfa 100644 --- a/ynab-api/docs/BudgetSummaryResponseData.md +++ b/ynab-api/docs/BudgetSummaryResponseData.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **budgets** | [**Vec<::models::BudgetSummary>**](BudgetSummary.md) | | -**default_budget** | [***::models::BudgetSummary**](BudgetSummary.md) | | +**default_budget** | [***::models::BudgetSummary**](BudgetSummary.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/Category.md b/ynab-api/docs/Category.md index 2afbe63..217979b 100644 --- a/ynab-api/docs/Category.md +++ b/ynab-api/docs/Category.md @@ -9,15 +9,15 @@ Name | Type | Description | Notes **name** | **String** | | **hidden** | **bool** | Whether or not the category is hidden | **original_category_group_id** | **String** | If category is hidden this is the id of the category group it originally belonged to before it was hidden. | [optional] -**note** | **String** | | +**note** | **String** | | [optional] **budgeted** | **i64** | Budgeted amount in milliunits format | **activity** | **i64** | Activity amount in milliunits format | **balance** | **i64** | Balance in milliunits format | -**goal_type** | **String** | The type of goal, if the cagegory has a goal (TB=Target Category Balance, TBD=Target Category Balance by Date, MF=Monthly Funding) | -**goal_creation_month** | [***String**](string.md) | The month a goal was created | +**goal_type** | **String** | The type of goal, if the cagegory has a goal (TB=Target Category Balance, TBD=Target Category Balance by Date, MF=Monthly Funding) | [optional] +**goal_creation_month** | [***String**](string.md) | The month a goal was created | [optional] **goal_target** | **i64** | The goal target amount in milliunits | -**goal_target_month** | [***String**](string.md) | If the goal type is 'TBD' (Target Category Balance by Date), this is the target month for the goal to be completed | -**goal_percentage_complete** | **i32** | The percentage completion of the goal | +**goal_target_month** | [***String**](string.md) | If the goal type is 'TBD' (Target Category Balance by Date), this is the target month for the goal to be completed | [optional] +**goal_percentage_complete** | **i32** | The percentage completion of the goal | [optional] **deleted** | **bool** | Whether or not the category has been deleted. Deleted categories will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/HybridTransaction.md b/ynab-api/docs/HybridTransaction.md index 8c88165..69c0a4e 100644 --- a/ynab-api/docs/HybridTransaction.md +++ b/ynab-api/docs/HybridTransaction.md @@ -7,17 +7,17 @@ Name | Type | Description | Notes **id** | **String** | | **date** | [***String**](string.md) | The transaction date in ISO format (e.g. 2016-12-01) | **amount** | **i64** | The transaction amount in milliunits format | -**memo** | **String** | | +**memo** | **String** | | [optional] **cleared** | **String** | The cleared status of the transaction | **approved** | **bool** | Whether or not the transaction is approved | -**flag_color** | **String** | The transaction flag | +**flag_color** | **String** | The transaction flag | [optional] **account_id** | **String** | | -**payee_id** | **String** | | -**category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | -**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | -**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | -**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | +**payee_id** | **String** | | [optional] +**category_id** | **String** | | [optional] +**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | [optional] +**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | [optional] +**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | [optional] +**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | [optional] **deleted** | **bool** | Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. | **_type** | **String** | Whether the hybrid transaction represents a regular transaction or a subtransaction | **parent_transaction_id** | **String** | For subtransaction types, this is the id of the pararent transaction. For transaction types, this id will be always be null. | diff --git a/ynab-api/docs/MonthDetail.md b/ynab-api/docs/MonthDetail.md index d1fc13a..1d7a22b 100644 --- a/ynab-api/docs/MonthDetail.md +++ b/ynab-api/docs/MonthDetail.md @@ -5,12 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **month** | [***String**](string.md) | | -**note** | **String** | | +**note** | **String** | | [optional] **income** | **i64** | The total amount in transactions categorized to 'Inflow: To be Budgeted' in the month | **budgeted** | **i64** | The total amount budgeted in the month | **activity** | **i64** | The total amount in transactions in the month, excluding those categorized to 'Inflow: To be Budgeted' | **to_be_budgeted** | **i64** | The available amount for 'To be Budgeted' | -**age_of_money** | **i32** | The Age of Money as of the month | +**age_of_money** | **i32** | The Age of Money as of the month | [optional] **deleted** | **bool** | Whether or not the month has been deleted. Deleted months will only be included in delta requests. | **categories** | [**Vec<::models::Category>**](Category.md) | The budget month categories. Amounts (budgeted, activity, balance, etc.) are specific to the {month} parameter specified. | diff --git a/ynab-api/docs/MonthSummary.md b/ynab-api/docs/MonthSummary.md index e48e3a4..a78cbfc 100644 --- a/ynab-api/docs/MonthSummary.md +++ b/ynab-api/docs/MonthSummary.md @@ -5,12 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **month** | [***String**](string.md) | | -**note** | **String** | | +**note** | **String** | | [optional] **income** | **i64** | The total amount in transactions categorized to 'Inflow: To be Budgeted' in the month | **budgeted** | **i64** | The total amount budgeted in the month | **activity** | **i64** | The total amount in transactions in the month, excluding those categorized to 'Inflow: To be Budgeted' | **to_be_budgeted** | **i64** | The available amount for 'To be Budgeted' | -**age_of_money** | **i32** | The Age of Money as of the month | +**age_of_money** | **i32** | The Age of Money as of the month | [optional] **deleted** | **bool** | Whether or not the month has been deleted. Deleted months will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/Payee.md b/ynab-api/docs/Payee.md index a52f0f9..ff886e6 100644 --- a/ynab-api/docs/Payee.md +++ b/ynab-api/docs/Payee.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **String** | | **name** | **String** | | -**transfer_account_id** | **String** | If a transfer payee, the account_id to which this payee transfers to | +**transfer_account_id** | **String** | If a transfer payee, the account_id to which this payee transfers to | [optional] **deleted** | **bool** | Whether or not the payee has been deleted. Deleted payees will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/ScheduledSubTransaction.md b/ynab-api/docs/ScheduledSubTransaction.md index 377c31f..6178bab 100644 --- a/ynab-api/docs/ScheduledSubTransaction.md +++ b/ynab-api/docs/ScheduledSubTransaction.md @@ -7,10 +7,10 @@ Name | Type | Description | Notes **id** | **String** | | **scheduled_transaction_id** | **String** | | **amount** | **i64** | The scheduled subtransaction amount in milliunits format | -**memo** | **String** | | -**payee_id** | **String** | | +**memo** | **String** | | [optional] +**payee_id** | **String** | | [optional] **category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled subtransaction transfers to | +**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled subtransaction transfers to | [optional] **deleted** | **bool** | Whether or not the scheduled subtransaction has been deleted. Deleted scheduled subtransactions will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/ScheduledTransactionDetail.md b/ynab-api/docs/ScheduledTransactionDetail.md index b140d03..5f45c7e 100644 --- a/ynab-api/docs/ScheduledTransactionDetail.md +++ b/ynab-api/docs/ScheduledTransactionDetail.md @@ -9,12 +9,12 @@ Name | Type | Description | Notes **date_next** | [***String**](string.md) | The next date for which the Scheduled Transaction is scheduled. | **frequency** | **String** | | **amount** | **i64** | The scheduled transaction amount in milliunits format | -**memo** | **String** | | +**memo** | **String** | | [optional] **flag_color** | **String** | The scheduled transaction flag | **account_id** | **String** | | -**payee_id** | **String** | | +**payee_id** | **String** | | [optional] **category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled transaction transfers to | +**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled transaction transfers to | [optional] **deleted** | **bool** | Whether or not the scheduled transaction has been deleted. Deleted scheduled transactions will only be included in delta requests. | **account_name** | **String** | | **payee_name** | **String** | | diff --git a/ynab-api/docs/ScheduledTransactionSummary.md b/ynab-api/docs/ScheduledTransactionSummary.md index e66c915..4b248b0 100644 --- a/ynab-api/docs/ScheduledTransactionSummary.md +++ b/ynab-api/docs/ScheduledTransactionSummary.md @@ -9,12 +9,12 @@ Name | Type | Description | Notes **date_next** | [***String**](string.md) | The next date for which the Scheduled Transaction is scheduled. | **frequency** | **String** | | **amount** | **i64** | The scheduled transaction amount in milliunits format | -**memo** | **String** | | +**memo** | **String** | | [optional] **flag_color** | **String** | The scheduled transaction flag | **account_id** | **String** | | -**payee_id** | **String** | | +**payee_id** | **String** | | [optional] **category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled transaction transfers to | +**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled transaction transfers to | [optional] **deleted** | **bool** | Whether or not the scheduled transaction has been deleted. Deleted scheduled transactions will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/SubTransaction.md b/ynab-api/docs/SubTransaction.md index 9e48239..77bad7f 100644 --- a/ynab-api/docs/SubTransaction.md +++ b/ynab-api/docs/SubTransaction.md @@ -7,10 +7,10 @@ Name | Type | Description | Notes **id** | **String** | | **transaction_id** | **String** | | **amount** | **i64** | The subtransaction amount in milliunits format | -**memo** | **String** | | -**payee_id** | **String** | | -**category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer, the account_id which the subtransaction transfers to | +**memo** | **String** | | [optional] +**payee_id** | **String** | | [optional] +**category_id** | **String** | | [optional] +**transfer_account_id** | **String** | If a transfer, the account_id which the subtransaction transfers to | [optional] **deleted** | **bool** | Whether or not the subtransaction has been deleted. Deleted subtransactions will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/docs/TransactionDetail.md b/ynab-api/docs/TransactionDetail.md index f9a1de5..ad156d7 100644 --- a/ynab-api/docs/TransactionDetail.md +++ b/ynab-api/docs/TransactionDetail.md @@ -7,17 +7,17 @@ Name | Type | Description | Notes **id** | **String** | | **date** | [***String**](string.md) | The transaction date in ISO format (e.g. 2016-12-01) | **amount** | **i64** | The transaction amount in milliunits format | -**memo** | **String** | | +**memo** | **String** | | [optional] **cleared** | **String** | The cleared status of the transaction | **approved** | **bool** | Whether or not the transaction is approved | -**flag_color** | **String** | The transaction flag | +**flag_color** | **String** | The transaction flag | [optional] **account_id** | **String** | | -**payee_id** | **String** | | -**category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | -**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | -**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | -**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | +**payee_id** | **String** | | [optional] +**category_id** | **String** | | [optional] +**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | [optional] +**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | [optional] +**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | [optional] +**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | [optional] **deleted** | **bool** | Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. | **account_name** | **String** | | **payee_name** | **String** | | diff --git a/ynab-api/docs/TransactionSummary.md b/ynab-api/docs/TransactionSummary.md index bad149c..fd93b15 100644 --- a/ynab-api/docs/TransactionSummary.md +++ b/ynab-api/docs/TransactionSummary.md @@ -7,17 +7,17 @@ Name | Type | Description | Notes **id** | **String** | | **date** | [***String**](string.md) | The transaction date in ISO format (e.g. 2016-12-01) | **amount** | **i64** | The transaction amount in milliunits format | -**memo** | **String** | | +**memo** | **String** | | [optional] **cleared** | **String** | The cleared status of the transaction | **approved** | **bool** | Whether or not the transaction is approved | -**flag_color** | **String** | The transaction flag | +**flag_color** | **String** | The transaction flag | [optional] **account_id** | **String** | | -**payee_id** | **String** | | -**category_id** | **String** | | -**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | -**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | -**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | -**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | +**payee_id** | **String** | | [optional] +**category_id** | **String** | | [optional] +**transfer_account_id** | **String** | If a transfer transaction, the account to which it transfers | [optional] +**transfer_transaction_id** | **String** | If a transfer transaction, the id of transaction on the other side of the transfer | [optional] +**matched_transaction_id** | **String** | If transaction is matched, the id of the matched transaction | [optional] +**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. | [optional] **deleted** | **bool** | Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/ynab-api/src/models/account.rs b/ynab-api/src/models/account.rs index 88f0353..6ffa1d5 100644 --- a/ynab-api/src/models/account.rs +++ b/ynab-api/src/models/account.rs @@ -28,8 +28,8 @@ pub struct Account { /// Whether this account is closed or not #[serde(rename = "closed")] pub closed: bool, - #[serde(rename = "note")] - pub note: String, + #[serde(rename = "note", skip_serializing_if = "Option::is_none")] + pub note: Option, /// The current balance of the account in milliunits format #[serde(rename = "balance")] pub balance: i64, @@ -48,14 +48,14 @@ pub struct Account { } impl Account { - pub fn new(id: String, name: String, _type: String, on_budget: bool, closed: bool, note: String, balance: i64, cleared_balance: i64, uncleared_balance: i64, transfer_payee_id: String, deleted: bool) -> Account { + pub fn new(id: String, name: String, _type: String, on_budget: bool, closed: bool, balance: i64, cleared_balance: i64, uncleared_balance: i64, transfer_payee_id: String, deleted: bool) -> Account { Account { id: id, name: name, _type: _type, on_budget: on_budget, closed: closed, - note: note, + note: None, balance: balance, cleared_balance: cleared_balance, uncleared_balance: uncleared_balance, diff --git a/ynab-api/src/models/budget_summary_response_data.rs b/ynab-api/src/models/budget_summary_response_data.rs index 35f3840..f6bec05 100644 --- a/ynab-api/src/models/budget_summary_response_data.rs +++ b/ynab-api/src/models/budget_summary_response_data.rs @@ -17,15 +17,15 @@ use serde_json::Value; pub struct BudgetSummaryResponseData { #[serde(rename = "budgets")] pub budgets: Vec<::models::BudgetSummary>, - #[serde(rename = "default_budget")] - pub default_budget: ::models::BudgetSummary, + #[serde(rename = "default_budget", skip_serializing_if = "Option::is_none")] + pub default_budget: Option<::models::BudgetSummary>, } impl BudgetSummaryResponseData { - pub fn new(budgets: Vec<::models::BudgetSummary>, default_budget: ::models::BudgetSummary) -> BudgetSummaryResponseData { + pub fn new(budgets: Vec<::models::BudgetSummary>) -> BudgetSummaryResponseData { BudgetSummaryResponseData { budgets: budgets, - default_budget: default_budget, + default_budget: None, } } } diff --git a/ynab-api/src/models/category.rs b/ynab-api/src/models/category.rs index 1662f64..1a62c6a 100644 --- a/ynab-api/src/models/category.rs +++ b/ynab-api/src/models/category.rs @@ -27,8 +27,8 @@ pub struct Category { /// If category is hidden this is the id of the category group it originally belonged to before it was hidden. #[serde(rename = "original_category_group_id", skip_serializing_if = "Option::is_none")] pub original_category_group_id: Option, - #[serde(rename = "note")] - pub note: String, + #[serde(rename = "note", skip_serializing_if = "Option::is_none")] + pub note: Option, /// Budgeted amount in milliunits format #[serde(rename = "budgeted")] pub budgeted: i64, @@ -39,42 +39,42 @@ pub struct Category { #[serde(rename = "balance")] pub balance: i64, /// The type of goal, if the cagegory has a goal (TB=Target Category Balance, TBD=Target Category Balance by Date, MF=Monthly Funding) - #[serde(rename = "goal_type")] - pub goal_type: String, + #[serde(rename = "goal_type", skip_serializing_if = "Option::is_none")] + pub goal_type: Option, /// The month a goal was created - #[serde(rename = "goal_creation_month")] - pub goal_creation_month: String, + #[serde(rename = "goal_creation_month", skip_serializing_if = "Option::is_none")] + pub goal_creation_month: Option, /// The goal target amount in milliunits #[serde(rename = "goal_target")] pub goal_target: i64, /// If the goal type is 'TBD' (Target Category Balance by Date), this is the target month for the goal to be completed - #[serde(rename = "goal_target_month")] - pub goal_target_month: String, + #[serde(rename = "goal_target_month", skip_serializing_if = "Option::is_none")] + pub goal_target_month: Option, /// The percentage completion of the goal - #[serde(rename = "goal_percentage_complete")] - pub goal_percentage_complete: i32, + #[serde(rename = "goal_percentage_complete", skip_serializing_if = "Option::is_none")] + pub goal_percentage_complete: Option, /// Whether or not the category has been deleted. Deleted categories will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl Category { - pub fn new(id: String, category_group_id: String, name: String, hidden: bool, note: String, budgeted: i64, activity: i64, balance: i64, goal_type: String, goal_creation_month: String, goal_target: i64, goal_target_month: String, goal_percentage_complete: i32, deleted: bool) -> Category { + pub fn new(id: String, category_group_id: String, name: String, hidden: bool, budgeted: i64, activity: i64, balance: i64, goal_target: i64, deleted: bool) -> Category { Category { id: id, category_group_id: category_group_id, name: name, hidden: hidden, original_category_group_id: None, - note: note, + note: None, budgeted: budgeted, activity: activity, balance: balance, - goal_type: goal_type, - goal_creation_month: goal_creation_month, + goal_type: None, + goal_creation_month: None, goal_target: goal_target, - goal_target_month: goal_target_month, - goal_percentage_complete: goal_percentage_complete, + goal_target_month: None, + goal_percentage_complete: None, deleted: deleted, } } diff --git a/ynab-api/src/models/hybrid_transaction.rs b/ynab-api/src/models/hybrid_transaction.rs index 240f49d..488872e 100644 --- a/ynab-api/src/models/hybrid_transaction.rs +++ b/ynab-api/src/models/hybrid_transaction.rs @@ -23,8 +23,8 @@ pub struct HybridTransaction { /// The transaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, /// The cleared status of the transaction #[serde(rename = "cleared")] pub cleared: String, @@ -32,26 +32,26 @@ pub struct HybridTransaction { #[serde(rename = "approved")] pub approved: bool, /// The transaction flag - #[serde(rename = "flag_color")] - pub flag_color: String, + #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")] + pub flag_color: Option, #[serde(rename = "account_id")] pub account_id: String, - #[serde(rename = "payee_id")] - pub payee_id: String, - #[serde(rename = "category_id")] - pub category_id: String, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, + #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")] + pub category_id: Option, /// If a transfer transaction, the account to which it transfers - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// If a transfer transaction, the id of transaction on the other side of the transfer - #[serde(rename = "transfer_transaction_id")] - pub transfer_transaction_id: String, + #[serde(rename = "transfer_transaction_id", skip_serializing_if = "Option::is_none")] + pub transfer_transaction_id: Option, /// If transaction is matched, the id of the matched transaction - #[serde(rename = "matched_transaction_id")] - pub matched_transaction_id: String, + #[serde(rename = "matched_transaction_id", skip_serializing_if = "Option::is_none")] + pub matched_transaction_id: Option, /// If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. - #[serde(rename = "import_id")] - pub import_id: String, + #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")] + pub import_id: Option, /// Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, @@ -70,22 +70,22 @@ pub struct HybridTransaction { } impl HybridTransaction { - pub fn new(id: String, date: String, amount: i64, memo: String, cleared: String, approved: bool, flag_color: String, account_id: String, payee_id: String, category_id: String, transfer_account_id: String, transfer_transaction_id: String, matched_transaction_id: String, import_id: String, deleted: bool, _type: String, parent_transaction_id: String, account_name: String, payee_name: String, category_name: String) -> HybridTransaction { + pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool, _type: String, parent_transaction_id: String, account_name: String, payee_name: String, category_name: String) -> HybridTransaction { HybridTransaction { id: id, date: date, amount: amount, - memo: memo, + memo: None, cleared: cleared, approved: approved, - flag_color: flag_color, + flag_color: None, account_id: account_id, - payee_id: payee_id, - category_id: category_id, - transfer_account_id: transfer_account_id, - transfer_transaction_id: transfer_transaction_id, - matched_transaction_id: matched_transaction_id, - import_id: import_id, + payee_id: None, + category_id: None, + transfer_account_id: None, + transfer_transaction_id: None, + matched_transaction_id: None, + import_id: None, deleted: deleted, _type: _type, parent_transaction_id: parent_transaction_id, diff --git a/ynab-api/src/models/month_detail.rs b/ynab-api/src/models/month_detail.rs index 9a2b1c2..a6f55d4 100644 --- a/ynab-api/src/models/month_detail.rs +++ b/ynab-api/src/models/month_detail.rs @@ -17,8 +17,8 @@ use serde_json::Value; pub struct MonthDetail { #[serde(rename = "month")] pub month: String, - #[serde(rename = "note")] - pub note: String, + #[serde(rename = "note", skip_serializing_if = "Option::is_none")] + pub note: Option, /// The total amount in transactions categorized to 'Inflow: To be Budgeted' in the month #[serde(rename = "income")] pub income: i64, @@ -32,8 +32,8 @@ pub struct MonthDetail { #[serde(rename = "to_be_budgeted")] pub to_be_budgeted: i64, /// The Age of Money as of the month - #[serde(rename = "age_of_money")] - pub age_of_money: i32, + #[serde(rename = "age_of_money", skip_serializing_if = "Option::is_none")] + pub age_of_money: Option, /// Whether or not the month has been deleted. Deleted months will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, @@ -43,15 +43,15 @@ pub struct MonthDetail { } impl MonthDetail { - pub fn new(month: String, note: String, income: i64, budgeted: i64, activity: i64, to_be_budgeted: i64, age_of_money: i32, deleted: bool, categories: Vec<::models::Category>) -> MonthDetail { + pub fn new(month: String, income: i64, budgeted: i64, activity: i64, to_be_budgeted: i64, deleted: bool, categories: Vec<::models::Category>) -> MonthDetail { MonthDetail { month: month, - note: note, + note: None, income: income, budgeted: budgeted, activity: activity, to_be_budgeted: to_be_budgeted, - age_of_money: age_of_money, + age_of_money: None, deleted: deleted, categories: categories, } diff --git a/ynab-api/src/models/month_summary.rs b/ynab-api/src/models/month_summary.rs index c7e980a..3c705d3 100644 --- a/ynab-api/src/models/month_summary.rs +++ b/ynab-api/src/models/month_summary.rs @@ -17,8 +17,8 @@ use serde_json::Value; pub struct MonthSummary { #[serde(rename = "month")] pub month: String, - #[serde(rename = "note")] - pub note: String, + #[serde(rename = "note", skip_serializing_if = "Option::is_none")] + pub note: Option, /// The total amount in transactions categorized to 'Inflow: To be Budgeted' in the month #[serde(rename = "income")] pub income: i64, @@ -32,23 +32,23 @@ pub struct MonthSummary { #[serde(rename = "to_be_budgeted")] pub to_be_budgeted: i64, /// The Age of Money as of the month - #[serde(rename = "age_of_money")] - pub age_of_money: i32, + #[serde(rename = "age_of_money", skip_serializing_if = "Option::is_none")] + pub age_of_money: Option, /// Whether or not the month has been deleted. Deleted months will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl MonthSummary { - pub fn new(month: String, note: String, income: i64, budgeted: i64, activity: i64, to_be_budgeted: i64, age_of_money: i32, deleted: bool) -> MonthSummary { + pub fn new(month: String, income: i64, budgeted: i64, activity: i64, to_be_budgeted: i64, deleted: bool) -> MonthSummary { MonthSummary { month: month, - note: note, + note: None, income: income, budgeted: budgeted, activity: activity, to_be_budgeted: to_be_budgeted, - age_of_money: age_of_money, + age_of_money: None, deleted: deleted, } } diff --git a/ynab-api/src/models/payee.rs b/ynab-api/src/models/payee.rs index 2508b31..13ad103 100644 --- a/ynab-api/src/models/payee.rs +++ b/ynab-api/src/models/payee.rs @@ -20,19 +20,19 @@ pub struct Payee { #[serde(rename = "name")] pub name: String, /// If a transfer payee, the account_id to which this payee transfers to - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// Whether or not the payee has been deleted. Deleted payees will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl Payee { - pub fn new(id: String, name: String, transfer_account_id: String, deleted: bool) -> Payee { + pub fn new(id: String, name: String, deleted: bool) -> Payee { Payee { id: id, name: name, - transfer_account_id: transfer_account_id, + transfer_account_id: None, deleted: deleted, } } diff --git a/ynab-api/src/models/scheduled_sub_transaction.rs b/ynab-api/src/models/scheduled_sub_transaction.rs index 760fa78..dfc0aca 100644 --- a/ynab-api/src/models/scheduled_sub_transaction.rs +++ b/ynab-api/src/models/scheduled_sub_transaction.rs @@ -22,30 +22,30 @@ pub struct ScheduledSubTransaction { /// The scheduled subtransaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, - #[serde(rename = "payee_id")] - pub payee_id: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, #[serde(rename = "category_id")] pub category_id: String, /// If a transfer, the account_id which the scheduled subtransaction transfers to - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// Whether or not the scheduled subtransaction has been deleted. Deleted scheduled subtransactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl ScheduledSubTransaction { - pub fn new(id: String, scheduled_transaction_id: String, amount: i64, memo: String, payee_id: String, category_id: String, transfer_account_id: String, deleted: bool) -> ScheduledSubTransaction { + pub fn new(id: String, scheduled_transaction_id: String, amount: i64, category_id: String, deleted: bool) -> ScheduledSubTransaction { ScheduledSubTransaction { id: id, scheduled_transaction_id: scheduled_transaction_id, amount: amount, - memo: memo, - payee_id: payee_id, + memo: None, + payee_id: None, category_id: category_id, - transfer_account_id: transfer_account_id, + transfer_account_id: None, deleted: deleted, } } diff --git a/ynab-api/src/models/scheduled_transaction_detail.rs b/ynab-api/src/models/scheduled_transaction_detail.rs index 65c2473..d86ef25 100644 --- a/ynab-api/src/models/scheduled_transaction_detail.rs +++ b/ynab-api/src/models/scheduled_transaction_detail.rs @@ -28,20 +28,20 @@ pub struct ScheduledTransactionDetail { /// The scheduled transaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, /// The scheduled transaction flag #[serde(rename = "flag_color")] pub flag_color: String, #[serde(rename = "account_id")] pub account_id: String, - #[serde(rename = "payee_id")] - pub payee_id: String, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, #[serde(rename = "category_id")] pub category_id: String, /// If a transfer, the account_id which the scheduled transaction transfers to - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// Whether or not the scheduled transaction has been deleted. Deleted scheduled transactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, @@ -57,19 +57,19 @@ pub struct ScheduledTransactionDetail { } impl ScheduledTransactionDetail { - pub fn new(id: String, date_first: String, date_next: String, frequency: String, amount: i64, memo: String, flag_color: String, account_id: String, payee_id: String, category_id: String, transfer_account_id: String, deleted: bool, account_name: String, payee_name: String, category_name: String, subtransactions: Vec<::models::ScheduledSubTransaction>) -> ScheduledTransactionDetail { + pub fn new(id: String, date_first: String, date_next: String, frequency: String, amount: i64, flag_color: String, account_id: String, category_id: String, deleted: bool, account_name: String, payee_name: String, category_name: String, subtransactions: Vec<::models::ScheduledSubTransaction>) -> ScheduledTransactionDetail { ScheduledTransactionDetail { id: id, date_first: date_first, date_next: date_next, frequency: frequency, amount: amount, - memo: memo, + memo: None, flag_color: flag_color, account_id: account_id, - payee_id: payee_id, + payee_id: None, category_id: category_id, - transfer_account_id: transfer_account_id, + transfer_account_id: None, deleted: deleted, account_name: account_name, payee_name: payee_name, diff --git a/ynab-api/src/models/scheduled_transaction_summary.rs b/ynab-api/src/models/scheduled_transaction_summary.rs index dfd6f1f..7966d2c 100644 --- a/ynab-api/src/models/scheduled_transaction_summary.rs +++ b/ynab-api/src/models/scheduled_transaction_summary.rs @@ -28,39 +28,39 @@ pub struct ScheduledTransactionSummary { /// The scheduled transaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, /// The scheduled transaction flag #[serde(rename = "flag_color")] pub flag_color: String, #[serde(rename = "account_id")] pub account_id: String, - #[serde(rename = "payee_id")] - pub payee_id: String, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, #[serde(rename = "category_id")] pub category_id: String, /// If a transfer, the account_id which the scheduled transaction transfers to - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// Whether or not the scheduled transaction has been deleted. Deleted scheduled transactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl ScheduledTransactionSummary { - pub fn new(id: String, date_first: String, date_next: String, frequency: String, amount: i64, memo: String, flag_color: String, account_id: String, payee_id: String, category_id: String, transfer_account_id: String, deleted: bool) -> ScheduledTransactionSummary { + pub fn new(id: String, date_first: String, date_next: String, frequency: String, amount: i64, flag_color: String, account_id: String, category_id: String, deleted: bool) -> ScheduledTransactionSummary { ScheduledTransactionSummary { id: id, date_first: date_first, date_next: date_next, frequency: frequency, amount: amount, - memo: memo, + memo: None, flag_color: flag_color, account_id: account_id, - payee_id: payee_id, + payee_id: None, category_id: category_id, - transfer_account_id: transfer_account_id, + transfer_account_id: None, deleted: deleted, } } diff --git a/ynab-api/src/models/sub_transaction.rs b/ynab-api/src/models/sub_transaction.rs index aa7ed37..633ae38 100644 --- a/ynab-api/src/models/sub_transaction.rs +++ b/ynab-api/src/models/sub_transaction.rs @@ -22,30 +22,30 @@ pub struct SubTransaction { /// The subtransaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, - #[serde(rename = "payee_id")] - pub payee_id: String, - #[serde(rename = "category_id")] - pub category_id: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, + #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")] + pub category_id: Option, /// If a transfer, the account_id which the subtransaction transfers to - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// Whether or not the subtransaction has been deleted. Deleted subtransactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl SubTransaction { - pub fn new(id: String, transaction_id: String, amount: i64, memo: String, payee_id: String, category_id: String, transfer_account_id: String, deleted: bool) -> SubTransaction { + pub fn new(id: String, transaction_id: String, amount: i64, deleted: bool) -> SubTransaction { SubTransaction { id: id, transaction_id: transaction_id, amount: amount, - memo: memo, - payee_id: payee_id, - category_id: category_id, - transfer_account_id: transfer_account_id, + memo: None, + payee_id: None, + category_id: None, + transfer_account_id: None, deleted: deleted, } } diff --git a/ynab-api/src/models/transaction_detail.rs b/ynab-api/src/models/transaction_detail.rs index 1558c7c..361813b 100644 --- a/ynab-api/src/models/transaction_detail.rs +++ b/ynab-api/src/models/transaction_detail.rs @@ -23,8 +23,8 @@ pub struct TransactionDetail { /// The transaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, /// The cleared status of the transaction #[serde(rename = "cleared")] pub cleared: String, @@ -32,26 +32,26 @@ pub struct TransactionDetail { #[serde(rename = "approved")] pub approved: bool, /// The transaction flag - #[serde(rename = "flag_color")] - pub flag_color: String, + #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")] + pub flag_color: Option, #[serde(rename = "account_id")] pub account_id: String, - #[serde(rename = "payee_id")] - pub payee_id: String, - #[serde(rename = "category_id")] - pub category_id: String, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, + #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")] + pub category_id: Option, /// If a transfer transaction, the account to which it transfers - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// If a transfer transaction, the id of transaction on the other side of the transfer - #[serde(rename = "transfer_transaction_id")] - pub transfer_transaction_id: String, + #[serde(rename = "transfer_transaction_id", skip_serializing_if = "Option::is_none")] + pub transfer_transaction_id: Option, /// If transaction is matched, the id of the matched transaction - #[serde(rename = "matched_transaction_id")] - pub matched_transaction_id: String, + #[serde(rename = "matched_transaction_id", skip_serializing_if = "Option::is_none")] + pub matched_transaction_id: Option, /// If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. - #[serde(rename = "import_id")] - pub import_id: String, + #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")] + pub import_id: Option, /// Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, @@ -67,22 +67,22 @@ pub struct TransactionDetail { } impl TransactionDetail { - pub fn new(id: String, date: String, amount: i64, memo: String, cleared: String, approved: bool, flag_color: String, account_id: String, payee_id: String, category_id: String, transfer_account_id: String, transfer_transaction_id: String, matched_transaction_id: String, import_id: String, deleted: bool, account_name: String, payee_name: String, category_name: String, subtransactions: Vec<::models::SubTransaction>) -> TransactionDetail { + pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool, account_name: String, payee_name: String, category_name: String, subtransactions: Vec<::models::SubTransaction>) -> TransactionDetail { TransactionDetail { id: id, date: date, amount: amount, - memo: memo, + memo: None, cleared: cleared, approved: approved, - flag_color: flag_color, + flag_color: None, account_id: account_id, - payee_id: payee_id, - category_id: category_id, - transfer_account_id: transfer_account_id, - transfer_transaction_id: transfer_transaction_id, - matched_transaction_id: matched_transaction_id, - import_id: import_id, + payee_id: None, + category_id: None, + transfer_account_id: None, + transfer_transaction_id: None, + matched_transaction_id: None, + import_id: None, deleted: deleted, account_name: account_name, payee_name: payee_name, diff --git a/ynab-api/src/models/transaction_summary.rs b/ynab-api/src/models/transaction_summary.rs index 31ef1c5..94ce164 100644 --- a/ynab-api/src/models/transaction_summary.rs +++ b/ynab-api/src/models/transaction_summary.rs @@ -23,8 +23,8 @@ pub struct TransactionSummary { /// The transaction amount in milliunits format #[serde(rename = "amount")] pub amount: i64, - #[serde(rename = "memo")] - pub memo: String, + #[serde(rename = "memo", skip_serializing_if = "Option::is_none")] + pub memo: Option, /// The cleared status of the transaction #[serde(rename = "cleared")] pub cleared: String, @@ -32,48 +32,48 @@ pub struct TransactionSummary { #[serde(rename = "approved")] pub approved: bool, /// The transaction flag - #[serde(rename = "flag_color")] - pub flag_color: String, + #[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")] + pub flag_color: Option, #[serde(rename = "account_id")] pub account_id: String, - #[serde(rename = "payee_id")] - pub payee_id: String, - #[serde(rename = "category_id")] - pub category_id: String, + #[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")] + pub payee_id: Option, + #[serde(rename = "category_id", skip_serializing_if = "Option::is_none")] + pub category_id: Option, /// If a transfer transaction, the account to which it transfers - #[serde(rename = "transfer_account_id")] - pub transfer_account_id: String, + #[serde(rename = "transfer_account_id", skip_serializing_if = "Option::is_none")] + pub transfer_account_id: Option, /// If a transfer transaction, the id of transaction on the other side of the transfer - #[serde(rename = "transfer_transaction_id")] - pub transfer_transaction_id: String, + #[serde(rename = "transfer_transaction_id", skip_serializing_if = "Option::is_none")] + pub transfer_transaction_id: Option, /// If transaction is matched, the id of the matched transaction - #[serde(rename = "matched_transaction_id")] - pub matched_transaction_id: String, + #[serde(rename = "matched_transaction_id", skip_serializing_if = "Option::is_none")] + pub matched_transaction_id: Option, /// If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. - #[serde(rename = "import_id")] - pub import_id: String, + #[serde(rename = "import_id", skip_serializing_if = "Option::is_none")] + pub import_id: Option, /// Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests. #[serde(rename = "deleted")] pub deleted: bool, } impl TransactionSummary { - pub fn new(id: String, date: String, amount: i64, memo: String, cleared: String, approved: bool, flag_color: String, account_id: String, payee_id: String, category_id: String, transfer_account_id: String, transfer_transaction_id: String, matched_transaction_id: String, import_id: String, deleted: bool) -> TransactionSummary { + pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool) -> TransactionSummary { TransactionSummary { id: id, date: date, amount: amount, - memo: memo, + memo: None, cleared: cleared, approved: approved, - flag_color: flag_color, + flag_color: None, account_id: account_id, - payee_id: payee_id, - category_id: category_id, - transfer_account_id: transfer_account_id, - transfer_transaction_id: transfer_transaction_id, - matched_transaction_id: matched_transaction_id, - import_id: import_id, + payee_id: None, + category_id: None, + transfer_account_id: None, + transfer_transaction_id: None, + matched_transaction_id: None, + import_id: None, deleted: deleted, } } -- cgit v1.2.3-54-g00ecf