├── .coveragerc ├── .gitignore ├── LICENSE.md ├── README.md ├── docs ├── README.md ├── pynab │ ├── api.md │ ├── constants.md │ ├── endpoints.md │ ├── enums.md │ ├── index.md │ ├── pynab.md │ ├── schemas.md │ └── utils.md ├── requirements.txt └── testing │ ├── index.md │ └── test_live_api.md ├── pynab ├── __init__.py ├── api.py ├── constants.py ├── endpoints.py ├── enums.py ├── pynab.py ├── schemas.py └── utils.py ├── requirements.txt ├── setup.py ├── testing ├── __init__.py ├── requirements.txt ├── test_budget.ynab4.zip └── test_live_api.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | tests/test_live_api.py 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 110 | .pdm.toml 111 | .pdm-python 112 | .pdm-build/ 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | 164 | .venv-test 165 | .venv-docs 166 | .vscode 167 | 168 | # MacOS 169 | .DS_Store 170 | 171 | # Bearer Token 172 | testing/.env -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [your name] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pynab 2 | 3 | **Pynab** is a Python library designed for seamless interaction with the YNAB (You Need A Budget) API. It provides a user-friendly interface to manage your budgets, accounts, transactions, and more with ease. 4 | 5 | Pynab currently works with YNAB's 1.72.0 API. For more information, see https://api.ynab.com/v1. 6 | 7 | ## Installation 8 | 9 | To install Pynab, follow these steps: 10 | 11 | ```sh 12 | git clone https://github.com/dynacylabs/pynab.git 13 | cd pynab 14 | python -m venv .venv 15 | source .venv/bin/activate 16 | pip install ./ 17 | ``` 18 | 19 | ## Usage 20 | 21 | ### Initialize Pynab 22 | 23 | To begin using Pynab, initialize it with your YNAB Bearer token: 24 | 25 | ```python 26 | from pynab import Pynab 27 | pynab = Pynab(bearer="YOUR_BEARER_TOKEN_HERE") 28 | ``` 29 | 30 | ### Retrieve Budgets 31 | 32 | Fetch a dictionary of your budgets: 33 | 34 | ```python 35 | budgets = pynab.budgets 36 | ``` 37 | 38 | ### Retrieve a Budget by Name* 39 | 40 | Retrieve a specific budget by its name: 41 | 42 | ```python 43 | test_budget = pynab.budgets.by(field="name", value="test_budget", first=True) 44 | ``` 45 | 46 | ### Retrieve Accounts for a Budget 47 | 48 | Fetch all accounts associated with a budget: 49 | 50 | ```python 51 | test_accounts = test_budget.accounts 52 | ``` 53 | 54 | ### Retrieve an Account by Name* 55 | 56 | Fetch a specific account within a budget by its name: 57 | 58 | ```python 59 | test_account = test_budget.accounts.by(field="name", value="test_account", first=True) 60 | ``` 61 | 62 | ### Retrieve Transactions for an Account 63 | 64 | Fetch all transactions associated with a specific account: 65 | 66 | ```python 67 | transactions = test_account.transactions 68 | ``` 69 | 70 | \* _Note: Multiple items may be returned. You should verify whether the result is a dictionary or a single `Budget`, `Account`, or `Transaction` instance._ 71 | 72 | ```python 73 | from pynab.schemas import Account 74 | test_account = test_budget.accounts.by(field="name", value="test_account", first=False) 75 | if isinstance(test_account, Account): 76 | # Single account returned 77 | else: 78 | # Multiple accounts returned {account_id: account} 79 | ``` 80 | 81 | ## Contributing 82 | 83 | We welcome contributions! Here's how to get started: 84 | 85 | 1. **Fork the Repository**: Create a personal copy of the repository on your GitHub account. 86 | 2. **Clone the Repository**: Clone the forked repository to your local machine: 87 | ```sh 88 | git clone https://github.com//.git 89 | ``` 90 | 3. **Create a Branch**: Always create a new branch for your changes to keep the history clean: 91 | ```sh 92 | git checkout -b 93 | ``` 94 | 4. **Make Your Changes**: Edit the code using your preferred editor or IDE. 95 | 5. **Commit Your Changes**: Provide a clear commit message describing your changes: 96 | ```sh 97 | git commit -m "" 98 | ``` 99 | 6. **Push Your Changes**: Push the changes to your forked repository: 100 | ```sh 101 | git push origin 102 | ``` 103 | 7. **Submit a Pull Request**: On GitHub, open a pull request from your fork to the main repository for review. 104 | 105 | Please ensure that your contributions do not break the live API tests. Run all tests before submitting your pull request. 106 | 107 | ## Testing 108 | 109 | ### Live API Testing 110 | 111 | YNAB's API primarily offers read-only access, so you'll need to create a test budget manually for live API testing. 112 | 113 | Live API tests confirm that Pynab's API calls are correctly interpreted by the server, and that Pynab can process the server's responses. 114 | 115 | #### Importing a Test Budget 116 | 117 | To import a test budget, upload `testing/test_budget.ynab4.zip` to YNAB by creating a new budget and using the "Migrate a YNAB 4 Budget" option. 118 | 119 | #### Manually Creating a Test Budget 120 | 121 | Follow these steps to manually create a test budget: 122 | 123 | | Item | Field | Value | Notes | 124 | |--------------------|------------------|------------------------------|---------------------------------------------------| 125 | | **Budget** | `name` | `Test Budget` | Delete all **Category Groups** and **Categories** | 126 | | **Category Group** | `name` | `Test Category Group` | | 127 | | **Category** | `name` | `Test Category` | | 128 | | **Account** | `name` | `Test Account` | | 129 | | **Transaction** | `payee` | `Test Payee` | Belongs to `Test Account` | 130 | | | `memo` | `Test Transaction` | | 131 | | | `category` | `Test Category` | | 132 | | **Transaction** | `date` | _any future date_ | Belongs to `Test Account` | 133 | | | `date > repeat` | _any frequency_ | | 134 | | | `memo` | `Test Scheduled Transaction` | | 135 | 136 | ### Running Tests with Tox 137 | 138 | Before running tests, create a `tests/.env` file with your API Bearer Token using the following format: 139 | ```sh 140 | # ynab personal access token 141 | API_KEY=your_API_token_goes_here 142 | ``` 143 | 144 | To run tests: 145 | ```sh 146 | python -m venv .venv-test 147 | source .venv-test/bin/activate 148 | pip install -r testing/requirements.txt 149 | tox 150 | ``` 151 | 152 | ## Documentation 153 | 154 | Please ensure any code changes are accompanied by corresponding updates to the documentation. You can generate updated documentation using Handsdown: 155 | 156 | ```sh 157 | python -m venv .venv-docs 158 | source .venv-docs/bin/activate 159 | pip install -r docs/requirements.txt 160 | handsdown 161 | ``` 162 | 163 | ## Future Development 164 | 165 | - Implement mock testing. 166 | - Additional testing for: 167 | - Server knowledge validation. 168 | - All non-GET endpoints. 169 | - Add comprehensive type definitions. 170 | 171 | ## License 172 | Pynab is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 173 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Pynab Index 2 | 3 | > Auto-generated documentation index. 4 | 5 | A full list of `Pynab` project modules. 6 | 7 | - [Pynab](pynab/index.md#pynab) 8 | - [Api](pynab/api.md#api) 9 | - [Constants](pynab/constants.md#constants) 10 | - [Endpoints](pynab/endpoints.md#endpoints) 11 | - [Enums](pynab/enums.md#enums) 12 | - [Pynab](pynab/pynab.md#pynab) 13 | - [Schemas](pynab/schemas.md#schemas) 14 | - [Utils](pynab/utils.md#utils) 15 | - [Testing](testing/index.md#testing) 16 | - [Test Live Api](testing/test_live_api.md#test-live-api) 17 | -------------------------------------------------------------------------------- /docs/pynab/api.md: -------------------------------------------------------------------------------- 1 | # Api 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Api 4 | 5 | > Auto-generated documentation for [pynab.api](../../pynab/api.py) module. 6 | 7 | - [Api](#api) 8 | - [Api](#api-1) 9 | - [Api().create_account](#api()create_account) 10 | - [Api().create_scheduled_transaction](#api()create_scheduled_transaction) 11 | - [Api().create_transactions](#api()create_transactions) 12 | - [Api().delete_transaction](#api()delete_transaction) 13 | - [Api().get_account](#api()get_account) 14 | - [Api().get_account_transactions](#api()get_account_transactions) 15 | - [Api().get_accounts](#api()get_accounts) 16 | - [Api().get_budget](#api()get_budget) 17 | - [Api().get_budget_payee_locations](#api()get_budget_payee_locations) 18 | - [Api().get_budget_settings](#api()get_budget_settings) 19 | - [Api().get_budgets](#api()get_budgets) 20 | - [Api().get_categories](#api()get_categories) 21 | - [Api().get_category](#api()get_category) 22 | - [Api().get_category_for_month](#api()get_category_for_month) 23 | - [Api().get_category_transactions](#api()get_category_transactions) 24 | - [Api().get_month](#api()get_month) 25 | - [Api().get_month_transactions](#api()get_month_transactions) 26 | - [Api().get_months](#api()get_months) 27 | - [Api().get_payee](#api()get_payee) 28 | - [Api().get_payee_location](#api()get_payee_location) 29 | - [Api().get_payee_locations](#api()get_payee_locations) 30 | - [Api().get_payee_transactions](#api()get_payee_transactions) 31 | - [Api().get_payees](#api()get_payees) 32 | - [Api().get_scheduled_transaction](#api()get_scheduled_transaction) 33 | - [Api().get_scheduled_transactions](#api()get_scheduled_transactions) 34 | - [Api().get_transaction](#api()get_transaction) 35 | - [Api().get_transactions](#api()get_transactions) 36 | - [Api().get_user](#api()get_user) 37 | - [Api().import_transactions](#api()import_transactions) 38 | - [Api().update_category](#api()update_category) 39 | - [Api().update_category_for_month](#api()update_category_for_month) 40 | - [Api().update_payee](#api()update_payee) 41 | - [Api().update_transaction](#api()update_transaction) 42 | - [Api().update_transactions](#api()update_transactions) 43 | 44 | ## Api 45 | 46 | [Show source in api.py:8](../../pynab/api.py#L8) 47 | 48 | #### Signature 49 | 50 | ```python 51 | class Api: 52 | def __init__(self, pynab=None): ... 53 | ``` 54 | 55 | ### Api().create_account 56 | 57 | [Show source in api.py:189](../../pynab/api.py#L189) 58 | 59 | Creates a new account. 60 | 61 | #### Arguments 62 | 63 | - `budget` *schemas.Budget, optional* - The budget to associate the account with. Defaults to None. 64 | - `budget_id` *str, optional* - The ID of the budget to associate the account with. Defaults to "last-used". 65 | - `account_name` *str, optional* - The name of the account. Defaults to None. 66 | - `account_type` *enums.AccountType, optional* - The type of the account. Defaults to None. 67 | - `account_balance` *int, optional* - The initial balance of the account. Defaults to 0. 68 | 69 | #### Returns 70 | 71 | - `schemas.Account` - The created account. 72 | 73 | #### Raises 74 | 75 | - `Exception` - If there is an error creating the account. 76 | 77 | #### Signature 78 | 79 | ```python 80 | def create_account( 81 | self, 82 | budget: schemas.Budget = None, 83 | budget_id: str = "last-used", 84 | account_name: str = None, 85 | account_type: enums.AccountType = None, 86 | account_balance: int = 0, 87 | ): ... 88 | ``` 89 | 90 | ### Api().create_scheduled_transaction 91 | 92 | [Show source in api.py:1475](../../pynab/api.py#L1475) 93 | 94 | Creates a scheduled transaction. 95 | 96 | #### Arguments 97 | 98 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 99 | - `budget_id` *str, optional* - The budget ID. Defaults to "last-used". 100 | - `scheduled_transaction` *schemas.ScheduledTransaction, optional* - The scheduled transaction object. Defaults to None. 101 | 102 | #### Returns 103 | 104 | - `Union[schemas.ScheduledTransaction,` *schemas.Error]* - The created scheduled transaction object or an error object. 105 | 106 | #### Signature 107 | 108 | ```python 109 | def create_scheduled_transaction( 110 | self, 111 | budget: schemas.Budget = None, 112 | budget_id: str = "last-used", 113 | scheduled_transaction: schemas.ScheduledTransaction = None, 114 | ): ... 115 | ``` 116 | 117 | ### Api().create_transactions 118 | 119 | [Show source in api.py:900](../../pynab/api.py#L900) 120 | 121 | Create transactions in the specified budget. 122 | 123 | #### Arguments 124 | 125 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 126 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 127 | - `transactions` *list, optional* - The list of transactions to create. Defaults to None. 128 | 129 | #### Returns 130 | 131 | Union[List[schemas.Transaction], Dict[str, Any]]: If a single transaction is created, returns the created transaction as a dictionary. If multiple transactions are created, returns a list of created transactions. 132 | 133 | #### Raises 134 | 135 | - `Exception` - If there is an error creating the transactions. 136 | 137 | #### Signature 138 | 139 | ```python 140 | def create_transactions( 141 | self, 142 | budget: schemas.Budget = None, 143 | budget_id: str = "last-used", 144 | transactions: list = None, 145 | ): ... 146 | ``` 147 | 148 | ### Api().delete_transaction 149 | 150 | [Show source in api.py:1165](../../pynab/api.py#L1165) 151 | 152 | Deletes a transaction from the specified budget. 153 | 154 | #### Arguments 155 | 156 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 157 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 158 | - `transaction` *schemas.Transaction, optional* - The transaction object. Defaults to None. 159 | - `transaction_id` *str, optional* - The ID of the transaction. Defaults to None. 160 | 161 | #### Returns 162 | 163 | - `schemas.Transaction` - The deleted transaction. 164 | 165 | #### Raises 166 | 167 | - `Exception` - If the deletion fails, an exception is raised with the error details. 168 | 169 | #### Signature 170 | 171 | ```python 172 | def delete_transaction( 173 | self, 174 | budget: schemas.Budget = None, 175 | budget_id: str = "last-used", 176 | transaction: schemas.Transaction = None, 177 | transaction_id: str = None, 178 | ): ... 179 | ``` 180 | 181 | ### Api().get_account 182 | 183 | [Show source in api.py:240](../../pynab/api.py#L240) 184 | 185 | Retrieves an account from the specified budget. 186 | 187 | #### Arguments 188 | 189 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 190 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 191 | - `account` *schemas.Account, optional* - The account object. Defaults to None. 192 | - `account_id` *str, optional* - The ID of the account. Defaults to None. 193 | 194 | #### Returns 195 | 196 | - `schemas.Account` - The retrieved account. 197 | 198 | #### Raises 199 | 200 | - `Exception` - If there is an error retrieving the account. 201 | 202 | #### Signature 203 | 204 | ```python 205 | def get_account( 206 | self, 207 | budget: schemas.Budget = None, 208 | budget_id: str = "last-used", 209 | account: schemas.Account = None, 210 | account_id: str = None, 211 | ): ... 212 | ``` 213 | 214 | ### Api().get_account_transactions 215 | 216 | [Show source in api.py:1204](../../pynab/api.py#L1204) 217 | 218 | Retrieves account transactions from the API. 219 | 220 | #### Arguments 221 | 222 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 223 | - `budget_id` *str, optional* - The budget ID. Defaults to "last-used". 224 | - `account` *schemas.Account, optional* - The account object. Defaults to None. 225 | - `account_id` *str, optional* - The account ID. Defaults to None. 226 | - `since_date` *str, optional* - The date to retrieve transactions since. Defaults to None. 227 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 228 | 229 | #### Returns 230 | 231 | - `dict` - A dictionary of transactions, where the transaction ID is the key and the transaction object is the value. 232 | 233 | #### Raises 234 | 235 | - `Exception` - If there is an error retrieving the transactions. 236 | 237 | #### Signature 238 | 239 | ```python 240 | def get_account_transactions( 241 | self, 242 | budget: schemas.Budget = None, 243 | budget_id: str = "last-used", 244 | account: schemas.Account = None, 245 | account_id: str = None, 246 | since_date: str = None, 247 | type: str = None, 248 | ): ... 249 | ``` 250 | 251 | ### Api().get_accounts 252 | 253 | [Show source in api.py:147](../../pynab/api.py#L147) 254 | 255 | Retrieves the accounts associated with the specified budget. 256 | 257 | #### Arguments 258 | 259 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 260 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 261 | 262 | #### Returns 263 | 264 | - `dict` - A dictionary containing the retrieved accounts, where the keys are the account IDs and the values are the account objects. 265 | 266 | #### Raises 267 | 268 | - `Exception` - If the response status code is not 200, an exception is raised with the error details. 269 | 270 | #### Signature 271 | 272 | ```python 273 | def get_accounts(self, budget: schemas.Budget = None, budget_id: str = "last-used"): ... 274 | ``` 275 | 276 | ### Api().get_budget 277 | 278 | [Show source in api.py:82](../../pynab/api.py#L82) 279 | 280 | Retrieves a budget from the server. 281 | 282 | #### Arguments 283 | 284 | - `budget` *schemas.Budget, optional* - The budget object to retrieve. Defaults to None. 285 | - `budget_id` *str, optional* - The ID of the budget to retrieve. Defaults to "last-used". 286 | 287 | #### Returns 288 | 289 | - `schemas.Budget` - The retrieved budget object. 290 | 291 | #### Raises 292 | 293 | - `Exception` - If there is an error retrieving the budget. 294 | 295 | #### Signature 296 | 297 | ```python 298 | def get_budget(self, budget: schemas.Budget = None, budget_id: str = "last-used"): ... 299 | ``` 300 | 301 | ### Api().get_budget_payee_locations 302 | 303 | [Show source in api.py:644](../../pynab/api.py#L644) 304 | 305 | Retrieves the payee locations for a given budget. 306 | 307 | #### Arguments 308 | 309 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 310 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 311 | 312 | #### Returns 313 | 314 | - `dict` - A dictionary containing the payee locations, where the keys are the payee location IDs and the values are the payee location objects. 315 | 316 | #### Raises 317 | 318 | - `Exception` - If there is an error retrieving the payee locations. 319 | 320 | #### Signature 321 | 322 | ```python 323 | def get_budget_payee_locations( 324 | self, budget: schemas.Budget = None, budget_id: str = "last-used" 325 | ): ... 326 | ``` 327 | 328 | ### Api().get_budget_settings 329 | 330 | [Show source in api.py:118](../../pynab/api.py#L118) 331 | 332 | Retrieves the budget settings for a given budget or the last-used budget. 333 | 334 | #### Arguments 335 | 336 | - budget (schemas.Budget, optional): The budget object for which to retrieve the settings. If not provided, the last-used budget will be used. 337 | - budget_id (str, optional): The ID of the budget for which to retrieve the settings. Defaults to "last-used" if not provided. 338 | 339 | #### Returns 340 | 341 | - `-` *schemas.BudgetSettings* - The budget settings object. 342 | 343 | #### Raises 344 | 345 | - `-` *Exception* - If the API request fails or returns an error. 346 | 347 | #### Signature 348 | 349 | ```python 350 | def get_budget_settings( 351 | self, budget: schemas.Budget = None, budget_id: str = "last-used" 352 | ): ... 353 | ``` 354 | 355 | ### Api().get_budgets 356 | 357 | [Show source in api.py:42](../../pynab/api.py#L42) 358 | 359 | Retrieves budgets from the API. 360 | 361 | #### Arguments 362 | 363 | - `include_accounts` *bool, optional* - Whether to include accounts in the response. Defaults to False. 364 | 365 | #### Returns 366 | 367 | - `dict` - A dictionary containing the budgets retrieved from the API. The keys are the budget IDs and the values are instances of the `Budget` class. 368 | 369 | #### Raises 370 | 371 | - `Exception` - If an error occurs while retrieving the budgets. 372 | 373 | #### Signature 374 | 375 | ```python 376 | def get_budgets(self, include_accounts: bool = False): ... 377 | ``` 378 | 379 | ### Api().get_categories 380 | 381 | [Show source in api.py:277](../../pynab/api.py#L277) 382 | 383 | Retrieves the categories for a given budget or the last-used budget. 384 | 385 | #### Arguments 386 | 387 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 388 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 389 | 390 | #### Returns 391 | 392 | - `dict` - A dictionary containing the category groups, where the keys are the category group IDs and the values are the category group objects. 393 | 394 | #### Raises 395 | 396 | - `Exception` - If there is an error in the API response. 397 | 398 | #### Signature 399 | 400 | ```python 401 | def get_categories( 402 | self, budget: schemas.Budget = None, budget_id: str = "last-used" 403 | ): ... 404 | ``` 405 | 406 | ### Api().get_category 407 | 408 | [Show source in api.py:321](../../pynab/api.py#L321) 409 | 410 | Retrieves a category from the API. 411 | 412 | #### Arguments 413 | 414 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 415 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 416 | - `category` *schemas.Category, optional* - The category object. Defaults to None. 417 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 418 | 419 | #### Returns 420 | 421 | - `schemas.Category` - The retrieved category. 422 | 423 | #### Raises 424 | 425 | - `Exception` - If the API request fails. 426 | 427 | #### Signature 428 | 429 | ```python 430 | def get_category( 431 | self, 432 | budget: schemas.Budget = None, 433 | budget_id: str = "last-used", 434 | category: schemas.Category = None, 435 | category_id: str = None, 436 | ): ... 437 | ``` 438 | 439 | ### Api().get_category_for_month 440 | 441 | [Show source in api.py:421](../../pynab/api.py#L421) 442 | 443 | Retrieves the category for a specific month in a budget. 444 | 445 | #### Arguments 446 | 447 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 448 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 449 | - `month` *str, optional* - The month to retrieve the category for. Defaults to "current". 450 | - `category` *schemas.Category, optional* - The category object. Defaults to None. 451 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 452 | 453 | #### Returns 454 | 455 | - `schemas.Category` - The category object for the specified month. 456 | 457 | #### Raises 458 | 459 | - `Exception` - If there is an error retrieving the category. 460 | 461 | #### Signature 462 | 463 | ```python 464 | def get_category_for_month( 465 | self, 466 | budget: schemas.Budget = None, 467 | budget_id: str = "last-used", 468 | month: str = "current", 469 | category: schemas.Category = None, 470 | category_id: str = None, 471 | ): ... 472 | ``` 473 | 474 | ### Api().get_category_transactions 475 | 476 | [Show source in api.py:1261](../../pynab/api.py#L1261) 477 | 478 | Retrieves transactions for a specific category. 479 | 480 | #### Arguments 481 | 482 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 483 | - `budget_id` *str, optional* - The budget ID. Defaults to "last-used". 484 | - `category` *schemas.Category, optional* - The category object. Defaults to None. 485 | - `category_id` *str, optional* - The category ID. Defaults to None. 486 | - `since_date` *str, optional* - The starting date for the transactions. Defaults to None. 487 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 488 | 489 | #### Returns 490 | 491 | - `dict` - A dictionary of transactions, where the keys are the transaction IDs and the values are the transaction objects. 492 | 493 | #### Raises 494 | 495 | - `Exception` - If there is an error retrieving the transactions. 496 | 497 | #### Signature 498 | 499 | ```python 500 | def get_category_transactions( 501 | self, 502 | budget: schemas.Budget = None, 503 | budget_id: str = "last-used", 504 | category: schemas.Category = None, 505 | category_id: str = None, 506 | since_date: str = None, 507 | type: str = None, 508 | ): ... 509 | ``` 510 | 511 | ### Api().get_month 512 | 513 | [Show source in api.py:810](../../pynab/api.py#L810) 514 | 515 | Retrieves a specific month from the budget. 516 | 517 | #### Arguments 518 | 519 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 520 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 521 | - `month` *schemas.Month, optional* - The month object. Defaults to None. 522 | - `month_id` *str, optional* - The ID of the month. Defaults to "current". 523 | 524 | #### Returns 525 | 526 | - `schemas.Month` - The retrieved month object. 527 | 528 | #### Raises 529 | 530 | - `Exception` - If there is an error retrieving the month. 531 | 532 | #### Signature 533 | 534 | ```python 535 | def get_month( 536 | self, 537 | budget: schemas.Budget = None, 538 | budget_id: str = "last-used", 539 | month: schemas.Month = None, 540 | month_id: str = "current", 541 | ): ... 542 | ``` 543 | 544 | ### Api().get_month_transactions 545 | 546 | [Show source in api.py:1373](../../pynab/api.py#L1373) 547 | 548 | Retrieves the transactions for a specific month in a budget. 549 | 550 | #### Arguments 551 | 552 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 553 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 554 | - `month` *schemas.Month, optional* - The month object. Defaults to None. 555 | - `month_id` *str, optional* - The ID of the month. Defaults to "current". 556 | - `since_date` *str, optional* - The starting date for the transactions. Defaults to None. 557 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 558 | 559 | #### Returns 560 | 561 | - `dict` - A dictionary of transactions, where the keys are the transaction IDs and the values are the transaction objects. 562 | 563 | #### Raises 564 | 565 | - `Exception` - If there is an error retrieving the transactions. 566 | 567 | #### Signature 568 | 569 | ```python 570 | def get_month_transactions( 571 | self, 572 | budget: schemas.Budget = None, 573 | budget_id: str = "last-used", 574 | month: schemas.Month = None, 575 | month_id: str = "current", 576 | since_date: str = None, 577 | type: str = None, 578 | ): ... 579 | ``` 580 | 581 | ### Api().get_months 582 | 583 | [Show source in api.py:766](../../pynab/api.py#L766) 584 | 585 | Retrieves the months for a given budget. 586 | 587 | #### Arguments 588 | 589 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 590 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 591 | 592 | #### Returns 593 | 594 | - `dict` - A dictionary containing the months as keys and their corresponding Month objects as values. 595 | 596 | #### Raises 597 | 598 | - `Exception` - If there is an error retrieving the months. 599 | 600 | #### Signature 601 | 602 | ```python 603 | def get_months(self, budget: schemas.Budget = None, budget_id: str = "last-used"): ... 604 | ``` 605 | 606 | ### Api().get_payee 607 | 608 | [Show source in api.py:558](../../pynab/api.py#L558) 609 | 610 | Retrieves a payee from the specified budget or the last-used budget. 611 | 612 | #### Arguments 613 | 614 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 615 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 616 | - `payee` *schemas.Payee, optional* - The payee object. Defaults to None. 617 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 618 | 619 | #### Returns 620 | 621 | - `schemas.Payee` - The retrieved payee object. 622 | 623 | #### Raises 624 | 625 | - `Exception` - If the API response status code is not 200, an exception is raised with the error details. 626 | 627 | #### Signature 628 | 629 | ```python 630 | def get_payee( 631 | self, 632 | budget: schemas.Budget = None, 633 | budget_id: str = "last-used", 634 | payee: schemas.Payee = None, 635 | payee_id: str = None, 636 | ): ... 637 | ``` 638 | 639 | ### Api().get_payee_location 640 | 641 | [Show source in api.py:679](../../pynab/api.py#L679) 642 | 643 | Retrieves a payee location from the API. 644 | 645 | #### Arguments 646 | 647 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 648 | - `budget_id` *str, optional* - The budget ID. Defaults to "last-used". 649 | - `payee_location` *schemas.PayeeLocation, optional* - The payee location object. Defaults to None. 650 | - `payee_location_id` *str, optional* - The payee location ID. Defaults to None. 651 | 652 | #### Returns 653 | 654 | - `schemas.PayeeLocation` - The retrieved payee location. 655 | 656 | #### Raises 657 | 658 | - `Exception` - If the API request fails. 659 | 660 | #### Signature 661 | 662 | ```python 663 | def get_payee_location( 664 | self, 665 | budget: schemas.Budget = None, 666 | budget_id: str = "last-used", 667 | payee_location: schemas.PayeeLocation = None, 668 | payee_location_id: str = None, 669 | ): ... 670 | ``` 671 | 672 | ### Api().get_payee_locations 673 | 674 | [Show source in api.py:722](../../pynab/api.py#L722) 675 | 676 | Retrieves the payee locations for a given budget and payee. 677 | 678 | #### Arguments 679 | 680 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 681 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 682 | - `payee` *schemas.Payee, optional* - The payee object. Defaults to None. 683 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 684 | 685 | #### Returns 686 | 687 | - `dict` - A dictionary of payee locations, where the keys are the payee location IDs and the values are the payee location objects. 688 | 689 | #### Raises 690 | 691 | - `Exception` - If the API response status code is not 200, an exception is raised with the error details. 692 | 693 | #### Signature 694 | 695 | ```python 696 | def get_payee_locations( 697 | self, 698 | budget: schemas.Budget = None, 699 | budget_id: str = "last-used", 700 | payee: schemas.Payee = None, 701 | payee_id: str = None, 702 | ): ... 703 | ``` 704 | 705 | ### Api().get_payee_transactions 706 | 707 | [Show source in api.py:1317](../../pynab/api.py#L1317) 708 | 709 | Retrieves transactions associated with a specific payee. 710 | 711 | #### Arguments 712 | 713 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 714 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 715 | - `payee` *schemas.Payee, optional* - The payee object. Defaults to None. 716 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 717 | - `since_date` *str, optional* - The starting date for the transactions. Defaults to None. 718 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 719 | 720 | #### Returns 721 | 722 | - `dict` - A dictionary of transactions, where the transaction ID is the key and the transaction object is the value. 723 | 724 | #### Raises 725 | 726 | - `Exception` - If there is an error retrieving the transactions. 727 | 728 | #### Signature 729 | 730 | ```python 731 | def get_payee_transactions( 732 | self, 733 | budget: schemas.Budget = None, 734 | budget_id: str = "last-used", 735 | payee: schemas.Payee = None, 736 | payee_id: str = None, 737 | since_date: str = None, 738 | type: str = None, 739 | ): ... 740 | ``` 741 | 742 | ### Api().get_payees 743 | 744 | [Show source in api.py:521](../../pynab/api.py#L521) 745 | 746 | Retrieves the payees associated with a budget. 747 | 748 | #### Arguments 749 | 750 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 751 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 752 | 753 | #### Returns 754 | 755 | - `dict` - A dictionary containing the payees, where the key is the payee ID and the value is the payee object. 756 | 757 | If the request is successful, the dictionary will contain the payees associated with the budget. 758 | If the request fails, an error object will be returned. 759 | 760 | #### Signature 761 | 762 | ```python 763 | def get_payees(self, budget: schemas.Budget = None, budget_id: str = "last-used"): ... 764 | ``` 765 | 766 | ### Api().get_scheduled_transaction 767 | 768 | [Show source in api.py:1528](../../pynab/api.py#L1528) 769 | 770 | Retrieves a scheduled transaction from the API. 771 | 772 | #### Arguments 773 | 774 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 775 | - `budget_id` *str, optional* - The budget ID. Defaults to "last-used". 776 | - `schedule_transaction` *schemas.ScheduledTransaction, optional* - The scheduled transaction object. Defaults to None. 777 | - `scheduled_transaction_id` *str, optional* - The scheduled transaction ID. Defaults to None. 778 | 779 | #### Returns 780 | 781 | - `schemas.ScheduledTransaction` - The retrieved scheduled transaction. 782 | 783 | #### Raises 784 | 785 | - `Exception` - If the API request fails. 786 | 787 | #### Signature 788 | 789 | ```python 790 | def get_scheduled_transaction( 791 | self, 792 | budget: schemas.Budget = None, 793 | budget_id: str = "last-used", 794 | schedule_transaction: schemas.ScheduledTransaction = None, 795 | scheduled_transaction_id: str = None, 796 | ): ... 797 | ``` 798 | 799 | ### Api().get_scheduled_transactions 800 | 801 | [Show source in api.py:1429](../../pynab/api.py#L1429) 802 | 803 | Retrieves the scheduled transactions from the specified budget or the last-used budget. 804 | 805 | #### Arguments 806 | 807 | - `budget` *schemas.Budget, optional* - The budget object to retrieve scheduled transactions from. Defaults to None. 808 | - `budget_id` *str, optional* - The ID of the budget to retrieve scheduled transactions from. Defaults to "last-used". 809 | 810 | #### Returns 811 | 812 | - `dict` - A dictionary of scheduled transactions, where the keys are the transaction IDs and the values are the corresponding ScheduledTransaction objects. 813 | 814 | #### Raises 815 | 816 | - `Exception` - If there is an error retrieving the scheduled transactions. 817 | 818 | #### Signature 819 | 820 | ```python 821 | def get_scheduled_transactions( 822 | self, budget: schemas.Budget = None, budget_id: str = "last-used" 823 | ): ... 824 | ``` 825 | 826 | ### Api().get_transaction 827 | 828 | [Show source in api.py:1081](../../pynab/api.py#L1081) 829 | 830 | Retrieves a transaction from the specified budget or the last-used budget. 831 | 832 | #### Arguments 833 | 834 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 835 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 836 | - `transaction` *schemas.Transaction, optional* - The transaction object. Defaults to None. 837 | - `transaction_id` *str, optional* - The ID of the transaction. Defaults to None. 838 | 839 | #### Returns 840 | 841 | - `schemas.Transaction` - The retrieved transaction. 842 | 843 | #### Raises 844 | 845 | - `Exception` - If there is an error retrieving the transaction. 846 | 847 | #### Signature 848 | 849 | ```python 850 | def get_transaction( 851 | self, 852 | budget: schemas.Budget = None, 853 | budget_id: str = "last-used", 854 | transaction: schemas.Transaction = None, 855 | transaction_id: str = None, 856 | ): ... 857 | ``` 858 | 859 | ### Api().get_transactions 860 | 861 | [Show source in api.py:851](../../pynab/api.py#L851) 862 | 863 | Retrieves transactions from the specified budget or the last-used budget. 864 | 865 | #### Arguments 866 | 867 | - `budget` *schemas.Budget, optional* - The budget object to retrieve transactions from. Defaults to None. 868 | - `budget_id` *str, optional* - The ID of the budget to retrieve transactions from. Defaults to "last-used". 869 | - `since_date` *str, optional* - The date to retrieve transactions from. Defaults to None. 870 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 871 | 872 | #### Returns 873 | 874 | - `dict` - A dictionary of transactions, where the keys are the transaction IDs and the values are the transaction objects. 875 | 876 | #### Raises 877 | 878 | - `Exception` - If there is an error retrieving the transactions. 879 | 880 | #### Signature 881 | 882 | ```python 883 | def get_transactions( 884 | self, 885 | budget: schemas.Budget = None, 886 | budget_id: str = "last-used", 887 | since_date: str = None, 888 | type: str = None, 889 | ): ... 890 | ``` 891 | 892 | ### Api().get_user 893 | 894 | [Show source in api.py:22](../../pynab/api.py#L22) 895 | 896 | Retrieves the user information from the API. 897 | 898 | #### Returns 899 | 900 | - `User` - An instance of the User class representing the user information. 901 | 902 | #### Raises 903 | 904 | - `Exception` - If the API response status code is not 200, an exception is raised with the error information. 905 | 906 | #### Signature 907 | 908 | ```python 909 | def get_user(self): ... 910 | ``` 911 | 912 | ### Api().import_transactions 913 | 914 | [Show source in api.py:1058](../../pynab/api.py#L1058) 915 | 916 | Imports transactions into the budget. 917 | 918 | #### Arguments 919 | 920 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 921 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 922 | 923 | #### Returns 924 | 925 | - `list` - A list of transaction IDs if the import is successful. 926 | - `schemas.Error` - An error object if the import fails. 927 | 928 | #### Signature 929 | 930 | ```python 931 | def import_transactions( 932 | self, budget: schemas.Budget = None, budget_id: str = "last-used" 933 | ): ... 934 | ``` 935 | 936 | ### Api().update_category 937 | 938 | [Show source in api.py:362](../../pynab/api.py#L362) 939 | 940 | Update a category in the budget. 941 | 942 | #### Arguments 943 | 944 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 945 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 946 | - `category_group` *schemas.CategoryGroup, optional* - The category group object. Defaults to None. 947 | - `category_group_id` *str, optional* - The ID of the category group. Defaults to None. 948 | - `category` *schemas.Category, optional* - The category object. Defaults to None. 949 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 950 | - `name` *any, optional* - The name of the category. Defaults to None. 951 | - `note` *str, optional* - The note for the category. Defaults to None. 952 | 953 | #### Returns 954 | 955 | - `schemas.Category` - The updated category object. 956 | 957 | #### Raises 958 | 959 | - `Exception` - If there is an error updating the category. 960 | 961 | #### Signature 962 | 963 | ```python 964 | def update_category( 965 | self, 966 | budget: schemas.Budget = None, 967 | budget_id: str = "last-used", 968 | category_group: schemas.CategoryGroup = None, 969 | category_group_id: str = None, 970 | category: schemas.Category = None, 971 | category_id: str = None, 972 | name=None, 973 | note: str = None, 974 | ): ... 975 | ``` 976 | 977 | ### Api().update_category_for_month 978 | 979 | [Show source in api.py:464](../../pynab/api.py#L464) 980 | 981 | Update the budgeted amount for a category in a specific month. 982 | 983 | #### Arguments 984 | 985 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 986 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 987 | - `month` *schemas.Month, optional* - The month object. Defaults to None. 988 | - `month_id` *str, optional* - The ID of the month. Defaults to "current". 989 | - `category` *schemas.Category, optional* - The category object. Defaults to None. 990 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 991 | - `request_body` *str, optional* - The request body. Defaults to None. 992 | 993 | #### Returns 994 | 995 | - `schemas.Category` - The updated category object. 996 | 997 | #### Raises 998 | 999 | - `Exception` - If the response status code is not 200, an exception is raised with the error details. 1000 | 1001 | #### Signature 1002 | 1003 | ```python 1004 | def update_category_for_month( 1005 | self, 1006 | budget: schemas.Budget = None, 1007 | budget_id: str = "last-used", 1008 | month: schemas.Month = None, 1009 | month_id: str = "current", 1010 | category: schemas.Category = None, 1011 | category_id: str = None, 1012 | request_body: str = None, 1013 | ): ... 1014 | ``` 1015 | 1016 | ### Api().update_payee 1017 | 1018 | [Show source in api.py:598](../../pynab/api.py#L598) 1019 | 1020 | Update a payee with the given information. 1021 | 1022 | #### Arguments 1023 | 1024 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 1025 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 1026 | - `payee` *schemas.Payee, optional* - The payee object. Defaults to None. 1027 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 1028 | - `name` *str, optional* - The new name for the payee. Defaults to None. 1029 | 1030 | #### Returns 1031 | 1032 | - `schemas.Payee` - The updated payee object. 1033 | 1034 | #### Raises 1035 | 1036 | - `Exception` - If the API request fails. 1037 | 1038 | #### Signature 1039 | 1040 | ```python 1041 | def update_payee( 1042 | self, 1043 | budget: schemas.Budget = None, 1044 | budget_id: str = "last-used", 1045 | payee: schemas.Payee = None, 1046 | payee_id: str = None, 1047 | name: str = None, 1048 | ): ... 1049 | ``` 1050 | 1051 | ### Api().update_transaction 1052 | 1053 | [Show source in api.py:1121](../../pynab/api.py#L1121) 1054 | 1055 | Update a transaction in the budget. 1056 | 1057 | #### Arguments 1058 | 1059 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 1060 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 1061 | - `transaction` *schemas.Transaction, optional* - The transaction object. Defaults to None. 1062 | - `transaction_id` *str, optional* - The ID of the transaction. Defaults to None. 1063 | - `request_body` *str, optional* - The request body. Defaults to None. 1064 | 1065 | #### Returns 1066 | 1067 | - `schemas.Transaction` - The updated transaction object. 1068 | 1069 | #### Raises 1070 | 1071 | - `Exception` - If there is an error updating the transaction. 1072 | 1073 | #### Signature 1074 | 1075 | ```python 1076 | def update_transaction( 1077 | self, 1078 | budget: schemas.Budget = None, 1079 | budget_id: str = "last-used", 1080 | transaction: schemas.Transaction = None, 1081 | transaction_id: str = None, 1082 | request_body: str = None, 1083 | ): ... 1084 | ``` 1085 | 1086 | ### Api().update_transactions 1087 | 1088 | [Show source in api.py:999](../../pynab/api.py#L999) 1089 | 1090 | Update transactions in the budget. 1091 | 1092 | #### Arguments 1093 | 1094 | - `budget` *schemas.Budget, optional* - The budget object. Defaults to None. 1095 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 1096 | - `transactions` *list, optional* - List of transactions to update. Defaults to None. 1097 | 1098 | #### Returns 1099 | 1100 | - `dict` - A dictionary containing the updated transaction information. 1101 | 1102 | #### Raises 1103 | 1104 | - `Exception` - If there is an error in the update process. 1105 | 1106 | #### Signature 1107 | 1108 | ```python 1109 | def update_transactions( 1110 | self, 1111 | budget: schemas.Budget = None, 1112 | budget_id: str = "last-used", 1113 | transactions: list = None, 1114 | ): ... 1115 | ``` -------------------------------------------------------------------------------- /docs/pynab/constants.md: -------------------------------------------------------------------------------- 1 | # Constants 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Constants 4 | 5 | > Auto-generated documentation for [pynab.constants](../../pynab/constants.py) module. 6 | - [Constants](#constants) 7 | -------------------------------------------------------------------------------- /docs/pynab/endpoints.md: -------------------------------------------------------------------------------- 1 | # Endpoints 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Endpoints 4 | 5 | > Auto-generated documentation for [pynab.endpoints](../../pynab/endpoints.py) module. 6 | 7 | - [Endpoints](#endpoints) 8 | - [Endpoints](#endpoints-1) 9 | - [Endpoints().request_create_account](#endpoints()request_create_account) 10 | - [Endpoints().request_create_scheduled_transaction](#endpoints()request_create_scheduled_transaction) 11 | - [Endpoints().request_create_transactions](#endpoints()request_create_transactions) 12 | - [Endpoints().request_delete_transaction](#endpoints()request_delete_transaction) 13 | - [Endpoints().request_get_account](#endpoints()request_get_account) 14 | - [Endpoints().request_get_account_transactions](#endpoints()request_get_account_transactions) 15 | - [Endpoints().request_get_accounts](#endpoints()request_get_accounts) 16 | - [Endpoints().request_get_all_payee_locations](#endpoints()request_get_all_payee_locations) 17 | - [Endpoints().request_get_budget](#endpoints()request_get_budget) 18 | - [Endpoints().request_get_budget_settings](#endpoints()request_get_budget_settings) 19 | - [Endpoints().request_get_budgets](#endpoints()request_get_budgets) 20 | - [Endpoints().request_get_categories](#endpoints()request_get_categories) 21 | - [Endpoints().request_get_category](#endpoints()request_get_category) 22 | - [Endpoints().request_get_category_for_month](#endpoints()request_get_category_for_month) 23 | - [Endpoints().request_get_category_transactions](#endpoints()request_get_category_transactions) 24 | - [Endpoints().request_get_month](#endpoints()request_get_month) 25 | - [Endpoints().request_get_month_transactions](#endpoints()request_get_month_transactions) 26 | - [Endpoints().request_get_months](#endpoints()request_get_months) 27 | - [Endpoints().request_get_payee](#endpoints()request_get_payee) 28 | - [Endpoints().request_get_payee_location](#endpoints()request_get_payee_location) 29 | - [Endpoints().request_get_payee_locations](#endpoints()request_get_payee_locations) 30 | - [Endpoints().request_get_payee_transactions](#endpoints()request_get_payee_transactions) 31 | - [Endpoints().request_get_payees](#endpoints()request_get_payees) 32 | - [Endpoints().request_get_scheduled_transaction](#endpoints()request_get_scheduled_transaction) 33 | - [Endpoints().request_get_scheduled_transactions](#endpoints()request_get_scheduled_transactions) 34 | - [Endpoints().request_get_transaction](#endpoints()request_get_transaction) 35 | - [Endpoints().request_get_transactions](#endpoints()request_get_transactions) 36 | - [Endpoints().request_get_user](#endpoints()request_get_user) 37 | - [Endpoints().request_import_transactions](#endpoints()request_import_transactions) 38 | - [Endpoints().request_update_category](#endpoints()request_update_category) 39 | - [Endpoints().request_update_category_for_month](#endpoints()request_update_category_for_month) 40 | - [Endpoints().request_update_payee](#endpoints()request_update_payee) 41 | - [Endpoints().request_update_transaction](#endpoints()request_update_transaction) 42 | - [Endpoints().request_update_transactions](#endpoints()request_update_transactions) 43 | 44 | ## Endpoints 45 | 46 | [Show source in endpoints.py:5](../../pynab/endpoints.py#L5) 47 | 48 | #### Signature 49 | 50 | ```python 51 | class Endpoints: 52 | def __init__(self, pynab: pynab = None): ... 53 | ``` 54 | 55 | #### See also 56 | 57 | - [Pynab](./pynab.md#pynab) 58 | 59 | ### Endpoints().request_create_account 60 | 61 | [Show source in endpoints.py:109](../../pynab/endpoints.py#L109) 62 | 63 | Creates a new account in the specified budget. 64 | 65 | #### Arguments 66 | 67 | - `budget_id` *str, optional* - The ID of the budget to create the account in. Defaults to "last-used". 68 | - `request_body` *str, optional* - The JSON request body containing the account details. Defaults to None. 69 | 70 | #### Returns 71 | 72 | The response from the API call. 73 | 74 | #### Signature 75 | 76 | ```python 77 | def request_create_account( 78 | self, budget_id: str = "last-used", request_body: str = None 79 | ): ... 80 | ``` 81 | 82 | ### Endpoints().request_create_scheduled_transaction 83 | 84 | [Show source in endpoints.py:681](../../pynab/endpoints.py#L681) 85 | 86 | Creates a new scheduled transaction for the specified budget. 87 | 88 | #### Arguments 89 | 90 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 91 | - `request_body` *str, optional* - The request body containing the details of the scheduled transaction. Defaults to None. 92 | 93 | #### Returns 94 | 95 | The response from the API call. 96 | 97 | #### Signature 98 | 99 | ```python 100 | def request_create_scheduled_transaction( 101 | self, budget_id: str = "last-used", request_body: str = None 102 | ): ... 103 | ``` 104 | 105 | ### Endpoints().request_create_transactions 106 | 107 | [Show source in endpoints.py:431](../../pynab/endpoints.py#L431) 108 | 109 | Sends a request to create transactions for a specific budget. 110 | 111 | #### Arguments 112 | 113 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 114 | - `request_body` *str, optional* - The JSON request body containing the transaction data. Defaults to None. 115 | 116 | #### Returns 117 | 118 | The response from the API call. 119 | 120 | #### Signature 121 | 122 | ```python 123 | def request_create_transactions( 124 | self, budget_id: str = "last-used", request_body: str = None 125 | ): ... 126 | ``` 127 | 128 | ### Endpoints().request_delete_transaction 129 | 130 | [Show source in endpoints.py:520](../../pynab/endpoints.py#L520) 131 | 132 | Sends a request to delete a transaction. 133 | 134 | #### Arguments 135 | 136 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 137 | - `transaction_id` *str, optional* - The ID of the transaction to be deleted. 138 | 139 | #### Returns 140 | 141 | The response from the HTTP request. 142 | 143 | #### Signature 144 | 145 | ```python 146 | def request_delete_transaction( 147 | self, budget_id: str = "last-used", transaction_id: str = None 148 | ): ... 149 | ``` 150 | 151 | ### Endpoints().request_get_account 152 | 153 | [Show source in endpoints.py:126](../../pynab/endpoints.py#L126) 154 | 155 | Retrieves information about a specific account in a budget. 156 | 157 | #### Arguments 158 | 159 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 160 | - `account_id` *str, optional* - The ID of the account. If not provided, information about all accounts will be returned. 161 | 162 | #### Returns 163 | 164 | - `dict` - A dictionary containing the account information. 165 | 166 | #### Raises 167 | 168 | - `HTTPException` - If the request fails or the account is not found. 169 | 170 | #### Signature 171 | 172 | ```python 173 | def request_get_account(self, budget_id: str = "last-used", account_id: str = None): ... 174 | ``` 175 | 176 | ### Endpoints().request_get_account_transactions 177 | 178 | [Show source in endpoints.py:537](../../pynab/endpoints.py#L537) 179 | 180 | Retrieves the account transactions for a specific budget and account. 181 | 182 | #### Arguments 183 | 184 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 185 | - `account_id` *str, optional* - The ID of the account. Defaults to None. 186 | - `since_date` *str, optional* - The date to retrieve transactions from. Defaults to None. 187 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 188 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 189 | 190 | #### Returns 191 | 192 | The account transactions. 193 | 194 | #### Signature 195 | 196 | ```python 197 | def request_get_account_transactions( 198 | self, 199 | budget_id: str = "last-used", 200 | account_id: str = None, 201 | since_date: str = None, 202 | type: str = None, 203 | last_knowledge_of_server: int = 0, 204 | ): ... 205 | ``` 206 | 207 | ### Endpoints().request_get_accounts 208 | 209 | [Show source in endpoints.py:90](../../pynab/endpoints.py#L90) 210 | 211 | Retrieves the accounts associated with a specific budget. 212 | 213 | #### Arguments 214 | 215 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 216 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 217 | 218 | #### Returns 219 | 220 | The response from the HTTP GET request. 221 | 222 | #### Signature 223 | 224 | ```python 225 | def request_get_accounts( 226 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 227 | ): ... 228 | ``` 229 | 230 | ### Endpoints().request_get_all_payee_locations 231 | 232 | [Show source in endpoints.py:309](../../pynab/endpoints.py#L309) 233 | 234 | Retrieves all payee locations for a specific budget. 235 | 236 | #### Arguments 237 | 238 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 239 | 240 | #### Returns 241 | 242 | - `dict` - A dictionary containing the response data. 243 | 244 | #### Raises 245 | 246 | None 247 | 248 | #### Signature 249 | 250 | ```python 251 | def request_get_all_payee_locations(self, budget_id: str = "last-used"): ... 252 | ``` 253 | 254 | ### Endpoints().request_get_budget 255 | 256 | [Show source in endpoints.py:51](../../pynab/endpoints.py#L51) 257 | 258 | Retrieves the budget information from the server. 259 | 260 | #### Arguments 261 | 262 | - `budget_id` *str, optional* - The ID of the budget to retrieve. Defaults to "last-used". 263 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server to determine if the budget has been updated. Defaults to 0. 264 | 265 | #### Returns 266 | 267 | - `dict` - The budget information. 268 | 269 | #### Raises 270 | 271 | - `HTTPException` - If an error occurs during the HTTP request. 272 | 273 | #### Signature 274 | 275 | ```python 276 | def request_get_budget( 277 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 278 | ): ... 279 | ``` 280 | 281 | ### Endpoints().request_get_budget_settings 282 | 283 | [Show source in endpoints.py:73](../../pynab/endpoints.py#L73) 284 | 285 | Retrieves the budget settings for the specified budget ID. 286 | 287 | #### Arguments 288 | 289 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 290 | 291 | #### Returns 292 | 293 | - `dict` - The budget settings. 294 | 295 | #### Raises 296 | 297 | - `HTTPError` - If an HTTP error occurs. 298 | 299 | #### Signature 300 | 301 | ```python 302 | def request_get_budget_settings(self, budget_id: str = "last-used"): ... 303 | ``` 304 | 305 | ### Endpoints().request_get_budgets 306 | 307 | [Show source in endpoints.py:32](../../pynab/endpoints.py#L32) 308 | 309 | Sends a GET request to retrieve budgets. 310 | 311 | #### Arguments 312 | 313 | - `include_accounts` *bool, optional* - Whether to include accounts in the response. Defaults to False. 314 | 315 | #### Returns 316 | 317 | - `dict` - The response from the API. 318 | 319 | #### Raises 320 | 321 | None 322 | 323 | #### Signature 324 | 325 | ```python 326 | def request_get_budgets(self, include_accounts: bool = False): ... 327 | ``` 328 | 329 | ### Endpoints().request_get_categories 330 | 331 | [Show source in endpoints.py:144](../../pynab/endpoints.py#L144) 332 | 333 | Retrieves the categories for a specific budget. 334 | 335 | #### Arguments 336 | 337 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 338 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 339 | 340 | #### Returns 341 | 342 | The response from the HTTP GET request. 343 | 344 | #### Signature 345 | 346 | ```python 347 | def request_get_categories( 348 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 349 | ): ... 350 | ``` 351 | 352 | ### Endpoints().request_get_category 353 | 354 | [Show source in endpoints.py:163](../../pynab/endpoints.py#L163) 355 | 356 | Retrieves a specific category from a budget. 357 | 358 | #### Arguments 359 | 360 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 361 | - `category_id` *str, optional* - The ID of the category. If not provided, retrieves all categories. 362 | 363 | #### Returns 364 | 365 | - `dict` - The category information. 366 | 367 | #### Raises 368 | 369 | - `HTTPError` - If the request fails. 370 | 371 | #### Signature 372 | 373 | ```python 374 | def request_get_category( 375 | self, budget_id: str = "last-used", category_id: str = None 376 | ): ... 377 | ``` 378 | 379 | ### Endpoints().request_get_category_for_month 380 | 381 | [Show source in endpoints.py:207](../../pynab/endpoints.py#L207) 382 | 383 | Retrieves the category for a specific month in a budget. 384 | 385 | #### Arguments 386 | 387 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 388 | - `month` *str, optional* - The month to retrieve the category for. Defaults to "current". 389 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 390 | 391 | #### Returns 392 | 393 | The response from the API call. 394 | 395 | #### Signature 396 | 397 | ```python 398 | def request_get_category_for_month( 399 | self, budget_id: str = "last-used", month: str = "current", category_id: str = None 400 | ): ... 401 | ``` 402 | 403 | ### Endpoints().request_get_category_transactions 404 | 405 | [Show source in endpoints.py:569](../../pynab/endpoints.py#L569) 406 | 407 | Retrieves transactions for a specific category. 408 | 409 | #### Arguments 410 | 411 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 412 | - `category_id` *str, optional* - The ID of the category. Defaults to None. 413 | - `since_date` *str, optional* - The starting date to retrieve transactions from. Defaults to None. 414 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 415 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server to retrieve transactions from. Defaults to 0. 416 | 417 | #### Returns 418 | 419 | - `dict` - The response containing the retrieved transactions. 420 | 421 | #### Signature 422 | 423 | ```python 424 | def request_get_category_transactions( 425 | self, 426 | budget_id: str = "last-used", 427 | category_id: str = None, 428 | since_date: str = None, 429 | type: str = None, 430 | last_knowledge_of_server: int = 0, 431 | ): ... 432 | ``` 433 | 434 | ### Endpoints().request_get_month 435 | 436 | [Show source in endpoints.py:382](../../pynab/endpoints.py#L382) 437 | 438 | Retrieves the details of a specific month in a budget. 439 | 440 | #### Arguments 441 | 442 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 443 | - `month_id` *str, optional* - The ID of the month. Defaults to "current". 444 | 445 | #### Returns 446 | 447 | - `dict` - The details of the requested month. 448 | 449 | #### Raises 450 | 451 | - `HTTPError` - If the request fails. 452 | 453 | #### Signature 454 | 455 | ```python 456 | def request_get_month(self, budget_id: str = "last-used", month_id: str = "current"): ... 457 | ``` 458 | 459 | ### Endpoints().request_get_month_transactions 460 | 461 | [Show source in endpoints.py:631](../../pynab/endpoints.py#L631) 462 | 463 | Retrieves the transactions for a specific month in a budget. 464 | 465 | #### Arguments 466 | 467 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 468 | - `month` *str, optional* - The month to retrieve transactions for. Defaults to "current". 469 | - `since_date` *str, optional* - The starting date for the transactions. Defaults to None. 470 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 471 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 472 | 473 | #### Returns 474 | 475 | The response from the API containing the transactions for the specified month. 476 | 477 | #### Signature 478 | 479 | ```python 480 | def request_get_month_transactions( 481 | self, 482 | budget_id: str = "last-used", 483 | month: str = "current", 484 | since_date: str = None, 485 | type: str = None, 486 | last_knowledge_of_server: int = 0, 487 | ): ... 488 | ``` 489 | 490 | ### Endpoints().request_get_months 491 | 492 | [Show source in endpoints.py:363](../../pynab/endpoints.py#L363) 493 | 494 | Retrieves the months for a specific budget. 495 | 496 | #### Arguments 497 | 498 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 499 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 500 | 501 | #### Returns 502 | 503 | The response from the server. 504 | 505 | #### Signature 506 | 507 | ```python 508 | def request_get_months( 509 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 510 | ): ... 511 | ``` 512 | 513 | ### Endpoints().request_get_payee 514 | 515 | [Show source in endpoints.py:270](../../pynab/endpoints.py#L270) 516 | 517 | Retrieves a specific payee from the specified budget. 518 | 519 | #### Arguments 520 | 521 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 522 | - `payee_id` *str, optional* - The ID of the payee. If not provided, all payees will be returned. 523 | 524 | #### Returns 525 | 526 | - `dict` - The payee information. 527 | 528 | #### Raises 529 | 530 | - `HTTPError` - If the request fails. 531 | 532 | #### Signature 533 | 534 | ```python 535 | def request_get_payee(self, budget_id: str = "last-used", payee_id: str = None): ... 536 | ``` 537 | 538 | ### Endpoints().request_get_payee_location 539 | 540 | [Show source in endpoints.py:326](../../pynab/endpoints.py#L326) 541 | 542 | Retrieves a specific payee location from the specified budget. 543 | 544 | #### Arguments 545 | 546 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 547 | - `payee_location_id` *str, optional* - The ID of the payee location. Defaults to None. 548 | 549 | #### Returns 550 | 551 | - `dict` - The payee location information. 552 | 553 | #### Raises 554 | 555 | - `HTTPError` - If the request fails. 556 | 557 | #### Signature 558 | 559 | ```python 560 | def request_get_payee_location( 561 | self, budget_id: str = "last-used", payee_location_id: str = None 562 | ): ... 563 | ``` 564 | 565 | ### Endpoints().request_get_payee_locations 566 | 567 | [Show source in endpoints.py:346](../../pynab/endpoints.py#L346) 568 | 569 | Retrieves the payee locations for a specific payee in a budget. 570 | 571 | #### Arguments 572 | 573 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 574 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 575 | 576 | #### Returns 577 | 578 | - `dict` - The payee locations for the specified payee in the budget. 579 | 580 | #### Signature 581 | 582 | ```python 583 | def request_get_payee_locations( 584 | self, budget_id: str = "last-used", payee_id: str = None 585 | ): ... 586 | ``` 587 | 588 | ### Endpoints().request_get_payee_transactions 589 | 590 | [Show source in endpoints.py:600](../../pynab/endpoints.py#L600) 591 | 592 | Retrieves transactions for a specific payee. 593 | 594 | #### Arguments 595 | 596 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 597 | - `payee_id` *str, optional* - The ID of the payee. Defaults to None. 598 | - `since_date` *str, optional* - The date to retrieve transactions since. Defaults to None. 599 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 600 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 601 | 602 | #### Returns 603 | 604 | The response from the API containing the payee transactions. 605 | 606 | #### Signature 607 | 608 | ```python 609 | def request_get_payee_transactions( 610 | self, 611 | budget_id: str = "last-used", 612 | payee_id: str = None, 613 | since_date: str = None, 614 | type: str = None, 615 | last_knowledge_of_server: int = 0, 616 | ): ... 617 | ``` 618 | 619 | ### Endpoints().request_get_payees 620 | 621 | [Show source in endpoints.py:251](../../pynab/endpoints.py#L251) 622 | 623 | Retrieves the payees for a specific budget. 624 | 625 | #### Arguments 626 | 627 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 628 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 629 | 630 | #### Returns 631 | 632 | The response from the HTTP GET request. 633 | 634 | #### Signature 635 | 636 | ```python 637 | def request_get_payees( 638 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 639 | ): ... 640 | ``` 641 | 642 | ### Endpoints().request_get_scheduled_transaction 643 | 644 | [Show source in endpoints.py:698](../../pynab/endpoints.py#L698) 645 | 646 | Retrieves a scheduled transaction from the specified budget. 647 | 648 | #### Arguments 649 | 650 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 651 | - `scheduled_transaction_id` *str, optional* - The ID of the scheduled transaction. 652 | 653 | #### Returns 654 | 655 | - `dict` - The scheduled transaction information. 656 | 657 | #### Raises 658 | 659 | - `HTTPException` - If the request fails. 660 | 661 | #### Signature 662 | 663 | ```python 664 | def request_get_scheduled_transaction( 665 | self, budget_id: str = "last-used", scheduled_transaction_id: str = None 666 | ): ... 667 | ``` 668 | 669 | ### Endpoints().request_get_scheduled_transactions 670 | 671 | [Show source in endpoints.py:662](../../pynab/endpoints.py#L662) 672 | 673 | Retrieves the scheduled transactions for a specific budget. 674 | 675 | #### Arguments 676 | 677 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 678 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server. Defaults to 0. 679 | 680 | #### Returns 681 | 682 | The response from the server containing the scheduled transactions. 683 | 684 | #### Signature 685 | 686 | ```python 687 | def request_get_scheduled_transactions( 688 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 689 | ): ... 690 | ``` 691 | 692 | ### Endpoints().request_get_transaction 693 | 694 | [Show source in endpoints.py:479](../../pynab/endpoints.py#L479) 695 | 696 | Retrieves a specific transaction from a budget. 697 | 698 | #### Arguments 699 | 700 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 701 | - `transaction_id` *str, optional* - The ID of the transaction. If not provided, all transactions will be returned. 702 | 703 | #### Returns 704 | 705 | - `dict` - The retrieved transaction information. 706 | 707 | #### Raises 708 | 709 | - `HTTPError` - If the request fails or the transaction is not found. 710 | 711 | #### Signature 712 | 713 | ```python 714 | def request_get_transaction( 715 | self, budget_id: str = "last-used", transaction_id: str = None 716 | ): ... 717 | ``` 718 | 719 | ### Endpoints().request_get_transactions 720 | 721 | [Show source in endpoints.py:402](../../pynab/endpoints.py#L402) 722 | 723 | Sends a GET request to retrieve transactions from the specified budget. 724 | 725 | #### Arguments 726 | 727 | - `budget_id` *str, optional* - The ID of the budget to retrieve transactions from. Defaults to "last-used". 728 | - `since_date` *str, optional* - The date to retrieve transactions since. Defaults to None. 729 | - `type` *str, optional* - The type of transactions to retrieve. Defaults to None. 730 | - `last_knowledge_of_server` *int, optional* - The knowledge of the server to retrieve transactions from. Defaults to 0. 731 | 732 | #### Returns 733 | 734 | - `dict` - The response from the server containing the retrieved transactions. 735 | 736 | #### Signature 737 | 738 | ```python 739 | def request_get_transactions( 740 | self, 741 | budget_id: str = "last-used", 742 | since_date: str = None, 743 | type: str = None, 744 | last_knowledge_of_server: int = 0, 745 | ): ... 746 | ``` 747 | 748 | ### Endpoints().request_get_user 749 | 750 | [Show source in endpoints.py:21](../../pynab/endpoints.py#L21) 751 | 752 | Sends a GET request to retrieve user information. 753 | 754 | #### Returns 755 | 756 | The response from the GET request. 757 | 758 | #### Signature 759 | 760 | ```python 761 | def request_get_user(self): ... 762 | ``` 763 | 764 | ### Endpoints().request_import_transactions 765 | 766 | [Show source in endpoints.py:465](../../pynab/endpoints.py#L465) 767 | 768 | Sends a request to import transactions for a specific budget. 769 | 770 | #### Arguments 771 | 772 | - `budget_id` *str, optional* - The ID of the budget to import transactions for. Defaults to "last-used". 773 | 774 | #### Returns 775 | 776 | The response from the HTTP POST request. 777 | 778 | #### Signature 779 | 780 | ```python 781 | def request_import_transactions(self, budget_id: str = "last-used"): ... 782 | ``` 783 | 784 | ### Endpoints().request_update_category 785 | 786 | [Show source in endpoints.py:183](../../pynab/endpoints.py#L183) 787 | 788 | Sends a PATCH request to update a category in the specified budget. 789 | 790 | #### Arguments 791 | 792 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 793 | - `category_id` *str, optional* - The ID of the category to update. 794 | - `request_body` *str, optional* - The JSON request body containing the updated category data. 795 | 796 | #### Returns 797 | 798 | The response from the PATCH request. 799 | 800 | #### Raises 801 | 802 | None. 803 | 804 | #### Signature 805 | 806 | ```python 807 | def request_update_category( 808 | self, budget_id: str = "last-used", category_id: str = None, request_body: str = None 809 | ): ... 810 | ``` 811 | 812 | ### Endpoints().request_update_category_for_month 813 | 814 | [Show source in endpoints.py:228](../../pynab/endpoints.py#L228) 815 | 816 | Sends a PATCH request to update a category for a specific month in a budget. 817 | 818 | #### Arguments 819 | 820 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 821 | - `month_id` *str, optional* - The ID of the month. Defaults to "current". 822 | - `category_id` *str, optional* - The ID of the category to update. 823 | - `request_body` *str, optional* - The JSON request body. 824 | 825 | #### Returns 826 | 827 | The response from the PATCH request. 828 | 829 | #### Signature 830 | 831 | ```python 832 | def request_update_category_for_month( 833 | self, 834 | budget_id: str = "last-used", 835 | month_id: str = "current", 836 | category_id: str = None, 837 | request_body: str = None, 838 | ): ... 839 | ``` 840 | 841 | ### Endpoints().request_update_payee 842 | 843 | [Show source in endpoints.py:288](../../pynab/endpoints.py#L288) 844 | 845 | Sends a PATCH request to update a payee. 846 | 847 | #### Arguments 848 | 849 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 850 | - `payee_id` *str, optional* - The ID of the payee to update. 851 | - `request_body` *str, optional* - The JSON request body. 852 | 853 | #### Returns 854 | 855 | The response from the PATCH request. 856 | 857 | #### Signature 858 | 859 | ```python 860 | def request_update_payee( 861 | self, budget_id: str = "last-used", payee_id: str = None, request_body: str = None 862 | ): ... 863 | ``` 864 | 865 | ### Endpoints().request_update_transaction 866 | 867 | [Show source in endpoints.py:499](../../pynab/endpoints.py#L499) 868 | 869 | Updates a transaction in the specified budget. 870 | 871 | #### Arguments 872 | 873 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 874 | - `transaction_id` *str, optional* - The ID of the transaction to update. 875 | - `request_body` *str, optional* - The JSON request body containing the updated transaction data. 876 | 877 | #### Returns 878 | 879 | The response from the API call. 880 | 881 | #### Signature 882 | 883 | ```python 884 | def request_update_transaction( 885 | self, 886 | budget_id: str = "last-used", 887 | transaction_id: str = None, 888 | request_body: str = None, 889 | ): ... 890 | ``` 891 | 892 | ### Endpoints().request_update_transactions 893 | 894 | [Show source in endpoints.py:448](../../pynab/endpoints.py#L448) 895 | 896 | Sends a PATCH request to update transactions for a specific budget. 897 | 898 | #### Arguments 899 | 900 | - `budget_id` *str, optional* - The ID of the budget. Defaults to "last-used". 901 | - `request_body` *str, optional* - The JSON request body. Defaults to None. 902 | 903 | #### Returns 904 | 905 | The response from the PATCH request. 906 | 907 | #### Signature 908 | 909 | ```python 910 | def request_update_transactions( 911 | self, budget_id: str = "last-used", request_body: str = None 912 | ): ... 913 | ``` -------------------------------------------------------------------------------- /docs/pynab/enums.md: -------------------------------------------------------------------------------- 1 | # Enums 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Enums 4 | 5 | > Auto-generated documentation for [pynab.enums](../../pynab/enums.py) module. 6 | 7 | - [Enums](#enums) 8 | - [AccountType](#accounttype) 9 | - [DebtTransactionType](#debttransactiontype) 10 | - [Frequency](#frequency) 11 | - [GoalType](#goaltype) 12 | - [TransactionClearedStatus](#transactionclearedstatus) 13 | - [TransactionFlagColor](#transactionflagcolor) 14 | 15 | ## AccountType 16 | 17 | [Show source in enums.py:129](../../pynab/enums.py#L129) 18 | 19 | Enum representing different types of accounts. 20 | 21 | #### Attributes 22 | 23 | - `CHECKING` *str* - Represents a checking account. 24 | - `SAVINGS` *str* - Represents a savings account. 25 | - `CASH` *str* - Represents a cash account. 26 | - `CREDIT_CARD` *str* - Represents a credit card account. 27 | - `LINE_OF_CREDIT` *str* - Represents a line of credit account. 28 | - `OTHER_ASSET` *str* - Represents an other asset account. 29 | - `OTHER_LIABILITY` *str* - Represents an other liability account. 30 | - `MORTGAGE` *str* - Represents a mortgage account. 31 | - `AUTO_LOAN` *str* - Represents an auto loan account. 32 | - `STUDENT_LOAN` *str* - Represents a student loan account. 33 | - `PERSONAL_LOAN` *str* - Represents a personal loan account. 34 | - `MEDICAL_DEBT` *str* - Represents a medical debt account. 35 | - `OTHER_DEBT` *str* - Represents an other debt account. 36 | - `NONE` *None* - Represents no account type. 37 | 38 | #### Signature 39 | 40 | ```python 41 | class AccountType(Enum): ... 42 | ``` 43 | 44 | 45 | 46 | ## DebtTransactionType 47 | 48 | [Show source in enums.py:41](../../pynab/enums.py#L41) 49 | 50 | Enum class representing different types of debt transactions. 51 | 52 | #### Attributes 53 | 54 | - `PAYMENT` *str* - Represents a payment transaction. 55 | - `REFUND` *str* - Represents a refund transaction. 56 | - `FEE` *str* - Represents a fee transaction. 57 | - `INTEREST` *str* - Represents an interest transaction. 58 | - `ESCROW` *str* - Represents an escrow transaction. 59 | - `BALANCE_ADJUSTMENT` *str* - Represents a balance adjustment transaction. 60 | - `CREDIT` *str* - Represents a credit transaction. 61 | - `CHARGE` *str* - Represents a charge transaction. 62 | - `NONE` *None* - Represents no transaction type. 63 | 64 | #### Signature 65 | 66 | ```python 67 | class DebtTransactionType(Enum): ... 68 | ``` 69 | 70 | 71 | 72 | ## Frequency 73 | 74 | [Show source in enums.py:4](../../pynab/enums.py#L4) 75 | 76 | Enum representing different frequencies. 77 | 78 | #### Attributes 79 | 80 | - `NEVER` *str* - Represents never. 81 | - `DAILY` *str* - Represents daily. 82 | - `WEEKLY` *str* - Represents weekly. 83 | - `EVERY_OTHER_WEEK` *str* - Represents every other week. 84 | - `TWICE_A_MONTH` *str* - Represents twice a month. 85 | - `EVERY_4_WEEKS` *str* - Represents every 4 weeks. 86 | - `MONTHLY` *str* - Represents monthly. 87 | - `EVERY_OTHER_MONTH` *str* - Represents every other month. 88 | - `EVERY_3_MONTHS` *str* - Represents every 3 months. 89 | - `EVERY_4_MONTHS` *str* - Represents every 4 months. 90 | - `TWICE_A_YEAR` *str* - Represents twice a year. 91 | - `YEARLY` *str* - Represents yearly. 92 | - `EVERY_OTHER_YEAR` *str* - Represents every other year. 93 | - `NONE` *None* - Represents none. 94 | 95 | #### Signature 96 | 97 | ```python 98 | class Frequency(Enum): ... 99 | ``` 100 | 101 | 102 | 103 | ## GoalType 104 | 105 | [Show source in enums.py:108](../../pynab/enums.py#L108) 106 | 107 | Enum class representing different types of goals. 108 | 109 | #### Attributes 110 | 111 | - `TARGET_CATEGORY_BALANCE` *str* - Target category balance goal type. 112 | - `TARGET_CATEGORY_BALANCE_BY_DATE` *str* - Target category balance by date goal type. 113 | - `MONTHLY_FUNDING` *str* - Monthly funding goal type. 114 | - `PLAN_YOUR_SPENDING` *str* - Plan your spending goal type. 115 | - `DEBT` *str* - Debt goal type. 116 | - `NONE` *None* - No goal type. 117 | 118 | #### Signature 119 | 120 | ```python 121 | class GoalType(Enum): ... 122 | ``` 123 | 124 | 125 | 126 | ## TransactionClearedStatus 127 | 128 | [Show source in enums.py:91](../../pynab/enums.py#L91) 129 | 130 | Enum representing the cleared status of a transaction. 131 | 132 | #### Attributes 133 | 134 | - `CLEARED` *str* - Represents a cleared transaction. 135 | - `UNCLEARED` *str* - Represents an uncleared transaction. 136 | - `RECONCILED` *str* - Represents a reconciled transaction. 137 | - `NONE` *None* - Represents no cleared status. 138 | 139 | #### Signature 140 | 141 | ```python 142 | class TransactionClearedStatus(Enum): ... 143 | ``` 144 | 145 | 146 | 147 | ## TransactionFlagColor 148 | 149 | [Show source in enums.py:68](../../pynab/enums.py#L68) 150 | 151 | Enum class representing the color of a transaction flag. 152 | 153 | #### Attributes 154 | 155 | - `RED` *str* - The color red. 156 | - `ORANGE` *str* - The color orange. 157 | - `YELLOW` *str* - The color yellow. 158 | - `GREEN` *str* - The color green. 159 | - `BLUE` *str* - The color blue. 160 | - `PURPLE` *str* - The color purple. 161 | - `NONE` *None* - No color specified. 162 | 163 | #### Signature 164 | 165 | ```python 166 | class TransactionFlagColor(Enum): ... 167 | ``` -------------------------------------------------------------------------------- /docs/pynab/index.md: -------------------------------------------------------------------------------- 1 | # Pynab 2 | 3 | [Pynab Index](../README.md#pynab-index) / Pynab 4 | 5 | > Auto-generated documentation for [pynab](../../pynab/__init__.py) module. 6 | 7 | - [Pynab](#pynab) 8 | - [Modules](#modules) 9 | 10 | ## Modules 11 | 12 | - [Api](./api.md) 13 | - [Constants](./constants.md) 14 | - [Endpoints](./endpoints.md) 15 | - [Enums](./enums.md) 16 | - [Pynab](./pynab.md) 17 | - [Schemas](./schemas.md) 18 | - [Utils](./utils.md) -------------------------------------------------------------------------------- /docs/pynab/pynab.md: -------------------------------------------------------------------------------- 1 | # Pynab 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Pynab 4 | 5 | > Auto-generated documentation for [pynab.pynab](../../pynab/pynab.py) module. 6 | 7 | - [Pynab](#pynab) 8 | - [Pynab](#pynab-1) 9 | - [Pynab().budgets](#pynab()budgets) 10 | - [Pynab().server_knowledges](#pynab()server_knowledges) 11 | - [Pynab().user](#pynab()user) 12 | 13 | ## Pynab 14 | 15 | [Show source in pynab.py:5](../../pynab/pynab.py#L5) 16 | 17 | #### Signature 18 | 19 | ```python 20 | class Pynab: 21 | def __init__(self, bearer: str = None): ... 22 | ``` 23 | 24 | ### Pynab().budgets 25 | 26 | [Show source in pynab.py:65](../../pynab/pynab.py#L65) 27 | 28 | Retrieves the budgets from the API. 29 | 30 | #### Returns 31 | 32 | - `list` - A list of budgets. 33 | 34 | #### Signature 35 | 36 | ```python 37 | @property 38 | def budgets(self): ... 39 | ``` 40 | 41 | ### Pynab().server_knowledges 42 | 43 | [Show source in pynab.py:40](../../pynab/pynab.py#L40) 44 | 45 | Retrieves the server knowledge for a specific endpoint. 46 | 47 | #### Arguments 48 | 49 | - `endpoint` *str* - The endpoint for which to retrieve the server knowledge. If not provided, the default value is None. 50 | 51 | #### Returns 52 | 53 | - `int` - The server knowledge for the specified endpoint. If server knowledge tracking is disabled, returns 0. 54 | 55 | #### Signature 56 | 57 | ```python 58 | def server_knowledges(self, endpoint: str = None): ... 59 | ``` 60 | 61 | ### Pynab().user 62 | 63 | [Show source in pynab.py:55](../../pynab/pynab.py#L55) 64 | 65 | Retrieves the user information from the API. 66 | 67 | #### Returns 68 | 69 | - `dict` - A dictionary containing the user information. 70 | 71 | #### Signature 72 | 73 | ```python 74 | @property 75 | def user(self): ... 76 | ``` -------------------------------------------------------------------------------- /docs/pynab/schemas.md: -------------------------------------------------------------------------------- 1 | # Schemas 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Schemas 4 | 5 | > Auto-generated documentation for [pynab.schemas](../../pynab/schemas.py) module. 6 | 7 | - [Schemas](#schemas) 8 | - [Account](#account) 9 | - [Account().payee_locations](#account()payee_locations) 10 | - [Account().payees](#account()payees) 11 | - [Account().scheduled_transactions](#account()scheduled_transactions) 12 | - [Account().transactions](#account()transactions) 13 | - [Account().transfer_payees](#account()transfer_payees) 14 | - [Budget](#budget) 15 | - [Budget().accounts](#budget()accounts) 16 | - [Budget().accounts](#budget()accounts-1) 17 | - [Budget().accounts](#budget()accounts-2) 18 | - [Budget().categories](#budget()categories) 19 | - [Budget().categories](#budget()categories-1) 20 | - [Budget().categories](#budget()categories-2) 21 | - [Budget().category_groups](#budget()category_groups) 22 | - [Budget().category_groups](#budget()category_groups-1) 23 | - [Budget().category_groups](#budget()category_groups-2) 24 | - [Budget().detail](#budget()detail) 25 | - [Budget().months](#budget()months) 26 | - [Budget().months](#budget()months-1) 27 | - [Budget().months](#budget()months-2) 28 | - [Budget().payee_locations](#budget()payee_locations) 29 | - [Budget().payee_locations](#budget()payee_locations-1) 30 | - [Budget().payee_locations](#budget()payee_locations-2) 31 | - [Budget().payees](#budget()payees) 32 | - [Budget().payees](#budget()payees-1) 33 | - [Budget().payees](#budget()payees-2) 34 | - [Budget().scheduled_subtransactions](#budget()scheduled_subtransactions) 35 | - [Budget().scheduled_subtransactions](#budget()scheduled_subtransactions-1) 36 | - [Budget().scheduled_subtransactions](#budget()scheduled_subtransactions-2) 37 | - [Budget().scheduled_transactions](#budget()scheduled_transactions) 38 | - [Budget().scheduled_transactions](#budget()scheduled_transactions-1) 39 | - [Budget().scheduled_transactions](#budget()scheduled_transactions-2) 40 | - [Budget().settings](#budget()settings) 41 | - [Budget().subtransactions](#budget()subtransactions) 42 | - [Budget().subtransactions](#budget()subtransactions-1) 43 | - [Budget().subtransactions](#budget()subtransactions-2) 44 | - [Budget().transactions](#budget()transactions) 45 | - [Budget().transactions](#budget()transactions-1) 46 | - [Budget().transactions](#budget()transactions-2) 47 | - [BudgetSettings](#budgetsettings) 48 | - [Category](#category) 49 | - [Category().category_group](#category()category_group) 50 | - [Category().original_category_group](#category()original_category_group) 51 | - [Category().scheduled_subtransactions](#category()scheduled_subtransactions) 52 | - [Category().scheduled_transactions](#category()scheduled_transactions) 53 | - [Category().subtransactions](#category()subtransactions) 54 | - [Category().transactions](#category()transactions) 55 | - [CategoryGroup](#categorygroup) 56 | - [CurrencyFormat](#currencyformat) 57 | - [DateFormat](#dateformat) 58 | - [DebtEscrowAmounts](#debtescrowamounts) 59 | - [DebtInterestRates](#debtinterestrates) 60 | - [DebtMinimumPayments](#debtminimumpayments) 61 | - [Error](#error) 62 | - [Error().__str__](#error()__str__) 63 | - [Month](#month) 64 | - [Payee](#payee) 65 | - [Payee().payee_locations](#payee()payee_locations) 66 | - [Payee().scheduled_subtransactions](#payee()scheduled_subtransactions) 67 | - [Payee().scheduled_transactions](#payee()scheduled_transactions) 68 | - [Payee().subtransactions](#payee()subtransactions) 69 | - [Payee().transactions](#payee()transactions) 70 | - [Payee().transfer_account](#payee()transfer_account) 71 | - [PayeeLocation](#payeelocation) 72 | - [PayeeLocation().payee](#payeelocation()payee) 73 | - [ScheduledSubTransaction](#scheduledsubtransaction) 74 | - [ScheduledSubTransaction().category](#scheduledsubtransaction()category) 75 | - [ScheduledSubTransaction().payee](#scheduledsubtransaction()payee) 76 | - [ScheduledSubTransaction().scheduled_transaction](#scheduledsubtransaction()scheduled_transaction) 77 | - [ScheduledSubTransaction().transfer_account](#scheduledsubtransaction()transfer_account) 78 | - [ScheduledTransaction](#scheduledtransaction) 79 | - [ScheduledTransaction().account](#scheduledtransaction()account) 80 | - [ScheduledTransaction().category](#scheduledtransaction()category) 81 | - [ScheduledTransaction().payee](#scheduledtransaction()payee) 82 | - [ScheduledTransaction().to_dict](#scheduledtransaction()to_dict) 83 | - [ScheduledTransaction().to_json](#scheduledtransaction()to_json) 84 | - [ScheduledTransaction().transfer_account](#scheduledtransaction()transfer_account) 85 | - [SubTransaction](#subtransaction) 86 | - [SubTransaction().category](#subtransaction()category) 87 | - [SubTransaction().payee](#subtransaction()payee) 88 | - [SubTransaction().transaction](#subtransaction()transaction) 89 | - [SubTransaction().transfer_account](#subtransaction()transfer_account) 90 | - [SubTransaction().transfer_transaction](#subtransaction()transfer_transaction) 91 | - [Transaction](#transaction) 92 | - [Transaction().account](#transaction()account) 93 | - [Transaction().categories](#transaction()categories) 94 | - [Transaction().matched_transaction](#transaction()matched_transaction) 95 | - [Transaction().payee](#transaction()payee) 96 | - [Transaction().to_dict](#transaction()to_dict) 97 | - [Transaction().to_json](#transaction()to_json) 98 | - [Transaction().transfer_account](#transaction()transfer_account) 99 | - [Transaction().transfer_transaction](#transaction()transfer_transaction) 100 | - [User](#user) 101 | - [User().to_dict](#user()to_dict) 102 | - [User().to_json](#user()to_json) 103 | 104 | ## Account 105 | 106 | [Show source in schemas.py:704](../../pynab/schemas.py#L704) 107 | 108 | #### Signature 109 | 110 | ```python 111 | class Account: 112 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 113 | ``` 114 | 115 | #### See also 116 | 117 | - [Budget](#budget) 118 | 119 | ### Account().payee_locations 120 | 121 | [Show source in schemas.py:795](../../pynab/schemas.py#L795) 122 | 123 | Retrieves the locations associated with each payee. 124 | 125 | #### Returns 126 | 127 | A list of payee locations. 128 | 129 | #### Signature 130 | 131 | ```python 132 | @property 133 | def payee_locations(self): ... 134 | ``` 135 | 136 | ### Account().payees 137 | 138 | [Show source in schemas.py:784](../../pynab/schemas.py#L784) 139 | 140 | Retrieve the payees associated with the budget. 141 | 142 | #### Returns 143 | 144 | - `list` - A list of payees associated with the budget. 145 | 146 | #### Signature 147 | 148 | ```python 149 | @property 150 | def payees(self): ... 151 | ``` 152 | 153 | ### Account().scheduled_transactions 154 | 155 | [Show source in schemas.py:820](../../pynab/schemas.py#L820) 156 | 157 | Retrieves the scheduled transactions associated with the account. 158 | 159 | #### Returns 160 | 161 | - `list` - A list of scheduled transactions. 162 | 163 | #### Signature 164 | 165 | ```python 166 | @property 167 | def scheduled_transactions(self): ... 168 | ``` 169 | 170 | ### Account().transactions 171 | 172 | [Show source in schemas.py:808](../../pynab/schemas.py#L808) 173 | 174 | Retrieve transactions associated with the account. 175 | 176 | #### Returns 177 | 178 | - `list` - A list of transactions associated with the account. 179 | 180 | #### Signature 181 | 182 | ```python 183 | @property 184 | def transactions(self): ... 185 | ``` 186 | 187 | ### Account().transfer_payees 188 | 189 | [Show source in schemas.py:774](../../pynab/schemas.py#L774) 190 | 191 | Returns the payee associated with the transfer_payee_id. 192 | 193 | #### Returns 194 | 195 | The payee object associated with the transfer_payee_id. 196 | 197 | #### Signature 198 | 199 | ```python 200 | @property 201 | def transfer_payees(self): ... 202 | ``` 203 | 204 | 205 | 206 | ## Budget 207 | 208 | [Show source in schemas.py:91](../../pynab/schemas.py#L91) 209 | 210 | #### Signature 211 | 212 | ```python 213 | class Budget: 214 | def __init__(self, pynab=None, _json: str = None): ... 215 | ``` 216 | 217 | ### Budget().accounts 218 | 219 | [Show source in schemas.py:184](../../pynab/schemas.py#L184) 220 | 221 | Returns the accounts associated with the object. 222 | 223 | #### Returns 224 | 225 | - `list` - A list of accounts. 226 | 227 | #### Signature 228 | 229 | ```python 230 | @property 231 | def accounts(self): ... 232 | ``` 233 | 234 | ### Budget().accounts 235 | 236 | [Show source in schemas.py:194](../../pynab/schemas.py#L194) 237 | 238 | Process the given JSON string and create Account objects for each account. 239 | 240 | #### Arguments 241 | 242 | - `_json` *str* - The JSON string containing account information. 243 | 244 | #### Returns 245 | 246 | None 247 | 248 | #### Signature 249 | 250 | ```python 251 | @accounts.setter 252 | def accounts(self, _json: str = ""): ... 253 | ``` 254 | 255 | ### Budget().accounts 256 | 257 | [Show source in schemas.py:209](../../pynab/schemas.py#L209) 258 | 259 | Retrieve the accounts associated with the budget. 260 | 261 | #### Returns 262 | 263 | - `dict` - A dictionary containing the accounts associated with the budget. 264 | 265 | #### Signature 266 | 267 | ```python 268 | @accounts.getter 269 | def accounts(self): ... 270 | ``` 271 | 272 | ### Budget().categories 273 | 274 | [Show source in schemas.py:344](../../pynab/schemas.py#L344) 275 | 276 | Returns the categories associated with the object. 277 | 278 | #### Returns 279 | 280 | The categories associated with the object. 281 | 282 | #### Signature 283 | 284 | ```python 285 | @property 286 | def categories(self): ... 287 | ``` 288 | 289 | ### Budget().categories 290 | 291 | [Show source in schemas.py:354](../../pynab/schemas.py#L354) 292 | 293 | Process the given JSON string and create Category objects for each category. 294 | 295 | #### Arguments 296 | 297 | - `_json` *str* - The JSON string containing the categories. 298 | 299 | #### Returns 300 | 301 | None 302 | 303 | #### Signature 304 | 305 | ```python 306 | @categories.setter 307 | def categories(self, _json: str = ""): ... 308 | ``` 309 | 310 | ### Budget().categories 311 | 312 | [Show source in schemas.py:369](../../pynab/schemas.py#L369) 313 | 314 | Retrieves the categories associated with the budget. 315 | 316 | If the categories have not been fetched yet, it makes a request to the Pynab API 317 | to retrieve the budget's categories. The fetched categories are then stored in 318 | the `_categories` attribute for future use. 319 | 320 | #### Returns 321 | 322 | - `dict` - A dictionary containing the budget's categories. 323 | 324 | #### Signature 325 | 326 | ```python 327 | @categories.getter 328 | def categories(self): ... 329 | ``` 330 | 331 | ### Budget().category_groups 332 | 333 | [Show source in schemas.py:305](../../pynab/schemas.py#L305) 334 | 335 | Returns the category groups associated with the object. 336 | 337 | #### Returns 338 | 339 | The category groups. 340 | 341 | #### Signature 342 | 343 | ```python 344 | @property 345 | def category_groups(self): ... 346 | ``` 347 | 348 | ### Budget().category_groups 349 | 350 | [Show source in schemas.py:314](../../pynab/schemas.py#L314) 351 | 352 | Parses the given JSON string and creates CategoryGroup objects for each category group. 353 | 354 | #### Arguments 355 | 356 | - `_json` *str* - The JSON string containing the category groups. 357 | 358 | #### Returns 359 | 360 | None 361 | 362 | #### Signature 363 | 364 | ```python 365 | @category_groups.setter 366 | def category_groups(self, _json: str = ""): ... 367 | ``` 368 | 369 | ### Budget().category_groups 370 | 371 | [Show source in schemas.py:329](../../pynab/schemas.py#L329) 372 | 373 | Retrieves the category groups for the budget. 374 | 375 | If the category groups have not been fetched yet, it calls the `get_categories` method of the [Api](./api.md#api) object 376 | passing the current budget as an argument and assigns the result to the `_category_groups` attribute. 377 | 378 | #### Returns 379 | 380 | - `dict` - A dictionary containing the category groups for the budget. 381 | 382 | #### Signature 383 | 384 | ```python 385 | @category_groups.getter 386 | def category_groups(self): ... 387 | ``` 388 | 389 | ### Budget().detail 390 | 391 | [Show source in schemas.py:593](../../pynab/schemas.py#L593) 392 | 393 | Retrieves detailed information about the budget. 394 | 395 | #### Returns 396 | 397 | The budget object with additional details. 398 | 399 | #### Signature 400 | 401 | ```python 402 | @property 403 | def detail(self): ... 404 | ``` 405 | 406 | ### Budget().months 407 | 408 | [Show source in schemas.py:385](../../pynab/schemas.py#L385) 409 | 410 | Returns the months attribute. 411 | 412 | #### Returns 413 | 414 | The months attribute. 415 | 416 | #### Signature 417 | 418 | ```python 419 | @property 420 | def months(self): ... 421 | ``` 422 | 423 | ### Budget().months 424 | 425 | [Show source in schemas.py:394](../../pynab/schemas.py#L394) 426 | 427 | Process the given JSON string and create Month objects for each month in the JSON. 428 | 429 | #### Arguments 430 | 431 | - `_json` *str* - The JSON string containing the months data. 432 | 433 | #### Returns 434 | 435 | None 436 | 437 | #### Signature 438 | 439 | ```python 440 | @months.setter 441 | def months(self, _json: str = ""): ... 442 | ``` 443 | 444 | ### Budget().months 445 | 446 | [Show source in schemas.py:409](../../pynab/schemas.py#L409) 447 | 448 | Returns the months associated with the budget. 449 | 450 | If the `_months` attribute is empty, it retrieves the months using the `get_months` method from the [Api](./api.md#api) module. 451 | 452 | #### Returns 453 | 454 | - `dict` - A dictionary containing the months associated with the budget. 455 | 456 | #### Signature 457 | 458 | ```python 459 | @months.getter 460 | def months(self): ... 461 | ``` 462 | 463 | ### Budget().payee_locations 464 | 465 | [Show source in schemas.py:262](../../pynab/schemas.py#L262) 466 | 467 | Returns the payee locations associated with the object. 468 | 469 | #### Returns 470 | 471 | The payee locations. 472 | 473 | #### Signature 474 | 475 | ```python 476 | @property 477 | def payee_locations(self): ... 478 | ``` 479 | 480 | ### Budget().payee_locations 481 | 482 | [Show source in schemas.py:273](../../pynab/schemas.py#L273) 483 | 484 | Adds payee locations to the schema. 485 | 486 | #### Arguments 487 | 488 | - _json (str): A string representing the JSON data for payee locations. 489 | 490 | #### Returns 491 | 492 | None 493 | 494 | #### Signature 495 | 496 | ```python 497 | @payee_locations.setter 498 | def payee_locations(self, _json: str = ""): ... 499 | ``` 500 | 501 | ### Budget().payee_locations 502 | 503 | [Show source in schemas.py:288](../../pynab/schemas.py#L288) 504 | 505 | Retrieves and returns the payee locations associated with the budget. 506 | 507 | If the payee locations have not been fetched yet, it calls the `get_payee_locations` method 508 | from the [Api](./api.md#api) module to retrieve the payee locations and stores them in the `_payee_locations` 509 | attribute. Subsequent calls to this method will return the cached payee locations. 510 | 511 | #### Returns 512 | 513 | - `dict` - A dictionary containing the payee locations associated with the budget. 514 | 515 | #### Signature 516 | 517 | ```python 518 | @payee_locations.getter 519 | def payee_locations(self): ... 520 | ``` 521 | 522 | ### Budget().payees 523 | 524 | [Show source in schemas.py:221](../../pynab/schemas.py#L221) 525 | 526 | Returns the payees associated with the object. 527 | 528 | #### Returns 529 | 530 | The payees associated with the object. 531 | 532 | #### Signature 533 | 534 | ```python 535 | @property 536 | def payees(self): ... 537 | ``` 538 | 539 | ### Budget().payees 540 | 541 | [Show source in schemas.py:231](../../pynab/schemas.py#L231) 542 | 543 | Adds payees to the schema. 544 | 545 | #### Arguments 546 | 547 | - `_json` *str* - A JSON string containing payee information. 548 | 549 | #### Returns 550 | 551 | None 552 | 553 | #### Signature 554 | 555 | ```python 556 | @payees.setter 557 | def payees(self, _json: str = ""): ... 558 | ``` 559 | 560 | ### Budget().payees 561 | 562 | [Show source in schemas.py:246](../../pynab/schemas.py#L246) 563 | 564 | Retrieves the payees associated with the budget. 565 | 566 | If the payees have not been fetched yet, it calls the `get_payees` method from the [Api](./api.md#api) module 567 | and stores the result in the `_payees` attribute. 568 | 569 | #### Returns 570 | 571 | - `dict` - A dictionary containing the payees associated with the budget. 572 | 573 | #### Signature 574 | 575 | ```python 576 | @payees.getter 577 | def payees(self): ... 578 | ``` 579 | 580 | ### Budget().scheduled_subtransactions 581 | 582 | [Show source in schemas.py:549](../../pynab/schemas.py#L549) 583 | 584 | Returns the scheduled subtransactions. 585 | 586 | #### Returns 587 | 588 | The scheduled subtransactions. 589 | 590 | #### Signature 591 | 592 | ```python 593 | @property 594 | def scheduled_subtransactions(self): ... 595 | ``` 596 | 597 | ### Budget().scheduled_subtransactions 598 | 599 | [Show source in schemas.py:558](../../pynab/schemas.py#L558) 600 | 601 | Process the scheduled subtransactions from the given JSON string and store them in the `_scheduled_subtransactions` dictionary. 602 | 603 | #### Arguments 604 | 605 | - _json (str): The JSON string containing the scheduled subtransactions. 606 | 607 | #### Returns 608 | 609 | - None 610 | 611 | #### Signature 612 | 613 | ```python 614 | @scheduled_subtransactions.setter 615 | def scheduled_subtransactions(self, _json: str = ""): ... 616 | ``` 617 | 618 | ### Budget().scheduled_subtransactions 619 | 620 | [Show source in schemas.py:577](../../pynab/schemas.py#L577) 621 | 622 | Retrieves the scheduled subtransactions for the budget. 623 | 624 | If the scheduled subtransactions have not been fetched yet, it fetches them from the API 625 | and stores them in the `_scheduled_subtransactions` attribute. 626 | 627 | #### Returns 628 | 629 | - `dict` - A dictionary containing the scheduled subtransactions. 630 | 631 | #### Signature 632 | 633 | ```python 634 | @scheduled_subtransactions.getter 635 | def scheduled_subtransactions(self): ... 636 | ``` 637 | 638 | ### Budget().scheduled_transactions 639 | 640 | [Show source in schemas.py:504](../../pynab/schemas.py#L504) 641 | 642 | Returns the scheduled transactions. 643 | 644 | #### Returns 645 | 646 | The scheduled transactions. 647 | 648 | #### Signature 649 | 650 | ```python 651 | @property 652 | def scheduled_transactions(self): ... 653 | ``` 654 | 655 | ### Budget().scheduled_transactions 656 | 657 | [Show source in schemas.py:513](../../pynab/schemas.py#L513) 658 | 659 | Adds scheduled transactions to the schema. 660 | 661 | #### Arguments 662 | 663 | - `_json` *str* - A JSON string representing the scheduled transactions. 664 | 665 | #### Returns 666 | 667 | None 668 | 669 | #### Signature 670 | 671 | ```python 672 | @scheduled_transactions.setter 673 | def scheduled_transactions(self, _json: str = ""): ... 674 | ``` 675 | 676 | ### Budget().scheduled_transactions 677 | 678 | [Show source in schemas.py:532](../../pynab/schemas.py#L532) 679 | 680 | Retrieves the scheduled transactions for the budget. 681 | 682 | If the scheduled transactions have not been fetched yet, it calls the `get_scheduled_transactions` method 683 | from the [Api](./api.md#api) module to fetch them and stores them in the `_scheduled_transactions` attribute. 684 | 685 | #### Returns 686 | 687 | - `dict` - A dictionary containing the scheduled transactions for the budget. 688 | 689 | #### Signature 690 | 691 | ```python 692 | @scheduled_transactions.getter 693 | def scheduled_transactions(self): ... 694 | ``` 695 | 696 | ### Budget().settings 697 | 698 | [Show source in schemas.py:604](../../pynab/schemas.py#L604) 699 | 700 | Retrieves the budget settings from the Pynab API. 701 | 702 | If the settings have already been retrieved, it returns the cached settings. 703 | Otherwise, it makes a request to the Pynab API to fetch the settings. 704 | 705 | #### Returns 706 | 707 | The budget settings. 708 | 709 | #### Signature 710 | 711 | ```python 712 | @property 713 | def settings(self): ... 714 | ``` 715 | 716 | ### Budget().subtransactions 717 | 718 | [Show source in schemas.py:465](../../pynab/schemas.py#L465) 719 | 720 | Returns the subtransactions of the object. 721 | 722 | #### Returns 723 | 724 | The subtransactions. 725 | 726 | #### Signature 727 | 728 | ```python 729 | @property 730 | def subtransactions(self): ... 731 | ``` 732 | 733 | ### Budget().subtransactions 734 | 735 | [Show source in schemas.py:474](../../pynab/schemas.py#L474) 736 | 737 | Process the subtransactions from the given JSON string and store them in the `_subtransactions` dictionary. 738 | 739 | #### Arguments 740 | 741 | - `_json` *str* - The JSON string containing the subtransactions. 742 | 743 | #### Returns 744 | 745 | None 746 | 747 | #### Signature 748 | 749 | ```python 750 | @subtransactions.setter 751 | def subtransactions(self, _json: str = ""): ... 752 | ``` 753 | 754 | ### Budget().subtransactions 755 | 756 | [Show source in schemas.py:489](../../pynab/schemas.py#L489) 757 | 758 | Retrieves the subtransactions associated with the budget. 759 | 760 | If the subtransactions have not been fetched yet, it fetches them from the API and stores them in the `_subtransactions` attribute. 761 | 762 | #### Returns 763 | 764 | - `dict` - A dictionary containing the subtransactions associated with the budget. 765 | 766 | #### Signature 767 | 768 | ```python 769 | @subtransactions.getter 770 | def subtransactions(self): ... 771 | ``` 772 | 773 | ### Budget().transactions 774 | 775 | [Show source in schemas.py:423](../../pynab/schemas.py#L423) 776 | 777 | Returns the transactions associated with the object. 778 | 779 | #### Returns 780 | 781 | The transactions associated with the object. 782 | 783 | #### Signature 784 | 785 | ```python 786 | @property 787 | def transactions(self): ... 788 | ``` 789 | 790 | ### Budget().transactions 791 | 792 | [Show source in schemas.py:432](../../pynab/schemas.py#L432) 793 | 794 | Process the given transactions and store them in the `_transactions` dictionary. 795 | 796 | #### Arguments 797 | 798 | - _json (str): A string containing the transactions in JSON format. 799 | 800 | #### Returns 801 | 802 | - None 803 | 804 | #### Signature 805 | 806 | ```python 807 | @transactions.setter 808 | def transactions(self, _json: str = ""): ... 809 | ``` 810 | 811 | ### Budget().transactions 812 | 813 | [Show source in schemas.py:448](../../pynab/schemas.py#L448) 814 | 815 | Retrieves the transactions associated with the budget. 816 | 817 | If the transactions have not been fetched yet, it calls the `get_transactions` method of the [Api](./api.md#api) object 818 | passing the current budget as a parameter. The fetched transactions are then stored in the `_transactions` 819 | attribute of the budget object. 820 | 821 | #### Returns 822 | 823 | - `dict` - A dictionary containing the fetched transactions. 824 | 825 | #### Signature 826 | 827 | ```python 828 | @transactions.getter 829 | def transactions(self): ... 830 | ``` 831 | 832 | 833 | 834 | ## BudgetSettings 835 | 836 | [Show source in schemas.py:621](../../pynab/schemas.py#L621) 837 | 838 | #### Signature 839 | 840 | ```python 841 | class BudgetSettings: 842 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 843 | ``` 844 | 845 | #### See also 846 | 847 | - [Budget](#budget) 848 | 849 | 850 | 851 | ## Category 852 | 853 | [Show source in schemas.py:1094](../../pynab/schemas.py#L1094) 854 | 855 | #### Signature 856 | 857 | ```python 858 | class Category: 859 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 860 | ``` 861 | 862 | #### See also 863 | 864 | - [Budget](#budget) 865 | 866 | ### Category().category_group 867 | 868 | [Show source in schemas.py:1171](../../pynab/schemas.py#L1171) 869 | 870 | Returns the category group associated with the current budget category. 871 | 872 | #### Returns 873 | 874 | - [CategoryGroup](#categorygroup) - The category group object associated with the current budget category. 875 | 876 | #### Signature 877 | 878 | ```python 879 | @property 880 | def category_group(self): ... 881 | ``` 882 | 883 | ### Category().original_category_group 884 | 885 | [Show source in schemas.py:1181](../../pynab/schemas.py#L1181) 886 | 887 | Returns the original category group associated with the transaction. 888 | 889 | #### Returns 890 | 891 | - [CategoryGroup](#categorygroup) - The original category group object. 892 | 893 | #### Signature 894 | 895 | ```python 896 | @property 897 | def original_category_group(self): ... 898 | ``` 899 | 900 | ### Category().scheduled_subtransactions 901 | 902 | [Show source in schemas.py:1227](../../pynab/schemas.py#L1227) 903 | 904 | Retrieves the scheduled subtransactions associated with the category. 905 | 906 | #### Returns 907 | 908 | - `list` - A list of scheduled subtransactions. 909 | 910 | #### Signature 911 | 912 | ```python 913 | @property 914 | def scheduled_subtransactions(self): ... 915 | ``` 916 | 917 | ### Category().scheduled_transactions 918 | 919 | [Show source in schemas.py:1215](../../pynab/schemas.py#L1215) 920 | 921 | Retrieves the scheduled transactions associated with the category. 922 | 923 | #### Returns 924 | 925 | A list of scheduled transactions. 926 | 927 | #### Signature 928 | 929 | ```python 930 | @property 931 | def scheduled_transactions(self): ... 932 | ``` 933 | 934 | ### Category().subtransactions 935 | 936 | [Show source in schemas.py:1203](../../pynab/schemas.py#L1203) 937 | 938 | Retrieves the subtransactions associated with the current category. 939 | 940 | #### Returns 941 | 942 | - `list` - A list of subtransactions belonging to the category. 943 | 944 | #### Signature 945 | 946 | ```python 947 | @property 948 | def subtransactions(self): ... 949 | ``` 950 | 951 | ### Category().transactions 952 | 953 | [Show source in schemas.py:1191](../../pynab/schemas.py#L1191) 954 | 955 | Retrieve transactions associated with the category. 956 | 957 | #### Returns 958 | 959 | - `list` - A list of transactions associated with the category. 960 | 961 | #### Signature 962 | 963 | ```python 964 | @property 965 | def transactions(self): ... 966 | ``` 967 | 968 | 969 | 970 | ## CategoryGroup 971 | 972 | [Show source in schemas.py:1063](../../pynab/schemas.py#L1063) 973 | 974 | #### Signature 975 | 976 | ```python 977 | class CategoryGroup: 978 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 979 | ``` 980 | 981 | #### See also 982 | 983 | - [Budget](#budget) 984 | 985 | 986 | 987 | ## CurrencyFormat 988 | 989 | [Show source in schemas.py:667](../../pynab/schemas.py#L667) 990 | 991 | #### Signature 992 | 993 | ```python 994 | class CurrencyFormat: 995 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 996 | ``` 997 | 998 | #### See also 999 | 1000 | - [Budget](#budget) 1001 | 1002 | 1003 | 1004 | ## DateFormat 1005 | 1006 | [Show source in schemas.py:647](../../pynab/schemas.py#L647) 1007 | 1008 | #### Signature 1009 | 1010 | ```python 1011 | class DateFormat: 1012 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1013 | ``` 1014 | 1015 | #### See also 1016 | 1017 | - [Budget](#budget) 1018 | 1019 | 1020 | 1021 | ## DebtEscrowAmounts 1022 | 1023 | [Show source in schemas.py:895](../../pynab/schemas.py#L895) 1024 | 1025 | #### Signature 1026 | 1027 | ```python 1028 | class DebtEscrowAmounts: 1029 | def __init__( 1030 | self, 1031 | pynab=None, 1032 | budget: Budget = None, 1033 | account: Account = None, 1034 | _json: str = None, 1035 | ): ... 1036 | ``` 1037 | 1038 | #### See also 1039 | 1040 | - [Account](#account) 1041 | - [Budget](#budget) 1042 | 1043 | 1044 | 1045 | ## DebtInterestRates 1046 | 1047 | [Show source in schemas.py:833](../../pynab/schemas.py#L833) 1048 | 1049 | #### Signature 1050 | 1051 | ```python 1052 | class DebtInterestRates: 1053 | def __init__( 1054 | self, 1055 | pynab=None, 1056 | budget: Budget = None, 1057 | account: Account = None, 1058 | _json: str = None, 1059 | ): ... 1060 | ``` 1061 | 1062 | #### See also 1063 | 1064 | - [Account](#account) 1065 | - [Budget](#budget) 1066 | 1067 | 1068 | 1069 | ## DebtMinimumPayments 1070 | 1071 | [Show source in schemas.py:864](../../pynab/schemas.py#L864) 1072 | 1073 | #### Signature 1074 | 1075 | ```python 1076 | class DebtMinimumPayments: 1077 | def __init__( 1078 | self, 1079 | pynab=None, 1080 | budget: Budget = None, 1081 | account: Account = None, 1082 | _json: str = None, 1083 | ): ... 1084 | ``` 1085 | 1086 | #### See also 1087 | 1088 | - [Account](#account) 1089 | - [Budget](#budget) 1090 | 1091 | 1092 | 1093 | ## Error 1094 | 1095 | [Show source in schemas.py:52](../../pynab/schemas.py#L52) 1096 | 1097 | #### Signature 1098 | 1099 | ```python 1100 | class Error: 1101 | def __init__(self, pynab=None, _json: str = None): ... 1102 | ``` 1103 | 1104 | ### Error().__str__ 1105 | 1106 | [Show source in schemas.py:81](../../pynab/schemas.py#L81) 1107 | 1108 | Returns a string representation of the object. 1109 | 1110 | #### Returns 1111 | 1112 | - `str` - A string representation of the object, formatted as "api error: {id} - {name} - {detail}". 1113 | 1114 | #### Signature 1115 | 1116 | ```python 1117 | def __str__(self): ... 1118 | ``` 1119 | 1120 | 1121 | 1122 | ## Month 1123 | 1124 | [Show source in schemas.py:1240](../../pynab/schemas.py#L1240) 1125 | 1126 | #### Signature 1127 | 1128 | ```python 1129 | class Month: 1130 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1131 | ``` 1132 | 1133 | #### See also 1134 | 1135 | - [Budget](#budget) 1136 | 1137 | 1138 | 1139 | ## Payee 1140 | 1141 | [Show source in schemas.py:926](../../pynab/schemas.py#L926) 1142 | 1143 | #### Signature 1144 | 1145 | ```python 1146 | class Payee: 1147 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1148 | ``` 1149 | 1150 | #### See also 1151 | 1152 | - [Budget](#budget) 1153 | 1154 | ### Payee().payee_locations 1155 | 1156 | [Show source in schemas.py:976](../../pynab/schemas.py#L976) 1157 | 1158 | Retrieves the payee locations associated with the current payee. 1159 | 1160 | #### Returns 1161 | 1162 | A list of payee locations. 1163 | 1164 | #### Signature 1165 | 1166 | ```python 1167 | @property 1168 | def payee_locations(self): ... 1169 | ``` 1170 | 1171 | ### Payee().scheduled_subtransactions 1172 | 1173 | [Show source in schemas.py:1012](../../pynab/schemas.py#L1012) 1174 | 1175 | Retrieves the scheduled subtransactions associated with the current payee. 1176 | 1177 | #### Returns 1178 | 1179 | A list of scheduled subtransactions. 1180 | 1181 | #### Signature 1182 | 1183 | ```python 1184 | def scheduled_subtransactions(self): ... 1185 | ``` 1186 | 1187 | ### Payee().scheduled_transactions 1188 | 1189 | [Show source in schemas.py:989](../../pynab/schemas.py#L989) 1190 | 1191 | Retrieve all scheduled transactions associated with the payee. 1192 | 1193 | #### Returns 1194 | 1195 | - `list` - A list of scheduled transactions. 1196 | 1197 | #### Signature 1198 | 1199 | ```python 1200 | @property 1201 | def scheduled_transactions(self): ... 1202 | ``` 1203 | 1204 | ### Payee().subtransactions 1205 | 1206 | [Show source in schemas.py:1001](../../pynab/schemas.py#L1001) 1207 | 1208 | Retrieves subtransactions associated with the current budget. 1209 | 1210 | #### Returns 1211 | 1212 | - `list` - A list of subtransactions matching the specified criteria. 1213 | 1214 | #### Signature 1215 | 1216 | ```python 1217 | def subtransactions(self): ... 1218 | ``` 1219 | 1220 | ### Payee().transactions 1221 | 1222 | [Show source in schemas.py:966](../../pynab/schemas.py#L966) 1223 | 1224 | Retrieve transactions associated with the payee. 1225 | 1226 | #### Returns 1227 | 1228 | - `list` - A list of transactions associated with the payee. 1229 | 1230 | #### Signature 1231 | 1232 | ```python 1233 | @property 1234 | def transactions(self): ... 1235 | ``` 1236 | 1237 | ### Payee().transfer_account 1238 | 1239 | [Show source in schemas.py:956](../../pynab/schemas.py#L956) 1240 | 1241 | Retrieves the account associated with the transfer_account_id. 1242 | 1243 | #### Returns 1244 | 1245 | - [Account](#account) - The account associated with the transfer_account_id. 1246 | 1247 | #### Signature 1248 | 1249 | ```python 1250 | @property 1251 | def transfer_account(self): ... 1252 | ``` 1253 | 1254 | 1255 | 1256 | ## PayeeLocation 1257 | 1258 | [Show source in schemas.py:1025](../../pynab/schemas.py#L1025) 1259 | 1260 | #### Signature 1261 | 1262 | ```python 1263 | class PayeeLocation: 1264 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1265 | ``` 1266 | 1267 | #### See also 1268 | 1269 | - [Budget](#budget) 1270 | 1271 | ### PayeeLocation().payee 1272 | 1273 | [Show source in schemas.py:1052](../../pynab/schemas.py#L1052) 1274 | 1275 | Returns the payee associated with the transaction. 1276 | 1277 | #### Returns 1278 | 1279 | - [Payee](#payee) - The payee object associated with the transaction. 1280 | 1281 | #### Signature 1282 | 1283 | ```python 1284 | @property 1285 | def payee(self): ... 1286 | ``` 1287 | 1288 | 1289 | 1290 | ## ScheduledSubTransaction 1291 | 1292 | [Show source in schemas.py:1694](../../pynab/schemas.py#L1694) 1293 | 1294 | #### Signature 1295 | 1296 | ```python 1297 | class ScheduledSubTransaction: 1298 | def __init__(self, pynab=None, _json: str = None): ... 1299 | ``` 1300 | 1301 | ### ScheduledSubTransaction().category 1302 | 1303 | [Show source in schemas.py:1744](../../pynab/schemas.py#L1744) 1304 | 1305 | Returns the category associated with the current instance. 1306 | 1307 | #### Returns 1308 | 1309 | - [Category](#category) - The category object associated with the current instance. 1310 | 1311 | #### Signature 1312 | 1313 | ```python 1314 | @property 1315 | def category(self): ... 1316 | ``` 1317 | 1318 | ### ScheduledSubTransaction().payee 1319 | 1320 | [Show source in schemas.py:1737](../../pynab/schemas.py#L1737) 1321 | 1322 | Returns the payee associated with the transaction. 1323 | 1324 | #### Signature 1325 | 1326 | ```python 1327 | @property 1328 | def payee(self): ... 1329 | ``` 1330 | 1331 | ### ScheduledSubTransaction().scheduled_transaction 1332 | 1333 | [Show source in schemas.py:1727](../../pynab/schemas.py#L1727) 1334 | 1335 | Returns the scheduled transaction associated with the current instance. 1336 | 1337 | #### Returns 1338 | 1339 | The scheduled transaction object. 1340 | 1341 | #### Signature 1342 | 1343 | ```python 1344 | @property 1345 | def scheduled_transaction(self): ... 1346 | ``` 1347 | 1348 | ### ScheduledSubTransaction().transfer_account 1349 | 1350 | [Show source in schemas.py:1754](../../pynab/schemas.py#L1754) 1351 | 1352 | Returns the account associated with the transfer_account_id. 1353 | 1354 | #### Returns 1355 | 1356 | - [Account](#account) - The account associated with the transfer_account_id. 1357 | 1358 | #### Signature 1359 | 1360 | ```python 1361 | @property 1362 | def transfer_account(self): ... 1363 | ``` 1364 | 1365 | 1366 | 1367 | ## ScheduledTransaction 1368 | 1369 | [Show source in schemas.py:1557](../../pynab/schemas.py#L1557) 1370 | 1371 | #### Signature 1372 | 1373 | ```python 1374 | class ScheduledTransaction: 1375 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1376 | ``` 1377 | 1378 | #### See also 1379 | 1380 | - [Budget](#budget) 1381 | 1382 | ### ScheduledTransaction().account 1383 | 1384 | [Show source in schemas.py:1656](../../pynab/schemas.py#L1656) 1385 | 1386 | Returns the account associated with the current instance. 1387 | 1388 | #### Signature 1389 | 1390 | ```python 1391 | @property 1392 | def account(self): ... 1393 | ``` 1394 | 1395 | ### ScheduledTransaction().category 1396 | 1397 | [Show source in schemas.py:1673](../../pynab/schemas.py#L1673) 1398 | 1399 | Returns the category associated with the current instance. 1400 | 1401 | #### Returns 1402 | 1403 | - [Category](#category) - The category object associated with the current instance. 1404 | 1405 | #### Signature 1406 | 1407 | ```python 1408 | @property 1409 | def category(self): ... 1410 | ``` 1411 | 1412 | ### ScheduledTransaction().payee 1413 | 1414 | [Show source in schemas.py:1663](../../pynab/schemas.py#L1663) 1415 | 1416 | Returns the payee associated with the transaction. 1417 | 1418 | #### Returns 1419 | 1420 | - [Payee](#payee) - The payee object associated with the transaction. 1421 | 1422 | #### Signature 1423 | 1424 | ```python 1425 | @property 1426 | def payee(self): ... 1427 | ``` 1428 | 1429 | ### ScheduledTransaction().to_dict 1430 | 1431 | [Show source in schemas.py:1618](../../pynab/schemas.py#L1618) 1432 | 1433 | Converts the object to a dictionary representation. 1434 | 1435 | #### Returns 1436 | 1437 | - `dict` - A dictionary representation of the object. 1438 | 1439 | #### Signature 1440 | 1441 | ```python 1442 | def to_dict(self): ... 1443 | ``` 1444 | 1445 | ### ScheduledTransaction().to_json 1446 | 1447 | [Show source in schemas.py:1644](../../pynab/schemas.py#L1644) 1448 | 1449 | Convert the object to a JSON string representation. 1450 | 1451 | #### Arguments 1452 | 1453 | - `indent` *int, optional* - The number of spaces to use for indentation. Defaults to 4. 1454 | 1455 | #### Returns 1456 | 1457 | - `str` - The JSON string representation of the object. 1458 | 1459 | #### Signature 1460 | 1461 | ```python 1462 | def to_json(self, indent: int = 4): ... 1463 | ``` 1464 | 1465 | ### ScheduledTransaction().transfer_account 1466 | 1467 | [Show source in schemas.py:1683](../../pynab/schemas.py#L1683) 1468 | 1469 | Returns the account associated with the transfer_account_id. 1470 | 1471 | #### Returns 1472 | 1473 | - [Account](#account) - The account associated with the transfer_account_id. 1474 | 1475 | #### Signature 1476 | 1477 | ```python 1478 | @property 1479 | def transfer_account(self): ... 1480 | ``` 1481 | 1482 | 1483 | 1484 | ## SubTransaction 1485 | 1486 | [Show source in schemas.py:1466](../../pynab/schemas.py#L1466) 1487 | 1488 | #### Signature 1489 | 1490 | ```python 1491 | class SubTransaction: 1492 | def __init__(self, pynab=None, budget: Budget = None, _json: str = None): ... 1493 | ``` 1494 | 1495 | #### See also 1496 | 1497 | - [Budget](#budget) 1498 | 1499 | ### SubTransaction().category 1500 | 1501 | [Show source in schemas.py:1526](../../pynab/schemas.py#L1526) 1502 | 1503 | Returns the category associated with the current instance. 1504 | 1505 | #### Returns 1506 | 1507 | - [Category](#category) - The category object associated with the current instance. 1508 | 1509 | #### Signature 1510 | 1511 | ```python 1512 | @property 1513 | def category(self): ... 1514 | ``` 1515 | 1516 | ### SubTransaction().payee 1517 | 1518 | [Show source in schemas.py:1516](../../pynab/schemas.py#L1516) 1519 | 1520 | Returns the payee associated with the transaction. 1521 | 1522 | #### Returns 1523 | 1524 | - [Payee](#payee) - The payee object associated with the transaction. 1525 | 1526 | #### Signature 1527 | 1528 | ```python 1529 | @property 1530 | def payee(self): ... 1531 | ``` 1532 | 1533 | ### SubTransaction().transaction 1534 | 1535 | [Show source in schemas.py:1507](../../pynab/schemas.py#L1507) 1536 | 1537 | Returns the transaction associated with the current transaction_id. 1538 | 1539 | #### Returns 1540 | 1541 | - [Transaction](#transaction) - The transaction object. 1542 | 1543 | #### Signature 1544 | 1545 | ```python 1546 | def transaction(self): ... 1547 | ``` 1548 | 1549 | ### SubTransaction().transfer_account 1550 | 1551 | [Show source in schemas.py:1536](../../pynab/schemas.py#L1536) 1552 | 1553 | Retrieves the account associated with the transfer_account_id. 1554 | 1555 | #### Returns 1556 | 1557 | - [Account](#account) - The account associated with the transfer_account_id. 1558 | 1559 | #### Signature 1560 | 1561 | ```python 1562 | @property 1563 | def transfer_account(self): ... 1564 | ``` 1565 | 1566 | ### SubTransaction().transfer_transaction 1567 | 1568 | [Show source in schemas.py:1546](../../pynab/schemas.py#L1546) 1569 | 1570 | Retrieves the transfer transaction associated with the current instance. 1571 | 1572 | #### Returns 1573 | 1574 | - [Transaction](#transaction) - The transfer transaction object. 1575 | 1576 | #### Signature 1577 | 1578 | ```python 1579 | @property 1580 | def transfer_transaction(self): ... 1581 | ``` 1582 | 1583 | 1584 | 1585 | ## Transaction 1586 | 1587 | [Show source in schemas.py:1281](../../pynab/schemas.py#L1281) 1588 | 1589 | #### Signature 1590 | 1591 | ```python 1592 | class Transaction: 1593 | def __init__(self, pynab=None, budget: Budget = None, _json: dict = None): ... 1594 | ``` 1595 | 1596 | #### See also 1597 | 1598 | - [Budget](#budget) 1599 | 1600 | ### Transaction().account 1601 | 1602 | [Show source in schemas.py:1406](../../pynab/schemas.py#L1406) 1603 | 1604 | Returns the account associated with the current instance. 1605 | 1606 | #### Signature 1607 | 1608 | ```python 1609 | @property 1610 | def account(self): ... 1611 | ``` 1612 | 1613 | ### Transaction().categories 1614 | 1615 | [Show source in schemas.py:1423](../../pynab/schemas.py#L1423) 1616 | 1617 | Retrieve the categories associated with the budget. 1618 | 1619 | #### Returns 1620 | 1621 | - `list` - A list of categories associated with the budget. 1622 | 1623 | #### Signature 1624 | 1625 | ```python 1626 | @property 1627 | def categories(self): ... 1628 | ``` 1629 | 1630 | ### Transaction().matched_transaction 1631 | 1632 | [Show source in schemas.py:1455](../../pynab/schemas.py#L1455) 1633 | 1634 | Returns the matched transaction based on the `matched_transaction_id`. 1635 | 1636 | #### Returns 1637 | 1638 | - [Transaction](#transaction) - The matched transaction object. 1639 | 1640 | #### Signature 1641 | 1642 | ```python 1643 | @property 1644 | def matched_transaction(self): ... 1645 | ``` 1646 | 1647 | ### Transaction().payee 1648 | 1649 | [Show source in schemas.py:1413](../../pynab/schemas.py#L1413) 1650 | 1651 | Returns the payee associated with the transaction. 1652 | 1653 | #### Returns 1654 | 1655 | - [Payee](#payee) - The payee object associated with the transaction. 1656 | 1657 | #### Signature 1658 | 1659 | ```python 1660 | @property 1661 | def payee(self): ... 1662 | ``` 1663 | 1664 | ### Transaction().to_dict 1665 | 1666 | [Show source in schemas.py:1359](../../pynab/schemas.py#L1359) 1667 | 1668 | Converts the object to a dictionary representation. 1669 | 1670 | #### Returns 1671 | 1672 | - `dict` - A dictionary containing the object's attributes. 1673 | 1674 | #### Signature 1675 | 1676 | ```python 1677 | def to_dict(self): ... 1678 | ``` 1679 | 1680 | ### Transaction().to_json 1681 | 1682 | [Show source in schemas.py:1394](../../pynab/schemas.py#L1394) 1683 | 1684 | Convert the object to a JSON string representation. 1685 | 1686 | #### Arguments 1687 | 1688 | - `indent` *int, optional* - The number of spaces to use for indentation. Defaults to 4. 1689 | 1690 | #### Returns 1691 | 1692 | - `str` - The JSON string representation of the object. 1693 | 1694 | #### Signature 1695 | 1696 | ```python 1697 | def to_json(self, indent: int = 4): ... 1698 | ``` 1699 | 1700 | ### Transaction().transfer_account 1701 | 1702 | [Show source in schemas.py:1435](../../pynab/schemas.py#L1435) 1703 | 1704 | Returns the account associated with the transfer_account_id. 1705 | 1706 | #### Returns 1707 | 1708 | - [Account](#account) - The account associated with the transfer_account_id. 1709 | 1710 | #### Signature 1711 | 1712 | ```python 1713 | @property 1714 | def transfer_account(self): ... 1715 | ``` 1716 | 1717 | ### Transaction().transfer_transaction 1718 | 1719 | [Show source in schemas.py:1445](../../pynab/schemas.py#L1445) 1720 | 1721 | Returns the transfer transaction associated with the current instance. 1722 | 1723 | #### Returns 1724 | 1725 | - [Transaction](#transaction) - The transfer transaction object. 1726 | 1727 | #### Signature 1728 | 1729 | ```python 1730 | @property 1731 | def transfer_transaction(self): ... 1732 | ``` 1733 | 1734 | 1735 | 1736 | ## User 1737 | 1738 | [Show source in schemas.py:12](../../pynab/schemas.py#L12) 1739 | 1740 | #### Signature 1741 | 1742 | ```python 1743 | class User: 1744 | def __init__(self, pynab=None, _json: str = None): ... 1745 | ``` 1746 | 1747 | ### User().to_dict 1748 | 1749 | [Show source in schemas.py:30](../../pynab/schemas.py#L30) 1750 | 1751 | Converts the object to a dictionary. 1752 | 1753 | #### Returns 1754 | 1755 | - `dict` - A dictionary representation of the object, containing the 'id' attribute. 1756 | 1757 | #### Signature 1758 | 1759 | ```python 1760 | def to_dict(self): ... 1761 | ``` 1762 | 1763 | ### User().to_json 1764 | 1765 | [Show source in schemas.py:39](../../pynab/schemas.py#L39) 1766 | 1767 | Convert the object to a JSON string representation. 1768 | 1769 | #### Arguments 1770 | 1771 | - `indent` *int, optional* - The number of spaces to use for indentation. Defaults to 4. 1772 | 1773 | #### Returns 1774 | 1775 | - `str` - The JSON string representation of the object. 1776 | 1777 | #### Signature 1778 | 1779 | ```python 1780 | def to_json(self, indent: int = 4): ... 1781 | ``` -------------------------------------------------------------------------------- /docs/pynab/utils.md: -------------------------------------------------------------------------------- 1 | # Utils 2 | 3 | [Pynab Index](../README.md#pynab-index) / [Pynab](./index.md#pynab) / Utils 4 | 5 | > Auto-generated documentation for [pynab.utils](../../pynab/utils.py) module. 6 | 7 | - [Utils](#utils) 8 | - [CustomJsonEncoder](#customjsonencoder) 9 | - [CustomJsonEncoder().default](#customjsonencoder()default) 10 | - [_dict](#_dict) 11 | - [_dict().by](#_dict()by) 12 | - [http_utils](#http_utils) 13 | - [http_utils().delete](#http_utils()delete) 14 | - [http_utils().get](#http_utils()get) 15 | - [http_utils().patch](#http_utils()patch) 16 | - [http_utils().post](#http_utils()post) 17 | - [http_utils().put](#http_utils()put) 18 | 19 | ## CustomJsonEncoder 20 | 21 | [Show source in utils.py:129](../../pynab/utils.py#L129) 22 | 23 | #### Signature 24 | 25 | ```python 26 | class CustomJsonEncoder(json.JSONEncoder): ... 27 | ``` 28 | 29 | ### CustomJsonEncoder().default 30 | 31 | [Show source in utils.py:130](../../pynab/utils.py#L130) 32 | 33 | Returns the default JSON representation of an object. 34 | 35 | #### Arguments 36 | 37 | - `-` *obj* - The object to be serialized. 38 | 39 | #### Returns 40 | 41 | The JSON representation of the object. 42 | 43 | #### Notes 44 | 45 | - If the object is an instance of Enum, the value of the Enum is returned. 46 | - If the object is an instance of datetime or date, the ISO formatted string representation is returned. 47 | - For all other objects, the default JSONEncoder's default method is called. 48 | 49 | #### Signature 50 | 51 | ```python 52 | def default(self, obj): ... 53 | ``` 54 | 55 | 56 | 57 | ## _dict 58 | 59 | [Show source in utils.py:153](../../pynab/utils.py#L153) 60 | 61 | A custom dictionary class that provides additional functionality. 62 | 63 | This class extends the built-in `dict` class and adds a `by` method 64 | for filtering the dictionary items based on a specific field and value. 65 | 66 | #### Attributes 67 | 68 | None 69 | 70 | #### Methods 71 | 72 | - `by(field` - str = "", value: object = None, first: bool = True) -> Union[object, _dict]: 73 | Filters the dictionary items based on the specified field and value. 74 | 75 | #### Signature 76 | 77 | ```python 78 | class _dict(dict): ... 79 | ``` 80 | 81 | ### _dict().by 82 | 83 | [Show source in utils.py:169](../../pynab/utils.py#L169) 84 | 85 | Filters the dictionary items based on the specified field and value. 86 | 87 | #### Arguments 88 | 89 | - `field` *str* - The name of the field to filter on. 90 | - `value` *object* - The value to filter for. 91 | - `first` *bool* - If True, returns the first matching item. If False, returns a new dictionary with all matching items. 92 | 93 | #### Returns 94 | 95 | - `Union[object,` *_dict]* - If `first` is True, returns the first matching item. If `first` is False, returns a new `_dict` object with all matching items. 96 | 97 | #### Signature 98 | 99 | ```python 100 | def by(self, field: str = "", value: object = None, first: bool = True): ... 101 | ``` 102 | 103 | 104 | 105 | ## http_utils 106 | 107 | [Show source in utils.py:10](../../pynab/utils.py#L10) 108 | 109 | #### Signature 110 | 111 | ```python 112 | class http_utils: 113 | def __init__(self, pynab: pynab = None): ... 114 | ``` 115 | 116 | #### See also 117 | 118 | - [Pynab](./pynab.md#pynab) 119 | 120 | ### http_utils().delete 121 | 122 | [Show source in utils.py:107](../../pynab/utils.py#L107) 123 | 124 | Sends a DELETE request to the specified endpoint. 125 | 126 | #### Arguments 127 | 128 | - `endpoint` *str, optional* - The endpoint to send the request to. Defaults to None. 129 | 130 | #### Returns 131 | 132 | - `requests.Response` - The response object returned by the DELETE request. 133 | 134 | #### Signature 135 | 136 | ```python 137 | def delete(self, endpoint: str = None): ... 138 | ``` 139 | 140 | ### http_utils().get 141 | 142 | [Show source in utils.py:20](../../pynab/utils.py#L20) 143 | 144 | Sends a GET request to the specified endpoint. 145 | 146 | #### Arguments 147 | 148 | - `endpoint` *str, optional* - The endpoint to send the request to. Defaults to None. 149 | 150 | #### Returns 151 | 152 | - `Response` - The response object returned by the GET request. 153 | 154 | #### Signature 155 | 156 | ```python 157 | def get(self, endpoint: str = None): ... 158 | ``` 159 | 160 | ### http_utils().patch 161 | 162 | [Show source in utils.py:63](../../pynab/utils.py#L63) 163 | 164 | Sends a PATCH request to the specified endpoint with the provided JSON data. 165 | 166 | #### Arguments 167 | 168 | - `endpoint` *str, optional* - The endpoint to send the PATCH request to. Defaults to None. 169 | - `json` *dict, optional* - The JSON data to include in the request body. Defaults to {}. 170 | 171 | #### Returns 172 | 173 | - `Response` - The response object returned by the PATCH request. 174 | 175 | #### Signature 176 | 177 | ```python 178 | def patch(self, endpoint: str = None, json: dict = {}): ... 179 | ``` 180 | 181 | ### http_utils().post 182 | 183 | [Show source in utils.py:41](../../pynab/utils.py#L41) 184 | 185 | Sends a POST request to the specified endpoint with the provided JSON data. 186 | 187 | #### Arguments 188 | 189 | - `endpoint` *str* - The endpoint to send the request to. 190 | - `json` *dict* - The JSON data to include in the request body. 191 | 192 | #### Returns 193 | 194 | - `Response` - The response object received from the server. 195 | 196 | #### Signature 197 | 198 | ```python 199 | def post(self, endpoint: str = None, json: dict = {}): ... 200 | ``` 201 | 202 | ### http_utils().put 203 | 204 | [Show source in utils.py:85](../../pynab/utils.py#L85) 205 | 206 | Sends a PUT request to the specified endpoint with the given JSON payload. 207 | 208 | #### Arguments 209 | 210 | - `endpoint` *str* - The endpoint to send the request to. 211 | - `json` *dict* - The JSON payload to include in the request. 212 | 213 | #### Returns 214 | 215 | - `Response` - The response object returned by the server. 216 | 217 | #### Signature 218 | 219 | ```python 220 | def put(self, endpoint: str = None, json: dict = {}): ... 221 | ``` -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | black==24.8.0 2 | click==8.1.7 3 | handsdown==2.1.0 4 | importlib_resources==6.4.5 5 | Jinja2==3.1.4 6 | MarkupSafe==2.1.5 7 | mypy-extensions==1.0.0 8 | packaging==24.1 9 | pathspec==0.12.1 10 | platformdirs==4.3.3 11 | typed_ast==1.5.5 12 | -------------------------------------------------------------------------------- /docs/testing/index.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | [Pynab Index](../README.md#pynab-index) / Testing 4 | 5 | > Auto-generated documentation for [testing](../../testing/__init__.py) module. 6 | 7 | - [Testing](#testing) 8 | - [Modules](#modules) 9 | 10 | ## Modules 11 | 12 | - [Test Live Api](./test_live_api.md) -------------------------------------------------------------------------------- /pynab/__init__.py: -------------------------------------------------------------------------------- 1 | from .pynab import Pynab 2 | from pynab import Pynab 3 | 4 | __all__ = ["Pynab"] 5 | -------------------------------------------------------------------------------- /pynab/constants.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timezone 2 | 3 | """ 4 | This module contains constants used in the pynab package. 5 | 6 | Attributes: 7 | EPOCH (str): The string representation of the UTC datetime for the epoch (January 1, 1970). 8 | YNAB_API (str): The URL for the YNAB API. 9 | """ 10 | 11 | EPOCH = str(datetime(1970, 1, 1, tzinfo=timezone.utc)) 12 | 13 | YNAB_API = "https://api.ynab.com/v1" 14 | -------------------------------------------------------------------------------- /pynab/endpoints.py: -------------------------------------------------------------------------------- 1 | import pynab.utils as utils 2 | from pynab import pynab 3 | 4 | 5 | class Endpoints: 6 | 7 | def __init__(self, pynab: pynab = None): 8 | """ 9 | Initializes an instance of the endpoints class. 10 | 11 | Parameters: 12 | - pynab (pynab): An instance of the pynab class. 13 | 14 | Returns: 15 | - None 16 | """ 17 | self.pynab = pynab 18 | self.http_utils = utils.http_utils(pynab=self.pynab) 19 | 20 | # GET /user 21 | def request_get_user(self): 22 | """ 23 | Sends a GET request to retrieve user information. 24 | 25 | Returns: 26 | The response from the GET request. 27 | """ 28 | endpoint = f"/user" 29 | return self.http_utils.get(endpoint=endpoint) 30 | 31 | # GET /budgets 32 | def request_get_budgets(self, include_accounts: bool = False): 33 | """ 34 | Sends a GET request to retrieve budgets. 35 | 36 | Args: 37 | include_accounts (bool, optional): Whether to include accounts in the response. Defaults to False. 38 | 39 | Returns: 40 | dict: The response from the API. 41 | 42 | Raises: 43 | None 44 | """ 45 | endpoint = f"/budgets" 46 | if include_accounts: 47 | endpoint += "?include_accounts=true" 48 | return self.http_utils.get(endpoint=endpoint) 49 | 50 | # GET /budgets/{budget_id} 51 | def request_get_budget( 52 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 53 | ): 54 | """ 55 | Retrieves the budget information from the server. 56 | 57 | Args: 58 | budget_id (str, optional): The ID of the budget to retrieve. Defaults to "last-used". 59 | last_knowledge_of_server (int, optional): The knowledge of the server to determine if the budget has been updated. Defaults to 0. 60 | 61 | Returns: 62 | dict: The budget information. 63 | 64 | Raises: 65 | HTTPException: If an error occurs during the HTTP request. 66 | """ 67 | endpoint = f"/budgets/{budget_id}" 68 | if last_knowledge_of_server: 69 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 70 | return self.http_utils.get(endpoint=endpoint) 71 | 72 | # GET /budgets/{budget_id}/settings 73 | def request_get_budget_settings(self, budget_id: str = "last-used"): 74 | """ 75 | Retrieves the budget settings for the specified budget ID. 76 | 77 | Args: 78 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 79 | 80 | Returns: 81 | dict: The budget settings. 82 | 83 | Raises: 84 | HTTPError: If an HTTP error occurs. 85 | """ 86 | endpoint = f"/budgets/{budget_id}/settings" 87 | return self.http_utils.get(endpoint=endpoint) 88 | 89 | # GET /budgets/{budget_id}/accounts 90 | def request_get_accounts( 91 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 92 | ): 93 | """ 94 | Retrieves the accounts associated with a specific budget. 95 | 96 | Args: 97 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 98 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 99 | 100 | Returns: 101 | The response from the HTTP GET request. 102 | """ 103 | endpoint = f"/budgets/{budget_id}/accounts" 104 | if last_knowledge_of_server: 105 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 106 | return self.http_utils.get(endpoint=endpoint) 107 | 108 | # POST /budgets/{budget_id}/accounts 109 | def request_create_account( 110 | self, budget_id: str = "last-used", request_body: str = None 111 | ): 112 | """ 113 | Creates a new account in the specified budget. 114 | 115 | Args: 116 | budget_id (str, optional): The ID of the budget to create the account in. Defaults to "last-used". 117 | request_body (str, optional): The JSON request body containing the account details. Defaults to None. 118 | 119 | Returns: 120 | The response from the API call. 121 | """ 122 | endpoint = f"/budgets/{budget_id}/accounts" 123 | return self.http_utils.post(endpoint=endpoint, json=request_body) 124 | 125 | # GET /budgets/{budget_id}/accounts/{account_id} 126 | def request_get_account(self, budget_id: str = "last-used", account_id: str = None): 127 | """ 128 | Retrieves information about a specific account in a budget. 129 | 130 | Args: 131 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 132 | account_id (str, optional): The ID of the account. If not provided, information about all accounts will be returned. 133 | 134 | Returns: 135 | dict: A dictionary containing the account information. 136 | 137 | Raises: 138 | HTTPException: If the request fails or the account is not found. 139 | """ 140 | endpoint = f"/budgets/{budget_id}/accounts/{account_id}" 141 | return self.http_utils.get(endpoint=endpoint) 142 | 143 | # GET /budgets/{budget_id}/categories 144 | def request_get_categories( 145 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 146 | ): 147 | """ 148 | Retrieves the categories for a specific budget. 149 | 150 | Args: 151 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 152 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 153 | 154 | Returns: 155 | The response from the HTTP GET request. 156 | """ 157 | endpoint = f"/budgets/{budget_id}/categories" 158 | if last_knowledge_of_server: 159 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 160 | return self.http_utils.get(endpoint=endpoint) 161 | 162 | # GET /budgets/{budget_id}/categories/{category_id} 163 | def request_get_category( 164 | self, budget_id: str = "last-used", category_id: str = None 165 | ): 166 | """ 167 | Retrieves a specific category from a budget. 168 | 169 | Args: 170 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 171 | category_id (str, optional): The ID of the category. If not provided, retrieves all categories. 172 | 173 | Returns: 174 | dict: The category information. 175 | 176 | Raises: 177 | HTTPError: If the request fails. 178 | """ 179 | endpoint = f"/budgets/{budget_id}/categories/{category_id}" 180 | return self.http_utils.get(endpoint=endpoint) 181 | 182 | # PATCH /budgets/{budget_id}/categories/{category_id} 183 | def request_update_category( 184 | self, 185 | budget_id: str = "last-used", 186 | category_id: str = None, 187 | request_body: str = None, 188 | ): 189 | """ 190 | Sends a PATCH request to update a category in the specified budget. 191 | 192 | Args: 193 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 194 | category_id (str, optional): The ID of the category to update. 195 | request_body (str, optional): The JSON request body containing the updated category data. 196 | 197 | Returns: 198 | The response from the PATCH request. 199 | 200 | Raises: 201 | None. 202 | """ 203 | endpoint = f"/budgets/{budget_id}/categories/{category_id}" 204 | return self.http_utils.patch(endpoint=endpoint, json=request_body) 205 | 206 | # GET /budgets/{budget_id}/months/{month}/categories/{category_id} 207 | def request_get_category_for_month( 208 | self, 209 | budget_id: str = "last-used", 210 | month: str = "current", 211 | category_id: str = None, 212 | ): 213 | """ 214 | Retrieves the category for a specific month in a budget. 215 | 216 | Args: 217 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 218 | month (str, optional): The month to retrieve the category for. Defaults to "current". 219 | category_id (str, optional): The ID of the category. Defaults to None. 220 | 221 | Returns: 222 | The response from the API call. 223 | """ 224 | endpoint = f"/budgets/{budget_id}/months/{month}/categories/{category_id}" 225 | return self.http_utils.get(endpoint=endpoint) 226 | 227 | # PATCH /budgets/{budget_id}/months/{month}/categories/{category_id} 228 | def request_update_category_for_month( 229 | self, 230 | budget_id: str = "last-used", 231 | month_id: str = "current", 232 | category_id: str = None, 233 | request_body: str = None, 234 | ): 235 | """ 236 | Sends a PATCH request to update a category for a specific month in a budget. 237 | 238 | Args: 239 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 240 | month_id (str, optional): The ID of the month. Defaults to "current". 241 | category_id (str, optional): The ID of the category to update. 242 | request_body (str, optional): The JSON request body. 243 | 244 | Returns: 245 | The response from the PATCH request. 246 | """ 247 | endpoint = f"/budgets/{budget_id}/months/{month_id}/categories/{category_id}" 248 | return self.http_utils.patch(endpoint=endpoint, json=request_body) 249 | 250 | # GET /budgets/{budget_id}/payees 251 | def request_get_payees( 252 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 253 | ): 254 | """ 255 | Retrieves the payees for a specific budget. 256 | 257 | Args: 258 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 259 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 260 | 261 | Returns: 262 | The response from the HTTP GET request. 263 | """ 264 | endpoint = f"/budgets/{budget_id}/payees" 265 | if last_knowledge_of_server: 266 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 267 | return self.http_utils.get(endpoint=endpoint) 268 | 269 | # GET /budgets/{budget_id}/payees/{payee_id} 270 | def request_get_payee(self, budget_id: str = "last-used", payee_id: str = None): 271 | """ 272 | Retrieves a specific payee from the specified budget. 273 | 274 | Args: 275 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 276 | payee_id (str, optional): The ID of the payee. If not provided, all payees will be returned. 277 | 278 | Returns: 279 | dict: The payee information. 280 | 281 | Raises: 282 | HTTPError: If the request fails. 283 | """ 284 | endpoint = f"/budgets/{budget_id}/payees/{payee_id}" 285 | return self.http_utils.get(endpoint=endpoint) 286 | 287 | # PATCH /budgets/{budget_id}/payees/{payee_id} 288 | def request_update_payee( 289 | self, 290 | budget_id: str = "last-used", 291 | payee_id: str = None, 292 | request_body: str = None, 293 | ): 294 | """ 295 | Sends a PATCH request to update a payee. 296 | 297 | Args: 298 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 299 | payee_id (str, optional): The ID of the payee to update. 300 | request_body (str, optional): The JSON request body. 301 | 302 | Returns: 303 | The response from the PATCH request. 304 | """ 305 | endpoint = f"/budgets/{budget_id}/payees/{payee_id}" 306 | return self.http_utils.patch(endpoint=endpoint, json=request_body) 307 | 308 | # GET /budgets/{budget_id}/payee_locations 309 | def request_get_all_payee_locations(self, budget_id: str = "last-used"): 310 | """ 311 | Retrieves all payee locations for a specific budget. 312 | 313 | Args: 314 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 315 | 316 | Returns: 317 | dict: A dictionary containing the response data. 318 | 319 | Raises: 320 | None 321 | """ 322 | endpoint = f"/budgets/{budget_id}/payee_locations" 323 | return self.http_utils.get(endpoint=endpoint) 324 | 325 | # GET /budgets/{budget_id}/payee_locations/{payee_location_id} 326 | def request_get_payee_location( 327 | self, budget_id: str = "last-used", payee_location_id: str = None 328 | ): 329 | """ 330 | Retrieves a specific payee location from the specified budget. 331 | 332 | Args: 333 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 334 | payee_location_id (str, optional): The ID of the payee location. Defaults to None. 335 | 336 | Returns: 337 | dict: The payee location information. 338 | 339 | Raises: 340 | HTTPError: If the request fails. 341 | """ 342 | endpoint = f"/budgets/{budget_id}/payee_locations/{payee_location_id}" 343 | return self.http_utils.get(endpoint=endpoint) 344 | 345 | # GET /budgets/{budget_id}/payees/{payee_id}/payee_locations 346 | def request_get_payee_locations( 347 | self, budget_id: str = "last-used", payee_id: str = None 348 | ): 349 | """ 350 | Retrieves the payee locations for a specific payee in a budget. 351 | 352 | Args: 353 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 354 | payee_id (str, optional): The ID of the payee. Defaults to None. 355 | 356 | Returns: 357 | dict: The payee locations for the specified payee in the budget. 358 | """ 359 | endpoint = f"/budgets/{budget_id}/payees/{payee_id}/payee_locations" 360 | return self.http_utils.get(endpoint=endpoint) 361 | 362 | # GET /budgets/{budget_id}/months 363 | def request_get_months( 364 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 365 | ): 366 | """ 367 | Retrieves the months for a specific budget. 368 | 369 | Args: 370 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 371 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 372 | 373 | Returns: 374 | The response from the server. 375 | """ 376 | endpoint = f"/budgets/{budget_id}/months" 377 | if last_knowledge_of_server: 378 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 379 | return self.http_utils.get(endpoint=endpoint) 380 | 381 | # GET /budgets/{budget_id}/months/{month} 382 | def request_get_month( 383 | self, budget_id: str = "last-used", month_id: str = "current" 384 | ): 385 | """ 386 | Retrieves the details of a specific month in a budget. 387 | 388 | Args: 389 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 390 | month_id (str, optional): The ID of the month. Defaults to "current". 391 | 392 | Returns: 393 | dict: The details of the requested month. 394 | 395 | Raises: 396 | HTTPError: If the request fails. 397 | """ 398 | endpoint = f"/budgets/{budget_id}/months/{month_id}" 399 | return self.http_utils.get(endpoint=endpoint) 400 | 401 | # GET /budgets/{budget_id}/transactions 402 | def request_get_transactions( 403 | self, 404 | budget_id: str = "last-used", 405 | since_date: str = None, 406 | type: str = None, 407 | last_knowledge_of_server: int = 0, 408 | ): 409 | """ 410 | Sends a GET request to retrieve transactions from the specified budget. 411 | 412 | Args: 413 | budget_id (str, optional): The ID of the budget to retrieve transactions from. Defaults to "last-used". 414 | since_date (str, optional): The date to retrieve transactions since. Defaults to None. 415 | type (str, optional): The type of transactions to retrieve. Defaults to None. 416 | last_knowledge_of_server (int, optional): The knowledge of the server to retrieve transactions from. Defaults to 0. 417 | 418 | Returns: 419 | dict: The response from the server containing the retrieved transactions. 420 | """ 421 | endpoint = f"/budgets/{budget_id}/transactions" 422 | if since_date: 423 | endpoint += f"?since_date={since_date}" 424 | if type: 425 | endpoint += f"?type={type}" 426 | if last_knowledge_of_server: 427 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 428 | return self.http_utils.get(endpoint=endpoint) 429 | 430 | # POST /budgets/{budget_id}/transactions 431 | def request_create_transactions( 432 | self, budget_id: str = "last-used", request_body: str = None 433 | ): 434 | """ 435 | Sends a request to create transactions for a specific budget. 436 | 437 | Args: 438 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 439 | request_body (str, optional): The JSON request body containing the transaction data. Defaults to None. 440 | 441 | Returns: 442 | The response from the API call. 443 | """ 444 | endpoint = f"/budgets/{budget_id}/transactions" 445 | return self.http_utils.post(endpoint=endpoint, json=request_body) 446 | 447 | # PATCH /budgets/{budget_id}/transactions 448 | def request_update_transactions( 449 | self, budget_id: str = "last-used", request_body: str = None 450 | ): 451 | """ 452 | Sends a PATCH request to update transactions for a specific budget. 453 | 454 | Args: 455 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 456 | request_body (str, optional): The JSON request body. Defaults to None. 457 | 458 | Returns: 459 | The response from the PATCH request. 460 | """ 461 | endpoint = f"/budgets/{budget_id}/transactions" 462 | return self.http_utils.patch(endpoint=endpoint, json=request_body) 463 | 464 | # POST /budgets/{budget_id}/transactions/import 465 | def request_import_transactions(self, budget_id: str = "last-used"): 466 | """ 467 | Sends a request to import transactions for a specific budget. 468 | 469 | Args: 470 | budget_id (str, optional): The ID of the budget to import transactions for. Defaults to "last-used". 471 | 472 | Returns: 473 | The response from the HTTP POST request. 474 | """ 475 | endpoint = f"/budgets/{budget_id}/transactions/import" 476 | return self.http_utils.post(endpoint=endpoint) 477 | 478 | # GET /budgets/{budget_id}/transactions/{transaction_id} 479 | def request_get_transaction( 480 | self, budget_id: str = "last-used", transaction_id: str = None 481 | ): 482 | """ 483 | Retrieves a specific transaction from a budget. 484 | 485 | Args: 486 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 487 | transaction_id (str, optional): The ID of the transaction. If not provided, all transactions will be returned. 488 | 489 | Returns: 490 | dict: The retrieved transaction information. 491 | 492 | Raises: 493 | HTTPError: If the request fails or the transaction is not found. 494 | """ 495 | endpoint = f"/budgets/{budget_id}/transactions/{transaction_id}" 496 | return self.http_utils.get(endpoint=endpoint) 497 | 498 | # PUT /budgets/{budget_id}/transactions/{transaction_id} 499 | def request_update_transaction( 500 | self, 501 | budget_id: str = "last-used", 502 | transaction_id: str = None, 503 | request_body: str = None, 504 | ): 505 | """ 506 | Updates a transaction in the specified budget. 507 | 508 | Args: 509 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 510 | transaction_id (str, optional): The ID of the transaction to update. 511 | request_body (str, optional): The JSON request body containing the updated transaction data. 512 | 513 | Returns: 514 | The response from the API call. 515 | """ 516 | endpoint = f"/budgets/{budget_id}/transactions/{transaction_id}" 517 | return self.http_utils.put(endpoint=endpoint, json=request_body) 518 | 519 | # DELETE /budgets/{budget_id}/transactions/{transaction_id} 520 | def request_delete_transaction( 521 | self, budget_id: str = "last-used", transaction_id: str = None 522 | ): 523 | """ 524 | Sends a request to delete a transaction. 525 | 526 | Args: 527 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 528 | transaction_id (str, optional): The ID of the transaction to be deleted. 529 | 530 | Returns: 531 | The response from the HTTP request. 532 | """ 533 | endpoint = f"/budgets/{budget_id}/transactions/{transaction_id}" 534 | return self.http_utils.delete(endpoint=endpoint) 535 | 536 | # GET /budgets/{budget_id}/accounts/{account_id}/transactions 537 | def request_get_account_transactions( 538 | self, 539 | budget_id: str = "last-used", 540 | account_id: str = None, 541 | since_date: str = None, 542 | type: str = None, 543 | last_knowledge_of_server: int = 0, 544 | ): 545 | """ 546 | Retrieves the account transactions for a specific budget and account. 547 | 548 | Args: 549 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 550 | account_id (str, optional): The ID of the account. Defaults to None. 551 | since_date (str, optional): The date to retrieve transactions from. Defaults to None. 552 | type (str, optional): The type of transactions to retrieve. Defaults to None. 553 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 554 | 555 | Returns: 556 | The account transactions. 557 | 558 | """ 559 | endpoint = f"/budgets/{budget_id}/accounts/{account_id}/transactions" 560 | if since_date: 561 | endpoint += f"?since_date={since_date}" 562 | if type: 563 | endpoint += f"?type={type}" 564 | if last_knowledge_of_server: 565 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 566 | return self.http_utils.get(endpoint=endpoint) 567 | 568 | # GET /budgets/{budget_id}/categories/{category_id}/transactions 569 | def request_get_category_transactions( 570 | self, 571 | budget_id: str = "last-used", 572 | category_id: str = None, 573 | since_date: str = None, 574 | type: str = None, 575 | last_knowledge_of_server: int = 0, 576 | ): 577 | """ 578 | Retrieves transactions for a specific category. 579 | 580 | Args: 581 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 582 | category_id (str, optional): The ID of the category. Defaults to None. 583 | since_date (str, optional): The starting date to retrieve transactions from. Defaults to None. 584 | type (str, optional): The type of transactions to retrieve. Defaults to None. 585 | last_knowledge_of_server (int, optional): The knowledge of the server to retrieve transactions from. Defaults to 0. 586 | 587 | Returns: 588 | dict: The response containing the retrieved transactions. 589 | """ 590 | endpoint = f"/budgets/{budget_id}/categories/{category_id}/transactions" 591 | if since_date: 592 | endpoint += f"?since_date={since_date}" 593 | if type: 594 | endpoint += f"?type={type}" 595 | if last_knowledge_of_server: 596 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 597 | return self.http_utils.get(endpoint=endpoint) 598 | 599 | # GET /budgets/{budget_id}/payees/{payee_id}/transactions 600 | def request_get_payee_transactions( 601 | self, 602 | budget_id: str = "last-used", 603 | payee_id: str = None, 604 | since_date: str = None, 605 | type: str = None, 606 | last_knowledge_of_server: int = 0, 607 | ): 608 | """ 609 | Retrieves transactions for a specific payee. 610 | 611 | Args: 612 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 613 | payee_id (str, optional): The ID of the payee. Defaults to None. 614 | since_date (str, optional): The date to retrieve transactions since. Defaults to None. 615 | type (str, optional): The type of transactions to retrieve. Defaults to None. 616 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 617 | 618 | Returns: 619 | The response from the API containing the payee transactions. 620 | """ 621 | endpoint = f"/budgets/{budget_id}/payees/{payee_id}/transactions" 622 | if since_date: 623 | endpoint += f"?since_date={since_date}" 624 | if type: 625 | endpoint += f"?type={type}" 626 | if last_knowledge_of_server: 627 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 628 | return self.http_utils.get(endpoint=endpoint) 629 | 630 | # GET /budgets/{budget_id}/months/{month}/transactions 631 | def request_get_month_transactions( 632 | self, 633 | budget_id: str = "last-used", 634 | month: str = "current", 635 | since_date: str = None, 636 | type: str = None, 637 | last_knowledge_of_server: int = 0, 638 | ): 639 | """ 640 | Retrieves the transactions for a specific month in a budget. 641 | 642 | Args: 643 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 644 | month (str, optional): The month to retrieve transactions for. Defaults to "current". 645 | since_date (str, optional): The starting date for the transactions. Defaults to None. 646 | type (str, optional): The type of transactions to retrieve. Defaults to None. 647 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 648 | 649 | Returns: 650 | The response from the API containing the transactions for the specified month. 651 | """ 652 | endpoint = f"/budgets/{budget_id}/months/{month}/transactions" 653 | if since_date: 654 | endpoint += f"?since_date={since_date}" 655 | if type: 656 | endpoint += f"?type={type}" 657 | if last_knowledge_of_server: 658 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 659 | return self.http_utils.get(endpoint=endpoint) 660 | 661 | # GET /budgets/{budget_id}/scheduled_transactions 662 | def request_get_scheduled_transactions( 663 | self, budget_id: str = "last-used", last_knowledge_of_server: int = 0 664 | ): 665 | """ 666 | Retrieves the scheduled transactions for a specific budget. 667 | 668 | Args: 669 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 670 | last_knowledge_of_server (int, optional): The knowledge of the server. Defaults to 0. 671 | 672 | Returns: 673 | The response from the server containing the scheduled transactions. 674 | """ 675 | endpoint = f"/budgets/{budget_id}/scheduled_transactions" 676 | if last_knowledge_of_server: 677 | endpoint += f"?last_knowledge_of_server={last_knowledge_of_server}" 678 | return self.http_utils.get(endpoint=endpoint) 679 | 680 | # POST /budgets/{budget_id}/scheduled_transactions 681 | def request_create_scheduled_transaction( 682 | self, budget_id: str = "last-used", request_body: str = None 683 | ): 684 | """ 685 | Creates a new scheduled transaction for the specified budget. 686 | 687 | Args: 688 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 689 | request_body (str, optional): The request body containing the details of the scheduled transaction. Defaults to None. 690 | 691 | Returns: 692 | The response from the API call. 693 | """ 694 | endpoint = f"/budgets/{budget_id}/scheduled_transactions" 695 | return self.http_utils.post(endpoint=endpoint, json=request_body) 696 | 697 | # GET /budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id} 698 | def request_get_scheduled_transaction( 699 | self, budget_id: str = "last-used", scheduled_transaction_id: str = None 700 | ): 701 | """ 702 | Retrieves a scheduled transaction from the specified budget. 703 | 704 | Args: 705 | budget_id (str, optional): The ID of the budget. Defaults to "last-used". 706 | scheduled_transaction_id (str, optional): The ID of the scheduled transaction. 707 | 708 | Returns: 709 | dict: The scheduled transaction information. 710 | 711 | Raises: 712 | HTTPException: If the request fails. 713 | """ 714 | endpoint = ( 715 | f"/budgets/{budget_id}/scheduled_transactions/{scheduled_transaction_id}" 716 | ) 717 | return self.http_utils.get(endpoint=endpoint) 718 | -------------------------------------------------------------------------------- /pynab/enums.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Frequency(Enum): 5 | """ 6 | Enum representing different frequencies. 7 | 8 | Attributes: 9 | NEVER (str): Represents never. 10 | DAILY (str): Represents daily. 11 | WEEKLY (str): Represents weekly. 12 | EVERY_OTHER_WEEK (str): Represents every other week. 13 | TWICE_A_MONTH (str): Represents twice a month. 14 | EVERY_4_WEEKS (str): Represents every 4 weeks. 15 | MONTHLY (str): Represents monthly. 16 | EVERY_OTHER_MONTH (str): Represents every other month. 17 | EVERY_3_MONTHS (str): Represents every 3 months. 18 | EVERY_4_MONTHS (str): Represents every 4 months. 19 | TWICE_A_YEAR (str): Represents twice a year. 20 | YEARLY (str): Represents yearly. 21 | EVERY_OTHER_YEAR (str): Represents every other year. 22 | NONE (None): Represents none. 23 | """ 24 | 25 | NEVER = "never" 26 | DAILY = "daily" 27 | WEEKLY = "weekly" 28 | EVERY_OTHER_WEEK = "everyOtherWeek" 29 | TWICE_A_MONTH = "twiceAMonth" 30 | EVERY_4_WEEKS = "every4Weeks" 31 | MONTHLY = "monthly" 32 | EVERY_OTHER_MONTH = "everyOtherMonth" 33 | EVERY_3_MONTHS = "every3Months" 34 | EVERY_4_MONTHS = "every4Months" 35 | TWICE_A_YEAR = "twiceAYear" 36 | YEARLY = "yearly" 37 | EVERY_OTHER_YEAR = "everyOtherYear" 38 | NONE = None 39 | 40 | 41 | class DebtTransactionType(Enum): 42 | """ 43 | Enum class representing different types of debt transactions. 44 | 45 | Attributes: 46 | PAYMENT (str): Represents a payment transaction. 47 | REFUND (str): Represents a refund transaction. 48 | FEE (str): Represents a fee transaction. 49 | INTEREST (str): Represents an interest transaction. 50 | ESCROW (str): Represents an escrow transaction. 51 | BALANCE_ADJUSTMENT (str): Represents a balance adjustment transaction. 52 | CREDIT (str): Represents a credit transaction. 53 | CHARGE (str): Represents a charge transaction. 54 | NONE (None): Represents no transaction type. 55 | """ 56 | 57 | PAYMENT = "payment" 58 | REFUND = "refund" 59 | FEE = "fee" 60 | INTEREST = "interest" 61 | ESCROW = "escrow" 62 | BALANCE_ADJUSTMENT = "balanceAdjustment" 63 | CREDIT = "credit" 64 | CHARGE = "charge" 65 | NONE = None 66 | 67 | 68 | class TransactionFlagColor(Enum): 69 | """ 70 | Enum class representing the color of a transaction flag. 71 | 72 | Attributes: 73 | RED (str): The color red. 74 | ORANGE (str): The color orange. 75 | YELLOW (str): The color yellow. 76 | GREEN (str): The color green. 77 | BLUE (str): The color blue. 78 | PURPLE (str): The color purple. 79 | NONE (None): No color specified. 80 | """ 81 | 82 | RED = "red" 83 | ORANGE = "orange" 84 | YELLOW = "yellow" 85 | GREEN = "green" 86 | BLUE = "blue" 87 | PURPLE = "purple" 88 | NONE = None 89 | 90 | 91 | class TransactionClearedStatus(Enum): 92 | """ 93 | Enum representing the cleared status of a transaction. 94 | 95 | Attributes: 96 | CLEARED (str): Represents a cleared transaction. 97 | UNCLEARED (str): Represents an uncleared transaction. 98 | RECONCILED (str): Represents a reconciled transaction. 99 | NONE (None): Represents no cleared status. 100 | """ 101 | 102 | CLEARED = "cleared" 103 | UNCLEARED = "uncleared" 104 | RECONCILED = "reconciled" 105 | NONE = None 106 | 107 | 108 | class GoalType(Enum): 109 | """ 110 | Enum class representing different types of goals. 111 | 112 | Attributes: 113 | TARGET_CATEGORY_BALANCE (str): Target category balance goal type. 114 | TARGET_CATEGORY_BALANCE_BY_DATE (str): Target category balance by date goal type. 115 | MONTHLY_FUNDING (str): Monthly funding goal type. 116 | PLAN_YOUR_SPENDING (str): Plan your spending goal type. 117 | DEBT (str): Debt goal type. 118 | NONE (None): No goal type. 119 | """ 120 | 121 | TARGET_CATEGORY_BALANCE = "TB" 122 | TARGET_CATEGORY_BALANCE_BY_DATE = "TBD" 123 | MONTHLY_FUNDING = "MF" 124 | PLAN_YOUR_SPENDING = "NEED" 125 | DEBT = "DEBT" 126 | NONE = None 127 | 128 | 129 | class AccountType(Enum): 130 | """ 131 | Enum representing different types of accounts. 132 | 133 | Attributes: 134 | CHECKING (str): Represents a checking account. 135 | SAVINGS (str): Represents a savings account. 136 | CASH (str): Represents a cash account. 137 | CREDIT_CARD (str): Represents a credit card account. 138 | LINE_OF_CREDIT (str): Represents a line of credit account. 139 | OTHER_ASSET (str): Represents an other asset account. 140 | OTHER_LIABILITY (str): Represents an other liability account. 141 | MORTGAGE (str): Represents a mortgage account. 142 | AUTO_LOAN (str): Represents an auto loan account. 143 | STUDENT_LOAN (str): Represents a student loan account. 144 | PERSONAL_LOAN (str): Represents a personal loan account. 145 | MEDICAL_DEBT (str): Represents a medical debt account. 146 | OTHER_DEBT (str): Represents an other debt account. 147 | NONE (None): Represents no account type. 148 | """ 149 | 150 | CHECKING = "checking" 151 | SAVINGS = "savings" 152 | CASH = "cash" 153 | CREDIT_CARD = "creditCard" 154 | LINE_OF_CREDIT = "lineOfCredit" 155 | OTHER_ASSET = "otherAsset" 156 | OTHER_LIABILITY = "otherLiability" 157 | MORTGAGE = "mortgage" 158 | AUTO_LOAN = "autoLoan" 159 | STUDENT_LOAN = "studentLoan" 160 | PERSONAL_LOAN = "personalLoan" 161 | MEDICAL_DEBT = "medicalDebt" 162 | OTHER_DEBT = "otherDebt" 163 | NONE = None 164 | -------------------------------------------------------------------------------- /pynab/pynab.py: -------------------------------------------------------------------------------- 1 | from pynab.api import Api 2 | from pynab import constants 3 | 4 | 5 | class Pynab: 6 | def __init__(self, bearer: str = None): 7 | """ 8 | Initializes a new instance of the `pynab` class. 9 | 10 | Args: 11 | bearer (str, optional): The bearer token for authentication. Defaults to None. 12 | """ 13 | self.api_url = constants.YNAB_API 14 | 15 | self._bearer = bearer 16 | self._fetch = True 17 | self._track_server_knowledge = False 18 | 19 | self._requests_remaining = 0 20 | self._headers = { 21 | "Authorization": f"Bearer {self._bearer}", 22 | "accept": "application/json", 23 | } 24 | 25 | self._server_knowledges = { 26 | "get_budget": 0, 27 | "get_accounts": 0, 28 | "get_categories": 0, 29 | "get_months": 0, 30 | "get_transactions": 0, 31 | "get_account_transactions": 0, 32 | "get_category_transactions": 0, 33 | "get_payee_transactions": 0, 34 | "get_month_transactions": 0, 35 | "get_scheduled_transactions": 0, 36 | } 37 | 38 | self.api = Api(pynab=self) 39 | 40 | def server_knowledges(self, endpoint: str = None): 41 | """ 42 | Retrieves the server knowledge for a specific endpoint. 43 | 44 | Parameters: 45 | endpoint (str): The endpoint for which to retrieve the server knowledge. If not provided, the default value is None. 46 | 47 | Returns: 48 | int: The server knowledge for the specified endpoint. If server knowledge tracking is disabled, returns 0. 49 | """ 50 | if self._track_server_knowledge: 51 | return self._server_knowledges[endpoint] 52 | else: 53 | return 0 54 | 55 | @property 56 | def user(self): 57 | """ 58 | Retrieves the user information from the API. 59 | 60 | Returns: 61 | dict: A dictionary containing the user information. 62 | """ 63 | return self.api.get_user() 64 | 65 | @property 66 | def budgets(self): 67 | """ 68 | Retrieves the budgets from the API. 69 | 70 | Returns: 71 | list: A list of budgets. 72 | """ 73 | return self.api.get_budgets() 74 | -------------------------------------------------------------------------------- /pynab/utils.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, date 2 | from enum import Enum 3 | from pynab import pynab 4 | 5 | import json 6 | import requests 7 | import logging 8 | 9 | 10 | class http_utils: 11 | def __init__(self, pynab: pynab = None): 12 | """ 13 | Initializes an instance of the class. 14 | 15 | Args: 16 | pynab (pynab, optional): The pynab object. Defaults to None. 17 | """ 18 | self.pynab = pynab 19 | 20 | def get(self, endpoint: str = None): 21 | """ 22 | Sends a GET request to the specified endpoint. 23 | 24 | Args: 25 | endpoint (str, optional): The endpoint to send the request to. Defaults to None. 26 | 27 | Returns: 28 | Response: The response object returned by the GET request. 29 | """ 30 | url = f"{self.pynab.api_url}{endpoint}" 31 | logging.debug(f"GET {url}") 32 | response = requests.get(url, headers=self.pynab._headers) 33 | if "x-rate-limit" in response.headers: 34 | self.pynab._requests_remaining = int( 35 | response.headers["x-rate-limit"].split("/")[1] 36 | ) - int(response.headers["x-rate-limit"].split("/")[0]) 37 | else: 38 | self.pynab._requests_remaining -= 1 39 | return response 40 | 41 | def post(self, endpoint: str = None, json: dict = {}): 42 | """ 43 | Sends a POST request to the specified endpoint with the provided JSON data. 44 | 45 | Args: 46 | endpoint (str): The endpoint to send the request to. 47 | json (dict): The JSON data to include in the request body. 48 | 49 | Returns: 50 | Response: The response object received from the server. 51 | """ 52 | url = f"{self.pynab.api_url}{endpoint}" 53 | logging.debug(f"POST {url}\n{json}") 54 | response = requests.post(url, json=json, headers=self.pynab._headers) 55 | if "x-rate-limit" in response.headers: 56 | self.pynab._requests_remaining = int( 57 | response.headers["x-rate-limit"].split("/")[1] 58 | ) - int(response.headers["x-rate-limit"].split("/")[0]) 59 | else: 60 | self.pynab._requests_remaining -= 1 61 | return response 62 | 63 | def patch(self, endpoint: str = None, json: dict = {}): 64 | """ 65 | Sends a PATCH request to the specified endpoint with the provided JSON data. 66 | 67 | Args: 68 | endpoint (str, optional): The endpoint to send the PATCH request to. Defaults to None. 69 | json (dict, optional): The JSON data to include in the request body. Defaults to {}. 70 | 71 | Returns: 72 | Response: The response object returned by the PATCH request. 73 | """ 74 | url = f"{self.pynab.api_url}{endpoint}" 75 | logging.debug(f"PATCH {url}\n{json}") 76 | response = requests.patch(url, json=json, headers=self.pynab._headers) 77 | if "x-rate-limit" in response.headers: 78 | self.pynab._requests_remaining = int( 79 | response.headers["x-rate-limit"].split("/")[1] 80 | ) - int(response.headers["x-rate-limit"].split("/")[0]) 81 | else: 82 | self.pynab._requests_remaining -= 1 83 | return response 84 | 85 | def put(self, endpoint: str = None, json: dict = {}): 86 | """ 87 | Sends a PUT request to the specified endpoint with the given JSON payload. 88 | 89 | Args: 90 | endpoint (str): The endpoint to send the request to. 91 | json (dict): The JSON payload to include in the request. 92 | 93 | Returns: 94 | Response: The response object returned by the server. 95 | """ 96 | url = f"{self.pynab.api_url}{endpoint}" 97 | logging.debug(f"PUT {url}\n{json}") 98 | response = requests.put(url, json=json, headers=self.pynab._headers) 99 | if "x-rate-limit" in response.headers: 100 | self.pynab._requests_remaining = int( 101 | response.headers["x-rate-limit"].split("/")[1] 102 | ) - int(response.headers["x-rate-limit"].split("/")[0]) 103 | else: 104 | self.pynab._requests_remaining -= 1 105 | return response 106 | 107 | def delete(self, endpoint: str = None): 108 | """ 109 | Sends a DELETE request to the specified endpoint. 110 | 111 | Args: 112 | endpoint (str, optional): The endpoint to send the request to. Defaults to None. 113 | 114 | Returns: 115 | requests.Response: The response object returned by the DELETE request. 116 | """ 117 | url = f"{self.pynab.api_url}{endpoint}" 118 | logging.info(f"DELETE {url}\n{json}") 119 | response = requests.delete(url, headers=self.pynab._headers) 120 | if "x-rate-limit" in response.headers: 121 | self.pynab._requests_remaining = int( 122 | response.headers["x-rate-limit"].split("/")[1] 123 | ) - int(response.headers["x-rate-limit"].split("/")[0]) 124 | else: 125 | self.pynab._requests_remaining -= 1 126 | return response 127 | 128 | 129 | class CustomJsonEncoder(json.JSONEncoder): 130 | def default(self, obj): 131 | """ 132 | Returns the default JSON representation of an object. 133 | 134 | Parameters: 135 | - obj: The object to be serialized. 136 | 137 | Returns: 138 | The JSON representation of the object. 139 | 140 | Note: 141 | - If the object is an instance of Enum, the value of the Enum is returned. 142 | - If the object is an instance of datetime or date, the ISO formatted string representation is returned. 143 | - For all other objects, the default JSONEncoder's default method is called. 144 | 145 | """ 146 | if isinstance(obj, Enum): 147 | return obj.value 148 | if isinstance(obj, (datetime, date)): 149 | return obj.isoformat() 150 | return json.JSONEncoder.default(self, obj) # pragma: no cover 151 | 152 | 153 | class _dict(dict): 154 | """ 155 | A custom dictionary class that provides additional functionality. 156 | 157 | This class extends the built-in `dict` class and adds a `by` method 158 | for filtering the dictionary items based on a specific field and value. 159 | 160 | Attributes: 161 | None 162 | 163 | Methods: 164 | by(field: str = "", value: object = None, first: bool = True) -> Union[object, _dict]: 165 | Filters the dictionary items based on the specified field and value. 166 | 167 | """ 168 | 169 | def by(self, field: str = "", value: object = None, first: bool = True): 170 | """ 171 | Filters the dictionary items based on the specified field and value. 172 | 173 | Args: 174 | field (str): The name of the field to filter on. 175 | value (object): The value to filter for. 176 | first (bool): If True, returns the first matching item. If False, returns a new dictionary with all matching items. 177 | 178 | Returns: 179 | Union[object, _dict]: If `first` is True, returns the first matching item. If `first` is False, returns a new `_dict` object with all matching items. 180 | 181 | """ 182 | items = _dict() 183 | for k, v in self.items(): 184 | if getattr(v, field, None) == value: 185 | if first: 186 | return v 187 | else: 188 | items[k] = v 189 | return items 190 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2024.8.30 2 | charset-normalizer==3.3.2 3 | idna==3.10 4 | python-dateutil==2.9.0.post0 5 | requests==2.32.3 6 | six==1.16.0 7 | urllib3==2.2.3 8 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name="pynab", 5 | version="1.0.0", 6 | description="A Python client for the You Need A Budget (YNAB) API", 7 | long_description=open("README.md").read(), 8 | long_description_content_type="text/markdown", 9 | author="Austin Conn", 10 | author_email="austinc@dynacylabs.com", 11 | url="https://github.com/dynacylabs/pynab", 12 | packages=find_packages(), 13 | install_requires=[ 14 | "requests", 15 | "python-dateutil", 16 | ], 17 | classifiers=[ 18 | "Programming Language :: Python :: 3", 19 | "License :: OSI Approved :: MIT License", 20 | "Operating System :: OS Independent", 21 | ], 22 | python_requires=">=3.6", 23 | ) 24 | -------------------------------------------------------------------------------- /testing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dynacylabs/pynab/0e5f650839fc754ac04ed572424fbb68e3b35201/testing/__init__.py -------------------------------------------------------------------------------- /testing/requirements.txt: -------------------------------------------------------------------------------- 1 | cachetools==5.5.0 2 | chardet==5.2.0 3 | colorama==0.4.6 4 | coverage==7.6.1 5 | distlib==0.3.8 6 | filelock==3.16.0 7 | iniconfig==2.0.0 8 | packaging==24.1 9 | platformdirs==4.3.3 10 | pluggy==1.5.0 11 | pyproject-api==1.7.1 12 | pytest==8.3.3 13 | python-dateutil==2.9.0.post0 14 | python-dotenv==1.0.1 15 | six==1.16.0 16 | tox==4.18.1 17 | virtualenv==20.26.4 18 | -------------------------------------------------------------------------------- /testing/test_budget.ynab4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dynacylabs/pynab/0e5f650839fc754ac04ed572424fbb68e3b35201/testing/test_budget.ynab4.zip -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py38, py39, py310 3 | 4 | [testenv] 5 | allowlist_externals = 6 | coverage 7 | setenv = 8 | LOG_LEVEL = DEBUG 9 | deps = 10 | -e . 11 | -r testing/requirements.txt 12 | commands = 13 | ; coverage run -m pytest -s --log-cli-level=DEBUG {posargs} 14 | coverage run -m pytest -s {posargs} 15 | coverage report -m 16 | coverage html --------------------------------------------------------------------------------