ynab-cli 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ynab_cli/__init__.py +0 -0
- ynab_cli/adapters/__init__.py +0 -0
- ynab_cli/adapters/rich/__init__.py +0 -0
- ynab_cli/adapters/rich/io.py +38 -0
- ynab_cli/adapters/textual/__init__.py +0 -0
- ynab_cli/adapters/textual/io.py +62 -0
- ynab_cli/adapters/ynab/__init__.py +8 -0
- ynab_cli/adapters/ynab/api/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/accounts/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/accounts/create_account.py +186 -0
- ynab_cli/adapters/ynab/api/accounts/get_account_by_id.py +177 -0
- ynab_cli/adapters/ynab/api/accounts/get_accounts.py +184 -0
- ynab_cli/adapters/ynab/api/budgets/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/budgets/get_budget_by_id.py +188 -0
- ynab_cli/adapters/ynab/api/budgets/get_budget_settings_by_id.py +163 -0
- ynab_cli/adapters/ynab/api/budgets/get_budgets.py +171 -0
- ynab_cli/adapters/ynab/api/categories/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/categories/get_categories.py +188 -0
- ynab_cli/adapters/ynab/api/categories/get_category_by_id.py +180 -0
- ynab_cli/adapters/ynab/api/categories/get_month_category_by_id.py +194 -0
- ynab_cli/adapters/ynab/api/categories/update_category.py +199 -0
- ynab_cli/adapters/ynab/api/categories/update_month_category.py +213 -0
- ynab_cli/adapters/ynab/api/months/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/months/get_budget_month.py +177 -0
- ynab_cli/adapters/ynab/api/months/get_budget_months.py +184 -0
- ynab_cli/adapters/ynab/api/payee_locations/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/payee_locations/get_payee_location_by_id.py +176 -0
- ynab_cli/adapters/ynab/api/payee_locations/get_payee_locations.py +163 -0
- ynab_cli/adapters/ynab/api/payee_locations/get_payee_locations_by_payee.py +176 -0
- ynab_cli/adapters/ynab/api/payees/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/payees/get_payee_by_id.py +176 -0
- ynab_cli/adapters/ynab/api/payees/get_payees.py +184 -0
- ynab_cli/adapters/ynab/api/payees/update_payee.py +199 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/create_scheduled_transaction.py +186 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/delete_scheduled_transaction.py +176 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/get_scheduled_transaction_by_id.py +176 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/get_scheduled_transactions.py +184 -0
- ynab_cli/adapters/ynab/api/scheduled_transactions/update_scheduled_transaction.py +199 -0
- ynab_cli/adapters/ynab/api/transactions/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/transactions/create_transaction.py +202 -0
- ynab_cli/adapters/ynab/api/transactions/delete_transaction.py +176 -0
- ynab_cli/adapters/ynab/api/transactions/get_transaction_by_id.py +176 -0
- ynab_cli/adapters/ynab/api/transactions/get_transactions.py +227 -0
- ynab_cli/adapters/ynab/api/transactions/get_transactions_by_account.py +236 -0
- ynab_cli/adapters/ynab/api/transactions/get_transactions_by_category.py +236 -0
- ynab_cli/adapters/ynab/api/transactions/get_transactions_by_month.py +236 -0
- ynab_cli/adapters/ynab/api/transactions/get_transactions_by_payee.py +236 -0
- ynab_cli/adapters/ynab/api/transactions/import_transactions.py +183 -0
- ynab_cli/adapters/ynab/api/transactions/update_transaction.py +199 -0
- ynab_cli/adapters/ynab/api/transactions/update_transactions.py +177 -0
- ynab_cli/adapters/ynab/api/user/__init__.py +1 -0
- ynab_cli/adapters/ynab/api/user/get_user.py +130 -0
- ynab_cli/adapters/ynab/client.py +268 -0
- ynab_cli/adapters/ynab/errors.py +16 -0
- ynab_cli/adapters/ynab/models/__init__.py +229 -0
- ynab_cli/adapters/ynab/models/account.py +345 -0
- ynab_cli/adapters/ynab/models/account_response.py +65 -0
- ynab_cli/adapters/ynab/models/account_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/account_type.py +23 -0
- ynab_cli/adapters/ynab/models/accounts_response.py +65 -0
- ynab_cli/adapters/ynab/models/accounts_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/budget_detail.py +405 -0
- ynab_cli/adapters/ynab/models/budget_detail_response.py +65 -0
- ynab_cli/adapters/ynab/models/budget_detail_response_data.py +73 -0
- ynab_cli/adapters/ynab/models/budget_settings.py +115 -0
- ynab_cli/adapters/ynab/models/budget_settings_response.py +65 -0
- ynab_cli/adapters/ynab/models/budget_settings_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/budget_summary.py +216 -0
- ynab_cli/adapters/ynab/models/budget_summary_response.py +65 -0
- ynab_cli/adapters/ynab/models/budget_summary_response_data.py +91 -0
- ynab_cli/adapters/ynab/models/bulk_response.py +65 -0
- ynab_cli/adapters/ynab/models/bulk_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/bulk_response_data_bulk.py +68 -0
- ynab_cli/adapters/ynab/models/bulk_transactions.py +75 -0
- ynab_cli/adapters/ynab/models/categories_response.py +65 -0
- ynab_cli/adapters/ynab/models/categories_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/category.py +519 -0
- ynab_cli/adapters/ynab/models/category_goal_type_type_1.py +15 -0
- ynab_cli/adapters/ynab/models/category_goal_type_type_2_type_1.py +15 -0
- ynab_cli/adapters/ynab/models/category_goal_type_type_3_type_1.py +15 -0
- ynab_cli/adapters/ynab/models/category_group.py +85 -0
- ynab_cli/adapters/ynab/models/category_group_with_categories.py +108 -0
- ynab_cli/adapters/ynab/models/category_response.py +65 -0
- ynab_cli/adapters/ynab/models/category_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/currency_format_type_0.py +117 -0
- ynab_cli/adapters/ynab/models/date_format_type_0.py +61 -0
- ynab_cli/adapters/ynab/models/error_detail.py +75 -0
- ynab_cli/adapters/ynab/models/error_response.py +65 -0
- ynab_cli/adapters/ynab/models/existing_transaction.py +322 -0
- ynab_cli/adapters/ynab/models/get_transactions_by_account_type.py +12 -0
- ynab_cli/adapters/ynab/models/get_transactions_by_category_type.py +12 -0
- ynab_cli/adapters/ynab/models/get_transactions_by_month_type.py +12 -0
- ynab_cli/adapters/ynab/models/get_transactions_by_payee_type.py +12 -0
- ynab_cli/adapters/ynab/models/get_transactions_type.py +12 -0
- ynab_cli/adapters/ynab/models/hybrid_transaction.py +567 -0
- ynab_cli/adapters/ynab/models/hybrid_transaction_type.py +12 -0
- ynab_cli/adapters/ynab/models/hybrid_transactions_response.py +65 -0
- ynab_cli/adapters/ynab/models/hybrid_transactions_response_data.py +84 -0
- ynab_cli/adapters/ynab/models/loan_account_periodic_value_type_0.py +44 -0
- ynab_cli/adapters/ynab/models/month_detail.py +168 -0
- ynab_cli/adapters/ynab/models/month_detail_response.py +65 -0
- ynab_cli/adapters/ynab/models/month_detail_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/month_summaries_response.py +65 -0
- ynab_cli/adapters/ynab/models/month_summaries_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/month_summary.py +145 -0
- ynab_cli/adapters/ynab/models/new_transaction.py +352 -0
- ynab_cli/adapters/ynab/models/patch_category_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/patch_month_category_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/patch_payee_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/patch_transactions_wrapper.py +73 -0
- ynab_cli/adapters/ynab/models/payee.py +100 -0
- ynab_cli/adapters/ynab/models/payee_location.py +93 -0
- ynab_cli/adapters/ynab/models/payee_location_response.py +65 -0
- ynab_cli/adapters/ynab/models/payee_location_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/payee_locations_response.py +65 -0
- ynab_cli/adapters/ynab/models/payee_locations_response_data.py +73 -0
- ynab_cli/adapters/ynab/models/payee_response.py +65 -0
- ynab_cli/adapters/ynab/models/payee_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/payees_response.py +65 -0
- ynab_cli/adapters/ynab/models/payees_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/post_account_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/post_scheduled_transaction_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/post_transactions_wrapper.py +91 -0
- ynab_cli/adapters/ynab/models/put_scheduled_transaction_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/put_transaction_wrapper.py +65 -0
- ynab_cli/adapters/ynab/models/save_account.py +77 -0
- ynab_cli/adapters/ynab/models/save_category.py +129 -0
- ynab_cli/adapters/ynab/models/save_category_response.py +65 -0
- ynab_cli/adapters/ynab/models/save_category_response_data.py +73 -0
- ynab_cli/adapters/ynab/models/save_month_category.py +59 -0
- ynab_cli/adapters/ynab/models/save_payee.py +59 -0
- ynab_cli/adapters/ynab/models/save_payee_response.py +65 -0
- ynab_cli/adapters/ynab/models/save_payee_response_data.py +73 -0
- ynab_cli/adapters/ynab/models/save_scheduled_transaction.py +269 -0
- ynab_cli/adapters/ynab/models/save_sub_transaction.py +166 -0
- ynab_cli/adapters/ynab/models/save_transaction_with_id_or_import_id.py +366 -0
- ynab_cli/adapters/ynab/models/save_transaction_with_optional_fields.py +322 -0
- ynab_cli/adapters/ynab/models/save_transactions_response.py +65 -0
- ynab_cli/adapters/ynab/models/save_transactions_response_data.py +123 -0
- ynab_cli/adapters/ynab/models/scheduled_sub_transaction.py +238 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_detail.py +381 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_frequency.py +23 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_response.py +65 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_summary.py +310 -0
- ynab_cli/adapters/ynab/models/scheduled_transaction_summary_frequency.py +23 -0
- ynab_cli/adapters/ynab/models/scheduled_transactions_response.py +65 -0
- ynab_cli/adapters/ynab/models/scheduled_transactions_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/sub_transaction.py +259 -0
- ynab_cli/adapters/ynab/models/transaction_cleared_status.py +13 -0
- ynab_cli/adapters/ynab/models/transaction_detail.py +570 -0
- ynab_cli/adapters/ynab/models/transaction_flag_color_type_1.py +16 -0
- ynab_cli/adapters/ynab/models/transaction_flag_color_type_2_type_1.py +16 -0
- ynab_cli/adapters/ynab/models/transaction_flag_color_type_3_type_1.py +16 -0
- ynab_cli/adapters/ynab/models/transaction_response.py +65 -0
- ynab_cli/adapters/ynab/models/transaction_response_data.py +65 -0
- ynab_cli/adapters/ynab/models/transaction_summary.py +499 -0
- ynab_cli/adapters/ynab/models/transaction_summary_debt_transaction_type_type_1.py +18 -0
- ynab_cli/adapters/ynab/models/transaction_summary_debt_transaction_type_type_2_type_1.py +18 -0
- ynab_cli/adapters/ynab/models/transaction_summary_debt_transaction_type_type_3_type_1.py +18 -0
- ynab_cli/adapters/ynab/models/transactions_import_response.py +65 -0
- ynab_cli/adapters/ynab/models/transactions_import_response_data.py +59 -0
- ynab_cli/adapters/ynab/models/transactions_response.py +65 -0
- ynab_cli/adapters/ynab/models/transactions_response_data.py +81 -0
- ynab_cli/adapters/ynab/models/user.py +60 -0
- ynab_cli/adapters/ynab/models/user_response.py +65 -0
- ynab_cli/adapters/ynab/models/user_response_data.py +65 -0
- ynab_cli/adapters/ynab/types.py +46 -0
- ynab_cli/adapters/ynab/util.py +78 -0
- ynab_cli/domain/__init__.py +0 -0
- ynab_cli/domain/constants.py +3 -0
- ynab_cli/domain/models/__init__.py +0 -0
- ynab_cli/domain/models/rules.py +37 -0
- ynab_cli/domain/ports/__init__.py +5 -0
- ynab_cli/domain/ports/io.py +63 -0
- ynab_cli/domain/settings.py +16 -0
- ynab_cli/domain/use_cases/__init__.py +0 -0
- ynab_cli/domain/use_cases/categories.py +105 -0
- ynab_cli/domain/use_cases/payees.py +232 -0
- ynab_cli/domain/use_cases/transactions.py +93 -0
- ynab_cli/host/__init__.py +14 -0
- ynab_cli/host/cli.py +37 -0
- ynab_cli/host/click/__init__.py +0 -0
- ynab_cli/host/click/cli.py +44 -0
- ynab_cli/host/click/commands/__init__.py +0 -0
- ynab_cli/host/click/commands/categories.py +92 -0
- ynab_cli/host/click/commands/payees.py +157 -0
- ynab_cli/host/click/commands/rich/__init__.py +0 -0
- ynab_cli/host/click/commands/rich/progress_table.py +37 -0
- ynab_cli/host/click/commands/transactions.py +76 -0
- ynab_cli/host/constants.py +3 -0
- ynab_cli/host/textual/__init__.py +0 -0
- ynab_cli/host/textual/app.py +98 -0
- ynab_cli/host/textual/app.tcss +47 -0
- ynab_cli/host/textual/cli.py +42 -0
- ynab_cli/host/textual/widgets/__init__.py +58 -0
- ynab_cli/host/textual/widgets/categories.py +90 -0
- ynab_cli/host/textual/widgets/payees.py +154 -0
- ynab_cli/host/textual/widgets/transactions.py +89 -0
- ynab_cli/py.typed +0 -0
- ynab_cli-0.3.0.dist-info/METADATA +102 -0
- ynab_cli-0.3.0.dist-info/RECORD +206 -0
- ynab_cli-0.3.0.dist-info/WHEEL +4 -0
- ynab_cli-0.3.0.dist-info/entry_points.txt +2 -0
- ynab_cli-0.3.0.dist-info/licenses/LICENSE.md +21 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
from dateutil.parser import isoparse
|
|
9
|
+
|
|
10
|
+
from ynab_cli.adapters.ynab.models.transaction_cleared_status import TransactionClearedStatus
|
|
11
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_1 import TransactionFlagColorType1
|
|
12
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_2_type_1 import TransactionFlagColorType2Type1
|
|
13
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_3_type_1 import TransactionFlagColorType3Type1
|
|
14
|
+
from ynab_cli.adapters.ynab.types import UNSET, Unset
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from ynab_cli.adapters.ynab.models.save_sub_transaction import SaveSubTransaction
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
T = TypeVar("T", bound="SaveTransactionWithIdOrImportId")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@_attrs_define
|
|
24
|
+
class SaveTransactionWithIdOrImportId:
|
|
25
|
+
"""
|
|
26
|
+
Attributes:
|
|
27
|
+
account_id (Union[Unset, UUID]):
|
|
28
|
+
date (Union[Unset, datetime.date]): The transaction date in ISO format (e.g. 2016-12-01). Future dates
|
|
29
|
+
(scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date
|
|
30
|
+
is supplied it will be ignored.
|
|
31
|
+
amount (Union[Unset, int]): The transaction amount in milliunits format. Split transaction amounts cannot be
|
|
32
|
+
changed and if a different amount is supplied it will be ignored.
|
|
33
|
+
payee_id (Union[None, UUID, Unset]): The payee for the transaction. To create a transfer between two accounts,
|
|
34
|
+
use the account transfer payee pointing to the target account. Account transfer payees are specified as
|
|
35
|
+
`transfer_payee_id` on the account resource.
|
|
36
|
+
payee_name (Union[None, Unset, str]): The payee name. If a `payee_name` value is provided and `payee_id` has a
|
|
37
|
+
null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule
|
|
38
|
+
(only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee.
|
|
39
|
+
category_id (Union[None, UUID, Unset]): The category for the transaction. To configure a split transaction, you
|
|
40
|
+
can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If
|
|
41
|
+
an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not
|
|
42
|
+
permitted and will be ignored if supplied.
|
|
43
|
+
memo (Union[None, Unset, str]):
|
|
44
|
+
cleared (Union[Unset, TransactionClearedStatus]): The cleared status of the transaction
|
|
45
|
+
approved (Union[Unset, bool]): Whether or not the transaction is approved. If not supplied, transaction will be
|
|
46
|
+
unapproved by default.
|
|
47
|
+
flag_color (Union[None, TransactionFlagColorType1, TransactionFlagColorType2Type1,
|
|
48
|
+
TransactionFlagColorType3Type1, Unset]): The transaction flag
|
|
49
|
+
subtransactions (Union[Unset, list['SaveSubTransaction']]): An array of subtransactions to configure a
|
|
50
|
+
transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
|
|
51
|
+
id (Union[None, Unset, str]): If specified, this id will be used to lookup a transaction by its `id` for the
|
|
52
|
+
purpose of updating the transaction itself. If not specified, an `import_id` should be supplied.
|
|
53
|
+
import_id (Union[None, Unset, str]): If specified, this id will be used to lookup a transaction by its
|
|
54
|
+
`import_id` for the purpose of updating the transaction itself. If not specified, an `id` should be supplied.
|
|
55
|
+
You may not provide both an `id` and an `import_id` and updating an `import_id` on an existing transaction is
|
|
56
|
+
not allowed.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
account_id: Unset | UUID = UNSET
|
|
60
|
+
date: Unset | datetime.date = UNSET
|
|
61
|
+
amount: Unset | int = UNSET
|
|
62
|
+
payee_id: None | UUID | Unset = UNSET
|
|
63
|
+
payee_name: None | Unset | str = UNSET
|
|
64
|
+
category_id: None | UUID | Unset = UNSET
|
|
65
|
+
memo: None | Unset | str = UNSET
|
|
66
|
+
cleared: Unset | TransactionClearedStatus = UNSET
|
|
67
|
+
approved: Unset | bool = UNSET
|
|
68
|
+
flag_color: (
|
|
69
|
+
None | TransactionFlagColorType1 | TransactionFlagColorType2Type1 | TransactionFlagColorType3Type1 | Unset
|
|
70
|
+
) = UNSET
|
|
71
|
+
subtransactions: Unset | list["SaveSubTransaction"] = UNSET
|
|
72
|
+
id: None | Unset | str = UNSET
|
|
73
|
+
import_id: None | Unset | str = UNSET
|
|
74
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
75
|
+
|
|
76
|
+
def to_dict(self) -> dict[str, Any]:
|
|
77
|
+
account_id: Unset | str = UNSET
|
|
78
|
+
if not isinstance(self.account_id, Unset):
|
|
79
|
+
account_id = str(self.account_id)
|
|
80
|
+
|
|
81
|
+
date: Unset | str = UNSET
|
|
82
|
+
if not isinstance(self.date, Unset):
|
|
83
|
+
date = self.date.isoformat()
|
|
84
|
+
|
|
85
|
+
amount = self.amount
|
|
86
|
+
|
|
87
|
+
payee_id: None | Unset | str
|
|
88
|
+
if isinstance(self.payee_id, Unset):
|
|
89
|
+
payee_id = UNSET
|
|
90
|
+
elif isinstance(self.payee_id, UUID):
|
|
91
|
+
payee_id = str(self.payee_id)
|
|
92
|
+
else:
|
|
93
|
+
payee_id = self.payee_id
|
|
94
|
+
|
|
95
|
+
payee_name: None | Unset | str
|
|
96
|
+
if isinstance(self.payee_name, Unset):
|
|
97
|
+
payee_name = UNSET
|
|
98
|
+
else:
|
|
99
|
+
payee_name = self.payee_name
|
|
100
|
+
|
|
101
|
+
category_id: None | Unset | str
|
|
102
|
+
if isinstance(self.category_id, Unset):
|
|
103
|
+
category_id = UNSET
|
|
104
|
+
elif isinstance(self.category_id, UUID):
|
|
105
|
+
category_id = str(self.category_id)
|
|
106
|
+
else:
|
|
107
|
+
category_id = self.category_id
|
|
108
|
+
|
|
109
|
+
memo: None | Unset | str
|
|
110
|
+
if isinstance(self.memo, Unset):
|
|
111
|
+
memo = UNSET
|
|
112
|
+
else:
|
|
113
|
+
memo = self.memo
|
|
114
|
+
|
|
115
|
+
cleared: Unset | str = UNSET
|
|
116
|
+
if not isinstance(self.cleared, Unset):
|
|
117
|
+
cleared = self.cleared.value
|
|
118
|
+
|
|
119
|
+
approved = self.approved
|
|
120
|
+
|
|
121
|
+
flag_color: None | Unset | str
|
|
122
|
+
if isinstance(self.flag_color, Unset):
|
|
123
|
+
flag_color = UNSET
|
|
124
|
+
elif isinstance(self.flag_color, TransactionFlagColorType1):
|
|
125
|
+
flag_color = self.flag_color.value
|
|
126
|
+
elif isinstance(self.flag_color, TransactionFlagColorType2Type1):
|
|
127
|
+
flag_color = self.flag_color.value
|
|
128
|
+
elif isinstance(self.flag_color, TransactionFlagColorType3Type1):
|
|
129
|
+
flag_color = self.flag_color.value
|
|
130
|
+
else:
|
|
131
|
+
flag_color = self.flag_color
|
|
132
|
+
|
|
133
|
+
subtransactions: Unset | list[dict[str, Any]] = UNSET
|
|
134
|
+
if not isinstance(self.subtransactions, Unset):
|
|
135
|
+
subtransactions = []
|
|
136
|
+
for subtransactions_item_data in self.subtransactions:
|
|
137
|
+
subtransactions_item = subtransactions_item_data.to_dict()
|
|
138
|
+
subtransactions.append(subtransactions_item)
|
|
139
|
+
|
|
140
|
+
id: None | Unset | str
|
|
141
|
+
if isinstance(self.id, Unset):
|
|
142
|
+
id = UNSET
|
|
143
|
+
else:
|
|
144
|
+
id = self.id
|
|
145
|
+
|
|
146
|
+
import_id: None | Unset | str
|
|
147
|
+
if isinstance(self.import_id, Unset):
|
|
148
|
+
import_id = UNSET
|
|
149
|
+
else:
|
|
150
|
+
import_id = self.import_id
|
|
151
|
+
|
|
152
|
+
field_dict: dict[str, Any] = {}
|
|
153
|
+
field_dict.update(self.additional_properties)
|
|
154
|
+
field_dict.update({})
|
|
155
|
+
if account_id is not UNSET:
|
|
156
|
+
field_dict["account_id"] = account_id
|
|
157
|
+
if date is not UNSET:
|
|
158
|
+
field_dict["date"] = date
|
|
159
|
+
if amount is not UNSET:
|
|
160
|
+
field_dict["amount"] = amount
|
|
161
|
+
if payee_id is not UNSET:
|
|
162
|
+
field_dict["payee_id"] = payee_id
|
|
163
|
+
if payee_name is not UNSET:
|
|
164
|
+
field_dict["payee_name"] = payee_name
|
|
165
|
+
if category_id is not UNSET:
|
|
166
|
+
field_dict["category_id"] = category_id
|
|
167
|
+
if memo is not UNSET:
|
|
168
|
+
field_dict["memo"] = memo
|
|
169
|
+
if cleared is not UNSET:
|
|
170
|
+
field_dict["cleared"] = cleared
|
|
171
|
+
if approved is not UNSET:
|
|
172
|
+
field_dict["approved"] = approved
|
|
173
|
+
if flag_color is not UNSET:
|
|
174
|
+
field_dict["flag_color"] = flag_color
|
|
175
|
+
if subtransactions is not UNSET:
|
|
176
|
+
field_dict["subtransactions"] = subtransactions
|
|
177
|
+
if id is not UNSET:
|
|
178
|
+
field_dict["id"] = id
|
|
179
|
+
if import_id is not UNSET:
|
|
180
|
+
field_dict["import_id"] = import_id
|
|
181
|
+
|
|
182
|
+
return field_dict
|
|
183
|
+
|
|
184
|
+
@classmethod
|
|
185
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
186
|
+
from ynab_cli.adapters.ynab.models.save_sub_transaction import SaveSubTransaction
|
|
187
|
+
|
|
188
|
+
d = dict(src_dict)
|
|
189
|
+
_account_id = d.pop("account_id", UNSET)
|
|
190
|
+
account_id: Unset | UUID
|
|
191
|
+
if isinstance(_account_id, Unset):
|
|
192
|
+
account_id = UNSET
|
|
193
|
+
else:
|
|
194
|
+
account_id = UUID(_account_id)
|
|
195
|
+
|
|
196
|
+
_date = d.pop("date", UNSET)
|
|
197
|
+
date: Unset | datetime.date
|
|
198
|
+
if isinstance(_date, Unset):
|
|
199
|
+
date = UNSET
|
|
200
|
+
else:
|
|
201
|
+
date = isoparse(_date).date()
|
|
202
|
+
|
|
203
|
+
amount = d.pop("amount", UNSET)
|
|
204
|
+
|
|
205
|
+
def _parse_payee_id(data: object) -> None | UUID | Unset:
|
|
206
|
+
if data is None:
|
|
207
|
+
return data
|
|
208
|
+
if isinstance(data, Unset):
|
|
209
|
+
return data
|
|
210
|
+
try:
|
|
211
|
+
if not isinstance(data, str):
|
|
212
|
+
raise TypeError()
|
|
213
|
+
payee_id_type_0 = UUID(data)
|
|
214
|
+
|
|
215
|
+
return payee_id_type_0
|
|
216
|
+
except: # noqa: E722
|
|
217
|
+
pass
|
|
218
|
+
return cast(None | UUID | Unset, data)
|
|
219
|
+
|
|
220
|
+
payee_id = _parse_payee_id(d.pop("payee_id", UNSET))
|
|
221
|
+
|
|
222
|
+
def _parse_payee_name(data: object) -> None | Unset | str:
|
|
223
|
+
if data is None:
|
|
224
|
+
return data
|
|
225
|
+
if isinstance(data, Unset):
|
|
226
|
+
return data
|
|
227
|
+
return cast(None | Unset | str, data)
|
|
228
|
+
|
|
229
|
+
payee_name = _parse_payee_name(d.pop("payee_name", UNSET))
|
|
230
|
+
|
|
231
|
+
def _parse_category_id(data: object) -> None | UUID | Unset:
|
|
232
|
+
if data is None:
|
|
233
|
+
return data
|
|
234
|
+
if isinstance(data, Unset):
|
|
235
|
+
return data
|
|
236
|
+
try:
|
|
237
|
+
if not isinstance(data, str):
|
|
238
|
+
raise TypeError()
|
|
239
|
+
category_id_type_0 = UUID(data)
|
|
240
|
+
|
|
241
|
+
return category_id_type_0
|
|
242
|
+
except: # noqa: E722
|
|
243
|
+
pass
|
|
244
|
+
return cast(None | UUID | Unset, data)
|
|
245
|
+
|
|
246
|
+
category_id = _parse_category_id(d.pop("category_id", UNSET))
|
|
247
|
+
|
|
248
|
+
def _parse_memo(data: object) -> None | Unset | str:
|
|
249
|
+
if data is None:
|
|
250
|
+
return data
|
|
251
|
+
if isinstance(data, Unset):
|
|
252
|
+
return data
|
|
253
|
+
return cast(None | Unset | str, data)
|
|
254
|
+
|
|
255
|
+
memo = _parse_memo(d.pop("memo", UNSET))
|
|
256
|
+
|
|
257
|
+
_cleared = d.pop("cleared", UNSET)
|
|
258
|
+
cleared: Unset | TransactionClearedStatus
|
|
259
|
+
if isinstance(_cleared, Unset):
|
|
260
|
+
cleared = UNSET
|
|
261
|
+
else:
|
|
262
|
+
cleared = TransactionClearedStatus(_cleared)
|
|
263
|
+
|
|
264
|
+
approved = d.pop("approved", UNSET)
|
|
265
|
+
|
|
266
|
+
def _parse_flag_color(
|
|
267
|
+
data: object,
|
|
268
|
+
) -> None | TransactionFlagColorType1 | TransactionFlagColorType2Type1 | TransactionFlagColorType3Type1 | Unset:
|
|
269
|
+
if data is None:
|
|
270
|
+
return data
|
|
271
|
+
if isinstance(data, Unset):
|
|
272
|
+
return data
|
|
273
|
+
try:
|
|
274
|
+
if not isinstance(data, str):
|
|
275
|
+
raise TypeError()
|
|
276
|
+
componentsschemas_transaction_flag_color_type_1 = TransactionFlagColorType1(data)
|
|
277
|
+
|
|
278
|
+
return componentsschemas_transaction_flag_color_type_1
|
|
279
|
+
except: # noqa: E722
|
|
280
|
+
pass
|
|
281
|
+
try:
|
|
282
|
+
if not isinstance(data, str):
|
|
283
|
+
raise TypeError()
|
|
284
|
+
componentsschemas_transaction_flag_color_type_2_type_1 = TransactionFlagColorType2Type1(data)
|
|
285
|
+
|
|
286
|
+
return componentsschemas_transaction_flag_color_type_2_type_1
|
|
287
|
+
except: # noqa: E722
|
|
288
|
+
pass
|
|
289
|
+
try:
|
|
290
|
+
if not isinstance(data, str):
|
|
291
|
+
raise TypeError()
|
|
292
|
+
componentsschemas_transaction_flag_color_type_3_type_1 = TransactionFlagColorType3Type1(data)
|
|
293
|
+
|
|
294
|
+
return componentsschemas_transaction_flag_color_type_3_type_1
|
|
295
|
+
except: # noqa: E722
|
|
296
|
+
pass
|
|
297
|
+
return cast(
|
|
298
|
+
None
|
|
299
|
+
| TransactionFlagColorType1
|
|
300
|
+
| TransactionFlagColorType2Type1
|
|
301
|
+
| TransactionFlagColorType3Type1
|
|
302
|
+
| Unset,
|
|
303
|
+
data,
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
flag_color = _parse_flag_color(d.pop("flag_color", UNSET))
|
|
307
|
+
|
|
308
|
+
subtransactions = []
|
|
309
|
+
_subtransactions = d.pop("subtransactions", UNSET)
|
|
310
|
+
for subtransactions_item_data in _subtransactions or []:
|
|
311
|
+
subtransactions_item = SaveSubTransaction.from_dict(subtransactions_item_data)
|
|
312
|
+
|
|
313
|
+
subtransactions.append(subtransactions_item)
|
|
314
|
+
|
|
315
|
+
def _parse_id(data: object) -> None | Unset | str:
|
|
316
|
+
if data is None:
|
|
317
|
+
return data
|
|
318
|
+
if isinstance(data, Unset):
|
|
319
|
+
return data
|
|
320
|
+
return cast(None | Unset | str, data)
|
|
321
|
+
|
|
322
|
+
id = _parse_id(d.pop("id", UNSET))
|
|
323
|
+
|
|
324
|
+
def _parse_import_id(data: object) -> None | Unset | str:
|
|
325
|
+
if data is None:
|
|
326
|
+
return data
|
|
327
|
+
if isinstance(data, Unset):
|
|
328
|
+
return data
|
|
329
|
+
return cast(None | Unset | str, data)
|
|
330
|
+
|
|
331
|
+
import_id = _parse_import_id(d.pop("import_id", UNSET))
|
|
332
|
+
|
|
333
|
+
save_transaction_with_id_or_import_id = cls(
|
|
334
|
+
account_id=account_id,
|
|
335
|
+
date=date,
|
|
336
|
+
amount=amount,
|
|
337
|
+
payee_id=payee_id,
|
|
338
|
+
payee_name=payee_name,
|
|
339
|
+
category_id=category_id,
|
|
340
|
+
memo=memo,
|
|
341
|
+
cleared=cleared,
|
|
342
|
+
approved=approved,
|
|
343
|
+
flag_color=flag_color,
|
|
344
|
+
subtransactions=subtransactions,
|
|
345
|
+
id=id,
|
|
346
|
+
import_id=import_id,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
save_transaction_with_id_or_import_id.additional_properties = d
|
|
350
|
+
return save_transaction_with_id_or_import_id
|
|
351
|
+
|
|
352
|
+
@property
|
|
353
|
+
def additional_keys(self) -> list[str]:
|
|
354
|
+
return list(self.additional_properties.keys())
|
|
355
|
+
|
|
356
|
+
def __getitem__(self, key: str) -> Any:
|
|
357
|
+
return self.additional_properties[key]
|
|
358
|
+
|
|
359
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
360
|
+
self.additional_properties[key] = value
|
|
361
|
+
|
|
362
|
+
def __delitem__(self, key: str) -> None:
|
|
363
|
+
del self.additional_properties[key]
|
|
364
|
+
|
|
365
|
+
def __contains__(self, key: str) -> bool:
|
|
366
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
from dateutil.parser import isoparse
|
|
9
|
+
|
|
10
|
+
from ynab_cli.adapters.ynab.models.transaction_cleared_status import TransactionClearedStatus
|
|
11
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_1 import TransactionFlagColorType1
|
|
12
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_2_type_1 import TransactionFlagColorType2Type1
|
|
13
|
+
from ynab_cli.adapters.ynab.models.transaction_flag_color_type_3_type_1 import TransactionFlagColorType3Type1
|
|
14
|
+
from ynab_cli.adapters.ynab.types import UNSET, Unset
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from ynab_cli.adapters.ynab.models.save_sub_transaction import SaveSubTransaction
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
T = TypeVar("T", bound="SaveTransactionWithOptionalFields")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@_attrs_define
|
|
24
|
+
class SaveTransactionWithOptionalFields:
|
|
25
|
+
"""
|
|
26
|
+
Attributes:
|
|
27
|
+
account_id (Union[Unset, UUID]):
|
|
28
|
+
date (Union[Unset, datetime.date]): The transaction date in ISO format (e.g. 2016-12-01). Future dates
|
|
29
|
+
(scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date
|
|
30
|
+
is supplied it will be ignored.
|
|
31
|
+
amount (Union[Unset, int]): The transaction amount in milliunits format. Split transaction amounts cannot be
|
|
32
|
+
changed and if a different amount is supplied it will be ignored.
|
|
33
|
+
payee_id (Union[None, UUID, Unset]): The payee for the transaction. To create a transfer between two accounts,
|
|
34
|
+
use the account transfer payee pointing to the target account. Account transfer payees are specified as
|
|
35
|
+
`transfer_payee_id` on the account resource.
|
|
36
|
+
payee_name (Union[None, Unset, str]): The payee name. If a `payee_name` value is provided and `payee_id` has a
|
|
37
|
+
null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule
|
|
38
|
+
(only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee.
|
|
39
|
+
category_id (Union[None, UUID, Unset]): The category for the transaction. To configure a split transaction, you
|
|
40
|
+
can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If
|
|
41
|
+
an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not
|
|
42
|
+
permitted and will be ignored if supplied.
|
|
43
|
+
memo (Union[None, Unset, str]):
|
|
44
|
+
cleared (Union[Unset, TransactionClearedStatus]): The cleared status of the transaction
|
|
45
|
+
approved (Union[Unset, bool]): Whether or not the transaction is approved. If not supplied, transaction will be
|
|
46
|
+
unapproved by default.
|
|
47
|
+
flag_color (Union[None, TransactionFlagColorType1, TransactionFlagColorType2Type1,
|
|
48
|
+
TransactionFlagColorType3Type1, Unset]): The transaction flag
|
|
49
|
+
subtransactions (Union[Unset, list['SaveSubTransaction']]): An array of subtransactions to configure a
|
|
50
|
+
transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
account_id: Unset | UUID = UNSET
|
|
54
|
+
date: Unset | datetime.date = UNSET
|
|
55
|
+
amount: Unset | int = UNSET
|
|
56
|
+
payee_id: None | UUID | Unset = UNSET
|
|
57
|
+
payee_name: None | Unset | str = UNSET
|
|
58
|
+
category_id: None | UUID | Unset = UNSET
|
|
59
|
+
memo: None | Unset | str = UNSET
|
|
60
|
+
cleared: Unset | TransactionClearedStatus = UNSET
|
|
61
|
+
approved: Unset | bool = UNSET
|
|
62
|
+
flag_color: (
|
|
63
|
+
None | TransactionFlagColorType1 | TransactionFlagColorType2Type1 | TransactionFlagColorType3Type1 | Unset
|
|
64
|
+
) = UNSET
|
|
65
|
+
subtransactions: Unset | list["SaveSubTransaction"] = UNSET
|
|
66
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
67
|
+
|
|
68
|
+
def to_dict(self) -> dict[str, Any]:
|
|
69
|
+
account_id: Unset | str = UNSET
|
|
70
|
+
if not isinstance(self.account_id, Unset):
|
|
71
|
+
account_id = str(self.account_id)
|
|
72
|
+
|
|
73
|
+
date: Unset | str = UNSET
|
|
74
|
+
if not isinstance(self.date, Unset):
|
|
75
|
+
date = self.date.isoformat()
|
|
76
|
+
|
|
77
|
+
amount = self.amount
|
|
78
|
+
|
|
79
|
+
payee_id: None | Unset | str
|
|
80
|
+
if isinstance(self.payee_id, Unset):
|
|
81
|
+
payee_id = UNSET
|
|
82
|
+
elif isinstance(self.payee_id, UUID):
|
|
83
|
+
payee_id = str(self.payee_id)
|
|
84
|
+
else:
|
|
85
|
+
payee_id = self.payee_id
|
|
86
|
+
|
|
87
|
+
payee_name: None | Unset | str
|
|
88
|
+
if isinstance(self.payee_name, Unset):
|
|
89
|
+
payee_name = UNSET
|
|
90
|
+
else:
|
|
91
|
+
payee_name = self.payee_name
|
|
92
|
+
|
|
93
|
+
category_id: None | Unset | str
|
|
94
|
+
if isinstance(self.category_id, Unset):
|
|
95
|
+
category_id = UNSET
|
|
96
|
+
elif isinstance(self.category_id, UUID):
|
|
97
|
+
category_id = str(self.category_id)
|
|
98
|
+
else:
|
|
99
|
+
category_id = self.category_id
|
|
100
|
+
|
|
101
|
+
memo: None | Unset | str
|
|
102
|
+
if isinstance(self.memo, Unset):
|
|
103
|
+
memo = UNSET
|
|
104
|
+
else:
|
|
105
|
+
memo = self.memo
|
|
106
|
+
|
|
107
|
+
cleared: Unset | str = UNSET
|
|
108
|
+
if not isinstance(self.cleared, Unset):
|
|
109
|
+
cleared = self.cleared.value
|
|
110
|
+
|
|
111
|
+
approved = self.approved
|
|
112
|
+
|
|
113
|
+
flag_color: None | Unset | str
|
|
114
|
+
if isinstance(self.flag_color, Unset):
|
|
115
|
+
flag_color = UNSET
|
|
116
|
+
elif isinstance(self.flag_color, TransactionFlagColorType1):
|
|
117
|
+
flag_color = self.flag_color.value
|
|
118
|
+
elif isinstance(self.flag_color, TransactionFlagColorType2Type1):
|
|
119
|
+
flag_color = self.flag_color.value
|
|
120
|
+
elif isinstance(self.flag_color, TransactionFlagColorType3Type1):
|
|
121
|
+
flag_color = self.flag_color.value
|
|
122
|
+
else:
|
|
123
|
+
flag_color = self.flag_color
|
|
124
|
+
|
|
125
|
+
subtransactions: Unset | list[dict[str, Any]] = UNSET
|
|
126
|
+
if not isinstance(self.subtransactions, Unset):
|
|
127
|
+
subtransactions = []
|
|
128
|
+
for subtransactions_item_data in self.subtransactions:
|
|
129
|
+
subtransactions_item = subtransactions_item_data.to_dict()
|
|
130
|
+
subtransactions.append(subtransactions_item)
|
|
131
|
+
|
|
132
|
+
field_dict: dict[str, Any] = {}
|
|
133
|
+
field_dict.update(self.additional_properties)
|
|
134
|
+
field_dict.update({})
|
|
135
|
+
if account_id is not UNSET:
|
|
136
|
+
field_dict["account_id"] = account_id
|
|
137
|
+
if date is not UNSET:
|
|
138
|
+
field_dict["date"] = date
|
|
139
|
+
if amount is not UNSET:
|
|
140
|
+
field_dict["amount"] = amount
|
|
141
|
+
if payee_id is not UNSET:
|
|
142
|
+
field_dict["payee_id"] = payee_id
|
|
143
|
+
if payee_name is not UNSET:
|
|
144
|
+
field_dict["payee_name"] = payee_name
|
|
145
|
+
if category_id is not UNSET:
|
|
146
|
+
field_dict["category_id"] = category_id
|
|
147
|
+
if memo is not UNSET:
|
|
148
|
+
field_dict["memo"] = memo
|
|
149
|
+
if cleared is not UNSET:
|
|
150
|
+
field_dict["cleared"] = cleared
|
|
151
|
+
if approved is not UNSET:
|
|
152
|
+
field_dict["approved"] = approved
|
|
153
|
+
if flag_color is not UNSET:
|
|
154
|
+
field_dict["flag_color"] = flag_color
|
|
155
|
+
if subtransactions is not UNSET:
|
|
156
|
+
field_dict["subtransactions"] = subtransactions
|
|
157
|
+
|
|
158
|
+
return field_dict
|
|
159
|
+
|
|
160
|
+
@classmethod
|
|
161
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
162
|
+
from ynab_cli.adapters.ynab.models.save_sub_transaction import SaveSubTransaction
|
|
163
|
+
|
|
164
|
+
d = dict(src_dict)
|
|
165
|
+
_account_id = d.pop("account_id", UNSET)
|
|
166
|
+
account_id: Unset | UUID
|
|
167
|
+
if isinstance(_account_id, Unset):
|
|
168
|
+
account_id = UNSET
|
|
169
|
+
else:
|
|
170
|
+
account_id = UUID(_account_id)
|
|
171
|
+
|
|
172
|
+
_date = d.pop("date", UNSET)
|
|
173
|
+
date: Unset | datetime.date
|
|
174
|
+
if isinstance(_date, Unset):
|
|
175
|
+
date = UNSET
|
|
176
|
+
else:
|
|
177
|
+
date = isoparse(_date).date()
|
|
178
|
+
|
|
179
|
+
amount = d.pop("amount", UNSET)
|
|
180
|
+
|
|
181
|
+
def _parse_payee_id(data: object) -> None | UUID | Unset:
|
|
182
|
+
if data is None:
|
|
183
|
+
return data
|
|
184
|
+
if isinstance(data, Unset):
|
|
185
|
+
return data
|
|
186
|
+
try:
|
|
187
|
+
if not isinstance(data, str):
|
|
188
|
+
raise TypeError()
|
|
189
|
+
payee_id_type_0 = UUID(data)
|
|
190
|
+
|
|
191
|
+
return payee_id_type_0
|
|
192
|
+
except: # noqa: E722
|
|
193
|
+
pass
|
|
194
|
+
return cast(None | UUID | Unset, data)
|
|
195
|
+
|
|
196
|
+
payee_id = _parse_payee_id(d.pop("payee_id", UNSET))
|
|
197
|
+
|
|
198
|
+
def _parse_payee_name(data: object) -> None | Unset | str:
|
|
199
|
+
if data is None:
|
|
200
|
+
return data
|
|
201
|
+
if isinstance(data, Unset):
|
|
202
|
+
return data
|
|
203
|
+
return cast(None | Unset | str, data)
|
|
204
|
+
|
|
205
|
+
payee_name = _parse_payee_name(d.pop("payee_name", UNSET))
|
|
206
|
+
|
|
207
|
+
def _parse_category_id(data: object) -> None | UUID | Unset:
|
|
208
|
+
if data is None:
|
|
209
|
+
return data
|
|
210
|
+
if isinstance(data, Unset):
|
|
211
|
+
return data
|
|
212
|
+
try:
|
|
213
|
+
if not isinstance(data, str):
|
|
214
|
+
raise TypeError()
|
|
215
|
+
category_id_type_0 = UUID(data)
|
|
216
|
+
|
|
217
|
+
return category_id_type_0
|
|
218
|
+
except: # noqa: E722
|
|
219
|
+
pass
|
|
220
|
+
return cast(None | UUID | Unset, data)
|
|
221
|
+
|
|
222
|
+
category_id = _parse_category_id(d.pop("category_id", UNSET))
|
|
223
|
+
|
|
224
|
+
def _parse_memo(data: object) -> None | Unset | str:
|
|
225
|
+
if data is None:
|
|
226
|
+
return data
|
|
227
|
+
if isinstance(data, Unset):
|
|
228
|
+
return data
|
|
229
|
+
return cast(None | Unset | str, data)
|
|
230
|
+
|
|
231
|
+
memo = _parse_memo(d.pop("memo", UNSET))
|
|
232
|
+
|
|
233
|
+
_cleared = d.pop("cleared", UNSET)
|
|
234
|
+
cleared: Unset | TransactionClearedStatus
|
|
235
|
+
if isinstance(_cleared, Unset):
|
|
236
|
+
cleared = UNSET
|
|
237
|
+
else:
|
|
238
|
+
cleared = TransactionClearedStatus(_cleared)
|
|
239
|
+
|
|
240
|
+
approved = d.pop("approved", UNSET)
|
|
241
|
+
|
|
242
|
+
def _parse_flag_color(
|
|
243
|
+
data: object,
|
|
244
|
+
) -> None | TransactionFlagColorType1 | TransactionFlagColorType2Type1 | TransactionFlagColorType3Type1 | Unset:
|
|
245
|
+
if data is None:
|
|
246
|
+
return data
|
|
247
|
+
if isinstance(data, Unset):
|
|
248
|
+
return data
|
|
249
|
+
try:
|
|
250
|
+
if not isinstance(data, str):
|
|
251
|
+
raise TypeError()
|
|
252
|
+
componentsschemas_transaction_flag_color_type_1 = TransactionFlagColorType1(data)
|
|
253
|
+
|
|
254
|
+
return componentsschemas_transaction_flag_color_type_1
|
|
255
|
+
except: # noqa: E722
|
|
256
|
+
pass
|
|
257
|
+
try:
|
|
258
|
+
if not isinstance(data, str):
|
|
259
|
+
raise TypeError()
|
|
260
|
+
componentsschemas_transaction_flag_color_type_2_type_1 = TransactionFlagColorType2Type1(data)
|
|
261
|
+
|
|
262
|
+
return componentsschemas_transaction_flag_color_type_2_type_1
|
|
263
|
+
except: # noqa: E722
|
|
264
|
+
pass
|
|
265
|
+
try:
|
|
266
|
+
if not isinstance(data, str):
|
|
267
|
+
raise TypeError()
|
|
268
|
+
componentsschemas_transaction_flag_color_type_3_type_1 = TransactionFlagColorType3Type1(data)
|
|
269
|
+
|
|
270
|
+
return componentsschemas_transaction_flag_color_type_3_type_1
|
|
271
|
+
except: # noqa: E722
|
|
272
|
+
pass
|
|
273
|
+
return cast(
|
|
274
|
+
None
|
|
275
|
+
| TransactionFlagColorType1
|
|
276
|
+
| TransactionFlagColorType2Type1
|
|
277
|
+
| TransactionFlagColorType3Type1
|
|
278
|
+
| Unset,
|
|
279
|
+
data,
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
flag_color = _parse_flag_color(d.pop("flag_color", UNSET))
|
|
283
|
+
|
|
284
|
+
subtransactions = []
|
|
285
|
+
_subtransactions = d.pop("subtransactions", UNSET)
|
|
286
|
+
for subtransactions_item_data in _subtransactions or []:
|
|
287
|
+
subtransactions_item = SaveSubTransaction.from_dict(subtransactions_item_data)
|
|
288
|
+
|
|
289
|
+
subtransactions.append(subtransactions_item)
|
|
290
|
+
|
|
291
|
+
save_transaction_with_optional_fields = cls(
|
|
292
|
+
account_id=account_id,
|
|
293
|
+
date=date,
|
|
294
|
+
amount=amount,
|
|
295
|
+
payee_id=payee_id,
|
|
296
|
+
payee_name=payee_name,
|
|
297
|
+
category_id=category_id,
|
|
298
|
+
memo=memo,
|
|
299
|
+
cleared=cleared,
|
|
300
|
+
approved=approved,
|
|
301
|
+
flag_color=flag_color,
|
|
302
|
+
subtransactions=subtransactions,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
save_transaction_with_optional_fields.additional_properties = d
|
|
306
|
+
return save_transaction_with_optional_fields
|
|
307
|
+
|
|
308
|
+
@property
|
|
309
|
+
def additional_keys(self) -> list[str]:
|
|
310
|
+
return list(self.additional_properties.keys())
|
|
311
|
+
|
|
312
|
+
def __getitem__(self, key: str) -> Any:
|
|
313
|
+
return self.additional_properties[key]
|
|
314
|
+
|
|
315
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
316
|
+
self.additional_properties[key] = value
|
|
317
|
+
|
|
318
|
+
def __delitem__(self, key: str) -> None:
|
|
319
|
+
del self.additional_properties[key]
|
|
320
|
+
|
|
321
|
+
def __contains__(self, key: str) -> bool:
|
|
322
|
+
return key in self.additional_properties
|