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,213 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from http import HTTPStatus
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ynab_cli.adapters.ynab import errors
|
|
8
|
+
from ynab_cli.adapters.ynab.client import AuthenticatedClient, Client
|
|
9
|
+
from ynab_cli.adapters.ynab.models.error_response import ErrorResponse
|
|
10
|
+
from ynab_cli.adapters.ynab.models.patch_month_category_wrapper import PatchMonthCategoryWrapper
|
|
11
|
+
from ynab_cli.adapters.ynab.models.save_category_response import SaveCategoryResponse
|
|
12
|
+
from ynab_cli.adapters.ynab.types import Response
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
budget_id: str,
|
|
17
|
+
month: datetime.date,
|
|
18
|
+
category_id: str,
|
|
19
|
+
*,
|
|
20
|
+
body: PatchMonthCategoryWrapper,
|
|
21
|
+
) -> dict[str, Any]:
|
|
22
|
+
headers: dict[str, Any] = {}
|
|
23
|
+
|
|
24
|
+
_kwargs: dict[str, Any] = {
|
|
25
|
+
"method": "patch",
|
|
26
|
+
"url": f"/budgets/{budget_id}/months/{month}/categories/{category_id}",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_body = body.to_dict()
|
|
30
|
+
|
|
31
|
+
_kwargs["json"] = _body
|
|
32
|
+
headers["Content-Type"] = "application/json"
|
|
33
|
+
|
|
34
|
+
_kwargs["headers"] = headers
|
|
35
|
+
return _kwargs
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _parse_response(
|
|
39
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
40
|
+
) -> ErrorResponse | SaveCategoryResponse | None:
|
|
41
|
+
if response.status_code == 200:
|
|
42
|
+
response_200 = SaveCategoryResponse.from_dict(response.json())
|
|
43
|
+
|
|
44
|
+
return response_200
|
|
45
|
+
if response.status_code == 400:
|
|
46
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
|
47
|
+
|
|
48
|
+
return response_400
|
|
49
|
+
if client.raise_on_unexpected_status:
|
|
50
|
+
raise errors.UnexpectedStatusError(response.status_code, response.content)
|
|
51
|
+
else:
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _build_response(
|
|
56
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
57
|
+
) -> Response[ErrorResponse | SaveCategoryResponse]:
|
|
58
|
+
return Response(
|
|
59
|
+
status_code=HTTPStatus(response.status_code),
|
|
60
|
+
content=response.content,
|
|
61
|
+
headers=response.headers,
|
|
62
|
+
parsed=_parse_response(client=client, response=response),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def sync_detailed(
|
|
67
|
+
budget_id: str,
|
|
68
|
+
month: datetime.date,
|
|
69
|
+
category_id: str,
|
|
70
|
+
*,
|
|
71
|
+
client: AuthenticatedClient | Client,
|
|
72
|
+
body: PatchMonthCategoryWrapper,
|
|
73
|
+
) -> Response[ErrorResponse | SaveCategoryResponse]:
|
|
74
|
+
"""Update a category for a specific month
|
|
75
|
+
|
|
76
|
+
Update a category for a specific month. Only `budgeted` amount can be updated.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
budget_id (str):
|
|
80
|
+
month (datetime.date):
|
|
81
|
+
category_id (str):
|
|
82
|
+
body (PatchMonthCategoryWrapper):
|
|
83
|
+
|
|
84
|
+
Raises:
|
|
85
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
86
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
Response[Union[ErrorResponse, SaveCategoryResponse]]
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
kwargs = _get_kwargs(
|
|
93
|
+
budget_id=budget_id,
|
|
94
|
+
month=month,
|
|
95
|
+
category_id=category_id,
|
|
96
|
+
body=body,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
response = client.get_httpx_client().request(
|
|
100
|
+
**kwargs,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
return _build_response(client=client, response=response)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def sync(
|
|
107
|
+
budget_id: str,
|
|
108
|
+
month: datetime.date,
|
|
109
|
+
category_id: str,
|
|
110
|
+
*,
|
|
111
|
+
client: AuthenticatedClient | Client,
|
|
112
|
+
body: PatchMonthCategoryWrapper,
|
|
113
|
+
) -> ErrorResponse | SaveCategoryResponse | None:
|
|
114
|
+
"""Update a category for a specific month
|
|
115
|
+
|
|
116
|
+
Update a category for a specific month. Only `budgeted` amount can be updated.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
budget_id (str):
|
|
120
|
+
month (datetime.date):
|
|
121
|
+
category_id (str):
|
|
122
|
+
body (PatchMonthCategoryWrapper):
|
|
123
|
+
|
|
124
|
+
Raises:
|
|
125
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
126
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
Union[ErrorResponse, SaveCategoryResponse]
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
return sync_detailed(
|
|
133
|
+
budget_id=budget_id,
|
|
134
|
+
month=month,
|
|
135
|
+
category_id=category_id,
|
|
136
|
+
client=client,
|
|
137
|
+
body=body,
|
|
138
|
+
).parsed
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
async def asyncio_detailed(
|
|
142
|
+
budget_id: str,
|
|
143
|
+
month: datetime.date,
|
|
144
|
+
category_id: str,
|
|
145
|
+
*,
|
|
146
|
+
client: AuthenticatedClient | Client,
|
|
147
|
+
body: PatchMonthCategoryWrapper,
|
|
148
|
+
) -> Response[ErrorResponse | SaveCategoryResponse]:
|
|
149
|
+
"""Update a category for a specific month
|
|
150
|
+
|
|
151
|
+
Update a category for a specific month. Only `budgeted` amount can be updated.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
budget_id (str):
|
|
155
|
+
month (datetime.date):
|
|
156
|
+
category_id (str):
|
|
157
|
+
body (PatchMonthCategoryWrapper):
|
|
158
|
+
|
|
159
|
+
Raises:
|
|
160
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
161
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Response[Union[ErrorResponse, SaveCategoryResponse]]
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
kwargs = _get_kwargs(
|
|
168
|
+
budget_id=budget_id,
|
|
169
|
+
month=month,
|
|
170
|
+
category_id=category_id,
|
|
171
|
+
body=body,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
175
|
+
|
|
176
|
+
return _build_response(client=client, response=response)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
async def asyncio(
|
|
180
|
+
budget_id: str,
|
|
181
|
+
month: datetime.date,
|
|
182
|
+
category_id: str,
|
|
183
|
+
*,
|
|
184
|
+
client: AuthenticatedClient | Client,
|
|
185
|
+
body: PatchMonthCategoryWrapper,
|
|
186
|
+
) -> ErrorResponse | SaveCategoryResponse | None:
|
|
187
|
+
"""Update a category for a specific month
|
|
188
|
+
|
|
189
|
+
Update a category for a specific month. Only `budgeted` amount can be updated.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
budget_id (str):
|
|
193
|
+
month (datetime.date):
|
|
194
|
+
category_id (str):
|
|
195
|
+
body (PatchMonthCategoryWrapper):
|
|
196
|
+
|
|
197
|
+
Raises:
|
|
198
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
199
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
Union[ErrorResponse, SaveCategoryResponse]
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
await asyncio_detailed(
|
|
207
|
+
budget_id=budget_id,
|
|
208
|
+
month=month,
|
|
209
|
+
category_id=category_id,
|
|
210
|
+
client=client,
|
|
211
|
+
body=body,
|
|
212
|
+
)
|
|
213
|
+
).parsed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from http import HTTPStatus
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ynab_cli.adapters.ynab import errors
|
|
8
|
+
from ynab_cli.adapters.ynab.client import AuthenticatedClient, Client
|
|
9
|
+
from ynab_cli.adapters.ynab.models.error_response import ErrorResponse
|
|
10
|
+
from ynab_cli.adapters.ynab.models.month_detail_response import MonthDetailResponse
|
|
11
|
+
from ynab_cli.adapters.ynab.types import Response
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
budget_id: str,
|
|
16
|
+
month: datetime.date,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
_kwargs: dict[str, Any] = {
|
|
19
|
+
"method": "get",
|
|
20
|
+
"url": f"/budgets/{budget_id}/months/{month}",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return _kwargs
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _parse_response(
|
|
27
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
28
|
+
) -> ErrorResponse | MonthDetailResponse | None:
|
|
29
|
+
if response.status_code == 200:
|
|
30
|
+
response_200 = MonthDetailResponse.from_dict(response.json())
|
|
31
|
+
|
|
32
|
+
return response_200
|
|
33
|
+
if response.status_code == 404:
|
|
34
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
|
35
|
+
|
|
36
|
+
return response_404
|
|
37
|
+
if client.raise_on_unexpected_status:
|
|
38
|
+
raise errors.UnexpectedStatusError(response.status_code, response.content)
|
|
39
|
+
else:
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _build_response(
|
|
44
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
45
|
+
) -> Response[ErrorResponse | MonthDetailResponse]:
|
|
46
|
+
return Response(
|
|
47
|
+
status_code=HTTPStatus(response.status_code),
|
|
48
|
+
content=response.content,
|
|
49
|
+
headers=response.headers,
|
|
50
|
+
parsed=_parse_response(client=client, response=response),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def sync_detailed(
|
|
55
|
+
budget_id: str,
|
|
56
|
+
month: datetime.date,
|
|
57
|
+
*,
|
|
58
|
+
client: AuthenticatedClient | Client,
|
|
59
|
+
) -> Response[ErrorResponse | MonthDetailResponse]:
|
|
60
|
+
"""Single budget month
|
|
61
|
+
|
|
62
|
+
Returns a single budget month
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
budget_id (str):
|
|
66
|
+
month (datetime.date):
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
70
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Response[Union[ErrorResponse, MonthDetailResponse]]
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
kwargs = _get_kwargs(
|
|
77
|
+
budget_id=budget_id,
|
|
78
|
+
month=month,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
response = client.get_httpx_client().request(
|
|
82
|
+
**kwargs,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
return _build_response(client=client, response=response)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def sync(
|
|
89
|
+
budget_id: str,
|
|
90
|
+
month: datetime.date,
|
|
91
|
+
*,
|
|
92
|
+
client: AuthenticatedClient | Client,
|
|
93
|
+
) -> ErrorResponse | MonthDetailResponse | None:
|
|
94
|
+
"""Single budget month
|
|
95
|
+
|
|
96
|
+
Returns a single budget month
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
budget_id (str):
|
|
100
|
+
month (datetime.date):
|
|
101
|
+
|
|
102
|
+
Raises:
|
|
103
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
104
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Union[ErrorResponse, MonthDetailResponse]
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
return sync_detailed(
|
|
111
|
+
budget_id=budget_id,
|
|
112
|
+
month=month,
|
|
113
|
+
client=client,
|
|
114
|
+
).parsed
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
async def asyncio_detailed(
|
|
118
|
+
budget_id: str,
|
|
119
|
+
month: datetime.date,
|
|
120
|
+
*,
|
|
121
|
+
client: AuthenticatedClient | Client,
|
|
122
|
+
) -> Response[ErrorResponse | MonthDetailResponse]:
|
|
123
|
+
"""Single budget month
|
|
124
|
+
|
|
125
|
+
Returns a single budget month
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
budget_id (str):
|
|
129
|
+
month (datetime.date):
|
|
130
|
+
|
|
131
|
+
Raises:
|
|
132
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
133
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
Response[Union[ErrorResponse, MonthDetailResponse]]
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
kwargs = _get_kwargs(
|
|
140
|
+
budget_id=budget_id,
|
|
141
|
+
month=month,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
145
|
+
|
|
146
|
+
return _build_response(client=client, response=response)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
async def asyncio(
|
|
150
|
+
budget_id: str,
|
|
151
|
+
month: datetime.date,
|
|
152
|
+
*,
|
|
153
|
+
client: AuthenticatedClient | Client,
|
|
154
|
+
) -> ErrorResponse | MonthDetailResponse | None:
|
|
155
|
+
"""Single budget month
|
|
156
|
+
|
|
157
|
+
Returns a single budget month
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
budget_id (str):
|
|
161
|
+
month (datetime.date):
|
|
162
|
+
|
|
163
|
+
Raises:
|
|
164
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
165
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
Union[ErrorResponse, MonthDetailResponse]
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
await asyncio_detailed(
|
|
173
|
+
budget_id=budget_id,
|
|
174
|
+
month=month,
|
|
175
|
+
client=client,
|
|
176
|
+
)
|
|
177
|
+
).parsed
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ynab_cli.adapters.ynab import errors
|
|
7
|
+
from ynab_cli.adapters.ynab.client import AuthenticatedClient, Client
|
|
8
|
+
from ynab_cli.adapters.ynab.models.error_response import ErrorResponse
|
|
9
|
+
from ynab_cli.adapters.ynab.models.month_summaries_response import MonthSummariesResponse
|
|
10
|
+
from ynab_cli.adapters.ynab.types import UNSET, Response, Unset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
budget_id: str,
|
|
15
|
+
*,
|
|
16
|
+
last_knowledge_of_server: Unset | int = UNSET,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
params: dict[str, Any] = {}
|
|
19
|
+
|
|
20
|
+
params["last_knowledge_of_server"] = last_knowledge_of_server
|
|
21
|
+
|
|
22
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
23
|
+
|
|
24
|
+
_kwargs: dict[str, Any] = {
|
|
25
|
+
"method": "get",
|
|
26
|
+
"url": f"/budgets/{budget_id}/months",
|
|
27
|
+
"params": params,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return _kwargs
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _parse_response(
|
|
34
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
35
|
+
) -> ErrorResponse | MonthSummariesResponse | None:
|
|
36
|
+
if response.status_code == 200:
|
|
37
|
+
response_200 = MonthSummariesResponse.from_dict(response.json())
|
|
38
|
+
|
|
39
|
+
return response_200
|
|
40
|
+
if response.status_code == 404:
|
|
41
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
|
42
|
+
|
|
43
|
+
return response_404
|
|
44
|
+
if client.raise_on_unexpected_status:
|
|
45
|
+
raise errors.UnexpectedStatusError(response.status_code, response.content)
|
|
46
|
+
else:
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _build_response(
|
|
51
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
52
|
+
) -> Response[ErrorResponse | MonthSummariesResponse]:
|
|
53
|
+
return Response(
|
|
54
|
+
status_code=HTTPStatus(response.status_code),
|
|
55
|
+
content=response.content,
|
|
56
|
+
headers=response.headers,
|
|
57
|
+
parsed=_parse_response(client=client, response=response),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def sync_detailed(
|
|
62
|
+
budget_id: str,
|
|
63
|
+
*,
|
|
64
|
+
client: AuthenticatedClient | Client,
|
|
65
|
+
last_knowledge_of_server: Unset | int = UNSET,
|
|
66
|
+
) -> Response[ErrorResponse | MonthSummariesResponse]:
|
|
67
|
+
"""List budget months
|
|
68
|
+
|
|
69
|
+
Returns all budget months
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
budget_id (str):
|
|
73
|
+
last_knowledge_of_server (Union[Unset, int]):
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
77
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Response[Union[ErrorResponse, MonthSummariesResponse]]
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
kwargs = _get_kwargs(
|
|
84
|
+
budget_id=budget_id,
|
|
85
|
+
last_knowledge_of_server=last_knowledge_of_server,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
response = client.get_httpx_client().request(
|
|
89
|
+
**kwargs,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return _build_response(client=client, response=response)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def sync(
|
|
96
|
+
budget_id: str,
|
|
97
|
+
*,
|
|
98
|
+
client: AuthenticatedClient | Client,
|
|
99
|
+
last_knowledge_of_server: Unset | int = UNSET,
|
|
100
|
+
) -> ErrorResponse | MonthSummariesResponse | None:
|
|
101
|
+
"""List budget months
|
|
102
|
+
|
|
103
|
+
Returns all budget months
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
budget_id (str):
|
|
107
|
+
last_knowledge_of_server (Union[Unset, int]):
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
111
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Union[ErrorResponse, MonthSummariesResponse]
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
return sync_detailed(
|
|
118
|
+
budget_id=budget_id,
|
|
119
|
+
client=client,
|
|
120
|
+
last_knowledge_of_server=last_knowledge_of_server,
|
|
121
|
+
).parsed
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async def asyncio_detailed(
|
|
125
|
+
budget_id: str,
|
|
126
|
+
*,
|
|
127
|
+
client: AuthenticatedClient | Client,
|
|
128
|
+
last_knowledge_of_server: Unset | int = UNSET,
|
|
129
|
+
) -> Response[ErrorResponse | MonthSummariesResponse]:
|
|
130
|
+
"""List budget months
|
|
131
|
+
|
|
132
|
+
Returns all budget months
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
budget_id (str):
|
|
136
|
+
last_knowledge_of_server (Union[Unset, int]):
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
140
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Response[Union[ErrorResponse, MonthSummariesResponse]]
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
kwargs = _get_kwargs(
|
|
147
|
+
budget_id=budget_id,
|
|
148
|
+
last_knowledge_of_server=last_knowledge_of_server,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
152
|
+
|
|
153
|
+
return _build_response(client=client, response=response)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
async def asyncio(
|
|
157
|
+
budget_id: str,
|
|
158
|
+
*,
|
|
159
|
+
client: AuthenticatedClient | Client,
|
|
160
|
+
last_knowledge_of_server: Unset | int = UNSET,
|
|
161
|
+
) -> ErrorResponse | MonthSummariesResponse | None:
|
|
162
|
+
"""List budget months
|
|
163
|
+
|
|
164
|
+
Returns all budget months
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
budget_id (str):
|
|
168
|
+
last_knowledge_of_server (Union[Unset, int]):
|
|
169
|
+
|
|
170
|
+
Raises:
|
|
171
|
+
errors.UnexpectedStatusError: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
172
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
Union[ErrorResponse, MonthSummariesResponse]
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
await asyncio_detailed(
|
|
180
|
+
budget_id=budget_id,
|
|
181
|
+
client=client,
|
|
182
|
+
last_knowledge_of_server=last_knowledge_of_server,
|
|
183
|
+
)
|
|
184
|
+
).parsed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|