diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 66fbec4..34bfe4f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -11,7 +11,7 @@ [//]: # (If there is a traceback please share it in a quote! You can do this by pasting the traceback text, highlighting it and pressing the quote button.) ## SDK version and environment -- Tested on [0.12.4](https://github.com/bunq/sdk_python/releases/tag/0.12.4) +- Tested on [1.14.1](https://github.com/bunq/sdk_python/releases/tag/1.14.1) - [ ] Sandbox - [ ] Production diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 2c24c0c..f3daf1b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,5 +4,5 @@ ## This PR closes/fixes the following issues: [//]: # (If for some reason your pull request does not require a test case you can just mark this box as checked and explain why it does not require a test case.) - - Closes bunq/sdk_php# + - Closes bunq/sdk_python# - [ ] Tested diff --git a/.github/workflows/slack-on-issue.yml b/.github/workflows/slack-on-issue.yml new file mode 100644 index 0000000..25dfe33 --- /dev/null +++ b/.github/workflows/slack-on-issue.yml @@ -0,0 +1,52 @@ +name: Notify Slack on New Issue or PR + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Send Slack notification + run: | + if [[ "${{ github.event_name }}" == "issues" ]]; then + TYPE="Issue" + TITLE="${{ github.event.issue.title }}" + URL="${{ github.event.issue.html_url }}" + USER="${{ github.event.issue.user.login }}" + else + TYPE="Pull Request" + TITLE="${{ github.event.pull_request.title }}" + URL="${{ github.event.pull_request.html_url }}" + USER="${{ github.event.pull_request.user.login }}" + fi + + PAYLOAD=$(jq -n \ + --arg type "$TYPE" \ + --arg title "$TITLE" \ + --arg url "$URL" \ + --arg user "$USER" \ + '{ + text: "*New GitHub \($type)* :sparkles:", + attachments: [ + { + color: "#36a64f", + title: $title, + title_link: $url, + fields: [ + { + title: "Author", + value: $user, + short: true + } + ] + } + ] + }') + + curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.gitignore b/.gitignore index 3448d22..9ee2613 100644 --- a/.gitignore +++ b/.gitignore @@ -6,29 +6,11 @@ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries +.idea # CMake cmake-build-debug/ -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - ## File-based project format: *.iws @@ -71,6 +53,8 @@ modules.xml /dist /MANIFEST /stripe.egg-info +/bunq_env +/.vscode .python-version *.pyc *.egg @@ -94,3 +78,9 @@ connectQr.png bunq_sdk.egg-info .idea/codeStyles/ venv + +tests/bunq-oauth-psd2-test.conf +tests/bunq-psd2-test.conf +tests/key.pem +tests/certificate.pem + diff --git a/CHANGELOG.md b/CHANGELOG.md index c8bfc9e..8f18749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,172 @@ -# Change Log +# Changelog -## [Unreleased](https://github.com/bunq/sdk_python/tree/1.0.0) +## [Unreleased](https://github.com/bunq/sdk_python/tree/HEAD) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.14.1...HEAD) + +**Implemented enhancements:** + +- Replace /sandbox-user with /sandbox-user-person and /sandbox-user-company [\#151](https://github.com/bunq/sdk_python/issues/151) + +**Fixed bugs:** + +- Remove \_\_get\_user\_object call immediately after UserContext creation \(reduce rate-limit hits\) [\#149](https://github.com/bunq/sdk_python/issues/149) +- Feature/sdk python\#149 save/restore User in SessionContext from file [\#153](https://github.com/bunq/sdk_python/pull/153) ([angelomelonas](https://github.com/angelomelonas)) + +**Merged pull requests:** + +- feature/sdk\_python\#151 Deprecated SandboxUser and replaced it with SandboxUserPerson/Company [\#152](https://github.com/bunq/sdk_python/pull/152) ([angelomelonas](https://github.com/angelomelonas)) +- feature/sdk\_python\#149 Remove get\_user\_object call directly after UserContext creation [\#150](https://github.com/bunq/sdk_python/pull/150) ([angelomelonas](https://github.com/angelomelonas)) + +## [1.14.1](https://github.com/bunq/sdk_python/tree/1.14.1) (2020-08-20) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.14.0...1.14.1) + +**Implemented enhancements:** + +- Add a test for oauth\_authorization\_uri [\#145](https://github.com/bunq/sdk_python/issues/145) +- Update tests with Type Hints \(and other small Type Hint improvements\) [\#139](https://github.com/bunq/sdk_python/issues/139) +- Complete OAuth/PSD2 implementation [\#136](https://github.com/bunq/sdk_python/issues/136) +- Allow for a looser range of runtime dependency versions in conformance with semver backward compatibility guarantees [\#107](https://github.com/bunq/sdk_python/issues/107) +- Updated dependencies, and made them more flexible [\#146](https://github.com/bunq/sdk_python/pull/146) ([angelomelonas](https://github.com/angelomelonas)) +- Added type hints for tests [\#141](https://github.com/bunq/sdk_python/pull/141) ([angelomelonas](https://github.com/angelomelonas)) + +**Fixed bugs:** + +- Add missing \_user\_payment\_service\_provider variable with the value None to session\_server [\#135](https://github.com/bunq/sdk_python/pull/135) ([siccovansas](https://github.com/siccovansas)) + +**Closed issues:** + +- Breaking changes since v1.13.0 [\#142](https://github.com/bunq/sdk_python/issues/142) +- Is this repository even maintained? [\#140](https://github.com/bunq/sdk_python/issues/140) +- AttributeError: 'SessionServer' object has no attribute '\_user\_payment\_service\_provider' [\#134](https://github.com/bunq/sdk_python/issues/134) +- cannot import name 'ApiContext' from 'bunq.sdk.context' [\#132](https://github.com/bunq/sdk_python/issues/132) +- The CHANGELOG is out of date [\#131](https://github.com/bunq/sdk_python/issues/131) +- Error in class conversion since BillingInvoice does not exist [\#124](https://github.com/bunq/sdk_python/issues/124) + +**Merged pull requests:** + +- Update CHANGELOG with breaking changes [\#143](https://github.com/bunq/sdk_python/pull/143) ([angelomelonas](https://github.com/angelomelonas)) +- sdk\_python\#136 complete Oauth/PSD2 implementation [\#138](https://github.com/bunq/sdk_python/pull/138) ([angelomelonas](https://github.com/angelomelonas)) +- update setup.py: only python 3.7 is supported. [\#133](https://github.com/bunq/sdk_python/pull/133) ([csdenboer](https://github.com/csdenboer)) + +## [1.14.0](https://github.com/bunq/sdk_python/tree/1.14.0) (2020-08-04) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.13.1...1.14.0) + +## [1.13.1](https://github.com/bunq/sdk_python/tree/1.13.1) (2020-02-21) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.13.0...1.13.1) + +**Implemented enhancements:** + +- Add type hint. [\#89](https://github.com/bunq/sdk_python/issues/89) +- Python SDK PSD2 [\#123](https://github.com/bunq/sdk_python/pull/123) ([angelomelonas](https://github.com/angelomelonas)) + +**Fixed bugs:** + +- Fix notification adapter and test. [\#126](https://github.com/bunq/sdk_python/pull/126) ([NickvandeGroes](https://github.com/NickvandeGroes)) + +**Closed issues:** + +- Dependencies severely out of date \(and vulnerable: CVEs\) [\#121](https://github.com/bunq/sdk_python/issues/121) +- Typo in EXCEPTIONS.md [\#110](https://github.com/bunq/sdk_python/issues/110) + +**Merged pull requests:** + +- feature/fix\_typo: fix typo. [\#129](https://github.com/bunq/sdk_python/pull/129) ([angelomelonas](https://github.com/angelomelonas)) +- Feature/dependency upgrades [\#128](https://github.com/bunq/sdk_python/pull/128) ([angelomelonas](https://github.com/angelomelonas)) +- Add internal NotificationFilters [\#127](https://github.com/bunq/sdk_python/pull/127) ([angelomelonas](https://github.com/angelomelonas)) + +## [1.13.0](https://github.com/bunq/sdk_python/tree/1.13.0) (2020-02-19) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.10.16...1.13.0) + +**Implemented enhancements:** + +- Python SDK Refactor [\#117](https://github.com/bunq/sdk_python/pull/117) ([angelomelonas](https://github.com/angelomelonas)) + +## [1.10.16](https://github.com/bunq/sdk_python/tree/1.10.16) (2019-06-17) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.10.2...1.10.16) + +**Closed issues:** + +- Fix README.md preventing from uploading a new version of sdk [\#113](https://github.com/bunq/sdk_python/issues/113) + +**Merged pull requests:** + +- Markdown fix. \(bunq/sdk\_python\#113\) [\#114](https://github.com/bunq/sdk_python/pull/114) ([kojoru](https://github.com/kojoru)) + +## [1.10.2](https://github.com/bunq/sdk_python/tree/1.10.2) (2019-05-22) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.10.1...1.10.2) + +**Closed issues:** + +- MonetaryAccountJoint.list not availeble [\#112](https://github.com/bunq/sdk_python/issues/112) + +## [1.10.1](https://github.com/bunq/sdk_python/tree/1.10.1) (2019-03-22) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.10.0...1.10.1) + +## [1.10.0](https://github.com/bunq/sdk_python/tree/1.10.0) (2019-03-22) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.1.0...1.10.0) + +**Closed issues:** + +- Minimum Python version to 3.5.3 [\#108](https://github.com/bunq/sdk_python/issues/108) + +**Merged pull requests:** + +- Edits to allow Python 3.5.3 as minimum [\#109](https://github.com/bunq/sdk_python/pull/109) ([eavanvalkenburg](https://github.com/eavanvalkenburg)) + +## [1.1.0](https://github.com/bunq/sdk_python/tree/1.1.0) (2018-10-05) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.0.1...1.1.0) + +**Closed issues:** + +- Setting the Status of ShareInviteBankInquiry to ACCEPTED causes error at reciver [\#105](https://github.com/bunq/sdk_python/issues/105) + +**Merged pull requests:** + +- Bunq/sdk\_python\#78/remove config dep [\#106](https://github.com/bunq/sdk_python/pull/106) ([OGKevin](https://github.com/OGKevin)) + +## [1.0.1](https://github.com/bunq/sdk_python/tree/1.0.1) (2018-09-01) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/1.0.0...1.0.1) + +## [1.0.0](https://github.com/bunq/sdk_python/tree/1.0.0) (2018-07-24) [Full Changelog](https://github.com/bunq/sdk_python/compare/0.13.1...1.0.0) +**Implemented enhancements:** + +- Added method to refresh user context data. \(bunq/sdk\_python\#79\) [\#80](https://github.com/bunq/sdk_python/pull/80) ([OGKevin](https://github.com/OGKevin)) + **Closed issues:** +- Add oath support. [\#102](https://github.com/bunq/sdk_python/issues/102) - Update Sandbox API key procedure [\#100](https://github.com/bunq/sdk_python/issues/100) **Merged pull requests:** - Oauth bunq/sdk\_python\#102 [\#103](https://github.com/bunq/sdk_python/pull/103) ([OGKevin](https://github.com/OGKevin)) - Update Sandbox API key procedure. \(bunq/sdk\_python\#100\) [\#101](https://github.com/bunq/sdk_python/pull/101) ([sandervdo](https://github.com/sandervdo)) +- Move to new sandbox bunq/sdk\_python\#98 [\#99](https://github.com/bunq/sdk_python/pull/99) ([OGKevin](https://github.com/OGKevin)) +- Updated readme to point to tinker for examples. \(bunq/sdk\_python\#87\) [\#95](https://github.com/bunq/sdk_python/pull/95) ([OGKevin](https://github.com/OGKevin)) +- Fix monetary account joint retrieval bunq/sdk\_python\#52 [\#94](https://github.com/bunq/sdk_python/pull/94) ([OGKevin](https://github.com/OGKevin)) +- Fix supperfouls fields error bunq/sdk\_python\#77 [\#91](https://github.com/bunq/sdk_python/pull/91) ([OGKevin](https://github.com/OGKevin)) +- Auto update bunq context bunq/sdk\_python\#65 [\#86](https://github.com/bunq/sdk_python/pull/86) ([OGKevin](https://github.com/OGKevin)) +- Increased min python version to 3.6. \(bunq/sdk\_python\#73\) [\#85](https://github.com/bunq/sdk_python/pull/85) ([OGKevin](https://github.com/OGKevin)) +- Replace examples with tinker bunq/sdk\_pyhton\#68 [\#84](https://github.com/bunq/sdk_python/pull/84) ([OGKevin](https://github.com/OGKevin)) +- Use ValueError isntead of JsonDecodeError. \(bunq/sdk\_python\#72\) [\#83](https://github.com/bunq/sdk_python/pull/83) ([OGKevin](https://github.com/OGKevin)) +- Optimise test framework auto topup bunq/sdk\_python\#78 [\#81](https://github.com/bunq/sdk_python/pull/81) ([OGKevin](https://github.com/OGKevin)) ## [0.13.1](https://github.com/bunq/sdk_python/tree/0.13.1) (2018-05-30) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.13.0...0.13.1) **Implemented enhancements:** @@ -27,7 +180,6 @@ - Monetary account joint cannot be retrieved. [\#52](https://github.com/bunq/sdk_python/issues/52) - Endpoint HTTP methods should not be static [\#41](https://github.com/bunq/sdk_python/issues/41) - Name field for pointer counterparty [\#29](https://github.com/bunq/sdk_python/issues/29) -- Added method to refresh user context data. \(bunq/sdk\_python\#79\) [\#80](https://github.com/bunq/sdk_python/pull/80) ([OGKevin](https://github.com/OGKevin)) **Fixed bugs:** @@ -37,28 +189,16 @@ **Closed issues:** +- Move to new sandbox env. [\#98](https://github.com/bunq/sdk_python/issues/98) - Bunq sdk release request [\#97](https://github.com/bunq/sdk_python/issues/97) - reopening of question \#12 generated.Payment.FIELD\_COUNTERPARTY\_ALIAS not working with IBAN [\#96](https://github.com/bunq/sdk_python/issues/96) - Update samples and readme [\#93](https://github.com/bunq/sdk_python/issues/93) - bunq.sdk.exception.BunqException: ApiContext has not been loaded. Please load ApiContext in BunqContext [\#92](https://github.com/bunq/sdk_python/issues/92) - Sample for reading/using shared accounts [\#90](https://github.com/bunq/sdk_python/issues/90) - Python 3.4.2: ImportError: cannot import name 'context' \(cyclic import?\) [\#73](https://github.com/bunq/sdk_python/issues/73) -- Add oath support. [\#102](https://github.com/bunq/sdk_python/issues/102) -- Move to new sandbox env. [\#98](https://github.com/bunq/sdk_python/issues/98) - -**Merged pull requests:** - -- Updated readme to point to tinker for examples. \(bunq/sdk\_python\#87\) [\#95](https://github.com/bunq/sdk_python/pull/95) ([OGKevin](https://github.com/OGKevin)) -- Fix monetary account joint retrieval bunq/sdk\_python\#52 [\#94](https://github.com/bunq/sdk_python/pull/94) ([OGKevin](https://github.com/OGKevin)) -- Fix supperfouls fields error bunq/sdk\_python\#77 [\#91](https://github.com/bunq/sdk_python/pull/91) ([OGKevin](https://github.com/OGKevin)) -- Auto update bunq context bunq/sdk\_python\#65 [\#86](https://github.com/bunq/sdk_python/pull/86) ([OGKevin](https://github.com/OGKevin)) -- Increased min python version to 3.6. \(bunq/sdk\_python\#73\) [\#85](https://github.com/bunq/sdk_python/pull/85) ([OGKevin](https://github.com/OGKevin)) -- Replace examples with tinker bunq/sdk\_pyhton\#68 [\#84](https://github.com/bunq/sdk_python/pull/84) ([OGKevin](https://github.com/OGKevin)) -- Use ValueError isntead of JsonDecodeError. \(bunq/sdk\_python\#72\) [\#83](https://github.com/bunq/sdk_python/pull/83) ([OGKevin](https://github.com/OGKevin)) -- Optimise test framework auto topup bunq/sdk\_python\#78 [\#81](https://github.com/bunq/sdk_python/pull/81) ([OGKevin](https://github.com/OGKevin)) -- Move to new sandbox bunq/sdk\_python\#98 [\#99](https://github.com/bunq/sdk_python/pull/99) ([OGKevin](https://github.com/OGKevin)) ## [0.13.0](https://github.com/bunq/sdk_python/tree/0.13.0) (2018-03-20) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.12.4...0.13.0) **Implemented enhancements:** @@ -89,6 +229,7 @@ - Bunq update 7 [\#76](https://github.com/bunq/sdk_python/pull/76) ([OGKevin](https://github.com/OGKevin)) ## [0.12.4](https://github.com/bunq/sdk_python/tree/0.12.4) (2017-12-21) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.12.3...0.12.4) **Implemented enhancements:** @@ -111,6 +252,7 @@ - Renamed camelCase methods. \(bunq/sdk\_python\#45\) [\#48](https://github.com/bunq/sdk_python/pull/48) ([OGKevin](https://github.com/OGKevin)) ## [0.12.3](https://github.com/bunq/sdk_python/tree/0.12.3) (2017-11-15) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.12.2...0.12.3) **Implemented enhancements:** @@ -123,6 +265,7 @@ - ScheduledPayment causes decode error due to Typo [\#44](https://github.com/bunq/sdk_python/issues/44) ## [0.12.2](https://github.com/bunq/sdk_python/tree/0.12.2) (2017-11-08) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.12.0...0.12.2) **Implemented enhancements:** @@ -143,6 +286,7 @@ - Feature/add missing cvc fields \#37 [\#38](https://github.com/bunq/sdk_python/pull/38) ([OGKevin](https://github.com/OGKevin)) ## [0.12.0](https://github.com/bunq/sdk_python/tree/0.12.0) (2017-10-11) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.11.0...0.12.0) **Implemented enhancements:** @@ -159,6 +303,7 @@ - Feature/exception handler [\#26](https://github.com/bunq/sdk_python/pull/26) ([OGKevin](https://github.com/OGKevin)) ## [0.11.0](https://github.com/bunq/sdk_python/tree/0.11.0) (2017-09-06) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.10.0...0.11.0) **Implemented enhancements:** @@ -168,6 +313,7 @@ - Add pagination [\#21](https://github.com/bunq/sdk_python/pull/21) ([dnl-blkv](https://github.com/dnl-blkv)) ## [0.10.0](https://github.com/bunq/sdk_python/tree/0.10.0) (2017-08-22) + [Full Changelog](https://github.com/bunq/sdk_python/compare/0.9.1...0.10.0) **Implemented enhancements:** @@ -189,6 +335,9 @@ - Add proxy support \[\#16\] [\#17](https://github.com/bunq/sdk_python/pull/17) ([dnl-blkv](https://github.com/dnl-blkv)) ## [0.9.1](https://github.com/bunq/sdk_python/tree/0.9.1) (2017-08-07) + +[Full Changelog](https://github.com/bunq/sdk_python/compare/4fb168bb3e1ed40b0b8ca00c8156b384debf2e29...0.9.1) + **Implemented enhancements:** - Submit this as package to PyPi [\#2](https://github.com/bunq/sdk_python/issues/2) @@ -202,4 +351,4 @@ -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd6c20e..361577d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,12 @@ ### How to contribute to the bunq Python SDK 😎 #### Want to add a new amazing feature to our SDK? πŸš€ -- First let’s discuss the feature that you would like to add. [Open a new issue](https://github.com/bunq/bunq-Python/issues/new), describe the feature and explain why you think it should be added. +- First let’s discuss the feature that you would like to add. [Open a new issue](https://github.com/bunq/sdk_python/issues/new), describe the feature and explain why you think it should be added. - Once we agree on the new feature, open a new GitHub pull request and include all the relevant information to get your code approved! #### Did you find a bug? πŸ› -- Before opening a new issue check if the bug hasn't already been reported by searching on GitHub under [issues](https://github.com/bunq/bunq-Python/issues). -- If it hasn't already been reported you can [open a new issue](https://github.com/bunq/bunq-Python/issues/new). Make sure you include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behaviour that is not occurring. +- Before opening a new issue check if the bug hasn't already been reported by searching on GitHub under [issues](https://github.com/bunq/sdk_python/issues). +- If it hasn't already been reported you can [open a new issue](https://github.com/bunq/sdk_python/issues/new). Make sure you include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behaviour that is not occurring. - If you wrote a patch that fixes a bug, open a new GitHub pull request and make sure to clearly describe the problem and your awesome solution. #### Do you have questions about the source code? diff --git a/MANIFEST.in b/MANIFEST.in index 0770e06..0e2c875 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include LICENSE include *.md +include VERSION \ No newline at end of file diff --git a/README.md b/README.md index 66bd2ee..cbea0b3 100644 --- a/README.md +++ b/README.md @@ -1,140 +1 @@ -# bunq Python SDK - -## Introduction -Hi developers! - -Welcome to the bunq Python SDK! πŸ‘¨β€πŸ’» - -We're very happy to introduce yet another unique product: complete banking SDKs! -Now you can build even bigger and better apps and integrate them with your bank of the free! 🌈 - -Before you dive into this brand new SDK, please consider: -- Checking out our new developer’s page [https://bunq.com/en/developer](https://bunq.com/en/developer) πŸ™Œ -- Grabbing your production API key from the bunq app or generate a Sandbox API key using [Tinker](https://www.bunq.com/developer) πŸ— -- Visiting [together.bunq.com](https://together.bunq.com) where you can share your creations, -questions and experience 🎀 - -Give us your feedback, create pull requests, build your very own bunq apps and most importantly: -have fun! πŸ’ͺ - -This SDK is in **beta**. We cannot guarantee constant availability or stability. -Thanks to your feedback we will make improvements on it. - -## Installation -``pip install bunq_sdk --upgrade`` - -## Usage - -### Creating an API context -In order to start making calls with the bunq API, you must first register your API key and device, -and create a session. In the SDKs, we group these actions and call it "creating an API context". The -context can be created by using the following code snippet: - -``` -apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY, - DEVICE_DESCRIPTION); -apiContext.save(API_CONTEXT_FILE_PATH) -context.BunqContext.loadApiContext(apiContext) -``` - -This code snippet, except for `context.BunqContext.loadApiContext(apiContext)` should be called once per API key. - -#### Example - -See [`tinker/setup_context`](https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L44-L59) - -#### Safety considerations -The file storing the context details (i.e. `bunq.conf`) is a key to your account. Anyone having -access to it is able to perform any Public API actions with your account. Therefore, we recommend -choosing a truly safe place to store it. - -### Making API calls -There is a class for each endpoint. Each class has functions for each supported action. These -actions can be `create`, `get`, `update`, `delete` and `list`. - -Sometimes API calls have dependencies, for instance `MonetaryAccount`. Making changes to a monetary -account always also needs a reference to a `User`. These dependencies are required as arguments when -performing API calls. Take a look at [doc.bunq.com](https://doc.bunq.com) for the full -documentation. - -#### Creating objects -Creating objects through the API requires an `ApiContext`, a `requestMap` and identifiers of all -dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers -can be passed to requests. - - -``` -payment_id = endpoint.Payment.create( - amount=Amount(amount_string, self._CURRENCY_EURL), - counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient), - description=description - ) -``` - -##### Example -See [`tinker/make_payment`](https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L140-L151) - -#### Reading objects -Reading objects through the API requires an `ApiContext`, identifiers of all dependencies (such as -User ID required for accessing a Monetary Account), and the identifier of the object to read (ID or -UUID) Optionally, custom headers can be passed to requests. - -This type of calls always returns a model. - -``` -monetary_account = generated.MonetaryAccountBank.get( - _MONETARY_ACCOUNT_ITEM_ID -) -``` - -##### Example -See [`tinker/list_all_payment`](https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L85-L103) - -#### Updating objects -Updating objects through the API goes the same way as creating objects, except that also the object to update identifier -(ID or UUID) is needed. - -``` -endpoint.Card.update( - card_id=int(card_id), - monetary_account_current_id=int(account_id) - ) -``` - -##### Example -See [`tinker/update_card`](https://github.com/bunq/tinker_python/blob/2182b8be276fda921657ad22cfe0b8b48a585ccf/tinker/libs/bunq_lib.py#L167-L174) - -#### Deleting objects -Deleting objects through the API requires an `ApiContext`, identifiers of all dependencies (such as User ID required for -accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be -passed to requests. - -``` -Session.delete(self._SESSION_ID) -``` - -##### Example - - -#### Listing objects -Listing objects through the API requires an `ApiContext` and identifiers of all dependencies (such as User ID required -for accessing a Monetary Account). Optionally, custom headers can be passed to requests. - -``` -users = generated.User.list(api_context) -``` - -##### Example -See [`UserListExample.py`](./examples/user_list_example.py) - -## Running Samples -To get an indication on how the SDK works you can use the python tinker which is located at https://github.com/bunq/tinker_python - -## Running Tests - -Information regarding the test cases can be found in the [README.md](./tests/README.md) -located in [test](/tests) - -## Exceptions -The SDK can raise multiple exceptions. For an overview of these exceptions please -take a look at [EXCEPTIONS.md](./EXCEPTIONS.md) +πŸ“š For full documentation about this sdk, visit [doc.bunq.com](https://doc.bunq.com/getting-started/tools/software-development-kits-sdks/python/usage). diff --git a/VERSION b/VERSION index 1cc5f65..2e77e5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.27.17.56 diff --git a/assets/attachment.jpg b/assets/attachment.jpg deleted file mode 100644 index 8396e33..0000000 Binary files a/assets/attachment.jpg and /dev/null differ diff --git a/bunq/__init__.py b/bunq/__init__.py index b938bc0..962e233 100644 --- a/bunq/__init__.py +++ b/bunq/__init__.py @@ -1,53 +1,53 @@ -from bunq.sdk.json import converter +from typing import Type +from bunq.sdk.context.api_environment_type import ApiEnvironmentType +from bunq.sdk.context.installation_context import InstallationContext +from bunq.sdk.http.pagination import Pagination +from bunq.sdk.json import converter +from bunq.sdk.model.core.anchor_object_interface import AnchorObjectInterface +from bunq.sdk.model.generated.object_ import GeolocationObject, ShareDetailObject, MonetaryAccountReference +from bunq.sdk.util.type_alias import T -def initialize_converter(): - """ - :rtype: None - """ +def initialize_converter() -> None: import datetime import inspect - from bunq.sdk import client - from bunq.sdk import context - from bunq.sdk.model import core - from bunq.sdk.json import adapters + from bunq.sdk.http import api_client + from bunq.sdk.context import api_context from bunq.sdk.json import converter from bunq.sdk.model.generated import object_ from bunq.sdk.model.generated import endpoint + from bunq.sdk.model.core.installation import Installation + from bunq.sdk.model.core.session_server import SessionServer + from bunq.sdk.json.installation_adapter import InstallationAdapter + from bunq.sdk.json.session_server_adapter import SessionServerAdapter + from bunq.sdk.json.installation_context_adapter import InstallationContextAdapter + from bunq.sdk.json.api_environment_type_adapter import ApiEnvironmentTypeAdapter + from bunq.sdk.json.float_adapter import FloatAdapter + from bunq.sdk.json.geolocation_adapter import GeolocationAdapter + from bunq.sdk.json.monetary_account_reference_adapter import MonetaryAccountReferenceAdapter + from bunq.sdk.json.share_detail_adapter import ShareDetailAdapter + from bunq.sdk.json.date_time_adapter import DateTimeAdapter + from bunq.sdk.json.pagination_adapter import PaginationAdapter + from bunq.sdk.json.anchor_object_adapter import AnchorObjectAdapter - converter.register_adapter(core.Installation, adapters.InstallationAdapter) - converter.register_adapter( - core.SessionServer, - adapters.SessionServerAdapter - ) - converter.register_adapter( - context.InstallationContext, - adapters.InstallationContextAdapter - ) - converter.register_adapter( - context.ApiEnvironmentType, - adapters.ApiEnvironmentTypeAdapter - ) - converter.register_adapter(float, adapters.FloatAdapter) - converter.register_adapter(object_.Geolocation, adapters.GeolocationAdapter) - converter.register_adapter( - object_.MonetaryAccountReference, - adapters.MonetaryAccountReferenceAdapter - ) - converter.register_adapter(object_.ShareDetail, adapters.ShareDetailAdapter) - converter.register_adapter(datetime.datetime, adapters.DateTimeAdapter) - converter.register_adapter(client.Pagination, adapters.PaginationAdapter) + converter.register_adapter(Installation, InstallationAdapter) + converter.register_adapter(SessionServer, SessionServerAdapter) + converter.register_adapter(InstallationContext, InstallationContextAdapter) + converter.register_adapter(ApiEnvironmentType, ApiEnvironmentTypeAdapter) + converter.register_adapter(float, FloatAdapter) + converter.register_adapter(GeolocationObject, GeolocationAdapter) + converter.register_adapter(MonetaryAccountReference, MonetaryAccountReferenceAdapter) + converter.register_adapter(ShareDetailObject, ShareDetailAdapter) + converter.register_adapter(datetime.datetime, DateTimeAdapter) + converter.register_adapter(Pagination, PaginationAdapter) - def register_anchor_adapter(class_to_regsiter): - if issubclass(class_to_regsiter, core.AnchoredObjectInterface): - converter.register_adapter( - class_to_regsiter, - adapters.AnchoredObjectModelAdapter - ) + def register_anchor_adapter(class_to_register: Type[T]) -> None: + if issubclass(class_to_register, AnchorObjectInterface): + converter.register_adapter(class_to_register, AnchorObjectAdapter) - def get_class(class_string_to_get): + def get_class(class_string_to_get: str) -> Type[T]: if hasattr(object_, class_string_to_get): return getattr(object_, class_string_to_get) diff --git a/bunq/sdk/client.py b/bunq/sdk/client.py deleted file mode 100644 index 44dfc36..0000000 --- a/bunq/sdk/client.py +++ /dev/null @@ -1,540 +0,0 @@ -import uuid -from urllib.parse import urlencode - -import requests - -from bunq.sdk import exception -from bunq.sdk import security -from bunq.sdk.exception_factory import ExceptionFactory -from bunq.sdk.json import converter - - -class ApiClient(object): - """ - :type _api_context: bunq.sdk.context.ApiContext - """ - - # Error constants - _ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER = ('The response header' - '"X-Bunq-Client-Response-' - 'Id" or "x-bunq-client-' - 'response-id" could not ' - 'be found.') - - # Endpoints not requiring active session for the request to succeed. - _URL_DEVICE_SERVER = 'device-server' - _URI_INSTALLATION = 'installation' - _URI_SESSION_SERVER = 'session-server' - _URIS_NOT_REQUIRING_ACTIVE_SESSION = [ - _URI_INSTALLATION, - _URI_SESSION_SERVER, - _URL_DEVICE_SERVER, - ] - - # HTTPS type of proxy, the only used at bunq - _FIELD_PROXY_HTTPS = 'https' - - # Header constants - HEADER_ATTACHMENT_DESCRIPTION = 'X-Bunq-Attachment-Description' - HEADER_CONTENT_TYPE = 'Content-Type' - HEADER_CACHE_CONTROL = 'Cache-Control' - HEADER_USER_AGENT = 'User-Agent' - HEADER_LANGUAGE = 'X-Bunq-Language' - HEADER_REGION = 'X-Bunq-Region' - HEADER_REQUEST_ID = 'X-Bunq-Client-Request-Id' - HEADER_GEOLOCATION = 'X-Bunq-Geolocation' - HEADER_SIGNATURE = 'X-Bunq-Client-Signature' - HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication' - HEADER_RESPONSE_ID_UPPER_CASED = 'X-Bunq-Client-Response-Id' - HEADER_RESPONSE_ID_LOWER_CASED = 'x-bunq-client-response-id' - - # Default header values - _USER_AGENT_BUNQ = 'bunq-sdk-python/1.1.0' - _GEOLOCATION_ZERO = '0 0 0 0 NL' - _LANGUAGE_EN_US = 'en_US' - _REGION_NL_NL = 'nl_NL' - _CACHE_CONTROL_NONE = 'no-cache' - - # Request method names - _METHOD_POST = 'POST' - _METHOD_PUT = 'PUT' - _METHOD_GET = 'GET' - _METHOD_DELETE = 'DELETE' - - # Delimiter between path and params in URL - _DELIMITER_URL_QUERY = '?' - - # Status code for successful execution - _STATUS_CODE_OK = 200 - - # Fields for fetching errors - _FIELD_ERROR = 'Error' - _FIELD_ERROR_DESCRIPTION = 'error_description' - - # Empty string - _STRING_EMPTY = '' - - # Empty bytes - _BYTES_EMPTY = b'' - - def __init__(self, api_context): - self._api_context = api_context - - def post(self, uri_relative, request_bytes, custom_headers): - """ - :type uri_relative: str - :type request_bytes: bytes - :type custom_headers: dict[str, str] - - :return: BunqResponseRaw - """ - - return self._request( - self._METHOD_POST, - uri_relative, - request_bytes, - {}, - custom_headers - ) - - def _request(self, method, uri_relative, request_bytes, params, - custom_headers): - """ - :type method: str - :type uri_relative: str - :type request_bytes: bytes - :type params: dict[str, str] - :type custom_headers: dict[str, str] - - :return: BunqResponseRaw - """ - - uri_relative_with_params = self._append_params_to_uri(uri_relative, - params) - if uri_relative not in self._URIS_NOT_REQUIRING_ACTIVE_SESSION: - if self._api_context.ensure_session_active(): - from bunq.sdk.context import BunqContext - - BunqContext.update_api_context(self._api_context) - - all_headers = self._get_all_headers( - method, - uri_relative_with_params, - request_bytes, - custom_headers - ) - - response = requests.request( - method, - self._get_uri_full(uri_relative_with_params), - data=request_bytes, - headers=all_headers, - proxies={self._FIELD_PROXY_HTTPS: self._api_context.proxy_url}, - ) - - self._assert_response_success(response) - - if self._api_context.installation_context is not None: - security.validate_response( - self._api_context.installation_context.public_key_server, - response.status_code, - response.content, - response.headers - ) - - return self._create_bunq_response_raw(response) - - @classmethod - def _append_params_to_uri(cls, uri, params): - """ - :type uri: str - :type params: dict[str, str] - - :rtype: str - """ - - if params: - return uri + cls._DELIMITER_URL_QUERY + urlencode(params) - - return uri - - def _get_all_headers(self, method, endpoint, request_bytes, custom_headers): - """ - :type method: str - :type endpoint: str - :type request_bytes: bytes - :type custom_headers: dict[str, str] - - :rtype: dict[str, str] - """ - - headers = self._get_default_headers() - headers.update(custom_headers) - - if self._api_context.token is not None: - headers[self.HEADER_AUTHENTICATION] = self._api_context.token - headers[self.HEADER_SIGNATURE] = security.sign_request( - self._api_context.installation_context.private_key_client, - method, - endpoint, - request_bytes, - headers - ) - - return headers - - @classmethod - def _get_default_headers(cls): - """ - :rtype: dict[str, str] - """ - - return { - cls.HEADER_USER_AGENT: cls._USER_AGENT_BUNQ, - cls.HEADER_REQUEST_ID: cls._generate_random_request_id(), - cls.HEADER_GEOLOCATION: cls._GEOLOCATION_ZERO, - cls.HEADER_LANGUAGE: cls._LANGUAGE_EN_US, - cls.HEADER_REGION: cls._REGION_NL_NL, - cls.HEADER_CACHE_CONTROL: cls._CACHE_CONTROL_NONE, - } - - @staticmethod - def _generate_random_request_id(): - """ - :rtype: str - """ - - return str(uuid.uuid4()) - - def _get_uri_full(self, uri_relative): - """ - :type uri_relative: str - - :rtype: str - """ - - return self._api_context.environment_type.uri_base + uri_relative - - def _assert_response_success(self, response): - """ - :type response: requests.Response - - :rtype: None - :raise ApiException: When the response is not successful. - """ - - if response.status_code != self._STATUS_CODE_OK: - raise ExceptionFactory.create_exception_for_response( - response.status_code, - self._fetch_all_error_message(response), - self._fetch_response_id(response) - ) - - @classmethod - def _create_bunq_response_raw(cls, response): - """ - :type response: requests.Response - - :rtype: BunqResponseRaw - """ - - return BunqResponseRaw(response.content, response.headers) - - def _fetch_all_error_message(self, response): - """ - :type response: requests.Response - - :rtype: list[str] - """ - - response_content_string = response.content.decode() - - try: - error_dict = converter.json_to_class(dict, response_content_string) - - return self._fetch_error_descriptions(error_dict) - except ValueError: - return [response_content_string] - - def _fetch_error_descriptions(self, error_dict): - """ - :type error_dict: dict[str, list[dict[str, str]] - - :rtype: list[str] - """ - - error_descriptions = [] - - for error in error_dict[self._FIELD_ERROR]: - description = error[self._FIELD_ERROR_DESCRIPTION] - error_descriptions.append(description) - - return error_descriptions - - def _fetch_response_id(self, response): - """ - :type response: requests.Response - - :rtype: str - """ - - headers = response.headers - - if self.HEADER_RESPONSE_ID_UPPER_CASED in headers: - return headers[self.HEADER_RESPONSE_ID_UPPER_CASED] - - if self.HEADER_RESPONSE_ID_LOWER_CASED in headers: - return headers[self.HEADER_RESPONSE_ID_LOWER_CASED] - - return self._ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER; - - def put(self, uri_relative, request_bytes, custom_headers): - """ - :type uri_relative: str - :type request_bytes: bytes - :type custom_headers: dict[str, str] - - :rtype: BunqResponseRaw - """ - - return self._request( - self._METHOD_PUT, - uri_relative, - request_bytes, - {}, - custom_headers - ) - - def get(self, uri_relative, params, custom_headers): - """ - :type uri_relative: str - :type params: dict[str, str] - :type custom_headers: dict[str, str] - - :rtype: BunqResponseRaw - """ - - return self._request( - self._METHOD_GET, - uri_relative, - self._BYTES_EMPTY, - params, - custom_headers - ) - - def delete(self, uri_relative, custom_headers): - """ - :type uri_relative: str - :type custom_headers: dict[str, str] - - :rtype: BunqResponseRaw - """ - - return self._request( - self._METHOD_DELETE, - uri_relative, - self._BYTES_EMPTY, - {}, - custom_headers - ) - - -class BunqResponseRaw(object): - """ - :type _body_bytes: bytes - :type _headers: dict[str, str] - """ - - def __init__(self, body_bytes, headers): - """ - :type body_bytes: bytes - :type headers: dict[str, str] - """ - - self._body_bytes = body_bytes - self._headers = headers - - @property - def body_bytes(self): - """ - :rtype: bytes - """ - - return self._body_bytes - - @property - def headers(self): - """ - :rtype: dict[str, str] - """ - - return self._headers - - -class BunqResponse(object): - """ - :type _value: T - :type _headers: dict[str, str] - :type _pagination: Pagination|None - """ - - def __init__(self, value, headers, pagination=None): - """ - :type value: T - :type headers: dict[str, str] - :type pagination Pagination|None - """ - - self._value = value - self._headers = headers - self._pagination = pagination - - @property - def value(self): - """ - :rtype: T - """ - - return self._value - - @property - def headers(self): - """ - :rtype: dict[str, str] - """ - - return self._headers - - @property - def pagination(self): - """ - :rtype: Pagination - """ - - return self._pagination - - @classmethod - def cast_from_bunq_response(cls, bunq_response): - """ - :type bunq_response: BunqResponse - """ - - return cls( - bunq_response.value, - bunq_response.headers, - bunq_response.pagination - ) - - -class Pagination(object): - """ - :type older_id: int|None - :type newer_id: int|None - :type future_id: int|None - :type count: int|None - """ - - # Error constants - _ERROR_NO_PREVIOUS_PAGE = 'Could not generate previous page URL params: ' \ - 'there is no previous page.' - _ERROR_NO_NEXT_PAGE = 'Could not generate next page URL params: ' \ - 'there is no next page.' - - # URL Param constants - PARAM_OLDER_ID = 'older_id' - PARAM_NEWER_ID = 'newer_id' - PARAM_COUNT = 'count' - - def __init__(self): - self.older_id = None - self.newer_id = None - self.future_id = None - self.count = None - - @property - def url_params_previous_page(self): - """ - :rtype: dict[str, str] - """ - - self.assert_has_previous_page() - - params = {self.PARAM_OLDER_ID: str(self.older_id)} - self._add_count_to_params_if_needed(params) - - return params - - def assert_has_previous_page(self): - """ - :raise: exception.BunqException - """ - - if not self.has_previous_page(): - raise exception.BunqException(self._ERROR_NO_PREVIOUS_PAGE) - - def has_previous_page(self): - """ - :rtype: bool - """ - - return self.older_id is not None - - @property - def url_params_count_only(self): - """ - :rtype: dict[str, str] - """ - - params = {} - self._add_count_to_params_if_needed(params) - - return params - - def _add_count_to_params_if_needed(self, params): - """ - :type params: dict[str, str] - - :rtype: None - """ - - if self.count is not None: - params[self.PARAM_COUNT] = str(self.count) - - def has_next_page_assured(self): - """ - :rtype: bool - """ - - return self.newer_id is not None - - @property - def url_params_next_page(self): - """ - :rtype: dict[str, str] - """ - - self.assert_has_next_page() - - params = {self.PARAM_NEWER_ID: str(self._next_id)} - self._add_count_to_params_if_needed(params) - - return params - - def assert_has_next_page(self): - """ - :raise: exception.BunqException - """ - - if self._next_id is None: - raise exception.BunqException(self._ERROR_NO_NEXT_PAGE) - - @property - def _next_id(self): - """ - :rtype: int - """ - - if self.has_next_page_assured(): - return self.newer_id - - return self.future_id diff --git a/bunq/sdk/context.py b/bunq/sdk/context.py deleted file mode 100644 index ee11399..0000000 --- a/bunq/sdk/context.py +++ /dev/null @@ -1,615 +0,0 @@ -import datetime - -import aenum -from Cryptodome.PublicKey import RSA - -from bunq.sdk import security -from bunq.sdk.exception import BunqException -from bunq.sdk.json import converter -from bunq.sdk.model import core -from bunq.sdk.model.generated import endpoint - - -class ApiEnvironmentType(aenum.AutoNumberEnum): - """ - :type PRODUCTION: ApiEnvironmentType - :type SANDBOX: ApiEnvironmentType - :type uri_base: str - """ - - PRODUCTION = 'https://api.bunq.com/v1/' - SANDBOX = 'https://public-api.sandbox.bunq.com/v1/' - - def __init__(self, uri_base): - """ - :type uri_base: str - """ - - self._uri_base = uri_base - - @property - def uri_base(self): - """ - :rtype: str - """ - - return self._uri_base - - -class ApiContext(object): - """ - :type _environment_type: ApiEnvironmentType - :type _api_key: str - :type _session_context: SessionContext - :type _installation_context: InstallationContext - :type _proxy_url: str|None - """ - - # File mode for saving and restoring the context - _FILE_MODE_WRITE = 'w' - _FILE_MODE_READ = 'r' - - # Minimum time to session expiry not requiring session reset - _TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS = 30 - - # Dummy ID to pass to Session endpoint - _SESSION_ID_DUMMY = 0 - - # Default path to the file storing serialized API context - _PATH_API_CONTEXT_DEFAULT = 'bunq.conf' - - def __init__(self, environment_type, api_key, device_description, - permitted_ips=None, proxy_url=None): - """ - :type environment_type: ApiEnvironmentType - :type api_key: str - :type device_description: str - :type permitted_ips: list[str]|None - :type proxy_url: str|None - """ - - if permitted_ips is None: - permitted_ips = [] - - self._environment_type = environment_type - self._api_key = api_key - self._installation_context = None - self._session_context = None - self._proxy_url = proxy_url - self._initialize(device_description, permitted_ips) - - def _initialize(self, device_description, permitted_ips): - """ - :type device_description: str - :type permitted_ips: list[str] - - :rtype: None - """ - - self._initialize_installation() - self._register_device(device_description, permitted_ips) - self._initialize_session() - - def _initialize_installation(self): - """ - :rtype: None - """ - - private_key_client = security.generate_rsa_private_key() - installation = core.Installation.create( - self, - security.public_key_to_string(private_key_client.publickey()) - ).value - token = installation.token.token - public_key_server_string = \ - installation.server_public_key.server_public_key - public_key_server = RSA.import_key(public_key_server_string) - - self._installation_context = InstallationContext( - token, - private_key_client, - public_key_server - ) - - def _register_device(self, device_description, - permitted_ips): - """ - :type device_description: str - :type permitted_ips: list[] - - :rtype: None - """ - - from bunq.sdk.model.device_server_internal import DeviceServerInternal - - DeviceServerInternal.create( - device_description, - self.api_key, - permitted_ips, - api_context=self - ) - - def _initialize_session(self): - """ - :rtype: None - """ - - session_server = core.SessionServer.create(self).value - token = session_server.token.token - expiry_time = self._get_expiry_timestamp(session_server) - user_id = session_server.get_referenced_user().id_ - - self._session_context = SessionContext(token, expiry_time, user_id) - - @classmethod - def _get_expiry_timestamp(cls, session_server): - """ - :type session_server: core.SessionServer - - :rtype: datetime.datetime - """ - - timeout_seconds = cls._get_session_timeout_seconds(session_server) - time_now = datetime.datetime.now() - - return time_now + datetime.timedelta(seconds=timeout_seconds) - - @classmethod - def _get_session_timeout_seconds(cls, session_server): - """ - :type session_server: core.SessionServer - - :rtype: int - """ - - if session_server.user_company is not None: - return session_server.user_company.session_timeout - elif session_server.user_person is not None: - return session_server.user_person.session_timeout - elif session_server.user_api_key is not None: - return session_server \ - .user_api_key \ - .requested_by_user \ - .get_referenced_object() \ - .session_timeout - else: - raise BunqException() - - def ensure_session_active(self) -> bool: - """ - Resets the session if it has expired. - - :rtype: bool - """ - - if not self.is_session_active(): - self.reset_session() - - return True - - return False - - def is_session_active(self): - """ - :rtype: bool - """ - - if self.session_context is None: - return False - - time_now = datetime.datetime.now() - time_to_expiry = self.session_context.expiry_time - time_now - time_to_expiry_minimum = datetime.timedelta( - seconds=self._TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS - ) - - return time_to_expiry > time_to_expiry_minimum - - def reset_session(self): - """ - Closes the current session and opens a new one. - - :rtype: None - """ - - self._drop_session_context() - self._initialize_session() - - def _drop_session_context(self): - """ - :rtype: None - """ - - self._session_context = None - - def close_session(self): - """ - Closes the current session. - - :rtype: None - """ - - self._delete_session() - self._drop_session_context() - - def _delete_session(self): - """ - :rtype: None - """ - - endpoint.Session.delete(self._SESSION_ID_DUMMY) - - @property - def environment_type(self): - """ - :rtype: ApiEnvironmentType - """ - - return self._environment_type - - @property - def api_key(self): - """ - :rtype: str - """ - - return self._api_key - - @property - def token(self): - """ - :rtype: str - """ - - if self._session_context is not None: - return self.session_context.token - elif self._installation_context is not None: - return self.installation_context.token - else: - return None - - @property - def installation_context(self): - """ - :rtype: InstallationContext - """ - - return self._installation_context - - @property - def session_context(self): - """ - :rtype: SessionContext - """ - - return self._session_context - - @property - def proxy_url(self): - """ - :rtype: str - """ - - return self._proxy_url - - def save(self, path=None): - """ - :type path: str - - :rtype: None - """ - - if path is None: - path = self._PATH_API_CONTEXT_DEFAULT - - with open(path, self._FILE_MODE_WRITE) as file_: - file_.write(self.to_json()) - - def to_json(self): - """ - Serializes an ApiContext to JSON string. - - :rtype: str - """ - - return converter.class_to_json(self) - - @classmethod - def restore(cls, path=None): - """ - :type path: str - - :rtype: ApiContext - """ - - if path is None: - path = cls._PATH_API_CONTEXT_DEFAULT - - with open(path, cls._FILE_MODE_READ) as file_: - return cls.from_json(file_.read()) - - @classmethod - def from_json(cls, json_str): - """ - Creates an ApiContext instance from JSON string. - - :type json_str: str - - :rtype: ApiContext - """ - - return converter.json_to_class(ApiContext, json_str) - - def __eq__(self, other): - return (self.token == other.token and - self.api_key == other.api_key and - self.environment_type == other.environment_type) - - -class InstallationContext(object): - """ - :type _token: str - :type _private_key_client: RSA.RsaKey - :type _public_key_server: RSA.RsaKey - """ - - def __init__(self, token, private_key_client, public_key_server): - """ - :type token: str - :type private_key_client: RSA.RsaKey - :type public_key_server: RSA.RsaKey - """ - - self._token = token - self._private_key_client = private_key_client - self._public_key_server = public_key_server - - @property - def token(self): - """ - :rtype: str - """ - - return self._token - - @property - def private_key_client(self): - """ - :rtype: RSA.RsaKey - """ - - return self._private_key_client - - @property - def public_key_server(self): - """ - :rtype: RSA.RsaKey - """ - - return self._public_key_server - - -class SessionContext(object): - """ - :type _token: str - :type _expiry_time: datetime.datetime - :type _user_id: int - """ - - def __init__(self, token, expiry_time, user_id): - """ - :type token: str - :type expiry_time: datetime.datetime - """ - - self._token = token - self._expiry_time = expiry_time - self._user_id = user_id - - @property - def token(self): - """ - :rtype: str - """ - - return self._token - - @property - def expiry_time(self): - """ - :rtype: datetime.datetime - """ - - return self._expiry_time - - @property - def user_id(self): - return self._user_id - - -class UserContext(object): - _ERROR_UNEXPECTED_USER_INSTANCE = '"{}" is unexpected user instance.' - _ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND = \ - 'No active monetary account found.' - _STATUS_ACTIVE = 'ACTIVE' - - def __init__(self, user_id): - """ - :type user_id: int - """ - - self._user_id = user_id - self._user_person = None - self._user_company = None - self._user_api_key = None - self._primary_monetary_account = None - - self._set_user(self.__get_user_object()) - - @staticmethod - def __get_user_object(): - """ - :rtype: core.BunqModel - """ - - return endpoint.User.list().value[0].get_referenced_object() - - def _set_user(self, user): - if isinstance(user, endpoint.UserPerson): - self._user_person = user - - elif isinstance(user, endpoint.UserCompany): - self._user_company = user - - elif isinstance(user, endpoint.UserApiKey): - self._user_api_key = user - - else: - raise BunqException( - self._ERROR_UNEXPECTED_USER_INSTANCE.format(user.__class__)) - - def init_main_monetary_account(self): - all_monetary_account = endpoint.MonetaryAccountBank.list().value - - for account in all_monetary_account: - if account.status == self._STATUS_ACTIVE: - self._primary_monetary_account = account - - return - - raise BunqException(self._ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND) - - @property - def user_id(self): - return self._user_id - - def is_only_user_person_set(self): - """ - :rtype: bool - """ - - return self._user_person is not None \ - and self._user_company is None \ - and self._user_api_key is None - - def is_only_user_company_set(self): - """ - :rtype: bool - """ - - return self._user_company is not None \ - and self._user_person is None \ - and self._user_api_key is None - - def is_only_user_api_key_set(self): - """ - :rtype: bool - """ - - return self._user_api_key is not None \ - and self._user_company is None \ - and self._user_person is None - - def is_all_user_type_set(self): - """ - :rtype: bool - """ - - return self._user_company is not None \ - and self._user_person is not None \ - and self._user_api_key is not None - - def refresh_user_context(self): - """ - """ - - self._set_user(self.__get_user_object()) - self.init_main_monetary_account() - - @property - def user_company(self): - """ - :rtype: endpoint.UserCompany - """ - - return self._user_company - - @property - def user_person(self): - """ - :rtype: endpoint.UserPerson - """ - - return self._user_person - - @property - def user_api_key(self): - """ - :rtype: endpoint.UserApiKey - """ - - return self._user_api_key - - @property - def primary_monetary_account(self): - """ - :rtype: endpoint.MonetaryAccountBank - """ - - return self._primary_monetary_account - - -class BunqContext(object): - _ERROR_CLASS_SHOULD_NOT_BE_INITIALIZED = \ - 'This class should not be instantiated' - _ERROR_API_CONTEXT_HAS_NOT_BEEN_LOADED = \ - 'ApiContext has not been loaded. Please load ApiContext in BunqContext' - _ERROR_USER_CONTEXT_HAS_NOT_BEEN_LOADED = \ - 'UserContext has not been loaded, please load this' \ - ' by loading ApiContext.' - - _api_context = None - _user_context = None - - def __init__(self): - raise TypeError(self._ERROR_CLASS_SHOULD_NOT_BE_INITIALIZED) - - @classmethod - def load_api_context(cls, api_context): - """ - :type api_context: ApiContext - """ - - cls._api_context = api_context - cls._user_context = UserContext(api_context.session_context.user_id) - cls._user_context.init_main_monetary_account() - - @classmethod - def api_context(cls): - """ - :rtype: ApiContext - """ - - if cls._api_context is not None: - return cls._api_context - - raise BunqException(cls._ERROR_API_CONTEXT_HAS_NOT_BEEN_LOADED) - - @classmethod - def user_context(cls): - """ - :rtype: UserContext - """ - - if cls._user_context is not None: - return cls._user_context - - raise BunqException(cls._ERROR_USER_CONTEXT_HAS_NOT_BEEN_LOADED) - - @classmethod - def update_api_context(cls, api_context: ApiContext): - """ - :type api_context: ApiContext - """ - - cls._api_context = api_context diff --git a/bunq/sdk/context/__init__.py b/bunq/sdk/context/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/context/api_context.py b/bunq/sdk/context/api_context.py new file mode 100644 index 0000000..5477cb6 --- /dev/null +++ b/bunq/sdk/context/api_context.py @@ -0,0 +1,293 @@ +from __future__ import annotations + +import datetime +import typing +from typing import List, Optional + +from Cryptodome.PublicKey import RSA + +from bunq.sdk.context.api_environment_type import ApiEnvironmentType +from bunq.sdk.context.installation_context import InstallationContext +from bunq.sdk.context.session_context import SessionContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.json import converter +from bunq.sdk.model.core.payment_service_provider_credential_internal import PaymentServiceProviderCredentialInternal +from bunq.sdk.model.generated.endpoint import UserCredentialPasswordIpApiObject, SessionApiObject +from bunq.sdk.security import security + +if typing.TYPE_CHECKING: + from bunq.sdk.model.core.session_server import SessionServer + + +class ApiContext: + """ + :type _environment_type: ApiEnvironmentType + :type _api_key: str|None + :type _session_context: SessionContext|None + :type _installation_context: InstallationContext|None + :type _proxy_url: str|None + """ + + # File mode for saving and restoring the context + _FILE_MODE_WRITE = 'w' + _FILE_MODE_READ = 'r' + + # Minimum time to session expiry not requiring session reset + _TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS = 30 + + # Dummy ID to pass to Session endpoint + _SESSION_ID_DUMMY = 0 + + # Default path to the file storing serialized API context + _PATH_API_CONTEXT_DEFAULT = 'bunq.conf' + + def __init__(self, + environment_type: ApiEnvironmentType, + proxy_url: List[str] = None) -> None: + self._environment_type = environment_type + self._proxy_url = proxy_url + self._api_key = None + self._installation_context = None + self._session_context = None + + @classmethod + def create(cls, + environment_type: ApiEnvironmentType, + api_key: str, + description: str, + all_permitted_ip: List[str] = None, + proxy_url: List[str] = None) -> ApiContext: + api_context = cls(environment_type, proxy_url) + + api_context._api_key = api_key + + api_context.__initialize_installation() + api_context.__register_device(description, all_permitted_ip) + api_context.__initialize_session() + + return api_context + + @classmethod + def create_for_psd2(cls, + environment_type: ApiEnvironmentType, + certificate: str, + private_key: str, + all_chain_certificate: List[str], + description: str, + all_permitted_ip: List[str] = None, + proxy_url: List[str] = None) -> ApiContext: + api_context = cls(environment_type, proxy_url) + + api_context.__initialize_installation() + + service_provider_credential = api_context.__initialize_psd2_credential( + certificate, + private_key, + all_chain_certificate + ) + + api_context._api_key = service_provider_credential.token_value + + api_context.__register_device(description, all_permitted_ip) + api_context.__initialize_session() + + return api_context + + def __initialize_installation(self) -> None: + from bunq.sdk.model.core.installation import Installation + + private_key_client = security.generate_rsa_private_key() + + installation = Installation.create( + self, + security.public_key_to_string(private_key_client.publickey()) + ).value + token = installation.token.token + public_key_server_string = installation.server_public_key.server_public_key + public_key_server = RSA.import_key(public_key_server_string) + + self._installation_context = InstallationContext( + token, + private_key_client, + public_key_server + ) + + def __initialize_psd2_credential(self, + certificate: str, + private_key: str, + all_chain_certificate: List[str]) -> UserCredentialPasswordIpApiObject: + session_token = self.installation_context.token + client_key_pair = self.installation_context.private_key_client + + string_to_sign = security.public_key_to_string(client_key_pair.publickey()) + "\n" + session_token + encoded_signature = security.generate_signature(string_to_sign, security.rsa_key_from_string(private_key)) + + payment_response_provider = PaymentServiceProviderCredentialInternal.create_with_api_context( + certificate, + security.get_certificate_chain_string(all_chain_certificate), + encoded_signature, + self + ) + + return payment_response_provider + + def __register_device(self, + device_description: str, + permitted_ips: List[str]) -> None: + from bunq.sdk.model.core.device_server_internal import DeviceServerInternal + + DeviceServerInternal.create( + device_description, + self.api_key, + permitted_ips, + api_context=self + ) + + def __initialize_session(self) -> None: + from bunq.sdk.model.core.session_server import SessionServer + session_server = SessionServer.create(self).value + + token = session_server.token + expiry_time = self._get_expiry_timestamp(session_server) + user = session_server.get_user_reference() + + self._session_context = SessionContext(token, expiry_time, user) + + @classmethod + def _get_expiry_timestamp(cls, session_server: SessionServer) -> datetime.datetime: + timeout_seconds = cls._get_session_timeout_seconds(session_server) + time_now = datetime.datetime.now() + + return time_now + datetime.timedelta(seconds=timeout_seconds) + + @classmethod + def _get_session_timeout_seconds(cls, session_server: SessionServer) -> int: + if session_server.user_company is not None: + return session_server.user_company.session_timeout + elif session_server.user_person is not None: + return session_server.user_person.session_timeout + elif session_server.user_payment_service_provider is not None: + return session_server.user_payment_service_provider.session_timeout + elif session_server.user_api_key is not None: + return session_server \ + .user_api_key \ + .requested_by_user \ + .get_referenced_object() \ + .session_timeout + else: + raise BunqException() + + def ensure_session_active(self) -> bool: + """ + Resets the session if it has expired. + + """ + + if not self.is_session_active(): + self.reset_session() + + return True + + return False + + def is_session_active(self) -> bool: + if self.session_context is None: + return False + + time_now = datetime.datetime.now() + time_to_expiry = self.session_context.expiry_time - time_now + time_to_expiry_minimum = datetime.timedelta( + seconds=self._TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS + ) + + return time_to_expiry > time_to_expiry_minimum + + def reset_session(self) -> None: + """ + Closes the current session and opens a new one. + + """ + + self._drop_session_context() + self.__initialize_session() + + def _drop_session_context(self) -> None: + self._session_context = None + + def close_session(self) -> None: + """ + Closes the current session. + + """ + + self._delete_session() + self._drop_session_context() + + def _delete_session(self) -> None: + Session.delete(self._SESSION_ID_DUMMY) + + @property + def environment_type(self) -> ApiEnvironmentType: + return self._environment_type + + @property + def api_key(self) -> str: + return self._api_key + + @property + def token(self) -> Optional[str]: + if self._session_context is not None: + return self.session_context.token + elif self._installation_context is not None: + return self.installation_context.token + else: + return None + + @property + def installation_context(self) -> InstallationContext: + return self._installation_context + + @property + def session_context(self) -> SessionContext: + return self._session_context + + @property + def proxy_url(self) -> str: + return self._proxy_url + + def save(self, path: str = None) -> None: + if path is None: + path = self._PATH_API_CONTEXT_DEFAULT + + with open(path, self._FILE_MODE_WRITE) as file_: + file_.write(self.to_json()) + + def to_json(self) -> str: + """ + Serializes an ApiContext to JSON string. + + """ + + return converter.class_to_json(self) + + @classmethod + def restore(cls, path: str = None) -> ApiContext: + if path is None: + path = cls._PATH_API_CONTEXT_DEFAULT + + with open(path, cls._FILE_MODE_READ) as file_: + return cls.from_json(file_.read()) + + @classmethod + def from_json(cls, json_str: str) -> ApiContext: + """ + Creates an ApiContext instance from JSON string. + + """ + + return converter.json_to_class(ApiContext, json_str) + + def __eq__(self, other: ApiContext) -> bool: + return (self.token == other.token and + self.api_key == other.api_key and + self.environment_type == other.environment_type) diff --git a/bunq/sdk/context/api_environment_type.py b/bunq/sdk/context/api_environment_type.py new file mode 100644 index 0000000..d713741 --- /dev/null +++ b/bunq/sdk/context/api_environment_type.py @@ -0,0 +1,19 @@ +import aenum + + +class ApiEnvironmentType(aenum.AutoNumberEnum): + """ + :type PRODUCTION: ApiEnvironmentType + :type SANDBOX: ApiEnvironmentType + :type uri_base: str + """ + + PRODUCTION = 'https://api.bunq.com/v1/' + SANDBOX = 'https://public-api.sandbox.bunq.com/v1/' + + def __init__(self, uri_base: str) -> None: + self._uri_base = uri_base + + @property + def uri_base(self) -> str: + return self._uri_base diff --git a/bunq/sdk/context/bunq_context.py b/bunq/sdk/context/bunq_context.py new file mode 100644 index 0000000..76b3af0 --- /dev/null +++ b/bunq/sdk/context/bunq_context.py @@ -0,0 +1,42 @@ +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.context.user_context import UserContext +from bunq.sdk.exception.bunq_exception import BunqException + + +class BunqContext: + _ERROR_CLASS_SHOULD_NOT_BE_INITIALIZED = 'This class should not be instantiated' + _ERROR_API_CONTEXT_HAS_NOT_BEEN_LOADED = 'ApiContext has not been loaded. Please load ApiContext in BunqContext' + _ERROR_USER_CONTEXT_HAS_NOT_BEEN_LOADED = 'UserContext has not been loaded, please load this by loading ApiContext.' + + _api_context = None + _user_context = None + + def __init__(self) -> None: + raise TypeError(self._ERROR_CLASS_SHOULD_NOT_BE_INITIALIZED) + + @classmethod + def load_api_context(cls, api_context: ApiContext) -> None: + cls._api_context = api_context + cls._user_context = UserContext( + api_context.session_context.user_id, + api_context.session_context.get_user_reference() + ) + cls._user_context.init_main_monetary_account() + + @classmethod + def api_context(cls) -> ApiContext: + if cls._api_context is not None: + return cls._api_context + + raise BunqException(cls._ERROR_API_CONTEXT_HAS_NOT_BEEN_LOADED) + + @classmethod + def user_context(cls) -> UserContext: + if cls._user_context is not None: + return cls._user_context + + raise BunqException(cls._ERROR_USER_CONTEXT_HAS_NOT_BEEN_LOADED) + + @classmethod + def update_api_context(cls, api_context: ApiContext) -> None: + cls._api_context = api_context diff --git a/bunq/sdk/context/installation_context.py b/bunq/sdk/context/installation_context.py new file mode 100644 index 0000000..8c11e79 --- /dev/null +++ b/bunq/sdk/context/installation_context.py @@ -0,0 +1,30 @@ +from Cryptodome.PublicKey import RSA +from Cryptodome.PublicKey.RSA import RsaKey + + +class InstallationContext: + """ + :type _token: str + :type _private_key_client: RSA.RsaKey + :type _public_key_server: RSA.RsaKey + """ + + def __init__(self, + token: str, + private_key_client: RsaKey, + public_key_server: RsaKey) -> None: + self._token = token + self._private_key_client = private_key_client + self._public_key_server = public_key_server + + @property + def token(self) -> str: + return self._token + + @property + def private_key_client(self) -> RsaKey: + return self._private_key_client + + @property + def public_key_server(self) -> RsaKey: + return self._public_key_server diff --git a/bunq/sdk/context/session_context.py b/bunq/sdk/context/session_context.py new file mode 100644 index 0000000..1ca3024 --- /dev/null +++ b/bunq/sdk/context/session_context.py @@ -0,0 +1,102 @@ +from __future__ import annotations + +import datetime +from typing import Optional + +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.core.session_token import SessionToken +from bunq.sdk.model.generated.endpoint import UserPersonApiObject, UserCompanyApiObject, UserApiKeyApiObject, UserPaymentServiceProviderApiObject + + +class SessionContext: + """ + :type _token: str + :type _expiry_time: datetime.datetime + :type _user_id: int + :type _user_person: UserPersonApiObject|None + :type _user_company: UserCompanyApiObject|None + :type _user_api_key: UserApiKeyApiObject|None + :type _user_payment_service_provider: UserPaymentServiceProviderApiObject|None + """ + + # Error constants + _ERROR_ALL_FIELD_IS_NULL = 'All fields are null' + _ERROR_UNEXPECTED_USER_INSTANCE = '"{}" is unexpected user instance.' + + @property + def token(self) -> str: + return self._token + + @property + def expiry_time(self) -> datetime.datetime: + return self._expiry_time + + @property + def user_id(self) -> int: + return self._user_id + + @property + def user_person(self) -> Optional[UserPersonApiObject]: + return self._user_person + + @property + def user_company(self) -> Optional[UserCompanyApiObject]: + return self._user_company + + @property + def user_api_key(self) -> Optional[UserApiKeyApiObject]: + return self._user_api_key + + @property + def user_payment_service_provider(self) -> Optional[UserPaymentServiceProviderApiObject]: + return self._user_payment_service_provider + + def __init__(self, token: SessionToken, expiry_time: datetime.datetime, user: BunqModel) -> None: + self._user_person = None + self._user_company = None + self._user_api_key = None + self._user_payment_service_provider = None + self._token = token.token + self._expiry_time = expiry_time + self._user_id = self.__get_user_id(user) + self.__set_user(user) + + def __get_user_id(self, user: BunqModel) -> int: + if isinstance(user, UserPersonApiObject): + return user.id_ + + if isinstance(user, UserCompanyApiObject): + return user.id_ + + if isinstance(user, UserApiKeyApiObject): + return user.id_ + + if isinstance(user, UserPaymentServiceProviderApiObject): + return user.id_ + + raise BunqException(self._ERROR_UNEXPECTED_USER_INSTANCE) + + def __set_user(self, user: BunqModel): + if isinstance(user, UserPersonApiObject): + self._user_person = user + elif isinstance(user, UserCompanyApiObject): + self._user_company = user + elif isinstance(user, UserApiKeyApiObject): + self._user_api_key = user + elif isinstance(user, UserPaymentServiceProviderApiObject): + self._user_payment_service_provider = user + else: + raise BunqException(self._ERROR_UNEXPECTED_USER_INSTANCE) + + def get_user_reference(self) -> BunqModel: + if self.user_person is not None: + return self.user_person + elif self.user_company is not None: + return self.user_company + elif self.user_api_key is not None: + return self.user_api_key + elif self.user_payment_service_provider is not None: + return self.user_payment_service_provider + else: + raise BunqException(self._ERROR_ALL_FIELD_IS_NULL) diff --git a/bunq/sdk/context/user_context.py b/bunq/sdk/context/user_context.py new file mode 100644 index 0000000..2b8cb06 --- /dev/null +++ b/bunq/sdk/context/user_context.py @@ -0,0 +1,103 @@ +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.generated.endpoint import UserPersonApiObject, UserCompanyApiObject, UserApiKeyApiObject, MonetaryAccountBankApiObject, UserApiObject, \ + UserPaymentServiceProviderApiObject + + +class UserContext: + _ERROR_UNEXPECTED_USER_INSTANCE = '"{}" is unexpected user instance.' + _ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND = 'No active monetary account found.' + _STATUS_ACTIVE = 'ACTIVE' + + def __init__(self, user_id: int, user: BunqModel) -> None: + self._user_id = user_id + self._user_person = None + self._user_company = None + self._user_api_key = None + self._user_payment_service_provider = None + self._primary_monetary_account = None + + self._set_user(user) + + @staticmethod + def __get_user_object() -> BunqModel: + return UserApiObject.list().value[0].get_referenced_object() + + def _set_user(self, user: BunqModel) -> None: + if isinstance(user, UserPersonApiObject): + self._user_person = user + + elif isinstance(user, UserCompanyApiObject): + self._user_company = user + + elif isinstance(user, UserApiKeyApiObject): + self._user_api_key = user + + elif isinstance(user, UserPaymentServiceProviderApiObject): + self._user_payment_service_provider = user + + else: + raise BunqException( + self._ERROR_UNEXPECTED_USER_INSTANCE.format(user.__class__)) + + def init_main_monetary_account(self) -> None: + if self._user_payment_service_provider is not None: + return + + all_monetary_account = MonetaryAccountBankApiObject.list().value + + for account in all_monetary_account: + if account.status == self._STATUS_ACTIVE: + self._primary_monetary_account = account + + return + + raise BunqException(self._ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND) + + @property + def user_id(self) -> int: + return self._user_id + + def is_only_user_person_set(self) -> bool: + return self._user_person is not None \ + and self._user_company is None \ + and self._user_api_key is None + + def is_only_user_company_set(self) -> bool: + return self._user_company is not None \ + and self._user_person is None \ + and self._user_api_key is None + + def is_only_user_api_key_set(self) -> bool: + return self._user_api_key is not None \ + and self._user_company is None \ + and self._user_person is None + + def is_all_user_type_set(self) -> bool: + return self._user_company is not None \ + and self._user_person is not None \ + and self._user_api_key is not None + + def refresh_user_context(self) -> None: + self._set_user(self.__get_user_object()) + + if self._user_payment_service_provider is not None: + return + + self.init_main_monetary_account() + + @property + def user_company(self) -> UserCompanyApiObject: + return self._user_company + + @property + def user_person(self) -> UserPersonApiObject: + return self._user_person + + @property + def user_api_key(self) -> UserApiKeyApiObject: + return self._user_api_key + + @property + def primary_monetary_account(self) -> MonetaryAccountBankApiObject: + return self._primary_monetary_account diff --git a/bunq/sdk/exception.py b/bunq/sdk/exception.py deleted file mode 100644 index 3410db1..0000000 --- a/bunq/sdk/exception.py +++ /dev/null @@ -1,74 +0,0 @@ -class ApiException(Exception): - def __init__(self, message, response_code, response_id): - """ - :type response_id: str - :type message: str - :type response_code: int - """ - - self._response_id = response_id - self._message = message - self._response_code = response_code - - super(ApiException, self).__init__(message) - - @property - def message(self): - """ - :rtype: str - """ - - return self._message - - @property - def response_code(self): - """ - :rtype: int - """ - - return self._response_code - - @property - def response_id(self): - """ - :rtype: str - """ - - return self._response_id - - -class BunqException(Exception): - def __init__(self, message): - super(BunqException, self).__init__(message) - - -class UnknownApiErrorException(ApiException): - pass - - -class BadRequestException(ApiException): - pass - - -class UnauthorizedException(ApiException): - pass - - -class ForbiddenException(ApiException): - pass - - -class NotFoundException(ApiException): - pass - - -class MethodNotAllowedException(ApiException): - pass - - -class TooManyRequestsException(ApiException): - pass - - -class PleaseContactBunqException(ApiException): - pass diff --git a/EXCEPTIONS.md b/bunq/sdk/exception/EXCEPTIONS.md similarity index 80% rename from EXCEPTIONS.md rename to bunq/sdk/exception/EXCEPTIONS.md index 14bf72b..e97471d 100644 --- a/EXCEPTIONS.md +++ b/bunq/sdk/exception/EXCEPTIONS.md @@ -1,9 +1,8 @@ ## Exceptions -When you make a request via the SDK, there is a chance of request failing +When you make a request via the SDK, there is a chance of request failing due to various reasons. When such a failure happens, an exception corresponding to the error occurred is raised. - ---- #### Possible Exceptions * `BadRequestException` If the request returns with status code `400` @@ -25,23 +24,17 @@ page here: https://doc.bunq.com/api/1/page/errors All the exceptions have the same base exception which looks like this: ```python class ApiException(Exception): - def __init__(self, message, response_code): + def __init__(self, + message: str, + response_code: int) -> None: pass - - @property - def message(self): - """ - :rtype: str - """ + @property + def message(self) -> str: return self._message @property - def response_code(self): - """ - :rtype: int - """ - + def response_code(self) -> int: return self._response_code ``` This means that each exception will have the response code and the error message @@ -53,15 +46,15 @@ Because we raise different exceptions for each error, you can catch an error if you expect it to be raised. ```python -from bunq.sdk.exception import BadRequestException -from bunq.sdk.context import ApiEnvironmentType, ApiContext +from bunq.sdk.exception.bad_request_exception import BadRequestException +from bunq.sdk.context.api_context import ApiEnvironmentType, ApiContext API_KEY = "Some invalid API key" -DESCRIPTION = "This wil raise a BadRequestException" +DESCRIPTION = "This will raise a BadRequestException" try: # Make a call that might raise an exception - ApiContext(ApiEnvironmentType.SANDBOX, API_KEY, DESCRIPTION) + ApiContext.create(ApiEnvironmentType.SANDBOX, API_KEY, DESCRIPTION) except BadRequestException as error: # Do something if exception is raised print(error.response_code) diff --git a/bunq/sdk/exception/__init__.py b/bunq/sdk/exception/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/exception/api_exception.py b/bunq/sdk/exception/api_exception.py new file mode 100644 index 0000000..815b81f --- /dev/null +++ b/bunq/sdk/exception/api_exception.py @@ -0,0 +1,22 @@ +class ApiException(Exception): + def __init__(self, + message: str, + response_code: int, + response_id: str) -> None: + self._response_id = response_id + self._message = message + self._response_code = response_code + + super(ApiException, self).__init__(message) + + @property + def message(self) -> str: + return self._message + + @property + def response_code(self) -> int: + return self._response_code + + @property + def response_id(self) -> str: + return self._response_id diff --git a/bunq/sdk/exception/bad_request_exception.py b/bunq/sdk/exception/bad_request_exception.py new file mode 100644 index 0000000..7e06b1e --- /dev/null +++ b/bunq/sdk/exception/bad_request_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class BadRequestException(ApiException): + pass diff --git a/bunq/sdk/exception/bunq_exception.py b/bunq/sdk/exception/bunq_exception.py new file mode 100644 index 0000000..0a656cc --- /dev/null +++ b/bunq/sdk/exception/bunq_exception.py @@ -0,0 +1,3 @@ +class BunqException(Exception): + def __init__(self, message: str) -> None: + super(BunqException, self).__init__(message) diff --git a/bunq/sdk/exception_factory.py b/bunq/sdk/exception/exception_factory.py similarity index 68% rename from bunq/sdk/exception_factory.py rename to bunq/sdk/exception/exception_factory.py index f9faafb..0eb3b03 100644 --- a/bunq/sdk/exception_factory.py +++ b/bunq/sdk/exception/exception_factory.py @@ -1,12 +1,14 @@ -from bunq.sdk.exception import BadRequestException -from bunq.sdk.exception import UnauthorizedException -from bunq.sdk.exception import ForbiddenException -from bunq.sdk.exception import NotFoundException -from bunq.sdk.exception import MethodNotAllowedException -from bunq.sdk.exception import TooManyRequestsException -from bunq.sdk.exception import PleaseContactBunqException -from bunq.sdk.exception import UnknownApiErrorException -from bunq.sdk.exception import ApiException +from typing import List + +from bunq.sdk.exception.api_exception import ApiException +from bunq.sdk.exception.bad_request_exception import BadRequestException +from bunq.sdk.exception.forbidden_exception import ForbiddenException +from bunq.sdk.exception.method_not_allowed_exception import MethodNotAllowedException +from bunq.sdk.exception.not_found_exception import NotFoundException +from bunq.sdk.exception.please_contact_bunq_exception import PleaseContactBunqException +from bunq.sdk.exception.too_many_requests_exception import TooManyRequestsException +from bunq.sdk.exception.unauthorized_exception import UnauthorizedException +from bunq.sdk.exception.unknown_api_error_exception import UnknownApiErrorException class ExceptionFactory: @@ -29,17 +31,13 @@ class ExceptionFactory: @classmethod def create_exception_for_response( cls, - response_code, - messages, - response_id - ): + response_code: int, + messages: List[str], + response_id: str + ) -> ApiException: """ - :type response_code: int - :type messages: list[str] - :type response_id: str :return: The exception according to the status code. - :rtype: ApiException """ error_message = cls._generate_message_error( @@ -98,32 +96,16 @@ def create_exception_for_response( ) @classmethod - def _generate_message_error(cls, response_code, messages, response_id): - """ - :type response_code: int - :type messages: list[str] - :type response_id: str - - :rtype: str - """ - - line_response_code = cls._FORMAT_RESPONSE_CODE_LINE \ - .format(response_code) + def _generate_message_error(cls, + response_code: int, + messages: List[str], + response_id: str) -> str: + line_response_code = cls._FORMAT_RESPONSE_CODE_LINE.format(response_code) line_response_id = cls._FORMAT_RESPONSE_ID_LINE.format(response_id) - line_error_message = cls._FORMAT_ERROR_MESSAGE_LINE.format( - cls._GLUE_ERROR_MESSAGE_STRING_EMPTY.join(messages) - ) + line_error_message = cls._FORMAT_ERROR_MESSAGE_LINE.format(cls._GLUE_ERROR_MESSAGE_STRING_EMPTY.join(messages)) - return cls._glue_all_error_message( - [line_response_code, line_response_id, line_error_message] - ) + return cls._glue_all_error_message([line_response_code, line_response_id, line_error_message]) @classmethod - def _glue_all_error_message(cls, messages): - """ - :type messages: list[str] - - :rtype: str - """ - + def _glue_all_error_message(cls, messages: List[str]) -> str: return cls._GLUE_ERROR_MESSAGE_NEW_LINE.join(messages) diff --git a/bunq/sdk/exception/forbidden_exception.py b/bunq/sdk/exception/forbidden_exception.py new file mode 100644 index 0000000..c08be9a --- /dev/null +++ b/bunq/sdk/exception/forbidden_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class ForbiddenException(ApiException): + pass diff --git a/bunq/sdk/exception/method_not_allowed_exception.py b/bunq/sdk/exception/method_not_allowed_exception.py new file mode 100644 index 0000000..46cc3ea --- /dev/null +++ b/bunq/sdk/exception/method_not_allowed_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class MethodNotAllowedException(ApiException): + pass diff --git a/bunq/sdk/exception/not_found_exception.py b/bunq/sdk/exception/not_found_exception.py new file mode 100644 index 0000000..8972866 --- /dev/null +++ b/bunq/sdk/exception/not_found_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class NotFoundException(ApiException): + pass diff --git a/bunq/sdk/exception/please_contact_bunq_exception.py b/bunq/sdk/exception/please_contact_bunq_exception.py new file mode 100644 index 0000000..9617bd0 --- /dev/null +++ b/bunq/sdk/exception/please_contact_bunq_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class PleaseContactBunqException(ApiException): + pass diff --git a/bunq/sdk/exception/too_many_requests_exception.py b/bunq/sdk/exception/too_many_requests_exception.py new file mode 100644 index 0000000..5f1105a --- /dev/null +++ b/bunq/sdk/exception/too_many_requests_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class TooManyRequestsException(ApiException): + pass diff --git a/bunq/sdk/exception/unauthorized_exception.py b/bunq/sdk/exception/unauthorized_exception.py new file mode 100644 index 0000000..5cfe476 --- /dev/null +++ b/bunq/sdk/exception/unauthorized_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class UnauthorizedException(ApiException): + pass diff --git a/bunq/sdk/exception/uncaught_exception_error.py b/bunq/sdk/exception/uncaught_exception_error.py new file mode 100644 index 0000000..897b295 --- /dev/null +++ b/bunq/sdk/exception/uncaught_exception_error.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class UncaughtExceptionError(ApiException): + pass diff --git a/bunq/sdk/exception/unknown_api_error_exception.py b/bunq/sdk/exception/unknown_api_error_exception.py new file mode 100644 index 0000000..a1a8c3f --- /dev/null +++ b/bunq/sdk/exception/unknown_api_error_exception.py @@ -0,0 +1,5 @@ +from bunq.sdk.exception.api_exception import ApiException + + +class UnknownApiErrorException(ApiException): + pass diff --git a/bunq/sdk/http/__init__.py b/bunq/sdk/http/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/http/anonymous_api_client.py b/bunq/sdk/http/anonymous_api_client.py new file mode 100644 index 0000000..32abb5f --- /dev/null +++ b/bunq/sdk/http/anonymous_api_client.py @@ -0,0 +1,64 @@ +from typing import Dict + +import requests + +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response_raw import BunqResponseRaw +from bunq.sdk.security import security + + +class AnonymousApiClient(ApiClient): + + def __init__(self, api_context: ApiContext) -> None: + super().__init__(api_context) + + def post(self, + uri_relative: str, + request_bytes: bytes, + custom_headers: Dict[str, str]) -> BunqResponseRaw: + return self._request( + self.METHOD_POST, + uri_relative, + request_bytes, + {}, + custom_headers + ) + + def _request(self, + method: str, + uri_relative: str, + request_bytes: bytes, + params: Dict[str, str], + custom_headers: Dict[str, str]) -> BunqResponseRaw: + from bunq.sdk.context.bunq_context import BunqContext + + uri_relative_with_params = self._append_params_to_uri(uri_relative, params) + if uri_relative not in self._URIS_NOT_REQUIRING_ACTIVE_SESSION: + if self._api_context.ensure_session_active(): + BunqContext.update_api_context(self._api_context) + + all_headers = self._get_all_headers( + request_bytes, + custom_headers + ) + + response = requests.request( + method, + uri_relative_with_params, + data=request_bytes, + headers=all_headers, + proxies={self.FIELD_PROXY_HTTPS: self._api_context.proxy_url}, + ) + + self._assert_response_success(response) + + if self._api_context.installation_context is not None: + security.validate_response( + self._api_context.installation_context.public_key_server, + response.status_code, + response.content, + response.headers + ) + + return BunqResponseRaw(response.content, response.headers) diff --git a/bunq/sdk/http/api_client.py b/bunq/sdk/http/api_client.py new file mode 100644 index 0000000..234385f --- /dev/null +++ b/bunq/sdk/http/api_client.py @@ -0,0 +1,265 @@ +from __future__ import annotations + +import typing +import uuid +from typing import Dict, List +from urllib.parse import urlencode + +import requests +from requests import Response + +from bunq.sdk.exception.exception_factory import ExceptionFactory +from bunq.sdk.http.bunq_response_raw import BunqResponseRaw +from bunq.sdk.json import converter +from bunq.sdk.security import security + +if typing.TYPE_CHECKING: + from bunq.sdk.context.api_context import ApiContext + + +class ApiClient: + """ + :type _api_context: ApiContext + """ + + # Error constants + _ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER = ('The response header' + '"X-Bunq-Client-Response-' + 'Id" or "x-bunq-client-' + 'response-id" could not ' + 'be found.') + + # Endpoints not requiring active session for the request to succeed. + _URL_DEVICE_SERVER = 'device-server' + _URI_INSTALLATION = 'installation' + _URI_SESSION_SERVER = 'session-server' + _URL_PAYMENT_SERVICE_PROVIDER_CREDENTIAL = 'payment-service-provider-credential' + _URIS_NOT_REQUIRING_ACTIVE_SESSION = [ + _URI_INSTALLATION, + _URI_SESSION_SERVER, + _URL_DEVICE_SERVER, + _URL_PAYMENT_SERVICE_PROVIDER_CREDENTIAL, + ] + + # HTTPS type of proxy, the only used at bunq + FIELD_PROXY_HTTPS = 'https' + + # Header constants + HEADER_ATTACHMENT_DESCRIPTION = 'X-Bunq-Attachment-Description' + HEADER_CONTENT_TYPE = 'Content-Type' + HEADER_CACHE_CONTROL = 'Cache-Control' + HEADER_USER_AGENT = 'User-Agent' + HEADER_LANGUAGE = 'X-Bunq-Language' + HEADER_REGION = 'X-Bunq-Region' + HEADER_REQUEST_ID = 'X-Bunq-Client-Request-Id' + HEADER_GEOLOCATION = 'X-Bunq-Geolocation' + HEADER_SIGNATURE = 'X-Bunq-Client-Signature' + HEADER_AUTHENTICATION = 'X-Bunq-Client-Authentication' + HEADER_RESPONSE_ID_UPPER_CASED = 'X-Bunq-Client-Response-Id' + HEADER_RESPONSE_ID_LOWER_CASED = 'x-bunq-client-response-id' + + # Default header values + USER_AGENT_BUNQ = 'bunq-sdk-python/1.14.18' + GEOLOCATION_ZERO = '0 0 0 0 NL' + LANGUAGE_EN_US = 'en_US' + REGION_NL_NL = 'nl_NL' + CACHE_CONTROL_NONE = 'no-cache' + + # Request method names + METHOD_POST = 'POST' + METHOD_PUT = 'PUT' + METHOD_GET = 'GET' + METHOD_DELETE = 'DELETE' + + # Delimiter between path and params in URL + DELIMITER_URL_QUERY = '?' + + # Status code for successful execution + STATUS_CODE_OK = 200 + + # Fields for fetching errors + FIELD_ERROR = 'Error' + FIELD_ERROR_DESCRIPTION = 'error_description' + + # Empty string + STRING_EMPTY = '' + + # Empty bytes + BYTES_EMPTY = b'' + + def __init__(self, api_context: ApiContext) -> None: + self._api_context = api_context + + def post(self, + uri_relative: str, + request_bytes: bytes, + custom_headers: Dict[str, str]) -> BunqResponseRaw: + return self._request( + self.METHOD_POST, + uri_relative, + request_bytes, + {}, + custom_headers + ) + + def _request(self, + method: str, + uri_relative: str, + request_bytes: bytes, + params: Dict[str, str], + custom_headers: Dict[str, str]) -> BunqResponseRaw: + from bunq.sdk.context.bunq_context import BunqContext + + uri_relative_with_params = self._append_params_to_uri(uri_relative, params) + if uri_relative not in self._URIS_NOT_REQUIRING_ACTIVE_SESSION: + if self._api_context.ensure_session_active(): + BunqContext.update_api_context(self._api_context) + + all_headers = self._get_all_headers( + request_bytes, + custom_headers + ) + + response = requests.request( + method, + self._get_uri_full(uri_relative_with_params), + data=request_bytes, + headers=all_headers, + proxies={self.FIELD_PROXY_HTTPS: self._api_context.proxy_url}, + ) + + self._assert_response_success(response) + + if self._api_context.installation_context is not None: + security.validate_response( + self._api_context.installation_context.public_key_server, + response.status_code, + response.content, + response.headers + ) + + return self._create_bunq_response_raw(response) + + @classmethod + def _append_params_to_uri(cls, + uri: str, + params: Dict[str, str]) -> str: + if params: + return uri + cls.DELIMITER_URL_QUERY + urlencode(params) + + return uri + + def _get_all_headers(self, + request_bytes: bytes, + custom_headers: Dict[str, str]) -> Dict[str, str]: + headers = self._get_default_headers() + headers.update(custom_headers) + + if self._api_context.token is not None: + headers[self.HEADER_AUTHENTICATION] = self._api_context.token + headers[self.HEADER_SIGNATURE] = security.sign_request( + self._api_context.installation_context.private_key_client, + request_bytes + ) + + return headers + + @classmethod + def _get_default_headers(cls) -> Dict[str, str]: + return { + cls.HEADER_USER_AGENT: cls.USER_AGENT_BUNQ, + cls.HEADER_REQUEST_ID: cls._generate_random_request_id(), + cls.HEADER_GEOLOCATION: cls.GEOLOCATION_ZERO, + cls.HEADER_LANGUAGE: cls.LANGUAGE_EN_US, + cls.HEADER_REGION: cls.REGION_NL_NL, + cls.HEADER_CACHE_CONTROL: cls.CACHE_CONTROL_NONE, + } + + @staticmethod + def _generate_random_request_id() -> str: + return str(uuid.uuid4()) + + def _get_uri_full(self, uri_relative: str) -> str: + return self._api_context.environment_type.uri_base + uri_relative + + def _assert_response_success(self, response: Response) -> None: + """ + + :raise ApiException: When the response is not successful. + """ + + if response.status_code != self.STATUS_CODE_OK: + raise ExceptionFactory.create_exception_for_response( + response.status_code, + self._fetch_all_error_message(response), + self._fetch_response_id(response) + ) + + @classmethod + def _create_bunq_response_raw(cls, response: Response) -> BunqResponseRaw: + return BunqResponseRaw(response.content, response.headers) + + def _fetch_all_error_message(self, response: Response) -> List[str]: + response_content_string = response.content.decode() + + try: + error_dict = converter.json_to_class(dict, response_content_string) + + return self._fetch_error_descriptions(error_dict) + except ValueError: + return [response_content_string] + + def _fetch_error_descriptions(self, error_dict: Dict[str, List[Dict[str, str]]]) -> List[str]: + error_descriptions = [] + + for error in error_dict[self.FIELD_ERROR]: + description = error[self.FIELD_ERROR_DESCRIPTION] + error_descriptions.append(description) + + return error_descriptions + + def _fetch_response_id(self, response: Response) -> str: + headers = response.headers + + if self.HEADER_RESPONSE_ID_UPPER_CASED in headers: + return headers[self.HEADER_RESPONSE_ID_UPPER_CASED] + + if self.HEADER_RESPONSE_ID_LOWER_CASED in headers: + return headers[self.HEADER_RESPONSE_ID_LOWER_CASED] + + return self._ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER + + def put(self, + uri_relative: str, + request_bytes: bytes, + custom_headers: Dict) -> BunqResponseRaw: + return self._request( + self.METHOD_PUT, + uri_relative, + request_bytes, + {}, + custom_headers + ) + + def get(self, + uri_relative: str, + params: Dict[str, str], + custom_headers: Dict[str, str]) -> BunqResponseRaw: + return self._request( + self.METHOD_GET, + uri_relative, + self.BYTES_EMPTY, + params, + custom_headers + ) + + def delete(self, + uri_relative: str, + custom_headers: Dict[str, str]) -> BunqResponseRaw: + return self._request( + self.METHOD_DELETE, + uri_relative, + self.BYTES_EMPTY, + {}, + custom_headers + ) diff --git a/bunq/sdk/http/bunq_response.py b/bunq/sdk/http/bunq_response.py new file mode 100644 index 0000000..d0ba1e4 --- /dev/null +++ b/bunq/sdk/http/bunq_response.py @@ -0,0 +1,42 @@ +from __future__ import annotations + +from typing import Dict, Generic + +from bunq import Pagination +from bunq.sdk.util.type_alias import T + + +class BunqResponse(Generic[T]): + """ + :type _value: T + :type _headers: dict[str, str] + :type _pagination: Pagination|None + """ + + def __init__(self, + value: T, + headers: Dict[str, str], + pagination: Pagination = None) -> None: + self._value = value + self._headers = headers + self._pagination = pagination + + @property + def value(self) -> T: + return self._value + + @property + def headers(self) -> Dict[str, str]: + return self._headers + + @property + def pagination(self) -> Pagination: + return self._pagination + + @classmethod + def cast_from_bunq_response(cls, bunq_response: BunqResponse) -> BunqResponse: + return cls( + bunq_response.value, + bunq_response.headers, + bunq_response.pagination + ) diff --git a/bunq/sdk/http/bunq_response_raw.py b/bunq/sdk/http/bunq_response_raw.py new file mode 100644 index 0000000..dd47749 --- /dev/null +++ b/bunq/sdk/http/bunq_response_raw.py @@ -0,0 +1,22 @@ +from typing import Dict + + +class BunqResponseRaw: + """ + :type _body_bytes: bytes + :type _headers: dict[str, str] + """ + + def __init__(self, + body_bytes: bytes, + headers: Dict[str, str]) -> None: + self._body_bytes = body_bytes + self._headers = headers + + @property + def body_bytes(self) -> bytes: + return self._body_bytes + + @property + def headers(self) -> Dict[str, str]: + return self._headers diff --git a/bunq/sdk/http/http_util.py b/bunq/sdk/http/http_util.py new file mode 100644 index 0000000..c2c59e8 --- /dev/null +++ b/bunq/sdk/http/http_util.py @@ -0,0 +1,15 @@ +from typing import Dict + + +class HttpUtil: + QUERY_FORMAT = '{}={}' + QUERY_DELIMITER = '&' + + @classmethod + def create_query_string(cls, all_parameter: Dict[str, str]): + encoded_parameters = [] + + for parameter, value in all_parameter.items(): + encoded_parameters.append(cls.QUERY_FORMAT.format(parameter, value)) + + return cls.QUERY_DELIMITER.join(encoded_parameters) diff --git a/bunq/sdk/http/pagination.py b/bunq/sdk/http/pagination.py new file mode 100644 index 0000000..de930f4 --- /dev/null +++ b/bunq/sdk/http/pagination.py @@ -0,0 +1,87 @@ +from typing import Dict + +from bunq.sdk.exception.bunq_exception import BunqException + + +class Pagination: + """ + :type older_id: int|None + :type newer_id: int|None + :type future_id: int|None + :type count: int|None + """ + + # Error constants + _ERROR_NO_PREVIOUS_PAGE = 'Could not generate previous page URL params: there is no previous page.' + _ERROR_NO_NEXT_PAGE = 'Could not generate next page URL params: there is no next page.' + + # URL Param constants + PARAM_OLDER_ID = 'older_id' + PARAM_NEWER_ID = 'newer_id' + PARAM_COUNT = 'count' + + def __init__(self) -> None: + self.older_id = None + self.newer_id = None + self.future_id = None + self.count = None + + @property + def url_params_previous_page(self) -> Dict[str, str]: + self.assert_has_previous_page() + + params = {self.PARAM_OLDER_ID: str(self.older_id)} + self._add_count_to_params_if_needed(params) + + return params + + def assert_has_previous_page(self) -> None: + """ + + :raise: BunqException + """ + + if not self.has_previous_page(): + raise BunqException(self._ERROR_NO_PREVIOUS_PAGE) + + def has_previous_page(self) -> bool: + return self.older_id is not None + + @property + def url_params_count_only(self) -> Dict[str, str]: + params = {} + self._add_count_to_params_if_needed(params) + + return params + + def _add_count_to_params_if_needed(self, params: Dict[str, str]) -> None: + if self.count is not None: + params[self.PARAM_COUNT] = str(self.count) + + def has_next_page_assured(self) -> bool: + return self.newer_id is not None + + @property + def url_params_next_page(self) -> Dict[str, str]: + self.assert_has_next_page() + + params = {self.PARAM_NEWER_ID: str(self._next_id)} + self._add_count_to_params_if_needed(params) + + return params + + def assert_has_next_page(self) -> None: + """ + + :raise: BunqException + """ + + if self._next_id is None: + raise BunqException(self._ERROR_NO_NEXT_PAGE) + + @property + def _next_id(self) -> int: + if self.has_next_page_assured(): + return self.newer_id + + return self.future_id diff --git a/bunq/sdk/json/adapters.py b/bunq/sdk/json/adapters.py deleted file mode 100644 index f93a3e8..0000000 --- a/bunq/sdk/json/adapters.py +++ /dev/null @@ -1,646 +0,0 @@ -import datetime -import urllib.parse as urlparse - -from bunq.sdk import client -from bunq.sdk import context -from bunq.sdk import security -from bunq.sdk.exception import BunqException -from bunq.sdk.json import converter -from bunq.sdk.model import core -from bunq.sdk.model.generated import endpoint -from bunq.sdk.model.generated import object_ - - -class AnchoredObjectModelAdapter(converter.JsonAdapter): - _ERROR_MODEL_NOT_FOUND = '{} is not in endpoint nor object.' - - __STRING_FORMAT_UNDERSCORE = '_' - - _override_field_map = { - 'ScheduledPayment': 'SchedulePayment', - 'ScheduledInstance': 'ScheduleInstance', - } - - @classmethod - def deserialize(cls, cls_target, obj_raw): - """ - :type cls_target: core.BunqModel - :type obj_raw: int|str|bool|float|list|dict|None - - :rtype: T - """ - - model_ = super()._deserialize_default(cls_target, obj_raw) - - if isinstance( - model_, - core.AnchoredObjectInterface - ) and model_.is_all_field_none(): - for field in model_.__dict__: - object_class = cls._get_object_class(field) - contents = super()._deserialize_default(object_class, obj_raw) - - if contents.is_all_field_none(): - setattr(model_, field, None) - else: - setattr(model_, field, contents) - - return model_ - - @classmethod - def can_serialize(cls): - return False - - @classmethod - def _get_object_class(cls, class_name): - """ - :type class_name: str - :rtype: core.BunqModel - """ - - class_name = class_name.lstrip(cls.__STRING_FORMAT_UNDERSCORE) - - if class_name in cls._override_field_map: - class_name = cls._override_field_map[class_name] - - try: - return getattr(endpoint, class_name) - except AttributeError: - pass - - try: - return getattr(object_, class_name) - except AttributeError: - pass - - raise BunqException(cls._ERROR_MODEL_NOT_FOUND.format(class_name)) - - -class InstallationAdapter(converter.JsonAdapter): - # Id constants - _ATTRIBUTE_ID = '_id_' - _INDEX_ID = 0 - _FIELD_ID = 'Id' - - # Token constants - _ATTRIBUTE_TOKEN = '_token' - _INDEX_TOKEN = 1 - _FIELD_TOKEN = 'Token' - - # Server Public Key constants - _ATTRIBUTE_SERVER_PUBLIC_KEY = '_server_public_key' - _INDEX_SERVER_PUBLIC_KEY = 2 - _FIELD_SERVER_PUBLIC_KEY = 'ServerPublicKey' - - @classmethod - def deserialize(cls, target_class, array): - """ - :type target_class: core.Installation|type - :type array: list - - :rtype: core.Installation - """ - - installation = target_class.__new__(target_class) - server_public_key_wrapped = array[cls._INDEX_SERVER_PUBLIC_KEY] - installation.__dict__ = { - cls._ATTRIBUTE_ID: converter.deserialize( - core.Id, - array[cls._INDEX_ID][cls._FIELD_ID] - ), - cls._ATTRIBUTE_TOKEN: converter.deserialize( - core.SessionToken, - array[cls._INDEX_TOKEN][cls._FIELD_TOKEN] - ), - cls._ATTRIBUTE_SERVER_PUBLIC_KEY: converter.deserialize( - core.PublicKeyServer, - server_public_key_wrapped[cls._FIELD_SERVER_PUBLIC_KEY] - ), - } - - return installation - - @classmethod - def serialize(cls, installation): - """ - :type installation: core.Installation - - :rtype: list - """ - - return [ - {cls._FIELD_ID: converter.serialize(installation.id_)}, - {cls._FIELD_TOKEN: converter.serialize(installation.token)}, - { - cls._FIELD_SERVER_PUBLIC_KEY: converter.serialize( - installation.server_public_key - ), - }, - ] - - -class SessionServerAdapter(converter.JsonAdapter): - # Error constants. - _ERROR_COULD_NOT_DETERMINE_USER = 'Could not determine user.' - - # Id constants - _ATTRIBUTE_ID = '_id_' - _INDEX_ID = 0 - _FIELD_ID = 'Id' - - # Token constants - _ATTRIBUTE_TOKEN = '_token' - _INDEX_TOKEN = 1 - _FIELD_TOKEN = 'Token' - - # User constants - _INDEX_USER = 2 - - # UserCompany constants - _ATTRIBUTE_USER_COMPANY = '_user_company' - _FIELD_USER_COMPANY = 'UserCompany' - - # UserPerson constants - _ATTRIBUTE_USER_PERSON = '_user_person' - _FIELD_USER_PERSON = 'UserPerson' - - # UserApiKey constants - _ATTRIBUTE_USER_API_KEY = '_user_api_key' - _FIELD_USER_API_KEY = 'UserApiKey' - - @classmethod - def deserialize(cls, target_class, array): - """ - :type target_class: core.SessionServer|type - :type array: list - - :rtype: core.SessionServer - """ - - session_server = target_class.__new__(target_class) - session_server.__dict__ = { - cls._ATTRIBUTE_ID: converter.deserialize( - core.Id, - array[cls._INDEX_ID][cls._FIELD_ID] - ), - cls._ATTRIBUTE_TOKEN: converter.deserialize( - core.SessionToken, - array[cls._INDEX_TOKEN][cls._FIELD_TOKEN] - ), - cls._ATTRIBUTE_USER_COMPANY: None, - cls._ATTRIBUTE_USER_PERSON: None, - } - - user_dict_wrapped = array[cls._INDEX_USER] - - if cls._FIELD_USER_COMPANY in user_dict_wrapped: - session_server.__dict__[cls._ATTRIBUTE_USER_COMPANY] = \ - converter.deserialize( - endpoint.UserCompany, - user_dict_wrapped[cls._FIELD_USER_COMPANY] - ) - elif cls._FIELD_USER_PERSON in user_dict_wrapped: - session_server.__dict__[cls._ATTRIBUTE_USER_PERSON] = \ - converter.deserialize( - endpoint.UserPerson, - user_dict_wrapped[cls._FIELD_USER_PERSON] - ) - elif cls._FIELD_USER_API_KEY in user_dict_wrapped: - session_server.__dict__[cls._ATTRIBUTE_USER_API_KEY] = \ - converter.deserialize( - endpoint.UserApiKey, - user_dict_wrapped[cls._FIELD_USER_API_KEY] - ) - else: - raise BunqException(cls._ERROR_COULD_NOT_DETERMINE_USER) - - return session_server - - @classmethod - def serialize(cls, session_server): - """ - :type session_server: core.SessionServer - - :rtype: list - """ - - return [ - {cls._FIELD_ID: converter.serialize(session_server.id_)}, - {cls._FIELD_TOKEN: converter.serialize(session_server.token)}, - { - cls._FIELD_USER_COMPANY: - converter.serialize(session_server.user_company), - }, - { - cls._FIELD_USER_PERSON: - converter.serialize(session_server.user_person), - }, - { - cls._FIELD_USER_API_KEY: - converter.serialize(session_server.user_api_key), - }, - ] - - -class InstallationContextAdapter(converter.JsonAdapter): - # Attribute/Field constants - _ATTRIBUTE_TOKEN = '_token' - _FIELD_TOKEN = 'token' - - _ATTRIBUTE_PRIVATE_KEY_CLIENT = '_private_key_client' - _FIELD_PRIVATE_KEY_CLIENT = 'private_key_client' - - _ATTRIBUTE_PUBLIC_KEY_CLIENT = '_public_key_client' - _FIELD_PUBLIC_KEY_CLIENT = 'public_key_client' - - _ATTRIBUTE_PUBLIC_KEY_SERVER = '_public_key_server' - _FIELD_PUBLIC_KEY_SERVER = 'public_key_server' - - @classmethod - def deserialize(cls, target_class, obj): - """ - :type target_class: context.InstallationContext|type - :type obj: dict - - :rtype: context.InstallationContext - """ - - installation_context = target_class.__new__(target_class) - private_key_client = security.rsa_key_from_string( - obj[cls._FIELD_PRIVATE_KEY_CLIENT] - ) - public_key_client = security.rsa_key_from_string( - obj[cls._FIELD_PUBLIC_KEY_CLIENT] - ) - public_key_server = security.rsa_key_from_string( - obj[cls._FIELD_PUBLIC_KEY_SERVER] - ) - installation_context.__dict__ = { - cls._ATTRIBUTE_TOKEN: obj[cls._FIELD_TOKEN], - cls._ATTRIBUTE_PRIVATE_KEY_CLIENT: private_key_client, - cls._ATTRIBUTE_PUBLIC_KEY_CLIENT: public_key_client, - cls._ATTRIBUTE_PUBLIC_KEY_SERVER: public_key_server, - } - - return installation_context - - @classmethod - def serialize(cls, installation_context): - """ - :type installation_context: context.InstallationContext - - :rtype: dict - """ - - return { - cls._FIELD_TOKEN: installation_context.token, - cls._FIELD_PUBLIC_KEY_CLIENT: security.public_key_to_string( - installation_context.private_key_client.publickey() - ), - cls._FIELD_PRIVATE_KEY_CLIENT: security.private_key_to_string( - installation_context.private_key_client - ), - cls._FIELD_PUBLIC_KEY_SERVER: security.public_key_to_string( - installation_context.public_key_server - ), - } - - -class ApiEnvironmentTypeAdapter(converter.JsonAdapter): - @classmethod - def deserialize(cls, target_class, name): - """ - :type target_class: context.ApiEnvironmentType|type - :type name: str - - :rtype: context.ApiEnvironmentType - """ - - _ = target_class - - return context.ApiEnvironmentType[name] - - @classmethod - def serialize(cls, api_environment_type): - """ - :type api_environment_type: context.ApiEnvironmentType - - :rtype: str - """ - - return api_environment_type.name - - -class FloatAdapter(converter.JsonAdapter): - # Precision to round the floats to before outputting them - _PRECISION_FLOAT = 2 - - @classmethod - def deserialize(cls, target_class, string): - """ - :type target_class: float|type - :type string: str - - :rtype: float - """ - - _ = target_class - - return float(string) - - @classmethod - def serialize(cls, number): - """ - :type number: float - - :rtype: str - """ - - return str(round(number, cls._PRECISION_FLOAT)) - - -class GeolocationAdapter(converter.JsonAdapter): - # Field constants - _FIELD_LATITUDE = 'latitude' - _FIELD_LONGITUDE = 'longitude' - _FIELD_ALTITUDE = 'altitude' - _FIELD_RADIUS = 'radius' - - @classmethod - def can_deserialize(cls): - """ - :rtype: bool - """ - - return False - - @classmethod - def deserialize(cls, target_class, obj): - """ - :type target_class: float|type - :type obj: dict - - :raise: NotImplementedError - """ - - _ = target_class, obj - - raise NotImplementedError() - - @classmethod - def serialize(cls, geolocation): - """ - :type geolocation: object_.Geolocation - - :rtype: dict - """ - - obj = {} - - cls.add_if_not_none(obj, cls._FIELD_LATITUDE, geolocation.latitude) - cls.add_if_not_none(obj, cls._FIELD_LONGITUDE, geolocation.longitude) - cls.add_if_not_none(obj, cls._FIELD_ALTITUDE, geolocation.altitude) - cls.add_if_not_none(obj, cls._FIELD_RADIUS, geolocation.radius) - - return obj - - @classmethod - def add_if_not_none(cls, dict_, key, value): - """ - :type dict_: dict[str, str] - :type key: str - :type value: float - - :rtype: None - """ - - if value is not None: - dict_[key] = str(value) - - -class MonetaryAccountReferenceAdapter(converter.JsonAdapter): - @classmethod - def deserialize(cls, target_class, obj): - """ - :type target_class: object_.MonetaryAccountReference|type - :type obj: dict - - :rtype: object_.MonetaryAccountReference - """ - - label_monetary_account = converter.deserialize( - object_.LabelMonetaryAccount, - obj - ) - - return target_class.create_from_label_monetary_account( - label_monetary_account - ) - - @classmethod - def serialize(cls, monetary_account_reference): - """ - :type monetary_account_reference: object_.MonetaryAccountReference - - :rtype: dict - """ - - return converter.serialize(monetary_account_reference.pointer) - - -class ShareDetailAdapter(converter.JsonAdapter): - # Attribute/Field constants - _ATTRIBUTE_PAYMENT = 'payment' - _FIELD_PAYMENT = 'ShareDetailPayment' - - _ATTRIBUTE_READ_ONLY = 'read_only' - _FIELD_READ_ONLY = 'ShareDetailReadOnly' - - _ATTRIBUTE_DRAFT_PAYMENT = 'draft_payment' - _FIELD_DRAFT_PAYMENT = 'ShareDetailDraftPayment' - - @classmethod - def deserialize(cls, target_class, obj): - """ - :type target_class: object_.ShareDetail|type - :type obj: dict - - :rtype: object_.ShareDetail - """ - - share_detail = target_class.__new__(target_class) - share_detail.__dict__ = { - cls._ATTRIBUTE_PAYMENT: converter.deserialize( - object_.ShareDetailPayment, - cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj) - ), - cls._ATTRIBUTE_READ_ONLY: converter.deserialize( - object_.ShareDetailReadOnly, - cls._get_field_or_none(cls._FIELD_READ_ONLY, obj) - ), - cls._ATTRIBUTE_DRAFT_PAYMENT: converter.deserialize( - object_.ShareDetailDraftPayment, - cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj) - ), - } - - return share_detail - - @staticmethod - def _get_field_or_none(field, obj): - """ - :type field: str - :type obj: dict - - :return: dict|None - """ - - return obj[field] if field in obj else None - - @classmethod - def serialize(cls, share_detail): - """ - :type share_detail: object_.ShareDetail - - :rtype: dict - """ - - return { - cls._FIELD_PAYMENT: converter.serialize( - share_detail._payment_field_for_request), - cls._FIELD_READ_ONLY: converter.serialize( - share_detail._read_only_field_for_request), - cls._FIELD_DRAFT_PAYMENT: converter.serialize( - share_detail._draft_payment - ), - } - - -class DateTimeAdapter(converter.JsonAdapter): - # bunq timestamp format - _FORMAT_TIMESTAMP = '%Y-%m-%d %H:%M:%S.%f' - - @classmethod - def deserialize(cls, target_class, string): - """ - :type target_class: datetime.datetime|type - :type string: str - - :rtype: datetime.datetime - """ - - return target_class.strptime(string, cls._FORMAT_TIMESTAMP) - - @classmethod - def serialize(cls, timestamp): - """ - :type timestamp: datetime.datetime - - :rtype: dict - """ - - return timestamp.strftime(cls._FORMAT_TIMESTAMP) - - -class PaginationAdapter(converter.JsonAdapter): - # Raw pagination response field constants. - _FIELD_FUTURE_URL = 'future_url' - _FIELD_NEWER_URL = 'newer_url' - _FIELD_OLDER_URL = 'older_url' - - # Processed pagination field constants. - _FIELD_OLDER_ID = 'older_id' - _FIELD_NEWER_ID = 'newer_id' - _FIELD_FUTURE_ID = 'future_id' - _FIELD_COUNT = 'count' - - # Very first index in an array. - _INDEX_FIRST = 0 - - @classmethod - def deserialize(cls, target_class, pagination_response): - """ - :type target_class: client.Pagination|type - :type pagination_response: dict - - :rtype: client.Pagination - """ - - pagination = client.Pagination() - pagination.__dict__.update( - cls.parse_pagination_dict(pagination_response) - ) - - return pagination - - @classmethod - def parse_pagination_dict(cls, response_obj): - """ - :type response_obj: dict - - :rtype: dict - """ - - pagination_dict = {} - - cls.update_dict_id_field_from_response_field( - pagination_dict, - cls._FIELD_OLDER_ID, - response_obj, - cls._FIELD_OLDER_URL, - client.Pagination.PARAM_OLDER_ID - ) - cls.update_dict_id_field_from_response_field( - pagination_dict, - cls._FIELD_NEWER_ID, - response_obj, - cls._FIELD_NEWER_URL, - client.Pagination.PARAM_NEWER_ID - ) - cls.update_dict_id_field_from_response_field( - pagination_dict, - cls._FIELD_FUTURE_ID, - response_obj, - cls._FIELD_FUTURE_URL, - client.Pagination.PARAM_NEWER_ID - ) - - return pagination_dict - - @classmethod - def update_dict_id_field_from_response_field(cls, dict_, dict_id_field, - response_obj, response_field, - response_param): - """ - :type dict_: dict - :type dict_id_field: str - :type response_obj: dict - :type response_field: str - :type response_param: str - """ - - url = response_obj[response_field] - - if url is not None: - url_parsed = urlparse.urlparse(url) - parameters = urlparse.parse_qs(url_parsed.query) - dict_[dict_id_field] = int( - parameters[response_param][cls._INDEX_FIRST] - ) - - if cls._FIELD_COUNT in parameters and cls._FIELD_COUNT not in dict_: - dict_[cls._FIELD_COUNT] = int( - parameters[client.Pagination.PARAM_COUNT][cls._INDEX_FIRST] - ) - - @classmethod - def serialize(cls, pagination): - """ - :type pagination: client.Pagination - - :raise: NotImplementedError - """ - - _ = pagination - - raise NotImplementedError() diff --git a/bunq/sdk/json/anchor_object_adapter.py b/bunq/sdk/json/anchor_object_adapter.py new file mode 100644 index 0000000..65a934c --- /dev/null +++ b/bunq/sdk/json/anchor_object_adapter.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +from bunq import AnchorObjectInterface +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.json import converter +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.generated import endpoint +from bunq.sdk.model.generated import object_ +from bunq.sdk.util.type_alias import JsonValue +from bunq.sdk.util.type_alias import T + + +class AnchorObjectAdapter(converter.JsonAdapter): + __ERROR_MODEL_NOT_FOUND = '{} is not in endpoint nor object.' + + __STRING_FORMAT_UNDERSCORE = '_' + + _override_field_map = { + 'ScheduledPayment': 'SchedulePayment', + 'ScheduledInstance': 'ScheduleInstance', + 'ShareInviteBankInquiry': 'ShareInviteMonetaryAccountInquiry', + 'ShareInviteBankResponse': 'ShareInviteMonetaryAccountResponse' + } + + @classmethod + def deserialize(cls, + cls_target: Type[T], + obj_raw: JsonValue) -> T: + model_ = super()._deserialize_default(cls_target, obj_raw) + + if isinstance(model_, AnchorObjectInterface) and model_.is_all_field_none(): + for field in model_.__dict__: + object_class = cls._get_object_class(field) + contents = super()._deserialize_default(object_class, obj_raw) + + if contents.is_all_field_none(): + setattr(model_, field, None) + else: + setattr(model_, field, contents) + + return model_ + + @classmethod + def can_serialize(cls) -> bool: + return False + + @classmethod + def _get_object_class(cls, class_name: str) -> BunqModel: + class_name = class_name.lstrip(cls.__STRING_FORMAT_UNDERSCORE) + + if class_name in cls._override_field_map: + class_name = cls._override_field_map[class_name] + + try: + return getattr(endpoint, class_name + "ApiObject") + except AttributeError: + pass + + try: + return getattr(endpoint, class_name) + except AttributeError: + pass + + try: + return getattr(object_, class_name + "Object") + except AttributeError: + pass + + try: + return getattr(object_, class_name) + except AttributeError: + pass + + raise BunqException(cls.__ERROR_MODEL_NOT_FOUND.format(class_name)) diff --git a/bunq/sdk/json/api_environment_type_adapter.py b/bunq/sdk/json/api_environment_type_adapter.py new file mode 100644 index 0000000..441366e --- /dev/null +++ b/bunq/sdk/json/api_environment_type_adapter.py @@ -0,0 +1,16 @@ +from typing import Type + +from bunq.sdk.context.api_environment_type import ApiEnvironmentType +from bunq.sdk.json import converter + + +class ApiEnvironmentTypeAdapter(converter.JsonAdapter): + @classmethod + def deserialize(cls, + target_class: Type[ApiEnvironmentType], + name: str) -> ApiEnvironmentType: + return ApiEnvironmentType[name] + + @classmethod + def serialize(cls, api_environment_type: ApiEnvironmentType) -> str: + return api_environment_type.name diff --git a/bunq/sdk/json/converter.py b/bunq/sdk/json/converter.py index 8e5cc30..b2bb007 100644 --- a/bunq/sdk/json/converter.py +++ b/bunq/sdk/json/converter.py @@ -1,18 +1,28 @@ +from __future__ import annotations + import inspect import json import re import sys +import typing import warnings +from types import ModuleType +from typing import Type, Optional, Callable, Generator, Dict, Match, List, Union, Generic, Any + +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.util.type_alias import T, JsonValue -from bunq.sdk import exception +if typing.TYPE_CHECKING: + pass # Indentation size we use for the serialized JSON output _JSON_INDENT = 4 -class JsonAdapter(object): +class JsonAdapter(Generic[T]): # Error constants _ERROR_COULD_NOT_FIND_CLASS = 'Could not find class: {}' + _ERROR_MISSING_DOC_COMMENT = 'A doc :type is missing for {} in class {}' # Maps to store custom serializers and deserializers _custom_serializers = {} @@ -32,16 +42,14 @@ class JsonAdapter(object): _PREFIX_KEY_PROTECTED = '_' # Constants to fetch param types from the docstrings - _TEMPLATE_PATTERN_PARAM_TYPES = \ - ':type (_?{}):[\s\n\r]+([\w.]+)(?:\[([\w.]+)\])?' - _PATTERN_PARAM_NAME_TYPED_ANY = ':type (\w+):' + _TEMPLATE_PATTERN_PARAM_TYPES = ':type (_?{}):[\\s\\n\\r]+([\\w.]+)(?:\\[([\\w.]+)\\])?' + _PATTERN_PARAM_NAME_TYPED_ANY = ':type (\\w+):' _SUBMATCH_INDEX_NAME = 1 _SUBMATCH_INDEX_TYPE_MAIN = 2 _SUBMATCH_INDEX_TYPE_SUB = 3 # List of builtin type names - _TYPE_NAMES_BUILTIN = {'int', 'bool', 'float', 'str', 'list', 'dict', - 'bytes', 'unicode'} + _TYPE_NAMES_BUILTIN = {'int', 'bool', 'float', 'str', 'list', 'dict', 'bytes', 'unicode'} # Delimiter between modules in class paths _DELIMITER_MODULE = '.' @@ -50,22 +58,13 @@ class JsonAdapter(object): _TYPE_NAMES_BYTES = {'bytes', 'unicode'} @classmethod - def set_initializer(cls, initializer): - """ - :type initializer: Generator[bool, None, None] - """ - + def set_initializer(cls, initializer: Generator[bool, None, None]) -> None: cls._initializer = initializer @classmethod - def register_custom_adapter(cls, target_class, adapter): - """ - :type target_class: type - :type adapter: JsonAdapter|type - - :rtype: None - """ - + def register_custom_adapter(cls, + target_class: Type[T], + adapter: Type[JsonAdapter]) -> None: class_name = target_class.__name__ if adapter.can_serialize(): @@ -75,48 +74,27 @@ def register_custom_adapter(cls, target_class, adapter): cls._custom_deserializers[class_name] = adapter @classmethod - def _get_serializer(cls, cls_for): - """ - :type cls_for: type - - :rtype: JsonAdapter - """ - + def _get_serializer(cls, cls_for: Type[T]) -> type: if cls_for.__name__ in cls._custom_serializers: return cls._custom_serializers[cls_for.__name__] return JsonAdapter @classmethod - def _get_deserializer(cls, cls_for): - """ - :type cls_for: type - - :rtype: JsonAdapter - """ - + def _get_deserializer(cls, cls_for: Type[T]) -> Type[JsonAdapter]: if cls_for.__name__ in cls._custom_deserializers: return cls._custom_deserializers[cls_for.__name__] return JsonAdapter @classmethod - def can_deserialize(cls): - """ - :rtype: bool - """ - + def can_deserialize(cls) -> bool: return True @classmethod - def deserialize(cls, cls_target, obj_raw): - """ - :type cls_target: T|type - :type obj_raw: int|str|bool|float|list|dict|None - - :rtype: T - """ - + def deserialize(cls, + cls_target: Type[T], + obj_raw: JsonValue) -> T: cls._initialize() deserializer = cls._get_deserializer(cls_target) @@ -126,22 +104,13 @@ def deserialize(cls, cls_target, obj_raw): return deserializer.deserialize(cls_target, obj_raw) @classmethod - def _initialize(cls): - """ - :rtype: None - """ - + def _initialize(cls) -> None: next(cls._initializer, None) @classmethod - def _deserialize_default(cls, cls_target, obj_raw): - """ - :type cls_target: T|type - :type obj_raw: int|str|bool|float|list|dict|None - - :rtype: T - """ - + def _deserialize_default(cls, + cls_target: Type[T], + obj_raw: JsonValue) -> T: if cls._is_deserialized(cls_target, obj_raw): return obj_raw elif type(obj_raw) == dict: @@ -150,14 +119,9 @@ def _deserialize_default(cls, cls_target, obj_raw): return cls_target(obj_raw) @classmethod - def _is_deserialized(cls, cls_target, obj): - """ - :type cls_target: type - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: bool - """ - + def _is_deserialized(cls, + cls_target: Type[T], + obj: T) -> bool: if cls_target is None: return True @@ -176,30 +140,19 @@ def _is_deserialized(cls, cls_target, obj): return False @classmethod - def _deserialize_dict(cls, cls_target, dict_): - """ - :type cls_target: T|type - :type dict_: dict - - :rtype: T - """ - + def _deserialize_dict(cls, + cls_target: Type[T], + dict_: Dict) -> T: instance = cls_target.__new__(cls_target) dict_deserialized = cls._deserialize_dict_attributes(cls_target, dict_) - instance.__dict__ = cls._fill_default_values(cls_target, - dict_deserialized) + instance.__dict__ = cls._fill_default_values(cls_target, dict_deserialized) return instance @classmethod - def _deserialize_dict_attributes(cls, cls_context, dict_): - """ - :type cls_context: type - :type dict_: dict - - :rtype: dict - """ - + def _deserialize_dict_attributes(cls, + cls_context: Type[T], + dict_: Dict) -> Dict: dict_deserialized = {} for key in dict_.keys(): @@ -207,53 +160,37 @@ def _deserialize_dict_attributes(cls, cls_context, dict_): value_specs = cls._get_value_specs(cls_context, key_deserialized) if value_specs is not None: - dict_deserialized[value_specs.name] = cls._deserialize_value( - value_specs.types, - dict_[key] - ) - else: - cls._warn_key_unknown(cls_context, key) + dict_deserialized[value_specs.name] = cls._deserialize_value(value_specs.types, dict_[key]) return dict_deserialized @classmethod - def _deserialize_key(cls, key): - """ - :type key: str - - :rtype: str - """ - + def _deserialize_key(cls, key: str) -> str: if key in cls._KEYS_OVERLAPPING: return key + cls._SUFFIX_KEY_OVERLAPPING return key @classmethod - def _get_value_specs(cls, cls_in, attribute_name): - """ - :type cls_in: type - :type attribute_name: str - - :rtype: ValueSpecs - """ - + def _get_value_specs(cls, + cls_in: Type[T], + attribute_name: str) -> ValueSpecs: if cls_in in {dict, list}: return ValueSpecs(None, ValueTypes(None, None)) else: return cls._fetch_attribute_specs_from_doc(cls_in, attribute_name) @classmethod - def _fetch_attribute_specs_from_doc(cls, cls_in, attribute_name): - """ - :type cls_in: type - :type attribute_name: str + def _fetch_attribute_specs_from_doc(cls, + cls_in: Type[T], + attribute_name: str) -> Optional[ValueSpecs]: + pattern = cls._TEMPLATE_PATTERN_PARAM_TYPES.format(attribute_name) + doc_type = cls_in.__doc__ - :rtype: ValueSpecs - """ + if doc_type is None: + raise BunqException(cls._ERROR_MISSING_DOC_COMMENT.format(attribute_name, cls_in)) - pattern = cls._TEMPLATE_PATTERN_PARAM_TYPES.format(attribute_name) - match = re.search(pattern, cls_in.__doc__) + match = re.search(pattern, doc_type) if match is not None: return ValueSpecs( @@ -267,37 +204,22 @@ def _fetch_attribute_specs_from_doc(cls, cls_in, attribute_name): return None @classmethod - def _fetch_name(cls, match): - """ - :type match: _sre.SRE_Match - - :rtype: str - """ - + def _fetch_name(cls, match: Match) -> str: return match.group(cls._SUBMATCH_INDEX_NAME) @classmethod - def _fetch_type_main(cls, cls_in, match): - """ - :type cls_in: type - :type match: _sre.SRE_Match - - :rtype: type - """ - + def _fetch_type_main(cls, + cls_in: Type[T], + match: Match) -> Type[T]: return cls._str_to_type( cls_in, match.group(cls._SUBMATCH_INDEX_TYPE_MAIN) ) @classmethod - def _fetch_type_sub(cls, cls_in, match): - """ - :type cls_in: type - :type match: _sre.SRE_Match - - :rtype: type - """ + def _fetch_type_sub(cls, + cls_in: Type[T], + match: Match) -> Optional[Type[T]]: if match.group(cls._SUBMATCH_INDEX_TYPE_SUB): return cls._str_to_type( @@ -308,14 +230,9 @@ def _fetch_type_sub(cls, cls_in, match): return None @classmethod - def _str_to_type(cls, context_class, string): - """ - :type context_class: type - :type string: str - - :rtype: type - """ - + def _str_to_type(cls, + context_class: Type[T], + string: str) -> Type[T]: if string in cls._TYPE_NAMES_BUILTIN: return eval(string) @@ -327,49 +244,72 @@ def _str_to_type(cls, context_class, string): return cls._str_to_type_from_member_module(module_, string) @classmethod - def _str_to_type_from_member_module(cls, module_, string): + def _str_to_type_from_member_module(cls, + module_: ModuleType, + string: str) -> Type[T]: """ - :type module_: module - :type string: str - - :rtype: type :raise: BunqException when could not find the class for the string. """ + # First try: direct attribute lookup by name + if cls._DELIMITER_MODULE not in string: + if hasattr(module_, string): + return getattr(module_, string) + + # Second try: check for naming conventions based on module type + if "object_" in module_.__name__: + obj_name = string + "Object" + if hasattr(module_, obj_name): + return getattr(module_, obj_name) + elif "endpoint" in module_.__name__: + api_name = string + "ApiObject" + if hasattr(module_, api_name): + return getattr(module_, api_name) + else: + api_name = string + "ApiObject" + if hasattr(module_, api_name): + return getattr(module_, api_name) + error_message = cls._ERROR_COULD_NOT_FIND_CLASS.format(string) + raise BunqException(error_message) + + # Handle module.class notation using delimiter module_name_short, class_name = string.split(cls._DELIMITER_MODULE) members = inspect.getmembers(module_, inspect.ismodule) + # Search through submodules for the class for name, module_member in members: if module_name_short == name: - return getattr(module_member, class_name) - - error_message = cls._ERROR_COULD_NOT_FIND_CLASS.format(string) + # Try direct class lookup first + if hasattr(module_member, class_name): + return getattr(module_member, class_name) - raise exception.BunqException(error_message) + # Try to find object via naming conventions + if "object_" in module_member.__name__: + obj_name = class_name + "Object" + if hasattr(module_member, obj_name): + return getattr(module_member, obj_name) - @classmethod - def _deserialize_value(cls, types, value): - """ - :type types: ValueTypes - :type value: int|str|bool|float|bytes|unicode|list|dict + if "endpoint" in module_member.__name__: + api_name = class_name + "ApiObject" + if hasattr(module_member, api_name): + return getattr(module_member, api_name) - :rtype: int|str|bool|float|bytes|unicode|list|dict|object - """ + error_message = cls._ERROR_COULD_NOT_FIND_CLASS.format(string) + raise BunqException(error_message) + @classmethod + def _deserialize_value(cls, + types: ValueTypes, + value: JsonValue) -> Union[T, List[T]]: if types.main == list and value is not None: return cls._deserialize_list(types.sub, value) else: return cls.deserialize(types.main, value) @classmethod - def _deserialize_list(cls, type_item, list_): - """ - :type type_item: T|type - :type list_: list - - :rtype: list[T] - """ - + def _deserialize_list(cls, + type_item: Type[T], + list_: List) -> List[T]: list_deserialized = [] for item in list_: @@ -379,26 +319,9 @@ def _deserialize_list(cls, type_item, list_): return list_deserialized @classmethod - def _warn_key_unknown(cls, cls_context, key): - """ - :type cls_context: type - :type key: str - - :rtype: None - """ - - context_name = cls_context.__name__ - warnings.warn(cls._WARNING_KEY_UNKNOWN.format(key, context_name)) - - @classmethod - def _fill_default_values(cls, cls_context, dict_): - """ - :type cls_context: type - :type dict_: dict - - :rtype: dict - """ - + def _fill_default_values(cls, + cls_context: Type[T], + dict_: Dict) -> Dict: dict_with_default_values = dict(dict_) params = re.findall(cls._PATTERN_PARAM_NAME_TYPED_ANY, cls_context.__doc__) @@ -410,21 +333,11 @@ def _fill_default_values(cls, cls_context, dict_): return dict_with_default_values @classmethod - def can_serialize(cls): - """ - :rtype: bool - """ - + def can_serialize(cls) -> bool: return True @classmethod - def serialize(cls, obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: int|str|bool|list|dict - """ - + def serialize(cls, obj: T) -> JsonValue: cls._initialize() serializer = cls._get_serializer(type(obj)) @@ -434,13 +347,7 @@ def serialize(cls, obj): return serializer.serialize(obj) @classmethod - def _serialize_default(cls, obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: int|str|bool|list|dict - """ - + def _serialize_default(cls, obj: T) -> JsonValue: if obj is None or cls._is_primitive(obj): return obj elif cls._is_bytes(obj): @@ -453,53 +360,23 @@ def _serialize_default(cls, obj): return cls._serialize_dict(dict_) @classmethod - def _is_primitive(cls, obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: bool - """ - + def _is_primitive(cls, obj: T) -> bool: return cls._is_type_primitive(type(obj)) @classmethod - def _is_type_primitive(cls, type_): - """ - :type type_: type - - :rtype: bool - """ - + def _is_type_primitive(cls, type_: Type[T]) -> bool: return type_ in {int, str, bool, float} @classmethod - def _is_bytes(cls, obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: bool - """ - + def _is_bytes(cls, obj: T) -> bool: return cls._is_bytes_type(type(obj)) @classmethod - def _is_bytes_type(cls, type_): - """ - :type type_: type - - :rtype: bool - """ - + def _is_bytes_type(cls, type_: Type[T]) -> bool: return type_.__name__ in cls._TYPE_NAMES_BYTES @classmethod - def _serialize_list(cls, list_): - """ - :type list_: list - - :rtype: list - """ - + def _serialize_list(cls, list_: List) -> List: list_serialized = [] for item in list_: @@ -509,23 +386,11 @@ def _serialize_list(cls, list_): return list_serialized @classmethod - def _get_obj_raw(cls, obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: dict - """ - + def _get_obj_raw(cls, obj: T) -> Dict: return obj if type(obj) == dict else obj.__dict__ @classmethod - def _serialize_dict(cls, dict_): - """ - :type dict_ dict - - :rtype: dict - """ - + def _serialize_dict(cls, dict_: Dict) -> Dict: obj_serialized = {} for key in dict_.keys(): @@ -539,85 +404,43 @@ def _serialize_dict(cls, dict_): return obj_serialized -class ValueTypes(object): - """ - :type _main: type|None - :type _sub: type|None - """ - - def __init__(self, main, sub): - """ - :type main: type|None - :type sub: type|None - """ - +class ValueTypes: + def __init__(self, + main: Type[T] = None, + sub: Type[T] = None) -> None: self._main = main self._sub = sub @property - def main(self): - """ - :rtype: type|None - """ - + def main(self) -> Type[T]: return self._main @property - def sub(self): - """ - :rtype: type|None - """ - + def sub(self) -> Type[T]: return self._sub -class ValueSpecs(object): - """ - :type _name: str|None - :type _types: ValueTypes|None - """ - - def __init__(self, name, types): - """ - :type name: str|None - :type types: ValueTypes|None - """ - +class ValueSpecs: + def __init__(self, + name: str = None, + types: ValueTypes = None) -> None: self._name = name self._types = types @property - def name(self): - """ - :rtype: str|None - """ - + def name(self) -> Optional[str]: return self._name @property - def types(self): - """ - :rtype: ValueTypes|None - """ - + def types(self) -> Optional[ValueTypes]: return self._types -def set_initializer_function(initializer_function): - """ - :type initializer_function: callable - """ - +def set_initializer_function(initializer_function: Callable) -> None: JsonAdapter.set_initializer(create_initializer(initializer_function)) -def create_initializer(initializer_function): - """ - :type initializer_function: callable - - :rtype: bool - """ - +def create_initializer(initializer_function: Callable) -> Generator[bool, None, None]: is_disposed = False if not is_disposed: @@ -627,58 +450,25 @@ def create_initializer(initializer_function): yield is_disposed -def register_adapter(target_class, adapter): - """ - :type target_class: type - :type adapter: JsonAdapter|type - - :rtype: None - """ - +def register_adapter(target_class: Type[T], adapter: Type[JsonAdapter]) -> None: JsonAdapter.register_custom_adapter(target_class, adapter) -def json_to_class(cls, json_str): - """ - :type cls: T|type - :type json_str: str - - :rtype: T - """ - +def json_to_class(cls: Type[T], json_str: str) -> T: obj_raw = json.loads(json_str) return deserialize(cls, obj_raw) -def deserialize(cls, obj_raw): - """ - :type cls: T|type - :type obj_raw: int|str|bool|float|list|dict|None - - :rtype: T - """ - +def deserialize(cls: Type[T], obj_raw: JsonValue) -> T: return JsonAdapter.deserialize(cls, obj_raw) -def class_to_json(obj): - """ - :type obj: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: int|str|bool|list|dict - """ - +def class_to_json(obj: T) -> JsonValue: obj_raw = serialize(obj) return json.dumps(obj_raw, indent=_JSON_INDENT, sort_keys=True) -def serialize(obj_cls): - """ - :type obj_cls: int|str|bool|float|bytes|unicode|list|dict|object - - :rtype: int|str|bool|list|dict - """ - +def serialize(obj_cls: T) -> JsonValue: return JsonAdapter.serialize(obj_cls) diff --git a/bunq/sdk/json/date_time_adapter.py b/bunq/sdk/json/date_time_adapter.py new file mode 100644 index 0000000..8a7d79d --- /dev/null +++ b/bunq/sdk/json/date_time_adapter.py @@ -0,0 +1,19 @@ +import datetime +from typing import Type + +from bunq.sdk.json import converter + + +class DateTimeAdapter(converter.JsonAdapter): + # bunq timestamp format + _FORMAT_TIMESTAMP = '%Y-%m-%d %H:%M:%S.%f' + + @classmethod + def deserialize(cls, + target_class: Type[datetime.datetime], + string: str) -> datetime.datetime: + return target_class.strptime(string, cls._FORMAT_TIMESTAMP) + + @classmethod + def serialize(cls, timestamp: datetime.datetime) -> str: + return timestamp.strftime(cls._FORMAT_TIMESTAMP) diff --git a/bunq/sdk/json/float_adapter.py b/bunq/sdk/json/float_adapter.py new file mode 100644 index 0000000..2d80fb1 --- /dev/null +++ b/bunq/sdk/json/float_adapter.py @@ -0,0 +1,20 @@ +from typing import Type + +from bunq.sdk.json import converter + + +class FloatAdapter(converter.JsonAdapter): + # Precision to round the floats to before outputting them + _PRECISION_FLOAT = 2 + + @classmethod + def deserialize(cls, + target_class: Type[float], + string: str) -> float: + _ = target_class + + return float(string) + + @classmethod + def serialize(cls, number: float) -> str: + return str(round(number, cls._PRECISION_FLOAT)) diff --git a/bunq/sdk/json/geolocation_adapter.py b/bunq/sdk/json/geolocation_adapter.py new file mode 100644 index 0000000..4e3d037 --- /dev/null +++ b/bunq/sdk/json/geolocation_adapter.py @@ -0,0 +1,46 @@ +from typing import Type, Dict + +from bunq.sdk.json import converter +from bunq.sdk.model.generated.object_ import GeolocationObject + + +class GeolocationAdapter(converter.JsonAdapter): + # Field constants + _FIELD_LATITUDE = 'latitude' + _FIELD_LONGITUDE = 'longitude' + _FIELD_ALTITUDE = 'altitude' + _FIELD_RADIUS = 'radius' + + @classmethod + def can_deserialize(cls) -> bool: + return False + + @classmethod + def deserialize(cls, + target_class: Type[float], + obj: Dict) -> None: + """ + + :raise: NotImplementedError + """ + + raise NotImplementedError() + + @classmethod + def serialize(cls, geolocation: GeolocationObject) -> Dict: + obj = {} + + cls.add_if_not_none(obj, cls._FIELD_LATITUDE, geolocation.latitude) + cls.add_if_not_none(obj, cls._FIELD_LONGITUDE, geolocation.longitude) + cls.add_if_not_none(obj, cls._FIELD_ALTITUDE, geolocation.altitude) + cls.add_if_not_none(obj, cls._FIELD_RADIUS, geolocation.radius) + + return obj + + @classmethod + def add_if_not_none(cls, + dict_: Dict[str, str], + key: str, + value: float) -> None: + if value is not None: + dict_[key] = str(value) diff --git a/bunq/sdk/json/installation_adapter.py b/bunq/sdk/json/installation_adapter.py new file mode 100644 index 0000000..a4b9485 --- /dev/null +++ b/bunq/sdk/json/installation_adapter.py @@ -0,0 +1,59 @@ +from typing import Type, List + +from bunq.sdk.json import converter +from bunq.sdk.model.core.id import Id +from bunq.sdk.model.core.installation import Installation +from bunq.sdk.model.core.public_key_server import PublicKeyServer +from bunq.sdk.model.core.session_token import SessionToken + + +class InstallationAdapter(converter.JsonAdapter): + # Id constants + _ATTRIBUTE_ID = '_id_' + _INDEX_ID = 0 + _FIELD_ID = 'Id' + + # Token constants + _ATTRIBUTE_TOKEN = '_token' + _INDEX_TOKEN = 1 + _FIELD_TOKEN = 'Token' + + # Server Public Key constants + _ATTRIBUTE_SERVER_PUBLIC_KEY = '_server_public_key' + _INDEX_SERVER_PUBLIC_KEY = 2 + _FIELD_SERVER_PUBLIC_KEY = 'ServerPublicKey' + + @classmethod + def deserialize(cls, + target_class: Type[Installation], + array: List) -> Installation: + installation = target_class.__new__(target_class) + server_public_key_wrapped = array[cls._INDEX_SERVER_PUBLIC_KEY] + installation.__dict__ = { + cls._ATTRIBUTE_ID: converter.deserialize( + Id, + array[cls._INDEX_ID][cls._FIELD_ID] + ), + cls._ATTRIBUTE_TOKEN: converter.deserialize( + SessionToken, + array[cls._INDEX_TOKEN][cls._FIELD_TOKEN] + ), + cls._ATTRIBUTE_SERVER_PUBLIC_KEY: converter.deserialize( + PublicKeyServer, + server_public_key_wrapped[cls._FIELD_SERVER_PUBLIC_KEY] + ), + } + + return installation + + @classmethod + def serialize(cls, installation: Installation) -> List: + return [ + {cls._FIELD_ID: converter.serialize(installation.id_)}, + {cls._FIELD_TOKEN: converter.serialize(installation.token)}, + {cls._FIELD_SERVER_PUBLIC_KEY: converter.serialize(installation.server_public_key)}, + ] + + @classmethod + def can_serialize(cls) -> bool: + return True diff --git a/bunq/sdk/json/installation_context_adapter.py b/bunq/sdk/json/installation_context_adapter.py new file mode 100644 index 0000000..69dab66 --- /dev/null +++ b/bunq/sdk/json/installation_context_adapter.py @@ -0,0 +1,58 @@ +from typing import Type, Dict + +from bunq import InstallationContext +from bunq.sdk.json import converter +from bunq.sdk.security import security + + +class InstallationContextAdapter(converter.JsonAdapter): + # Attribute/Field constants + _ATTRIBUTE_TOKEN = '_token' + _FIELD_TOKEN = 'token' + + _ATTRIBUTE_PRIVATE_KEY_CLIENT = '_private_key_client' + _FIELD_PRIVATE_KEY_CLIENT = 'private_key_client' + + _ATTRIBUTE_PUBLIC_KEY_CLIENT = '_public_key_client' + _FIELD_PUBLIC_KEY_CLIENT = 'public_key_client' + + _ATTRIBUTE_PUBLIC_KEY_SERVER = '_public_key_server' + _FIELD_PUBLIC_KEY_SERVER = 'public_key_server' + + @classmethod + def deserialize(cls, + target_class: Type[InstallationContext], + obj: Dict) -> InstallationContext: + installation_context = target_class.__new__(target_class) + private_key_client = security.rsa_key_from_string( + obj[cls._FIELD_PRIVATE_KEY_CLIENT] + ) + public_key_client = security.rsa_key_from_string( + obj[cls._FIELD_PUBLIC_KEY_CLIENT] + ) + public_key_server = security.rsa_key_from_string( + obj[cls._FIELD_PUBLIC_KEY_SERVER] + ) + installation_context.__dict__ = { + cls._ATTRIBUTE_TOKEN: obj[cls._FIELD_TOKEN], + cls._ATTRIBUTE_PRIVATE_KEY_CLIENT: private_key_client, + cls._ATTRIBUTE_PUBLIC_KEY_CLIENT: public_key_client, + cls._ATTRIBUTE_PUBLIC_KEY_SERVER: public_key_server, + } + + return installation_context + + @classmethod + def serialize(cls, installation_context: InstallationContext) -> Dict: + return { + cls._FIELD_TOKEN: installation_context.token, + cls._FIELD_PUBLIC_KEY_CLIENT: security.public_key_to_string( + installation_context.private_key_client.publickey() + ), + cls._FIELD_PRIVATE_KEY_CLIENT: security.private_key_to_string( + installation_context.private_key_client + ), + cls._FIELD_PUBLIC_KEY_SERVER: security.public_key_to_string( + installation_context.public_key_server + ), + } diff --git a/bunq/sdk/json/monetary_account_reference_adapter.py b/bunq/sdk/json/monetary_account_reference_adapter.py new file mode 100644 index 0000000..7fb47a1 --- /dev/null +++ b/bunq/sdk/json/monetary_account_reference_adapter.py @@ -0,0 +1,18 @@ +from typing import Type, Dict + +from bunq.sdk.json import converter +from bunq.sdk.model.generated.object_ import MonetaryAccountReference, LabelMonetaryAccountObject + + +class MonetaryAccountReferenceAdapter(converter.JsonAdapter): + @classmethod + def deserialize(cls, + target_class: Type[MonetaryAccountReference], + obj: Dict) -> MonetaryAccountReference: + label_monetary_account = converter.deserialize(LabelMonetaryAccountObject, obj) + + return target_class.create_from_label_monetary_account(label_monetary_account) + + @classmethod + def serialize(cls, monetary_account_reference: MonetaryAccountReference) -> Dict: + return converter.serialize(monetary_account_reference.pointer) diff --git a/bunq/sdk/json/pagination_adapter.py b/bunq/sdk/json/pagination_adapter.py new file mode 100644 index 0000000..9f30508 --- /dev/null +++ b/bunq/sdk/json/pagination_adapter.py @@ -0,0 +1,84 @@ +import urllib.parse as urlparse +from typing import Type, Dict + +from bunq import Pagination +from bunq.sdk.json import converter + + +class PaginationAdapter(converter.JsonAdapter): + # Raw pagination response field constants. + _FIELD_FUTURE_URL = 'future_url' + _FIELD_NEWER_URL = 'newer_url' + _FIELD_OLDER_URL = 'older_url' + + # Processed pagination field constants. + _FIELD_OLDER_ID = 'older_id' + _FIELD_NEWER_ID = 'newer_id' + _FIELD_FUTURE_ID = 'future_id' + _FIELD_COUNT = 'count' + + # Very first index in an array. + _INDEX_FIRST = 0 + + @classmethod + def deserialize(cls, + target_class: Type[Pagination], + pagination_response: Dict) -> Pagination: + pagination = Pagination() + pagination.__dict__.update( + cls.parse_pagination_dict(pagination_response) + ) + + return pagination + + @classmethod + def parse_pagination_dict(cls, response_obj: Dict) -> Dict: + pagination_dict = {} + + cls.update_dict_id_field_from_response_field( + pagination_dict, + cls._FIELD_OLDER_ID, + response_obj, + cls._FIELD_OLDER_URL, + Pagination.PARAM_OLDER_ID + ) + cls.update_dict_id_field_from_response_field( + pagination_dict, + cls._FIELD_NEWER_ID, + response_obj, + cls._FIELD_NEWER_URL, + Pagination.PARAM_NEWER_ID + ) + cls.update_dict_id_field_from_response_field( + pagination_dict, + cls._FIELD_FUTURE_ID, + response_obj, + cls._FIELD_FUTURE_URL, + Pagination.PARAM_NEWER_ID + ) + + return pagination_dict + + @classmethod + def update_dict_id_field_from_response_field(cls, dict_: Dict, + dict_id_field: str, + response_obj: Dict, + response_field: str, + response_param: str) -> None: + url = response_obj[response_field] + + if url is not None: + url_parsed = urlparse.urlparse(url) + parameters = urlparse.parse_qs(url_parsed.query) + dict_[dict_id_field] = int( + parameters[response_param][cls._INDEX_FIRST] + ) + + if cls._FIELD_COUNT in parameters and cls._FIELD_COUNT not in dict_: + dict_[cls._FIELD_COUNT] = int( + parameters[Pagination.PARAM_COUNT][cls._INDEX_FIRST] + ) + + @classmethod + def serialize(cls, pagination: Pagination) -> None: + raise NotImplementedError() diff --git a/bunq/sdk/json/session_server_adapter.py b/bunq/sdk/json/session_server_adapter.py new file mode 100644 index 0000000..55f92a0 --- /dev/null +++ b/bunq/sdk/json/session_server_adapter.py @@ -0,0 +1,115 @@ +from typing import Type, List + +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.json import converter +from bunq.sdk.model.core.id import Id +from bunq.sdk.model.core.session_server import SessionServer +from bunq.sdk.model.core.session_token import SessionToken +from bunq.sdk.model.generated.endpoint import UserCompanyApiObject, UserPersonApiObject, UserApiKeyApiObject, UserPaymentServiceProviderApiObject + + +class SessionServerAdapter(converter.JsonAdapter): + # Error constants. + _ERROR_COULD_NOT_DETERMINE_USER = 'Could not determine user.' + + # Id constants + _ATTRIBUTE_ID = '_id_' + _INDEX_ID = 0 + _FIELD_ID = 'Id' + + # Token constants + _ATTRIBUTE_TOKEN = '_token' + _INDEX_TOKEN = 1 + _FIELD_TOKEN = 'Token' + + # User constants + _INDEX_USER = 2 + + # UserCompany constants + _ATTRIBUTE_USER_COMPANY = '_user_company' + _FIELD_USER_COMPANY = 'UserCompany' + + # UserPerson constants + _ATTRIBUTE_USER_PERSON = '_user_person' + _FIELD_USER_PERSON = 'UserPerson' + + # UserApiKey constants + _ATTRIBUTE_USER_API_KEY = '_user_api_key' + _FIELD_USER_API_KEY = 'UserApiKey' + + # UserPaymentServiceProvider constants + _ATTRIBUTE_USER_PAYMENT_SERVER_PROVIDER = '_user_payment_service_provider' + _FIELD_USER_PAYMENT_SERVER_PROVIDER = 'UserPaymentServiceProvider' + + @classmethod + def deserialize(cls, + target_class: Type[SessionServer], + array: List) -> SessionServer: + session_server = target_class.__new__(target_class) + session_server.__dict__ = { + cls._ATTRIBUTE_ID: converter.deserialize( + Id, + array[cls._INDEX_ID][cls._FIELD_ID] + ), + cls._ATTRIBUTE_TOKEN: converter.deserialize( + SessionToken, + array[cls._INDEX_TOKEN][cls._FIELD_TOKEN] + ), + cls._ATTRIBUTE_USER_COMPANY: None, + cls._ATTRIBUTE_USER_PERSON: None, + cls._ATTRIBUTE_USER_PAYMENT_SERVER_PROVIDER: None, + } + + user_dict_wrapped = array[cls._INDEX_USER] + + if cls._FIELD_USER_COMPANY in user_dict_wrapped: + session_server.__dict__[cls._ATTRIBUTE_USER_COMPANY] = \ + converter.deserialize( + UserCompanyApiObject, + user_dict_wrapped[cls._FIELD_USER_COMPANY] + ) + elif cls._FIELD_USER_PERSON in user_dict_wrapped: + session_server.__dict__[cls._ATTRIBUTE_USER_PERSON] = \ + converter.deserialize( + UserPersonApiObject, + user_dict_wrapped[cls._FIELD_USER_PERSON] + ) + elif cls._FIELD_USER_API_KEY in user_dict_wrapped: + session_server.__dict__[cls._ATTRIBUTE_USER_API_KEY] = \ + converter.deserialize( + UserApiKeyApiObject, + user_dict_wrapped[cls._FIELD_USER_API_KEY] + ) + elif cls._FIELD_USER_PAYMENT_SERVER_PROVIDER in user_dict_wrapped: + session_server.__dict__[cls._ATTRIBUTE_USER_PAYMENT_SERVER_PROVIDER] = \ + converter.deserialize( + UserPaymentServiceProviderApiObject, + user_dict_wrapped[cls._FIELD_USER_PAYMENT_SERVER_PROVIDER] + ) + else: + raise BunqException(cls._ERROR_COULD_NOT_DETERMINE_USER) + + return session_server + + @classmethod + def serialize(cls, session_server: SessionServer) -> List: + return [ + {cls._FIELD_ID: converter.serialize(session_server.id_)}, + {cls._FIELD_TOKEN: converter.serialize(session_server.token)}, + { + cls._FIELD_USER_COMPANY: + converter.serialize(session_server.user_company), + }, + { + cls._FIELD_USER_PERSON: + converter.serialize(session_server.user_person), + }, + { + cls._FIELD_USER_API_KEY: + converter.serialize(session_server.user_api_key), + }, + { + cls._FIELD_USER_PAYMENT_SERVER_PROVIDER: + converter.serialize(session_server.user_payment_service_provider), + }, + ] diff --git a/bunq/sdk/json/share_detail_adapter.py b/bunq/sdk/json/share_detail_adapter.py new file mode 100644 index 0000000..9152ae1 --- /dev/null +++ b/bunq/sdk/json/share_detail_adapter.py @@ -0,0 +1,62 @@ +from typing import Dict, Type, Optional + +from bunq.sdk.json import converter +from bunq.sdk.model.generated.object_ import ShareDetailObject, ShareDetailPaymentObject, ShareDetailReadOnlyObject, \ + ShareDetailDraftPaymentObject + + +class ShareDetailAdapter(converter.JsonAdapter): + # Attribute/Field constants + _ATTRIBUTE_PAYMENT = 'payment' + _FIELD_PAYMENT = 'ShareDetailPayment' + + _ATTRIBUTE_READ_ONLY = 'read_only' + _FIELD_READ_ONLY = 'ShareDetailReadOnly' + + _ATTRIBUTE_DRAFT_PAYMENT = 'draft_payment' + _FIELD_DRAFT_PAYMENT = 'ShareDetailDraftPayment' + + @classmethod + def deserialize(cls, + target_class: Type[ShareDetailObject], + obj: Dict) -> ShareDetailObject: + """ + :type target_class: ShareDetail|type + :type obj: dict + + :rtype: ShareDetail + """ + + share_detail = target_class.__new__(target_class) + share_detail.__dict__ = { + cls._ATTRIBUTE_PAYMENT: converter.deserialize( + ShareDetailPaymentObject, + cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj) + ), + cls._ATTRIBUTE_READ_ONLY: converter.deserialize( + ShareDetailReadOnlyObject, + cls._get_field_or_none(cls._FIELD_READ_ONLY, obj) + ), + cls._ATTRIBUTE_DRAFT_PAYMENT: converter.deserialize( + ShareDetailDraftPaymentObject, + cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj) + ), + } + + return share_detail + + @staticmethod + def _get_field_or_none(field: str, obj: Dict) -> Optional[Dict]: + return obj[field] if field in obj else None + + @classmethod + def serialize(cls, share_detail: ShareDetailObject) -> Dict: + return { + cls._FIELD_PAYMENT: converter.serialize( + share_detail._payment_field_for_request), + cls._FIELD_READ_ONLY: converter.serialize( + share_detail._read_only_field_for_request), + cls._FIELD_DRAFT_PAYMENT: converter.serialize( + share_detail._draft_payment + ), + } diff --git a/bunq/sdk/model/core.py b/bunq/sdk/model/core.py deleted file mode 100644 index 247b17c..0000000 --- a/bunq/sdk/model/core.py +++ /dev/null @@ -1,521 +0,0 @@ -from bunq.sdk import client -from bunq.sdk.json import converter -from bunq.sdk.exception import BunqException -from bunq.sdk import context - - -class AnchoredObjectInterface: - pass - - -class BunqModel(object): - # Field constants - _FIELD_RESPONSE = 'Response' - _FIELD_PAGINATION = 'Pagination' - _FIELD_ID = 'Id' - _FIELD_UUID = 'Uuid' - - # The very first index of an array - _INDEX_FIRST = 0 - - __STRING_FORMAT_EMPTY = '' - __STRING_FORMAT_FIELD_FOR_REQUEST_ONE_UNDERSCORE = '_field_for_request' - __STRING_FORMAT_FIELD_FOR_REQUEST_TWO_UNDERSCORE = '__field_for_request' - - def is_all_field_none(self): - raise NotImplementedError - - def to_json(self): - """ - :rtype: str - """ - - return converter.class_to_json(self) - - @staticmethod - def from_json(json_str): - raise NotImplementedError - - @classmethod - def _from_json_array_nested(cls, response_raw): - """ - :type response_raw: client.BunqResponseRaw - - :rtype: bunq.sdk.client.BunqResponse[cls] - """ - - json = response_raw.body_bytes.decode() - obj = converter.json_to_class(dict, json) - value = converter.deserialize(cls, obj[cls._FIELD_RESPONSE]) - - return client.BunqResponse(value, response_raw.headers) - - @classmethod - def _from_json(cls, response_raw, wrapper=None): - """ - :type response_raw: client.BunqResponseRaw - :type wrapper: str|None - - :rtype: client.BunqResponse[cls] - """ - - json = response_raw.body_bytes.decode() - obj = converter.json_to_class(dict, json) - value = converter.deserialize( - cls, - cls._unwrap_response_single(obj, wrapper) - ) - - return client.BunqResponse(value, response_raw.headers) - - @classmethod - def _unwrap_response_single(cls, obj, wrapper=None): - """ - :type obj: dict - :type wrapper: str|None - - :rtype: dict - """ - - if wrapper is not None: - return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper] - - return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST] - - @classmethod - def _process_for_id(cls, response_raw): - """ - :type response_raw: client.BunqResponseRaw - - :rtype: client.BunqResponse[int] - """ - - json = response_raw.body_bytes.decode() - obj = converter.json_to_class(dict, json) - id_ = converter.deserialize( - Id, - cls._unwrap_response_single(obj, cls._FIELD_ID) - ) - - return client.BunqResponse(id_.id_, response_raw.headers) - - @classmethod - def _process_for_uuid(cls, response_raw): - """ - :type response_raw: client.BunqResponseRaw - - :rtype: client.BunqResponse[str] - """ - - json = response_raw.body_bytes.decode() - obj = converter.json_to_class(dict, json) - uuid = converter.deserialize( - Uuid, - cls._unwrap_response_single(obj, cls._FIELD_UUID) - ) - - return client.BunqResponse(uuid.uuid, response_raw.headers) - - @classmethod - def _from_json_list(cls, response_raw, wrapper=None): - """ - :type response_raw: client.BunqResponseRaw - :type wrapper: str|None - - :rtype: client.BunqResponse[list[cls]] - """ - - json = response_raw.body_bytes.decode() - obj = converter.json_to_class(dict, json) - array = obj[cls._FIELD_RESPONSE] - array_deserialized = [] - - for item in array: - item_unwrapped = item if wrapper is None else item[wrapper] - item_deserialized = converter.deserialize(cls, item_unwrapped) - array_deserialized.append(item_deserialized) - - pagination = converter.deserialize(client.Pagination, - obj[cls._FIELD_PAGINATION]) - - return client.BunqResponse(array_deserialized, response_raw.headers, - pagination) - - @classmethod - def _get_api_context(cls): - """ - :rtype: context.ApiContext - """ - - return context.BunqContext.api_context() - - @classmethod - def _determine_user_id(cls): - """ - :rtype: int - """ - - return context.BunqContext.user_context().user_id - - @classmethod - def _determine_monetary_account_id(cls, monetary_account_id=None): - """ - :type monetary_account_id: int - - :rtype: int - """ - - if monetary_account_id is None: - return context.BunqContext.user_context().primary_monetary_account.id_ - - return monetary_account_id - - @classmethod - def _remove_field_for_request(cls, json_str: str): - return json_str.replace( - cls.__STRING_FORMAT_FIELD_FOR_REQUEST_TWO_UNDERSCORE, - cls.__STRING_FORMAT_EMPTY - ).replace( - cls.__STRING_FORMAT_FIELD_FOR_REQUEST_ONE_UNDERSCORE, - cls.__STRING_FORMAT_EMPTY - ) - - -class Id(BunqModel): - """ - :type _id_: int - """ - - def __init__(self): - self._id_ = None - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - def is_all_field_none(self): - if self.id_ is not None: - return False - - return True - - - -class Uuid(BunqModel): - """ - :type _uuid: str - """ - - def __init__(self): - self._uuid = None - - @property - def uuid(self): - """ - :rtype: str - """ - - return self._uuid - - def is_all_field_none(self): - if self.uuid is not None: - return False - - return True - -class SessionToken(BunqModel): - """ - :type _id_: int - :type _created: str - :type _updated: str - :type _token: str - """ - - def __init__(self): - self._id_ = None - self._created = None - self._updated = None - self._token = None - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created - - @property - def updated(self): - """ - :rtype: str - """ - - return self._updated - - @property - def token(self): - """ - :rtype: str - """ - - return self._token - - def is_all_field_none(self): - if self.id_ is not None: - return False - - if self.created is not None: - return False - - if self.updated is not None: - return False - - if self.token is not None: - return False - - return True - - -class PublicKeyServer(BunqModel): - """ - :type _server_public_key: str - """ - - def __init__(self): - self._server_public_key = None - - @property - def server_public_key(self): - """ - :rtype: str - """ - - return self._server_public_key - - def is_all_field_none(self): - if self.server_public_key is not None: - return False - - return True - - -class Installation(BunqModel): - """ - :type _id_: Id - :type _token: SessionToken - :type _server_public_key: PublicKeyServer - """ - - # Endpoint name. - _ENDPOINT_URL_POST = "installation" - - # Field constants. - FIELD_CLIENT_PUBLIC_KEY = "client_public_key" - - def __init__(self): - self._id_ = None - self._token = None - self._server_public_key = None - - @property - def id_(self): - """ - :rtype: Id - """ - - return self._id_ - - @property - def token(self): - """ - :rtype: SessionToken - """ - - return self._token - - @property - def server_public_key(self): - """ - :rtype: PublicKeyServer - """ - - return self._server_public_key - - @classmethod - def create(cls, api_context, public_key_string): - """ - :type api_context: bunq.sdk.context.ApiContext - :type public_key_string: str - - :rtype: client.BunqResponse[Installation] - """ - - api_client = client.ApiClient(api_context) - body_bytes = cls.generate_request_body_bytes( - public_key_string - ) - response_raw = api_client.post(cls._ENDPOINT_URL_POST, body_bytes, {}) - - return cls._from_json_array_nested(response_raw) - - @classmethod - def generate_request_body_bytes(cls, public_key_string): - """ - :type public_key_string: str - - :rtype: bytes - """ - - return converter.class_to_json( - { - cls.FIELD_CLIENT_PUBLIC_KEY: public_key_string, - } - ).encode() - - def is_all_field_none(self): - if self.id_ is not None: - return False - - if self.token is not None: - return False - - if self.server_public_key is not None: - return False - - return True - -class SessionServer(BunqModel): - """ - :type _id_: Id - :type _token: SessionToken - :type _user_person: bunq.sdk.model.generated.UserPerson - :type _user_company: bunq.sdk.model.generated.UserCompany - :type _user_api_key: bunq.sdk.model.generated.UserApiKey - """ - - # Endpoint name. - _ENDPOINT_URL_POST = "session-server" - - # Field constants - FIELD_SECRET = "secret" - - # Error constants - _ERROR_ALL_FIELD_IS_NULL = 'All fields are null' - - def __init__(self): - self._id_ = None - self._token = None - self._user_person = None - self._user_company = None - self._user_api_key = None - - @property - def id_(self): - """ - :rtype: Id - """ - - return self._id_ - - @property - def token(self): - """ - :rtype: SessionToken - """ - - return self._token - - @property - def user_person(self): - """ - :rtype: bunq.sdk.model.generated.UserPerson - """ - - return self._user_person - - @property - def user_company(self): - """ - :rtype: bunq.sdk.model.generated.UserCompany - """ - - return self._user_company - - @property - def user_api_key(self): - """ - :rtype: bunq.sdk.model.generated.UserApiKey - """ - - return self._user_api_key - - @classmethod - def create(cls, api_context): - """ - :type api_context: bunq.sdk.context.ApiContext - - :rtype: client.BunqResponse[SessionServer] - """ - - api_client = client.ApiClient(api_context) - body_bytes = cls.generate_request_body_bytes(api_context.api_key) - response_raw = api_client.post(cls._ENDPOINT_URL_POST, body_bytes, {}) - - return cls._from_json_array_nested(response_raw) - - @classmethod - def generate_request_body_bytes(cls, secret): - """ - :type secret: str - - :rtype: bytes - """ - - return converter.class_to_json({cls.FIELD_SECRET: secret}).encode() - - def is_all_field_none(self): - if self.id_ is not None: - return False - - if self.token is not None: - return False - - if self.user_person is not None: - return False - - if self.user_company is not None: - return False - - if self.user_api_key is not None: - return False - - return True - - def get_referenced_user(self): - """ - :rtype: BunqModel - """ - - if self._user_person is not None: - return self._user_person - - if self._user_company is not None: - return self._user_company - - if self._user_api_key is not None: - return self._user_api_key - - raise BunqException(self._ERROR_ALL_FIELD_IS_NULL) diff --git a/bunq/sdk/model/core/__init__.py b/bunq/sdk/model/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/model/core/anchor_object_interface.py b/bunq/sdk/model/core/anchor_object_interface.py new file mode 100644 index 0000000..c881d2d --- /dev/null +++ b/bunq/sdk/model/core/anchor_object_interface.py @@ -0,0 +1,3 @@ +class AnchorObjectInterface: + def is_all_field_none(self) -> None: + pass diff --git a/bunq/sdk/model/core/bunq_model.py b/bunq/sdk/model/core/bunq_model.py new file mode 100644 index 0000000..1bd160f --- /dev/null +++ b/bunq/sdk/model/core/bunq_model.py @@ -0,0 +1,150 @@ +from __future__ import annotations + +import typing +from typing import Dict, List + +from bunq.sdk.util.type_alias import T +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.http.bunq_response_raw import BunqResponseRaw +from bunq.sdk.json import converter + +if typing.TYPE_CHECKING: + from bunq.sdk.context.api_context import ApiContext + + +class BunqModel: + # Field constants + _FIELD_RESPONSE = 'Response' + _FIELD_PAGINATION = 'Pagination' + _FIELD_ID = 'Id' + _FIELD_UUID = 'Uuid' + + # The very first index of an array + _INDEX_FIRST = 0 + + __STRING_FORMAT_EMPTY = '' + __STRING_FORMAT_FIELD_FOR_REQUEST_ONE_UNDERSCORE = '_field_for_request' + __STRING_FORMAT_FIELD_FOR_REQUEST_TWO_UNDERSCORE = '__field_for_request' + + def is_all_field_none(self) -> None: + raise NotImplementedError + + def to_json(self) -> str: + return converter.class_to_json(self) + + @classmethod + def _from_json_array_nested(cls, response_raw: BunqResponseRaw) -> BunqResponse[BunqModel]: + json = response_raw.body_bytes.decode() + obj = converter.json_to_class(dict, json) + value = converter.deserialize(cls, obj[cls._FIELD_RESPONSE]) + + return BunqResponse(value, response_raw.headers) + + @classmethod + def _from_json(cls, + response_raw: BunqResponseRaw, + wrapper: str = None) -> BunqResponse[BunqModel]: + json = response_raw.body_bytes.decode() + obj = converter.json_to_class(dict, json) + value = converter.deserialize( + cls, + cls._unwrap_response_single(obj, wrapper) + ) + + return BunqResponse(value, response_raw.headers) + + @classmethod + def _unwrap_response_single(cls, obj: Dict, wrapper: str = None) -> Dict: + if wrapper is None: + return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST] + + response_obj = obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST] + + if wrapper in response_obj: + return response_obj[wrapper] + + for key in response_obj.keys(): + if key.startswith(wrapper): + return response_obj[key] + + raise KeyError(f"Could not find '{wrapper}' or any subclass in response: {list(response_obj.keys())}") + + @classmethod + def _process_for_id(cls, response_raw: BunqResponseRaw) -> BunqResponse[int]: + from bunq.sdk.model.core.id import Id + + json = response_raw.body_bytes.decode() + obj = converter.json_to_class(dict, json) + id_ = converter.deserialize( + Id, + cls._unwrap_response_single(obj, cls._FIELD_ID) + ) + + return BunqResponse(id_.id_, response_raw.headers) + + @classmethod + def _process_for_uuid(cls, response_raw: BunqResponseRaw) -> BunqResponse[str]: + from bunq.sdk.model.core.uuid import Uuid + + json = response_raw.body_bytes.decode() + obj = converter.json_to_class(dict, json) + uuid = converter.deserialize( + Uuid, + cls._unwrap_response_single(obj, cls._FIELD_UUID) + ) + + return BunqResponse(uuid.uuid, response_raw.headers) + + @classmethod + def _from_json_list(cls, + response_raw: BunqResponseRaw, + wrapper: str = None) -> BunqResponse[List[T]]: + from bunq import Pagination + + json = response_raw.body_bytes.decode() + obj = converter.json_to_class(dict, json) + array = obj[cls._FIELD_RESPONSE] + array_deserialized = [] + + for item in array: + item_unwrapped = item if wrapper is None else item[wrapper] + item_deserialized = converter.deserialize(cls, item_unwrapped) + array_deserialized.append(item_deserialized) + + pagination = None + + if cls._FIELD_PAGINATION in obj: + pagination = converter.deserialize(Pagination, obj[cls._FIELD_PAGINATION]) + + return BunqResponse(array_deserialized, response_raw.headers, pagination) + + @classmethod + def _get_api_context(cls) -> ApiContext: + from bunq.sdk.context.bunq_context import BunqContext + + return BunqContext.api_context() + + @classmethod + def _determine_user_id(cls) -> int: + from bunq.sdk.context.bunq_context import BunqContext + + return BunqContext.user_context().user_id + + @classmethod + def _determine_monetary_account_id(cls, monetary_account_id: int = None) -> int: + from bunq.sdk.context.bunq_context import BunqContext + + if monetary_account_id is None: + return BunqContext.user_context().primary_monetary_account.id_ + + return monetary_account_id + + @classmethod + def _remove_field_for_request(cls, json_str: str) -> str: + return json_str.replace( + cls.__STRING_FORMAT_FIELD_FOR_REQUEST_TWO_UNDERSCORE, + cls.__STRING_FORMAT_EMPTY + ).replace( + cls.__STRING_FORMAT_FIELD_FOR_REQUEST_ONE_UNDERSCORE, + cls.__STRING_FORMAT_EMPTY + ) diff --git a/bunq/sdk/model/device_server_internal.py b/bunq/sdk/model/core/device_server_internal.py similarity index 75% rename from bunq/sdk/model/device_server_internal.py rename to bunq/sdk/model/core/device_server_internal.py index 7ab39e8..0daa79b 100644 --- a/bunq/sdk/model/device_server_internal.py +++ b/bunq/sdk/model/core/device_server_internal.py @@ -1,17 +1,23 @@ -from bunq.sdk.model.generated.endpoint import DeviceServer -from bunq.sdk.model.generated.endpoint import BunqResponseInt -from bunq.sdk import client +from typing import List, Dict + +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.api_client import ApiClient from bunq.sdk.json import converter -from bunq.sdk.exception import BunqException +from bunq.sdk.model.generated.endpoint import BunqResponseInt +from bunq.sdk.model.generated.endpoint import DeviceServerApiObject -class DeviceServerInternal(DeviceServer): - _ERROR_API_CONTEXT_IS_NULL = 'ApiContext should not be None,' \ - ' use the generated class instead.' +class DeviceServerInternal(DeviceServerApiObject): + _ERROR_API_CONTEXT_IS_NULL = 'ApiContext should not be None, use the generated class instead.' @classmethod - def create(cls, description, secret, permitted_ips=None, - custom_headers=None, api_context=None): + def create(cls, + description: str, + secret: str, + permitted_ips: List[str] = None, + custom_headers: Dict[str, str] = None, + api_context: ApiContext = None) -> BunqResponseInt: """ Create a new DeviceServer providing the installation token in the header and signing the request with the private part of the key you used to @@ -32,7 +38,7 @@ def create(cls, description, secret, permitted_ips=None, be able to do calls from. These will be linked to the API key. :type permitted_ips: list[str] :type custom_headers: dict[str, str]|None - :type api_context: context.ApiContext + :type api_context: ApiContext :rtype: BunqResponseInt """ @@ -49,7 +55,7 @@ def create(cls, description, secret, permitted_ips=None, cls.FIELD_PERMITTED_IPS: permitted_ips } - api_client = client.ApiClient(api_context) + api_client = ApiClient(api_context) request_bytes = converter.class_to_json(request_map).encode() endpoint_url = cls._ENDPOINT_URL_CREATE response_raw = api_client.post(endpoint_url, request_bytes, diff --git a/bunq/sdk/model/core/id.py b/bunq/sdk/model/core/id.py new file mode 100644 index 0000000..0205ac0 --- /dev/null +++ b/bunq/sdk/model/core/id.py @@ -0,0 +1,20 @@ +from bunq.sdk.model.core.bunq_model import BunqModel + + +class Id(BunqModel): + """ + :type _id_: int + """ + + def __init__(self) -> None: + self._id_ = None + + @property + def id_(self) -> int: + return self._id_ + + def is_all_field_none(self) -> bool: + if self.id_ is not None: + return False + + return True diff --git a/bunq/sdk/model/core/installation.py b/bunq/sdk/model/core/installation.py new file mode 100644 index 0000000..badfd1d --- /dev/null +++ b/bunq/sdk/model/core/installation.py @@ -0,0 +1,76 @@ +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.json import converter +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.core.id import Id +from bunq.sdk.model.core.public_key_server import PublicKeyServer +from bunq.sdk.model.core.session_token import SessionToken + + +class Installation(BunqModel): + """ + :type _id_: Id + :type _token: SessionToken + :type _server_public_key: PublicKeyServer + """ + + # Endpoint name. + _ENDPOINT_URL_POST = "installation" + + # Field constants. + FIELD_CLIENT_PUBLIC_KEY = "client_public_key" + + def __init__(self) -> None: + self._id_ = None + self._token = None + self._server_public_key = None + + @property + def id_(self) -> Id: + return self._id_ + + @property + def token(self) -> SessionToken: + return self._token + + @property + def server_public_key(self) -> PublicKeyServer: + return self._server_public_key + + @classmethod + def create(cls, + api_context: ApiContext, + public_key_string: str) -> BunqResponse: # TODO: Check + """ + :type api_context: ApiContext + :type public_key_string: str + + :rtype: BunqResponse[Installation] + """ + + api_client = ApiClient(api_context) + body_bytes = cls.generate_request_body_bytes(public_key_string) + response_raw = api_client.post(cls._ENDPOINT_URL_POST, body_bytes, {}) + + return cls._from_json_array_nested(response_raw) + + @classmethod + def generate_request_body_bytes(cls, public_key_string: str) -> bytes: + return converter.class_to_json( + { + cls.FIELD_CLIENT_PUBLIC_KEY: public_key_string, + } + ).encode() + + def is_all_field_none(self) -> bool: + if self.id_ is not None: + return False + + if self.token is not None: + return False + + if self.server_public_key is not None: + return False + + return True diff --git a/bunq/sdk/model/core/notification_filter_push_user_internal.py b/bunq/sdk/model/core/notification_filter_push_user_internal.py new file mode 100644 index 0000000..a1ecfa2 --- /dev/null +++ b/bunq/sdk/model/core/notification_filter_push_user_internal.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +from typing import List, Dict + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.json import converter +from bunq.sdk.model.generated.endpoint import NotificationFilterPushUser +from bunq.sdk.model.generated.object_ import NotificationFilterPush, NotificationFilterUrl + + +class NotificationFilterPushUserInternal(NotificationFilterPushUser): + @classmethod + def create_with_list_response(cls, + all_notification_filter: List[NotificationFilterPush] = None, + custom_headers: Dict[str, str] = None + ) -> BunqResponse[List[NotificationFilterPush]]: + if all_notification_filter is None: + all_notification_filter = [] + + if custom_headers is None: + custom_headers = {} + + request_map = { + cls.FIELD_NOTIFICATION_FILTERS: all_notification_filter + } + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return NotificationFilterUrl._from_json_list(response_raw, cls._OBJECT_TYPE_GET) diff --git a/bunq/sdk/model/core/notification_filter_url_monetary_account_internal.py b/bunq/sdk/model/core/notification_filter_url_monetary_account_internal.py new file mode 100644 index 0000000..efa7947 --- /dev/null +++ b/bunq/sdk/model/core/notification_filter_url_monetary_account_internal.py @@ -0,0 +1,37 @@ +from __future__ import annotations + +from typing import List, Dict + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.json import converter +from bunq.sdk.model.generated.endpoint import NotificationFilterUrlMonetaryAccount +from bunq.sdk.model.generated.object_ import NotificationFilterUrl + + +class NotificationFilterUrlMonetaryAccountInternal(NotificationFilterUrlMonetaryAccount): + @classmethod + def create_with_list_response(cls, + monetary_account_id: int = None, + all_notification_filter: List[NotificationFilterUrl] = None, + custom_headers: Dict[str, str] = None + ) -> BunqResponse[List[NotificationFilterUrl]]: + if all_notification_filter is None: + all_notification_filter = [] + + if custom_headers is None: + custom_headers = {} + + request_map = { + cls.FIELD_NOTIFICATION_FILTERS: all_notification_filter + } + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), + cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return NotificationFilterUrl._from_json_list(response_raw, cls._OBJECT_TYPE_GET) diff --git a/bunq/sdk/model/core/notification_filter_url_user_internal.py b/bunq/sdk/model/core/notification_filter_url_user_internal.py new file mode 100644 index 0000000..d87ed94 --- /dev/null +++ b/bunq/sdk/model/core/notification_filter_url_user_internal.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +from typing import List, Dict + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.json import converter +from bunq.sdk.model.generated.endpoint import NotificationFilterUrlUser +from bunq.sdk.model.generated.object_ import NotificationFilterUrl + + +class NotificationFilterUrlUserInternal(NotificationFilterUrlUser): + @classmethod + def create_with_list_response(cls, + all_notification_filter: List[NotificationFilterUrl] = None, + custom_headers: Dict[str, str] = None + ) -> BunqResponse[List[NotificationFilterUrl]]: + if all_notification_filter is None: + all_notification_filter = [] + + if custom_headers is None: + custom_headers = {} + + request_map = { + cls.FIELD_NOTIFICATION_FILTERS: all_notification_filter + } + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return NotificationFilterUrl._from_json_list(response_raw, cls._OBJECT_TYPE_GET) diff --git a/bunq/sdk/model/core/oauth_access_token.py b/bunq/sdk/model/core/oauth_access_token.py new file mode 100644 index 0000000..59bf222 --- /dev/null +++ b/bunq/sdk/model/core/oauth_access_token.py @@ -0,0 +1,105 @@ +from __future__ import annotations + +from typing import Optional, Type + +from bunq import ApiEnvironmentType +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.anonymous_api_client import AnonymousApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.http.bunq_response_raw import BunqResponseRaw +from bunq.sdk.http.http_util import HttpUtil +from bunq.sdk.json import converter +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.core.oauth_grant_type import OauthGrantType +from bunq.sdk.model.generated.endpoint import OauthClient +from bunq.sdk.util.type_alias import T + + +class OauthAccessToken(BunqModel): + # Field constants. + FIELD_GRANT_TYPE = "grant_type" + FIELD_CODE = "code" + FIELD_REDIRECT_URI = "redirect_uri" + FIELD_CLIENT_ID = "client_id" + FIELD_CLIENT_SECRET = "client_secret" + + # Token constants. + TOKEN_URI_FORMAT_SANDBOX = "https://api-oauth.sandbox.bunq.com/v1/token?%s" + TOKEN_URI_FORMAT_PRODUCTION = "https://api.oauth.bunq.com/v1/token?%s" + + # Error constants. + ERROR_ENVIRONMENT_TYPE_NOT_SUPPORTED = "You are trying to use an unsupported environment type." + + def __init__(self, token: str, token_type: str, state: str = None) -> None: + self._token = token + self._token_type = token_type + self._state = state + + @property + def token(self) -> str: + return self._token + + @property + def token_type(self) -> str: + return self._token_type + + @property + def state(self) -> Optional[str]: + return self._state + + @classmethod + def create(cls, + grant_type: OauthGrantType, + oauth_code: str, + redirect_uri: str, + client: OauthClient) -> OauthAccessToken: + api_client = AnonymousApiClient(BunqContext.api_context()) + response_raw = api_client.post( + cls.create_token_uri(grant_type.value, oauth_code, redirect_uri, client), + bytearray(), + {} + ) + + return cls.from_json(OauthAccessToken, response_raw).value + + @classmethod + def create_token_uri(cls, grant_type: str, auth_code: str, redirect_uri: str, client: OauthClient) -> str: + all_token_parameter = { + cls.FIELD_GRANT_TYPE: grant_type, + cls.FIELD_CODE: auth_code, + cls.FIELD_REDIRECT_URI: redirect_uri, + cls.FIELD_CLIENT_ID: client.id_, + cls.FIELD_CLIENT_SECRET: client.secret, + } + + return cls.determine_auth_uri_format().format(HttpUtil.create_query_string(all_token_parameter)) + + def is_all_field_none(self) -> bool: + if self._token is not None: + return False + elif self._token_type is not None: + return False + elif self._state is not None: + return False + + return True + + @classmethod + def from_json(cls, class_of_object: Type[T], response_raw: BunqResponseRaw): + response_item_object = converter.deserialize(class_of_object, response_raw) + response_value = converter.json_to_class(class_of_object, response_item_object) + + return BunqResponse(response_value, response_raw.headers) + + @classmethod + def determine_auth_uri_format(cls) -> str: + environment_type = BunqContext.api_context().environment_type + + if ApiEnvironmentType.PRODUCTION == environment_type: + return cls.TOKEN_URI_FORMAT_PRODUCTION + + if ApiEnvironmentType.SANDBOX == environment_type: + return cls.TOKEN_URI_FORMAT_SANDBOX + + raise BunqException(cls.ERROR_ENVIRONMENT_TYPE_NOT_SUPPORTED) diff --git a/bunq/sdk/model/core/oauth_authorization_uri.py b/bunq/sdk/model/core/oauth_authorization_uri.py new file mode 100644 index 0000000..508de35 --- /dev/null +++ b/bunq/sdk/model/core/oauth_authorization_uri.py @@ -0,0 +1,73 @@ +from __future__ import annotations + +from bunq import ApiEnvironmentType +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.http_util import HttpUtil +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.core.oauth_response_type import OauthResponseType +from bunq.sdk.model.generated.endpoint import OauthClient + + +class OauthAuthorizationUri(BunqModel): + # Auth constants. + AUTH_URI_FORMAT_SANDBOX = "https://oauth.sandbox.bunq.com/auth?{}" + AUTH_URI_FORMAT_PRODUCTION = "https://oauth.bunq.com/auth?{}" + + # Field constants + FIELD_RESPONSE_TYPE = "response_type" + FIELD_REDIRECT_URI = "redirect_uri" + FIELD_STATE = "state" + FIELD_CLIENT_ID = "client_id" + + # Error constants. + ERROR_ENVIRONMENT_TYPE_NOT_SUPPORTED = "You are trying to use an unsupported environment type." + + def __init__(self, authorization_uri: str) -> None: + self._authorization_uri = authorization_uri + + @property + def authorization_uri(self) -> str: + return self._authorization_uri + + @classmethod + def create(cls, + response_type: OauthResponseType, + redirect_uri: str, + client: OauthClient, + state: str = None) -> OauthAuthorizationUri: + all_request_parameter = { + cls.FIELD_REDIRECT_URI: redirect_uri, + cls.FIELD_RESPONSE_TYPE: response_type.name.lower() + } + + if client.client_id is not None: + all_request_parameter[cls.FIELD_CLIENT_ID] = client.client_id + + if state is not None: + all_request_parameter[cls.FIELD_STATE] = state + + return OauthAuthorizationUri( + cls.determine_auth_uri_format().format(HttpUtil.create_query_string(all_request_parameter)) + ) + + def get_authorization_uri(self) -> str: + return self._authorization_uri + + def is_all_field_none(self) -> bool: + if self._authorization_uri is None: + return True + else: + return False + + @classmethod + def determine_auth_uri_format(cls) -> str: + environment_type = BunqContext.api_context().environment_type + + if ApiEnvironmentType.PRODUCTION == environment_type: + return cls.AUTH_URI_FORMAT_PRODUCTION + + if ApiEnvironmentType.SANDBOX == environment_type: + return cls.AUTH_URI_FORMAT_SANDBOX + + raise BunqException(cls.ERROR_ENVIRONMENT_TYPE_NOT_SUPPORTED) diff --git a/bunq/sdk/model/core/oauth_grant_type.py b/bunq/sdk/model/core/oauth_grant_type.py new file mode 100644 index 0000000..a2aae4a --- /dev/null +++ b/bunq/sdk/model/core/oauth_grant_type.py @@ -0,0 +1,17 @@ +import aenum + + +class OauthGrantType(aenum.AutoNumberEnum): + """ + :type AUTHORIZATION_CODE: str + :type grant_type: str + """ + + AUTHORIZATION_CODE = 'authorization_code' + + def __init__(self, grant_type: str) -> None: + self._grant_type = grant_type + + @property + def grant_type(self) -> str: + return self.grant_type diff --git a/bunq/sdk/model/core/oauth_response_type.py b/bunq/sdk/model/core/oauth_response_type.py new file mode 100644 index 0000000..8a04401 --- /dev/null +++ b/bunq/sdk/model/core/oauth_response_type.py @@ -0,0 +1,17 @@ +import aenum + + +class OauthResponseType(aenum.AutoNumberEnum): + """ + :type CODE: str + :type response_type: str + """ + + CODE = 'code' + + def __init__(self, response_type: str) -> None: + self._response_type = response_type + + @property + def response_type(self) -> str: + return self._response_type diff --git a/bunq/sdk/model/core/payment_service_provider_credential_internal.py b/bunq/sdk/model/core/payment_service_provider_credential_internal.py new file mode 100644 index 0000000..2afde43 --- /dev/null +++ b/bunq/sdk/model/core/payment_service_provider_credential_internal.py @@ -0,0 +1,39 @@ +from __future__ import annotations + +import json +import typing + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.json import converter +from bunq.sdk.model.generated.endpoint import PaymentServiceProviderCredentialApiObject, UserCredentialPasswordIpApiObject + +if typing.TYPE_CHECKING: + from bunq.sdk.context.api_context import ApiContext + + +class PaymentServiceProviderCredentialInternal(PaymentServiceProviderCredentialApiObject): + @classmethod + def create_with_api_context(cls, + client_payment_service_provider_certificate: str, + client_payment_service_provider_certificate_chain: str, + client_public_key_signature: str, + api_context: ApiContext, + all_custom_header=None) -> UserCredentialPasswordIpApiObject: + request_map = { + cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE: client_payment_service_provider_certificate, + cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE_CHAIN: client_payment_service_provider_certificate_chain, + cls.FIELD_CLIENT_PUBLIC_KEY_SIGNATURE: client_public_key_signature + } + + if all_custom_header is None: + all_custom_header = {} + + api_client = ApiClient(api_context) + request_bytes = converter.class_to_json(request_map).encode() + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, all_custom_header) + + response_body = converter.json_to_class(dict, response_raw.body_bytes.decode()) + response_body_dict = converter.deserialize(cls, response_body[cls._FIELD_RESPONSE])[0] + + return UserCredentialPasswordIpApiObject.from_json(json.dumps(response_body_dict[cls._OBJECT_TYPE_GET])) diff --git a/bunq/sdk/model/core/public_key_server.py b/bunq/sdk/model/core/public_key_server.py new file mode 100644 index 0000000..45f33e2 --- /dev/null +++ b/bunq/sdk/model/core/public_key_server.py @@ -0,0 +1,20 @@ +from bunq.sdk.model.core.bunq_model import BunqModel + + +class PublicKeyServer(BunqModel): + """ + :type _server_public_key: str + """ + + def __init__(self) -> None: + self._server_public_key = None + + @property + def server_public_key(self) -> str: + return self._server_public_key + + def is_all_field_none(self) -> bool: + if self.server_public_key is not None: + return False + + return True diff --git a/bunq/sdk/model/core/session_server.py b/bunq/sdk/model/core/session_server.py new file mode 100644 index 0000000..dbc7f8c --- /dev/null +++ b/bunq/sdk/model/core/session_server.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +from typing import Optional + +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse +from bunq.sdk.json import converter +from bunq.sdk.model.core.bunq_model import BunqModel +from bunq.sdk.model.core.id import Id +from bunq.sdk.model.core.session_token import SessionToken +from bunq.sdk.model.generated.endpoint import UserPersonApiObject, UserCompanyApiObject, UserApiKeyApiObject, UserPaymentServiceProviderApiObject + + +class SessionServer(BunqModel): + """ + :type _id_: Id|None + :type _token: SessionToken|None + :type _user_person: UserPersonApiObject|None + :type _user_company: UserCompanyApiObject|None + :type _user_api_key: UserApiKeyApiObject|None + :type _user_payment_service_provider: UserPaymentServiceProviderApiObject|None + """ + + # Endpoint name. + _ENDPOINT_URL_POST = "session-server" + + # Field constants + FIELD_SECRET = "secret" + + # Error constants + _ERROR_ALL_FIELD_IS_NULL = 'All fields are null' + + @property + def id_(self) -> Optional[Id]: + return self._id_ + + @property + def token(self) -> Optional[SessionToken]: + return self._token + + @property + def user_person(self) -> Optional[UserPersonApiObject]: + return self._user_person + + @property + def user_company(self) -> Optional[UserCompanyApiObject]: + return self._user_company + + @property + def user_api_key(self) -> Optional[UserApiKeyApiObject]: + return self._user_api_key + + @property + def user_payment_service_provider(self) -> Optional[UserPaymentServiceProviderApiObject]: + return self._user_payment_service_provider + + def __init__(self) -> None: + self._user_person = None + self._user_company = None + self._user_api_key = None + self._user_payment_service_provider = None + self._token = None + self._id_ = None + + @classmethod + def create(cls, api_context: ApiContext) -> BunqResponse[SessionServer]: + cls.__init__(cls) + api_client = ApiClient(api_context) + body_bytes = cls.generate_request_body_bytes(api_context.api_key) + response_raw = api_client.post(cls._ENDPOINT_URL_POST, body_bytes, {}) + + return cls._from_json_array_nested(response_raw) + + @classmethod + def generate_request_body_bytes(cls, secret: str) -> bytes: + return converter.class_to_json({cls.FIELD_SECRET: secret}).encode() + + def is_all_field_none(self) -> bool: + if self.id_ is not None: + return False + elif self.token is not None: + return False + elif self.user_person is not None: + return False + elif self.user_company is not None: + return False + elif self.user_api_key is not None: + return False + elif self.user_payment_service_provider is not None: + return False + else: + return True + + def get_user_reference(self) -> BunqModel: + if self.user_person is not None: + return self.user_person + elif self.user_company is not None: + return self.user_company + elif self.user_api_key is not None: + return self.user_api_key + elif self.user_payment_service_provider is not None: + return self.user_payment_service_provider + else: + raise BunqException(self._ERROR_ALL_FIELD_IS_NULL) diff --git a/bunq/sdk/model/core/session_token.py b/bunq/sdk/model/core/session_token.py new file mode 100644 index 0000000..f893a5e --- /dev/null +++ b/bunq/sdk/model/core/session_token.py @@ -0,0 +1,47 @@ +from bunq.sdk.model.core.bunq_model import BunqModel + + +class SessionToken(BunqModel): + """ + :type _id_: int + :type _created: str + :type _updated: str + :type _token: str + """ + + def __init__(self) -> None: + self._id_ = None + self._created = None + self._updated = None + self._token = None + + @property + def id_(self) -> int: + return self._id_ + + @property + def created(self) -> str: + return self._created + + @property + def updated(self) -> str: + return self._updated + + @property + def token(self) -> str: + return self._token + + def is_all_field_none(self) -> bool: + if self.id_ is not None: + return False + + if self.created is not None: + return False + + if self.updated is not None: + return False + + if self.token is not None: + return False + + return True diff --git a/bunq/sdk/model/core/uuid.py b/bunq/sdk/model/core/uuid.py new file mode 100644 index 0000000..ddb5bbf --- /dev/null +++ b/bunq/sdk/model/core/uuid.py @@ -0,0 +1,20 @@ +from bunq.sdk.model.core.bunq_model import BunqModel + + +class Uuid(BunqModel): + """ + :type _uuid: str + """ + + def __init__(self) -> None: + self._uuid = None + + @property + def uuid(self) -> str: + return self._uuid + + def is_all_field_none(self) -> bool: + if self.uuid is not None: + return False + + return True diff --git a/bunq/sdk/model/generated/endpoint.py b/bunq/sdk/model/generated/endpoint.py index c7f8cc3..804856d 100644 --- a/bunq/sdk/model/generated/endpoint.py +++ b/bunq/sdk/model/generated/endpoint.py @@ -1,119 +1,87 @@ # -*- coding: utf-8 -*- -from bunq.sdk import client -from bunq.sdk import context -from bunq.sdk import exception -from bunq.sdk import security +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.http.bunq_response import BunqResponse from bunq.sdk.json import converter -from bunq.sdk.json import converter -from bunq.sdk.model import core +from bunq.sdk.model.core.anchor_object_interface import AnchorObjectInterface +from bunq.sdk.model.core.bunq_model import BunqModel from bunq.sdk.model.generated import object_ +from bunq.sdk.security import security -class Invoice(core.BunqModel): +class BillingContractSubscriptionApiObject(BunqModel): """ - Used to view a bunq invoice. + Show the subscription billing contract for the authenticated user. - :param _status: The invoice status. - :type _status: str - :param _description: The description provided by the admin. - :type _description: str - :param _external_url: The external url provided by the admin. - :type _external_url: str - :param _id_: The id of the invoice object. + :param _subscription_type: The subscription type of the user. Can be one of + PERSON_SUPER_LIGHT_V1, PERSON_LIGHT_V1, PERSON_MORE_V1, PERSON_FREE_V1, + PERSON_PREMIUM_V1, COMPANY_V1, or COMPANY_V2. + :type _subscription_type: str + :param _id_: The id of the billing contract. :type _id_: int - :param _created: The timestamp of the invoice object's creation. + :param _created: The timestamp when the billing contract was made. :type _created: str - :param _updated: The timestamp of the invoice object's last update. + :param _updated: The timestamp when the billing contract was last updated. :type _updated: str - :param _invoice_date: The invoice date. - :type _invoice_date: str - :param _invoice_number: The invoice number. - :type _invoice_number: str - :param _group: The invoice item groups. - :type _group: list[object_.InvoiceItemGroup] - :param _total_vat_inclusive: The total discounted item price including VAT. - :type _total_vat_inclusive: object_.Amount - :param _total_vat_exclusive: The total discounted item price excluding VAT. - :type _total_vat_exclusive: object_.Amount - :param _total_vat: The VAT on the total discounted item price. - :type _total_vat: object_.Amount - :param _alias: The label that's displayed to the counterparty with the - invoice. Includes user. - :type _alias: object_.MonetaryAccountReference - :param _address: The customer's address. - :type _address: object_.Address - :param _counterparty_alias: The label of the counterparty of the invoice. - Includes user. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _counterparty_address: The company's address. - :type _counterparty_address: object_.Address - :param _chamber_of_commerce_number: The company's chamber of commerce - number. - :type _chamber_of_commerce_number: str - :param _vat_number: The company's chamber of commerce number. - :type _vat_number: str - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] + :param _contract_date_start: The date from when the billing contract is + valid. + :type _contract_date_start: str + :param _contract_date_end: The date until when the billing contract is + valid. + :type _contract_date_end: str + :param _contract_version: The version of the billing contract. + :type _contract_version: int + :param _subscription_type_downgrade: The subscription type the user will + have after a subscription downgrade. Will be null if downgrading is not + possible. + :type _subscription_type_downgrade: str + :param _status: The subscription status. + :type _status: str + :param _sub_status: The subscription substatus. + :type _sub_status: str """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/invoice" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/invoice/{}" + _ENDPOINT_URL_LISTING = "user/{}/billing-contract-subscription" # Field constants. - FIELD_STATUS = "status" - FIELD_DESCRIPTION = "description" - FIELD_EXTERNAL_URL = "external_url" + FIELD_SUBSCRIPTION_TYPE = "subscription_type" # Object type. - _OBJECT_TYPE_GET = "Invoice" + _OBJECT_TYPE_GET = "BillingContractSubscription" _id_ = None _created = None _updated = None - _invoice_date = None - _invoice_number = None + _contract_date_start = None + _contract_date_end = None + _contract_version = None + _subscription_type = None + _subscription_type_downgrade = None _status = None - _group = None - _total_vat_inclusive = None - _total_vat_exclusive = None - _total_vat = None - _alias = None - _address = None - _counterparty_alias = None - _counterparty_address = None - _chamber_of_commerce_number = None - _vat_number = None - _request_reference_split_the_bill = None - _status_field_for_request = None - _description_field_for_request = None - _external_url_field_for_request = None + _sub_status = None + _subscription_type_field_for_request = None - def __init__(self, status=None, description=None, external_url=None): + def __init__(self, subscription_type): """ - :param status: The status of the invoice. - :type status: str - :param description: The description provided by the admin. - :type description: str - :param external_url: The external url provided by the admin. - :type external_url: str + :param subscription_type: The subscription type of the user. Can be one of + PERSON_LIGHT_V1, PERSON_MORE_V1, PERSON_FREE_V1, PERSON_PREMIUM_V1, + COMPANY_V1, or COMPANY_V2. + :type subscription_type: str """ - self._status_field_for_request = status - self._description_field_for_request = description - self._external_url_field_for_request = external_url + self._subscription_type_field_for_request = subscription_type @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ + Get all subscription billing contract for the authenticated user. + :type user_id: int - :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInvoiceList + :rtype: BunqResponseBillingContractSubscriptionList """ if params is None: @@ -122,42 +90,14 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseInvoiceList.cast_from_bunq_response( + return BunqResponseBillingContractSubscriptionList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, invoice_id, monetary_account_id=None, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type invoice_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInvoice - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - invoice_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseInvoice.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -183,116 +123,60 @@ def updated(self): return self._updated @property - def invoice_date(self): - """ - :rtype: str - """ - - return self._invoice_date - - @property - def invoice_number(self): + def contract_date_start(self): """ :rtype: str """ - return self._invoice_number + return self._contract_date_start @property - def status(self): + def contract_date_end(self): """ :rtype: str """ - return self._status - - @property - def group(self): - """ - :rtype: list[object_.InvoiceItemGroup] - """ - - return self._group - - @property - def total_vat_inclusive(self): - """ - :rtype: object_.Amount - """ - - return self._total_vat_inclusive - - @property - def total_vat_exclusive(self): - """ - :rtype: object_.Amount - """ - - return self._total_vat_exclusive - - @property - def total_vat(self): - """ - :rtype: object_.Amount - """ - - return self._total_vat - - @property - def alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._alias - - @property - def address(self): - """ - :rtype: object_.Address - """ - - return self._address + return self._contract_date_end @property - def counterparty_alias(self): + def contract_version(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: int """ - return self._counterparty_alias + return self._contract_version @property - def counterparty_address(self): + def subscription_type(self): """ - :rtype: object_.Address + :rtype: str """ - return self._counterparty_address + return self._subscription_type @property - def chamber_of_commerce_number(self): + def subscription_type_downgrade(self): """ :rtype: str """ - return self._chamber_of_commerce_number + return self._subscription_type_downgrade @property - def vat_number(self): + def status(self): """ :rtype: str """ - return self._vat_number + return self._status @property - def request_reference_split_the_bill(self): + def sub_status(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: str """ - return self._request_reference_split_the_bill + return self._sub_status def is_all_field_none(self): """ @@ -308,46 +192,25 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._invoice_date is not None: - return False - - if self._invoice_number is not None: - return False - - if self._status is not None: - return False - - if self._group is not None: - return False - - if self._total_vat_inclusive is not None: - return False - - if self._total_vat_exclusive is not None: - return False - - if self._total_vat is not None: - return False - - if self._alias is not None: + if self._contract_date_start is not None: return False - if self._address is not None: + if self._contract_date_end is not None: return False - if self._counterparty_alias is not None: + if self._contract_version is not None: return False - if self._counterparty_address is not None: + if self._subscription_type is not None: return False - if self._chamber_of_commerce_number is not None: + if self._subscription_type_downgrade is not None: return False - if self._vat_number is not None: + if self._status is not None: return False - if self._request_reference_split_the_bill is not None: + if self._sub_status is not None: return False return True @@ -357,85 +220,67 @@ def from_json(json_str): """ :type json_str: str - :rtype: Invoice + :rtype: BillingContractSubscriptionApiObject """ - return converter.json_to_class(Invoice, json_str) + return converter.json_to_class(BillingContractSubscriptionApiObject, json_str) -class InvoiceByUser(core.BunqModel): +class CustomerLimitApiObject(BunqModel): """ - Used to list bunq invoices by user. + Show the limits for the authenticated user. - :param _id_: The id of the invoice object. - :type _id_: int - :param _created: The timestamp of the invoice object's creation. - :type _created: str - :param _updated: The timestamp of the invoice object's last update. - :type _updated: str - :param _invoice_date: The invoice date. - :type _invoice_date: str - :param _invoice_number: The invoice number. - :type _invoice_number: str - :param _status: The invoice status. - :type _status: str - :param _group: The invoice item groups. - :type _group: list[object_.InvoiceItemGroup] - :param _total_vat_inclusive: The total discounted item price including VAT. - :type _total_vat_inclusive: object_.Amount - :param _total_vat_exclusive: The total discounted item price excluding VAT. - :type _total_vat_exclusive: object_.Amount - :param _total_vat: The VAT on the total discounted item price. - :type _total_vat: object_.Amount - :param _alias: The label that's displayed to the counterparty with the - invoice. Includes user. - :type _alias: object_.MonetaryAccountReference - :param _address: The customer's address. - :type _address: object_.Address - :param _counterparty_alias: The label of the counterparty of the invoice. - Includes user. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _counterparty_address: The company's address. - :type _counterparty_address: object_.Address - :param _chamber_of_commerce_number: The company's chamber of commerce - number. - :type _chamber_of_commerce_number: str - :param _vat_number: The company's chamber of commerce number. - :type _vat_number: str + :param _limit_monetary_account: The limit of monetary accounts. + :type _limit_monetary_account: int + :param _limit_monetary_account_remaining: The amount of additional monetary + accounts you can create. + :type _limit_monetary_account_remaining: int + :param _limit_card_debit_maestro: The limit of Maestro cards. + :type _limit_card_debit_maestro: int + :param _limit_card_debit_mastercard: The limit of MasterCard cards. + :type _limit_card_debit_mastercard: int + :param _limit_card_debit_wildcard: DEPRECTATED: The limit of wildcards, e.g. + Maestro or MasterCard cards. + :type _limit_card_debit_wildcard: int + :param _limit_card_wildcard: The limit of wildcards, e.g. Maestro or + MasterCard cards. + :type _limit_card_wildcard: int + :param _limit_card_replacement: The limit of free replacement cards. + :type _limit_card_replacement: int + :param _limit_amount_monthly: The maximum amount a user is allowed to spend + in a month. + :type _limit_amount_monthly: object_.Amount + :param _spent_amount_monthly: The amount the user has spent in the last + month. + :type _spent_amount_monthly: object_.Amount """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/invoice" - _ENDPOINT_URL_READ = "user/{}/invoice/{}" + _ENDPOINT_URL_LISTING = "user/{}/limit" # Object type. - _OBJECT_TYPE_GET = "Invoice" + _OBJECT_TYPE_GET = "CustomerLimit" - _id_ = None - _created = None - _updated = None - _invoice_date = None - _invoice_number = None - _status = None - _group = None - _total_vat_inclusive = None - _total_vat_exclusive = None - _total_vat = None - _alias = None - _address = None - _counterparty_alias = None - _counterparty_address = None - _chamber_of_commerce_number = None - _vat_number = None + _limit_monetary_account = None + _limit_monetary_account_remaining = None + _limit_card_debit_maestro = None + _limit_card_debit_mastercard = None + _limit_card_debit_wildcard = None + _limit_card_wildcard = None + _limit_card_replacement = None + _limit_amount_monthly = None + _spent_amount_monthly = None @classmethod def list(cls, params=None, custom_headers=None): """ + Get all limits for the authenticated user. + :type user_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInvoiceByUserList + :rtype: BunqResponseCustomerLimitList """ if params is None: @@ -444,217 +289,116 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseInvoiceByUserList.cast_from_bunq_response( + return BunqResponseCustomerLimitList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, invoice_by_user_id, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type invoice_by_user_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInvoiceByUser - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - invoice_by_user_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseInvoiceByUser.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property - def id_(self): + def limit_monetary_account(self): """ :rtype: int """ - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created + return self._limit_monetary_account @property - def updated(self): + def limit_monetary_account_remaining(self): """ - :rtype: str + :rtype: int """ - return self._updated + return self._limit_monetary_account_remaining @property - def invoice_date(self): + def limit_card_debit_maestro(self): """ - :rtype: str + :rtype: int """ - return self._invoice_date + return self._limit_card_debit_maestro @property - def invoice_number(self): + def limit_card_debit_mastercard(self): """ - :rtype: str + :rtype: int """ - return self._invoice_number + return self._limit_card_debit_mastercard @property - def status(self): + def limit_card_debit_wildcard(self): """ - :rtype: str + :rtype: int """ - return self._status + return self._limit_card_debit_wildcard @property - def group(self): + def limit_card_wildcard(self): """ - :rtype: list[object_.InvoiceItemGroup] + :rtype: int """ - return self._group + return self._limit_card_wildcard @property - def total_vat_inclusive(self): + def limit_card_replacement(self): """ - :rtype: object_.Amount + :rtype: int """ - return self._total_vat_inclusive + return self._limit_card_replacement @property - def total_vat_exclusive(self): + def limit_amount_monthly(self): """ :rtype: object_.Amount """ - return self._total_vat_exclusive + return self._limit_amount_monthly @property - def total_vat(self): + def spent_amount_monthly(self): """ :rtype: object_.Amount """ - return self._total_vat - - @property - def alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._alias - - @property - def address(self): - """ - :rtype: object_.Address - """ - - return self._address - - @property - def counterparty_alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._counterparty_alias - - @property - def counterparty_address(self): - """ - :rtype: object_.Address - """ - - return self._counterparty_address - - @property - def chamber_of_commerce_number(self): - """ - :rtype: str - """ - - return self._chamber_of_commerce_number - - @property - def vat_number(self): - """ - :rtype: str - """ - - return self._vat_number + return self._spent_amount_monthly def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._invoice_date is not None: - return False - - if self._invoice_number is not None: - return False - - if self._status is not None: - return False - - if self._group is not None: - return False - - if self._total_vat_inclusive is not None: + if self._limit_monetary_account is not None: return False - if self._total_vat_exclusive is not None: + if self._limit_monetary_account_remaining is not None: return False - if self._total_vat is not None: + if self._limit_card_debit_maestro is not None: return False - if self._alias is not None: + if self._limit_card_debit_mastercard is not None: return False - if self._address is not None: + if self._limit_card_debit_wildcard is not None: return False - if self._counterparty_alias is not None: + if self._limit_card_wildcard is not None: return False - if self._counterparty_address is not None: + if self._limit_card_replacement is not None: return False - if self._chamber_of_commerce_number is not None: + if self._limit_amount_monthly is not None: return False - if self._vat_number is not None: + if self._spent_amount_monthly is not None: return False return True @@ -664,217 +408,192 @@ def from_json(json_str): """ :type json_str: str - :rtype: InvoiceByUser + :rtype: CustomerLimitApiObject """ - return converter.json_to_class(InvoiceByUser, json_str) + return converter.json_to_class(CustomerLimitApiObject, json_str) -class AttachmentConversationContent(core.BunqModel): +class InvoiceExportPdfApiObject(BunqModel): """ - Fetch the raw content of an attachment with given ID. The raw content is the - base64 of a file, without any JSON wrapping. + Get a PDF export of an invoice. + + :param _id_: The id of the invoice export model. + :type _id_: int + :param _created: The timestamp of the invoice export's creation. + :type _created: str + :param _updated: The timestamp of the invoice export's last update. + :type _updated: str + :param _status: The status of the invoice export. + :type _status: str """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/chat-conversation/{}/attachment/{}/content" + _ENDPOINT_URL_READ = "user/{}/invoice/{}/invoice-export/{}" + _ENDPOINT_URL_CREATE = "user/{}/invoice/{}/invoice-export" + _ENDPOINT_URL_UPDATE = "user/{}/invoice/{}/invoice-export/{}" + _ENDPOINT_URL_DELETE = "user/{}/invoice/{}/invoice-export/{}" # Object type. - _OBJECT_TYPE_GET = "AttachmentConversationContent" + _OBJECT_TYPE_GET = "InvoiceExportPdf" + + _id_ = None + _created = None + _updated = None + _status = None @classmethod - def list(cls, chat_conversation_id, attachment_id, custom_headers=None): + def get(cls, invoice_id, invoice_export_pdf_id, custom_headers=None): """ - Get the raw content of a specific attachment. - + :type api_context: ApiContext :type user_id: int - :type chat_conversation_id: int - :type attachment_id: int + :type invoice_id: int + :type invoice_export_pdf_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBytes + :rtype: BunqResponseInvoiceExportPdf """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), chat_conversation_id, attachment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), invoice_id, invoice_export_pdf_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) + return BunqResponseInvoiceExportPdf.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - def is_all_field_none(self): - """ - :rtype: bool - """ - - return True - - @staticmethod - def from_json(json_str): + @classmethod + def create(cls,invoice_id, custom_headers=None): """ - :type json_str: str + :type user_id: int + :type invoice_id: int + :type custom_headers: dict[str, str]|None - :rtype: AttachmentConversationContent + :rtype: BunqResponseInt """ - return converter.json_to_class(AttachmentConversationContent, json_str) + if custom_headers is None: + custom_headers = {} + request_map = { -class AttachmentPublicContent(core.BunqModel): - """ - Fetch the raw content of a public attachment with given ID. The raw content - is the binary representation of a file, without any JSON wrapping. - """ +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - # Endpoint constants. - _ENDPOINT_URL_LISTING = "attachment-public/{}/content" + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), invoice_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - # Object type. - _OBJECT_TYPE_GET = "AttachmentPublicContent" + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) @classmethod - def list(cls, attachment_public_uuid, custom_headers=None): + def update(cls, invoice_id, invoice_export_pdf_id, custom_headers=None): """ - Get the raw content of a specific attachment. - - :type attachment_public_uuid: str + :type user_id: int + :type invoice_id: int + :type invoice_export_pdf_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBytes + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format(attachment_public_uuid) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) - - def is_all_field_none(self): - """ - :rtype: bool - """ - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: AttachmentPublicContent - """ - - return converter.json_to_class(AttachmentPublicContent, json_str) + api_client = ApiClient(cls._get_api_context()) + request_map = { -class AttachmentTabContent(core.BunqModel): - """ - Fetch the raw content of a tab attachment with given ID. The raw content is - the binary representation of a file, without any JSON wrapping. - """ +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/attachment-tab/{}/content" + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), invoice_id, invoice_export_pdf_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - # Object type. - _OBJECT_TYPE_GET = "AttachmentTabContent" + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) @classmethod - def list(cls, attachment_tab_id, monetary_account_id=None, - custom_headers=None): + def delete(cls, invoice_id, invoice_export_pdf_id, custom_headers=None): """ - Get the raw content of a specific attachment. - :type user_id: int - :type monetary_account_id: int - :type attachment_tab_id: int + :type invoice_id: int + :type invoice_export_pdf_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBytes + :rtype: BunqResponseNone """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - attachment_tab_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), invoice_id, invoice_export_pdf_id) + response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) ) - def is_all_field_none(self): + @property + def id_(self): """ - :rtype: bool + :rtype: int """ - return True + return self._id_ - @staticmethod - def from_json(json_str): + @property + def created(self): """ - :type json_str: str - - :rtype: AttachmentTabContent + :rtype: str """ - return converter.json_to_class(AttachmentTabContent, json_str) - - -class TabAttachmentTabContent(core.BunqModel): - """ - Fetch the raw content of a tab attachment with given ID. The raw content is - the binary representation of a file, without any JSON wrapping. - """ - - # Endpoint constants. - _ENDPOINT_URL_LISTING = "tab/{}/attachment/{}/content" - - # Object type. - _OBJECT_TYPE_GET = "TabAttachmentTabContent" + return self._created - @classmethod - def list(cls, tab_uuid, attachment_id, custom_headers=None): + @property + def updated(self): """ - Get the raw content of a specific attachment. - - :type tab_uuid: str - :type attachment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._updated - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format(tab_uuid, attachment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def status(self): + """ + :rtype: str + """ - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) + return self._status def is_all_field_none(self): """ :rtype: bool """ + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._status is not None: + return False + return True @staticmethod @@ -882,88 +601,50 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabAttachmentTabContent + :rtype: InvoiceExportPdfApiObject """ - return converter.json_to_class(TabAttachmentTabContent, json_str) + return converter.json_to_class(InvoiceExportPdfApiObject, json_str) -class AttachmentMonetaryAccount(core.BunqModel): +class InvoiceExportPdfContentApiObject(BunqModel): """ - This call is used to upload an attachment that can be referenced to in - payment requests and payments sent from a specific monetary account. - Attachments supported are png, jpg and gif. - - :param _attachment: The attachment. - :type _attachment: object_.Attachment - :param _id_: The ID of the attachment created. - :type _id_: int + Get a PDF export of an invoice. """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/attachment" + _ENDPOINT_URL_LISTING = "user/{}/invoice/{}/pdf-content" - _attachment = None - _id_ = None + # Object type. + _OBJECT_TYPE_GET = "InvoiceExportPdfContent" @classmethod - def create(cls, request_bytes, monetary_account_id=None, - custom_headers=None): + def list(cls, invoice_id, custom_headers=None): """ - Create a new monetary account attachment. Create a POST request with a - payload that contains the binary representation of the file, without any - JSON wrapping. Make sure you define the MIME type (i.e. image/jpeg) in - the Content-Type header. You are required to provide a description of - the attachment using the X-Bunq-Attachment-Description header. - :type user_id: int - :type monetary_account_id: int + :type invoice_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseBytes """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), invoice_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) ) - @property - def attachment(self): - """ - :rtype: object_.Attachment - """ - - return self._attachment - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ def is_all_field_none(self): """ :rtype: bool """ - if self._attachment is not None: - return False - - if self._id_ is not None: - return False - return True @staticmethod @@ -971,100 +652,166 @@ def from_json(json_str): """ :type json_str: str - :rtype: AttachmentMonetaryAccount + :rtype: InvoiceExportPdfContentApiObject """ - return converter.json_to_class(AttachmentMonetaryAccount, json_str) + return converter.json_to_class(InvoiceExportPdfContentApiObject, json_str) -class AttachmentPublic(core.BunqModel): +class InvoiceApiObject(BunqModel): """ - This call is used to upload an attachment that can be referenced to as an - avatar (through the Avatar endpoint) or in a tab sent. Attachments supported - are png, jpg and gif. + Used to view a bunq invoice. - :param _uuid: The UUID of the attachment. - :type _uuid: str - :param _created: The timestamp of the attachment's creation. + :param _status: The invoice status. + :type _status: str + :param _description: The description provided by the admin. + :type _description: str + :param _external_url: The external url provided by the admin. + :type _external_url: str + :param _id_: The id of the invoice object. + :type _id_: int + :param _created: The timestamp of the invoice object's creation. :type _created: str - :param _updated: The timestamp of the attachment's last update. + :param _updated: The timestamp of the invoice object's last update. :type _updated: str - :param _attachment: The attachment. - :type _attachment: object_.Attachment + :param _invoice_date: The invoice date. + :type _invoice_date: str + :param _invoice_number: The invoice number. + :type _invoice_number: str + :param _category: The category to display to the user. + :type _category: str + :param _group: The invoice item groups. + :type _group: list[object_.InvoiceItemGroup] + :param _total_vat_inclusive: The total discounted item price including VAT. + :type _total_vat_inclusive: object_.Amount + :param _total_vat_exclusive: The total discounted item price excluding VAT. + :type _total_vat_exclusive: object_.Amount + :param _total_vat: The VAT on the total discounted item price. + :type _total_vat: object_.Amount + :param _alias: The label that's displayed to the counterparty with the + invoice. Includes user. + :type _alias: object_.MonetaryAccountReference + :param _address: The customer's address. + :type _address: object_.Address + :param _counterparty_alias: The label of the counterparty of the invoice. + Includes user. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _counterparty_address: The company's address. + :type _counterparty_address: object_.Address + :param _chamber_of_commerce_number: The company's chamber of commerce + number. + :type _chamber_of_commerce_number: str + :param _vat_number: The company's chamber of commerce number. + :type _vat_number: str + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "attachment-public" - _ENDPOINT_URL_READ = "attachment-public/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/invoice" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/invoice/{}" + + # Field constants. + FIELD_STATUS = "status" + FIELD_DESCRIPTION = "description" + FIELD_EXTERNAL_URL = "external_url" # Object type. - _OBJECT_TYPE_POST = "Uuid" - _OBJECT_TYPE_GET = "AttachmentPublic" + _OBJECT_TYPE_GET = "Invoice" - _uuid = None + _id_ = None _created = None _updated = None - _attachment = None + _invoice_date = None + _invoice_number = None + _status = None + _category = None + _group = None + _total_vat_inclusive = None + _total_vat_exclusive = None + _total_vat = None + _alias = None + _address = None + _counterparty_alias = None + _counterparty_address = None + _chamber_of_commerce_number = None + _vat_number = None + _request_reference_split_the_bill = None + _status_field_for_request = None + _description_field_for_request = None + _external_url_field_for_request = None + + def __init__(self, status=None, description=None, external_url=None): + """ + :param status: The status of the invoice. + :type status: str + :param description: The description provided by the admin. + :type description: str + :param external_url: The external url provided by the admin. + :type external_url: str + """ + + self._status_field_for_request = status + self._description_field_for_request = description + self._external_url_field_for_request = external_url @classmethod - def create(cls, request_bytes, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Create a new public attachment. Create a POST request with a payload - that contains a binary representation of the file, without any JSON - wrapping. Make sure you define the MIME type (i.e. image/jpeg, or - image/png) in the Content-Type header. You are required to provide a - description of the attachment using the X-Bunq-Attachment-Description - header. - + :type user_id: int + :type monetary_account_id: int + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseStr + :rtype: BunqResponseInvoiceList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_CREATE - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) + return BunqResponseInvoiceList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, attachment_public_uuid, custom_headers=None): + def get(cls, invoice_id, monetary_account_id=None, custom_headers=None): """ - Get a specific attachment's metadata through its UUID. The Content-Type - header of the response will describe the MIME type of the attachment - file. - - :type api_context: context.ApiContext - :type attachment_public_uuid: str + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type invoice_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseAttachmentPublic + :rtype: BunqResponseInvoice """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(attachment_public_uuid) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), invoice_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseAttachmentPublic.cast_from_bunq_response( + return BunqResponseInvoice.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @property - def uuid(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._uuid + return self._id_ @property def created(self): @@ -1083,164 +830,124 @@ def updated(self): return self._updated @property - def attachment(self): + def invoice_date(self): """ - :rtype: object_.Attachment + :rtype: str """ - return self._attachment + return self._invoice_date - def is_all_field_none(self): + @property + def invoice_number(self): """ - :rtype: bool + :rtype: str """ - if self._uuid is not None: - return False + return self._invoice_number - if self._created is not None: - return False + @property + def status(self): + """ + :rtype: str + """ - if self._updated is not None: - return False + return self._status - if self._attachment is not None: - return False + @property + def category(self): + """ + :rtype: str + """ - return True + return self._category - @staticmethod - def from_json(json_str): + @property + def group(self): """ - :type json_str: str - - :rtype: AttachmentPublic + :rtype: list[object_.InvoiceItemGroup] """ - return converter.json_to_class(AttachmentPublic, json_str) - + return self._group -class AttachmentTab(core.BunqModel): - """ - This call is used to upload an attachment that will be accessible only - through tabs. This can be used for example to upload special promotions or - other attachments. Attachments supported are png, jpg and gif. - - :param _id_: The id of the attachment. - :type _id_: int - :param _created: The timestamp of the attachment's creation. - :type _created: str - :param _updated: The timestamp of the attachment's last update. - :type _updated: str - :param _attachment: The attachment. - :type _attachment: object_.Attachment - """ + @property + def total_vat_inclusive(self): + """ + :rtype: object_.Amount + """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/attachment-tab" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/attachment-tab/{}" + return self._total_vat_inclusive - # Object type. - _OBJECT_TYPE_GET = "AttachmentTab" + @property + def total_vat_exclusive(self): + """ + :rtype: object_.Amount + """ - _id_ = None - _created = None - _updated = None - _attachment = None + return self._total_vat_exclusive - @classmethod - def create(cls, request_bytes, monetary_account_id=None, - custom_headers=None): + @property + def total_vat(self): """ - Upload a new attachment to use with a tab, and to read its metadata. - Create a POST request with a payload that contains the binary - representation of the file, without any JSON wrapping. Make sure you - define the MIME type (i.e. image/jpeg) in the Content-Type header. You - are required to provide a description of the attachment using the - X-Bunq-Attachment-Description header. - - :type user_id: int - :type monetary_account_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} + return self._total_vat - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._alias - @classmethod - def get(cls, attachment_tab_id, monetary_account_id=None, - custom_headers=None): + @property + def address(self): """ - Get a specific attachment. The header of the response contains the - content-type of the attachment. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type attachment_tab_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseAttachmentTab + :rtype: object_.Address """ - if custom_headers is None: - custom_headers = {} + return self._address - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - attachment_tab_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseAttachmentTab.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._counterparty_alias @property - def id_(self): + def counterparty_address(self): """ - :rtype: int + :rtype: object_.Address """ - return self._id_ + return self._counterparty_address @property - def created(self): + def chamber_of_commerce_number(self): """ :rtype: str """ - return self._created + return self._chamber_of_commerce_number @property - def updated(self): + def vat_number(self): """ :rtype: str """ - return self._updated + return self._vat_number @property - def attachment(self): + def request_reference_split_the_bill(self): """ - :rtype: object_.Attachment + :rtype: list[object_.RequestInquiryReference] """ - return self._attachment + return self._request_reference_split_the_bill def is_all_field_none(self): """ @@ -1256,7 +963,49 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._attachment is not None: + if self._invoice_date is not None: + return False + + if self._invoice_number is not None: + return False + + if self._status is not None: + return False + + if self._category is not None: + return False + + if self._group is not None: + return False + + if self._total_vat_inclusive is not None: + return False + + if self._total_vat_exclusive is not None: + return False + + if self._total_vat is not None: + return False + + if self._alias is not None: + return False + + if self._address is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._counterparty_address is not None: + return False + + if self._chamber_of_commerce_number is not None: + return False + + if self._vat_number is not None: + return False + + if self._request_reference_split_the_bill is not None: return False return True @@ -1266,60 +1015,120 @@ def from_json(json_str): """ :type json_str: str - :rtype: AttachmentTab + :rtype: InvoiceApiObject """ - return converter.json_to_class(AttachmentTab, json_str) + return converter.json_to_class(InvoiceApiObject, json_str) -class TabAttachmentTab(core.BunqModel): +class InvoiceByUserApiObject(BunqModel): """ - This call is used to view an attachment that is linked to a tab. + Used to list bunq invoices by user. - :param _id_: The id of the attachment. + :param _id_: The id of the invoice object. :type _id_: int - :param _created: The timestamp of the attachment's creation. + :param _created: The timestamp of the invoice object's creation. :type _created: str - :param _updated: The timestamp of the attachment's last update. + :param _updated: The timestamp of the invoice object's last update. :type _updated: str - :param _attachment: The attachment. - :type _attachment: object_.Attachment + :param _invoice_date: The invoice date. + :type _invoice_date: str + :param _invoice_number: The invoice number. + :type _invoice_number: str + :param _status: The invoice status. + :type _status: str + :param _group: The invoice item groups. + :type _group: list[object_.InvoiceItemGroup] + :param _total_vat_inclusive: The total discounted item price including VAT. + :type _total_vat_inclusive: object_.Amount + :param _total_vat_exclusive: The total discounted item price excluding VAT. + :type _total_vat_exclusive: object_.Amount + :param _total_vat: The VAT on the total discounted item price. + :type _total_vat: object_.Amount + :param _alias: The label that's displayed to the counterparty with the + invoice. Includes user. + :type _alias: object_.MonetaryAccountReference + :param _address: The customer's address. + :type _address: object_.Address + :param _counterparty_alias: The label of the counterparty of the invoice. + Includes user. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _counterparty_address: The company's address. + :type _counterparty_address: object_.Address + :param _chamber_of_commerce_number: The company's chamber of commerce + number. + :type _chamber_of_commerce_number: str + :param _vat_number: The company's chamber of commerce number. + :type _vat_number: str """ # Endpoint constants. - _ENDPOINT_URL_READ = "tab/{}/attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/invoice" + _ENDPOINT_URL_READ = "user/{}/invoice/{}" # Object type. - _OBJECT_TYPE_GET = "TabAttachmentTab" + _OBJECT_TYPE_GET = "Invoice" _id_ = None _created = None _updated = None - _attachment = None + _invoice_date = None + _invoice_number = None + _status = None + _group = None + _total_vat_inclusive = None + _total_vat_exclusive = None + _total_vat = None + _alias = None + _address = None + _counterparty_alias = None + _counterparty_address = None + _chamber_of_commerce_number = None + _vat_number = None @classmethod - def get(cls, tab_uuid, tab_attachment_tab_id, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Get a specific attachment. The header of the response contains the - content-type of the attachment. + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None - :type api_context: context.ApiContext - :type tab_uuid: str - :type tab_attachment_tab_id: int + :rtype: BunqResponseInvoiceByUserList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseInvoiceByUserList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, invoice_by_user_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type invoice_by_user_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseTabAttachmentTab + :rtype: BunqResponseInvoiceByUser """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(tab_uuid, - tab_attachment_tab_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), invoice_by_user_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseTabAttachmentTab.cast_from_bunq_response( + return BunqResponseInvoiceByUser.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @@ -1348,334 +1157,222 @@ def updated(self): return self._updated @property - def attachment(self): + def invoice_date(self): """ - :rtype: object_.Attachment + :rtype: str """ - return self._attachment + return self._invoice_date - def is_all_field_none(self): + @property + def invoice_number(self): """ - :rtype: bool + :rtype: str """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._attachment is not None: - return False - - return True + return self._invoice_number - @staticmethod - def from_json(json_str): + @property + def status(self): """ - :type json_str: str - - :rtype: TabAttachmentTab + :rtype: str """ - return converter.json_to_class(TabAttachmentTab, json_str) + return self._status + @property + def group(self): + """ + :rtype: list[object_.InvoiceItemGroup] + """ -class Avatar(core.BunqModel): - """ - Avatars are public images used to represent you or your company. Avatars are - used to represent users, monetary accounts and cash registers. Avatars - cannot be deleted, only replaced. Avatars can be updated after uploading the - image you would like to use through AttachmentPublic. Using the - attachment_public_uuid which is returned you can update your Avatar. Avatars - used for cash registers and company accounts will be reviewed by bunq. - - :param _attachment_public_uuid: The public UUID of the public attachment - from which an avatar image must be created. - :type _attachment_public_uuid: str - :param _uuid: The UUID of the created avatar. - :type _uuid: str - :param _image: The content type of the image. - :type _image: list[object_.Image] - """ + return self._group - # Endpoint constants. - _ENDPOINT_URL_CREATE = "avatar" - _ENDPOINT_URL_READ = "avatar/{}" + @property + def total_vat_inclusive(self): + """ + :rtype: object_.Amount + """ - # Field constants. - FIELD_ATTACHMENT_PUBLIC_UUID = "attachment_public_uuid" + return self._total_vat_inclusive - # Object type. - _OBJECT_TYPE_POST = "Uuid" - _OBJECT_TYPE_GET = "Avatar" + @property + def total_vat_exclusive(self): + """ + :rtype: object_.Amount + """ - _uuid = None - _image = None - _attachment_public_uuid_field_for_request = None + return self._total_vat_exclusive - def __init__(self, attachment_public_uuid): + @property + def total_vat(self): """ - :param attachment_public_uuid: The public UUID of the public attachment from - which an avatar image must be created. - :type attachment_public_uuid: str + :rtype: object_.Amount """ - self._attachment_public_uuid_field_for_request = attachment_public_uuid + return self._total_vat - @classmethod - def create(cls, attachment_public_uuid, custom_headers=None): + @property + def alias(self): """ - :param attachment_public_uuid: The public UUID of the public attachment - from which an avatar image must be created. - :type attachment_public_uuid: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseStr + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_ATTACHMENT_PUBLIC_UUID: attachment_public_uuid - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._alias - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def address(self): + """ + :rtype: object_.Address + """ - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) - ) + return self._address - @classmethod - def get(cls, avatar_uuid, custom_headers=None): + @property + def counterparty_alias(self): """ - :type api_context: context.ApiContext - :type avatar_uuid: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseAvatar + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} + return self._counterparty_alias - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(avatar_uuid) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def counterparty_address(self): + """ + :rtype: object_.Address + """ - return BunqResponseAvatar.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._counterparty_address @property - def uuid(self): + def chamber_of_commerce_number(self): """ :rtype: str """ - return self._uuid + return self._chamber_of_commerce_number @property - def image(self): + def vat_number(self): """ - :rtype: list[object_.Image] + :rtype: str """ - return self._image + return self._vat_number def is_all_field_none(self): """ :rtype: bool """ - if self._uuid is not None: + if self._id_ is not None: return False - if self._image is not None: + if self._created is not None: return False - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: Avatar - """ + if self._updated is not None: + return False - return converter.json_to_class(Avatar, json_str) + if self._invoice_date is not None: + return False + if self._invoice_number is not None: + return False -class BunqMeTab(core.BunqModel): - """ - bunq.me tabs allows you to create a payment request and share the link - through e-mail, chat, etc. Multiple persons are able to respond to the - payment request and pay through bunq, iDeal or SOFORT. - - :param _bunqme_tab_entry: The bunq.me entry containing the payment - information. - :type _bunqme_tab_entry: BunqMeTabEntry - :param _status: The status of the bunq.me. Can be WAITING_FOR_PAYMENT, - CANCELLED or EXPIRED. - :type _status: str - :param _id_: The id of the created bunq.me. - :type _id_: int - :param _created: The timestamp when the bunq.me was created. - :type _created: str - :param _updated: The timestamp when the bunq.me was last updated. - :type _updated: str - :param _time_expiry: The timestamp of when the bunq.me expired or will - expire. - :type _time_expiry: str - :param _monetary_account_id: The id of the MonetaryAccount the bunq.me was - sent from. - :type _monetary_account_id: int - :param _bunqme_tab_share_url: The url that points to the bunq.me page. - :type _bunqme_tab_share_url: str - :param _result_inquiries: The list of bunq.me result Inquiries successfully - made and paid. - :type _result_inquiries: list[BunqMeTabResultInquiry] - """ + if self._status is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-tab" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-tab/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-tab" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-tab/{}" + if self._group is not None: + return False - # Field constants. - FIELD_BUNQME_TAB_ENTRY = "bunqme_tab_entry" - FIELD_STATUS = "status" + if self._total_vat_inclusive is not None: + return False - # Object type. - _OBJECT_TYPE_GET = "BunqMeTab" + if self._total_vat_exclusive is not None: + return False - _id_ = None - _created = None - _updated = None - _time_expiry = None - _monetary_account_id = None - _status = None - _bunqme_tab_share_url = None - _bunqme_tab_entry = None - _result_inquiries = None - _bunqme_tab_entry_field_for_request = None - _status_field_for_request = None + if self._total_vat is not None: + return False - def __init__(self, bunqme_tab_entry, status=None): - """ - :param bunqme_tab_entry: The bunq.me entry containing the payment - information. - :type bunqme_tab_entry: BunqMeTabEntry - :param status: The status of the bunq.me. Ignored in POST requests but can - be used for cancelling the bunq.me by setting status as CANCELLED with a PUT - request. - :type status: str - """ + if self._alias is not None: + return False - self._bunqme_tab_entry_field_for_request = bunqme_tab_entry - self._status_field_for_request = status + if self._address is not None: + return False - @classmethod - def create(cls, bunqme_tab_entry, monetary_account_id=None, status=None, - custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :param bunqme_tab_entry: The bunq.me entry containing the payment - information. - :type bunqme_tab_entry: BunqMeTabEntry - :param status: The status of the bunq.me. Ignored in POST requests but - can be used for cancelling the bunq.me by setting status as CANCELLED - with a PUT request. - :type status: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + if self._counterparty_alias is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._counterparty_address is not None: + return False - request_map = { - cls.FIELD_BUNQME_TAB_ENTRY: bunqme_tab_entry, - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._chamber_of_commerce_number is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._vat_number is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return True - @classmethod - def update(cls, bunq_me_tab_id, monetary_account_id=None, status=None, - custom_headers=None): + @staticmethod + def from_json(json_str): """ - :type user_id: int - :type monetary_account_id: int - :type bunq_me_tab_id: int - :param status: The status of the bunq.me. Ignored in POST requests but - can be used for cancelling the bunq.me by setting status as CANCELLED - with a PUT request. - :type status: str - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: InvoiceByUserApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(InvoiceByUserApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) +class AdditionalTransactionInformationCategoryApiObject(BunqModel): + """ + Get the available categories. + + :param _category: The category. + :type _category: str + :param _type_: Who created this category. + :type _type_: str + :param _status: Whether this category is active. Only relevant for + user-defined categories. + :type _status: str + :param _order: The sort order of the category. + :type _order: int + :param _description: The description of the category. + :type _description: str + :param _description_translated: The translation of the description of the + category. + :type _description_translated: str + :param _color: The color of the category. + :type _color: str + :param _icon: The icon of the category. + :type _icon: str + """ - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunq_me_tab_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/additional-transaction-information-category" - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + # Object type. + _OBJECT_TYPE_GET = "AdditionalTransactionInformationCategory" + + _category = None + _type_ = None + _status = None + _order = None + _description = None + _description_translated = None + _color = None + _icon = None @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ :type user_id: int - :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBunqMeTabList + :rtype: BunqResponseAdditionalTransactionInformationCategoryList """ if params is None: @@ -1684,144 +1381,105 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseBunqMeTabList.cast_from_bunq_response( + return BunqResponseAdditionalTransactionInformationCategoryList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, bunq_me_tab_id, monetary_account_id=None, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type bunq_me_tab_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBunqMeTab - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunq_me_tab_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseBunqMeTab.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - @property - def created(self): + def category(self): """ :rtype: str """ - return self._created + return self._category @property - def updated(self): + def type_(self): """ :rtype: str """ - return self._updated + return self._type_ @property - def time_expiry(self): + def status(self): """ :rtype: str """ - return self._time_expiry + return self._status @property - def monetary_account_id(self): + def order(self): """ :rtype: int """ - return self._monetary_account_id + return self._order @property - def status(self): + def description(self): """ :rtype: str """ - return self._status + return self._description @property - def bunqme_tab_share_url(self): + def description_translated(self): """ :rtype: str """ - return self._bunqme_tab_share_url + return self._description_translated @property - def bunqme_tab_entry(self): + def color(self): """ - :rtype: BunqMeTabEntry + :rtype: str """ - return self._bunqme_tab_entry + return self._color @property - def result_inquiries(self): + def icon(self): """ - :rtype: list[BunqMeTabResultInquiry] + :rtype: str """ - return self._result_inquiries + return self._icon def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: + if self._category is not None: return False - if self._updated is not None: + if self._type_ is not None: return False - if self._time_expiry is not None: + if self._status is not None: return False - if self._monetary_account_id is not None: + if self._order is not None: return False - if self._status is not None: + if self._description is not None: return False - if self._bunqme_tab_share_url is not None: + if self._description_translated is not None: return False - if self._bunqme_tab_entry is not None: + if self._color is not None: return False - if self._result_inquiries is not None: + if self._icon is not None: return False return True @@ -1831,151 +1489,278 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeTab + :rtype: AdditionalTransactionInformationCategoryApiObject """ - return converter.json_to_class(BunqMeTab, json_str) + return converter.json_to_class(AdditionalTransactionInformationCategoryApiObject, json_str) -class BunqMeTabEntry(core.BunqModel): +class AdditionalTransactionInformationCategoryUserDefinedApiObject(BunqModel): """ - bunq.me tabs allows you to create a payment request and share the link - through e-mail, chat, etc. Multiple persons are able to respond to the - payment request and pay through bunq, iDeal or SOFORT. + Manage user-defined categories. - :param _amount_inquired: The requested Amount. - :type _amount_inquired: object_.Amount - :param _description: The description for the bunq.me. Maximum 9000 - characters. - :type _description: str - :param _redirect_url: The URL which the user is sent to when a payment is - completed. - :type _redirect_url: str - :param _uuid: The uuid of the bunq.me. - :type _uuid: str - :param _alias: The LabelMonetaryAccount with the public information of the - User and the MonetaryAccount that created the bunq.me link. - :type _alias: object_.MonetaryAccountReference - :param _status: The status of the bunq.me. Can be WAITING_FOR_PAYMENT, - CANCELLED or EXPIRED. + :param _category: The category. + :type _category: str + :param _status: Whether this category is active. Only relevant for + user-defined categories. :type _status: str - :param _merchant_available: List of available merchants. - :type _merchant_available: list[object_.BunqMeMerchantAvailable] + :param _description: The description of the category. + :type _description: str + :param _color: The color of the category. + :type _color: str + :param _icon: The icon of the category. + :type _icon: str """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/additional-transaction-information-category-user-defined" + # Field constants. - FIELD_AMOUNT_INQUIRED = "amount_inquired" + FIELD_CATEGORY = "category" + FIELD_STATUS = "status" FIELD_DESCRIPTION = "description" - FIELD_REDIRECT_URL = "redirect_url" + FIELD_COLOR = "color" + FIELD_ICON = "icon" - _uuid = None - _amount_inquired = None - _alias = None - _description = None - _status = None - _redirect_url = None - _merchant_available = None - _amount_inquired_field_for_request = None + + _category_field_for_request = None + _status_field_for_request = None _description_field_for_request = None - _redirect_url_field_for_request = None + _color_field_for_request = None + _icon_field_for_request = None - def __init__(self, amount_inquired, description, redirect_url=None): + def __init__(self, status, category=None, description=None, color=None, icon=None): """ - :param amount_inquired: The Amount requested to be paid. Can be optional. - :type amount_inquired: object_.Amount - :param description: The description for the bunq.me. Maximum 9000 - characters. Field is required but can be an empty string. + :param status: Whether this category is active. Only relevant for + user-defined categories. + :type status: str + :param category: The category. + :type category: str + :param description: The description of the category. :type description: str - :param redirect_url: The URL which the user is sent to after making a - payment. - :type redirect_url: str + :param color: The color of the category. + :type color: str + :param icon: The icon of the category. + :type icon: str """ - self._amount_inquired_field_for_request = amount_inquired + self._status_field_for_request = status + self._category_field_for_request = category self._description_field_for_request = description - self._redirect_url_field_for_request = redirect_url + self._color_field_for_request = color + self._icon_field_for_request = icon - @property - def uuid(self): + @classmethod + def create(cls,status, category=None, description=None, color=None, icon=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :param status: Whether this category is active. Only relevant for + user-defined categories. + :type status: str + :param category: The category. + :type category: str + :param description: The description of the category. + :type description: str + :param color: The color of the category. + :type color: str + :param icon: The icon of the category. + :type icon: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._uuid + if custom_headers is None: + custom_headers = {} - @property - def amount_inquired(self): + request_map = { +cls.FIELD_CATEGORY : category, +cls.FIELD_STATUS : status, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_COLOR : color, +cls.FIELD_ICON : icon +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._amount_inquired + return True - @property - def alias(self): + @staticmethod + def from_json(json_str): """ - :rtype: object_.MonetaryAccountReference + :type json_str: str + + :rtype: AdditionalTransactionInformationCategoryUserDefinedApiObject """ - return self._alias + return converter.json_to_class(AdditionalTransactionInformationCategoryUserDefinedApiObject, json_str) - @property - def description(self): + +class AttachmentConversationContentApiObject(BunqModel): + """ + Fetch the raw content of an attachment with given ID. The raw content is the + base64 of a file, without any JSON wrapping. + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/chat-conversation/{}/attachment/{}/content" + + # Object type. + _OBJECT_TYPE_GET = "AttachmentConversationContent" + + @classmethod + def list(cls, chat_conversation_id, attachment_id, custom_headers=None): """ - :rtype: str + Get the raw content of a specific attachment. + + :type user_id: int + :type chat_conversation_id: int + :type attachment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return self._description + if custom_headers is None: + custom_headers = {} - @property - def status(self): + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), chat_conversation_id, attachment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) + + + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._status + return True - @property - def redirect_url(self): + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: AttachmentConversationContentApiObject """ - return self._redirect_url + return converter.json_to_class(AttachmentConversationContentApiObject, json_str) - @property - def merchant_available(self): + +class AttachmentMonetaryAccountContentApiObject(BunqModel): + """ + Fetch the raw content of a monetary account attachment with given ID. The + raw content is the binary representation of a file, without any JSON + wrapping. + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/attachment/{}/content" + + # Object type. + _OBJECT_TYPE_GET = "AttachmentMonetaryAccountContent" + + @classmethod + def list(cls, attachment_id, monetary_account_id=None, custom_headers=None): """ - :rtype: list[object_.BunqMeMerchantAvailable] + Get the raw content of a specific attachment. + + :type user_id: int + :type monetary_account_id: int + :type attachment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return self._merchant_available + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), attachment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) + def is_all_field_none(self): """ :rtype: bool """ - if self._uuid is not None: - return False + return True - if self._amount_inquired is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AttachmentMonetaryAccountContentApiObject + """ - if self._alias is not None: - return False + return converter.json_to_class(AttachmentMonetaryAccountContentApiObject, json_str) - if self._description is not None: - return False - if self._status is not None: - return False +class AttachmentPublicContentApiObject(BunqModel): + """ + Fetch the raw content of a public attachment with given ID. The raw content + is the binary representation of a file, without any JSON wrapping. + """ - if self._redirect_url is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "attachment-public/{}/content" - if self._merchant_available is not None: - return False + # Object type. + _OBJECT_TYPE_GET = "AttachmentPublicContent" + + @classmethod + def list(cls, attachment_public_uuid, custom_headers=None): + """ + Get the raw content of a specific attachment. + + :type attachment_public_uuid: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(attachment_public_uuid) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) + + + def is_all_field_none(self): + """ + :rtype: bool + """ return True @@ -1984,55 +1769,53 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeTabEntry + :rtype: AttachmentPublicContentApiObject """ - return converter.json_to_class(BunqMeTabEntry, json_str) + return converter.json_to_class(AttachmentPublicContentApiObject, json_str) -class BunqMeTabResultInquiry(core.BunqModel): +class AttachmentUserContentApiObject(BunqModel): """ - Used to view bunq.me TabResultInquiry objects belonging to a tab. A - TabResultInquiry is an object that holds details on both the tab and a - single payment made for that tab. - - :param _payment: The payment made for the Tab. - :type _payment: Payment - :param _bunq_me_tab_id: The Id of the bunq.me tab that this - BunqMeTabResultInquiry belongs to. - :type _bunq_me_tab_id: int + Fetch the raw content of a user attachment with given ID. The raw content is + the binary representation of a file, without any JSON wrapping. """ - _payment = None - _bunq_me_tab_id = None + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/attachment/{}/content" - @property - def payment(self): + # Object type. + _OBJECT_TYPE_GET = "AttachmentUserContent" + + @classmethod + def list(cls, attachment_id, custom_headers=None): """ - :rtype: Payment + Get the raw content of a specific attachment. + + :type user_id: int + :type attachment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return self._payment + if custom_headers is None: + custom_headers = {} - @property - def bunq_me_tab_id(self): - """ - :rtype: int - """ + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), attachment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) - return self._bunq_me_tab_id def is_all_field_none(self): """ :rtype: bool """ - if self._payment is not None: - return False - - if self._bunq_me_tab_id is not None: - return False - return True @staticmethod @@ -2040,189 +1823,42 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeTabResultInquiry + :rtype: AttachmentUserContentApiObject """ - return converter.json_to_class(BunqMeTabResultInquiry, json_str) + return converter.json_to_class(AttachmentUserContentApiObject, json_str) -class Payment(core.BunqModel): +class AttachmentMonetaryAccountApiObject(BunqModel): """ - Using Payment, you can send payments to bunq and non-bunq users from your - bunq MonetaryAccounts. This can be done using bunq Aliases or IBAN Aliases. - When transferring money to other bunq MonetaryAccounts you can also refer to - Attachments. These will be received by the counter-party as part of the - Payment. You can also retrieve a single Payment or all executed Payments of - a specific monetary account. + This call is used to upload an attachment that can be referenced to in + payment requests and payments sent from a specific monetary account. + Attachments supported are png, jpg and gif. - :param _amount: The Amount transferred by the Payment. Will be negative for - outgoing Payments and positive for incoming Payments (relative to the - MonetaryAccount indicated by monetary_account_id). - :type _amount: object_.Amount - :param _counterparty_alias: The LabelMonetaryAccount containing the public - information of the other (counterparty) side of the Payment. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _description: The description for the Payment. Maximum 140 characters - for Payments to external IBANs, 9000 characters for Payments to only other - bunq MonetaryAccounts. - :type _description: str - :param _attachment: The Attachments attached to the Payment. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] - :param _merchant_reference: Optional data included with the Payment specific - to the merchant. - :type _merchant_reference: str - :param _id_: The id of the created Payment. + :param _attachment: The attachment. + :type _attachment: object_.Attachment + :param _id_: The ID of the attachment created. :type _id_: int - :param _created: The timestamp when the Payment was done. - :type _created: str - :param _updated: The timestamp when the Payment was last updated (will be - updated when chat messages are received). - :type _updated: str - :param _monetary_account_id: The id of the MonetaryAccount the Payment was - made to or from (depending on whether this is an incoming or outgoing - Payment). - :type _monetary_account_id: int - :param _alias: The LabelMonetaryAccount containing the public information of - 'this' (party) side of the Payment. - :type _alias: object_.MonetaryAccountReference - :param _type_: The type of Payment, can be BUNQ, EBA_SCT, EBA_SDD, IDEAL, - SWIFT or FIS (card). - :type _type_: str - :param _sub_type: The sub-type of the Payment, can be PAYMENT, WITHDRAWAL, - REVERSAL, REQUEST, BILLING, SCT, SDD or NLO. - :type _sub_type: str - :param _bunqto_status: The status of the bunq.to payment. - :type _bunqto_status: str - :param _bunqto_sub_status: The sub status of the bunq.to payment. - :type _bunqto_sub_status: str - :param _bunqto_share_url: The status of the bunq.to payment. - :type _bunqto_share_url: str - :param _bunqto_expiry: When bunq.to payment is about to expire. - :type _bunqto_expiry: str - :param _bunqto_time_responded: The timestamp of when the bunq.to payment was - responded to. - :type _bunqto_time_responded: str - :param _batch_id: The id of the PaymentBatch if this Payment was part of - one. - :type _batch_id: int - :param _scheduled_id: The id of the JobScheduled if the Payment was - scheduled. - :type _scheduled_id: int - :param _address_shipping: A shipping Address provided with the Payment, - currently unused. - :type _address_shipping: object_.Address - :param _address_billing: A billing Address provided with the Payment, - currently unused. - :type _address_billing: object_.Address - :param _geolocation: The Geolocation where the Payment was done from. - :type _geolocation: object_.Geolocation - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment" - - # Field constants. - FIELD_AMOUNT = "amount" - FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT = "attachment" - FIELD_MERCHANT_REFERENCE = "merchant_reference" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/attachment" - # Object type. - _OBJECT_TYPE_GET = "Payment" - _id_ = None - _created = None - _updated = None - _monetary_account_id = None - _amount = None - _alias = None - _counterparty_alias = None - _description = None - _type_ = None - _sub_type = None - _bunqto_status = None - _bunqto_sub_status = None - _bunqto_share_url = None - _bunqto_expiry = None - _bunqto_time_responded = None _attachment = None - _merchant_reference = None - _batch_id = None - _scheduled_id = None - _address_shipping = None - _address_billing = None - _geolocation = None - _allow_chat = None - _request_reference_split_the_bill = None - _amount_field_for_request = None - _counterparty_alias_field_for_request = None - _description_field_for_request = None - _attachment_field_for_request = None - _merchant_reference_field_for_request = None - - def __init__(self, amount, counterparty_alias, description, attachment=None, - merchant_reference=None): - """ - :param amount: The Amount to transfer with the Payment. Must be bigger than - 0 and smaller than the MonetaryAccount's balance. - :type amount: object_.Amount - :param counterparty_alias: The Alias of the party we are transferring the - money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq - MonetaryAccounts or bunq.to payments) or IBAN (for external bank account). - :type counterparty_alias: object_.Pointer - :param description: The description for the Payment. Maximum 140 characters - for Payments to external IBANs, 9000 characters for Payments to only other - bunq MonetaryAccounts. Field is required but can be an empty string. - :type description: str - :param attachment: The Attachments to attach to the Payment. - :type attachment: list[object_.AttachmentMonetaryAccountPayment] - :param merchant_reference: Optional data to be included with the Payment - specific to the merchant. - :type merchant_reference: str - """ - - self._amount_field_for_request = amount - self._counterparty_alias_field_for_request = counterparty_alias - self._description_field_for_request = description - self._attachment_field_for_request = attachment - self._merchant_reference_field_for_request = merchant_reference + _id_ = None @classmethod - def create(cls, amount, counterparty_alias, description, - monetary_account_id=None, attachment=None, - merchant_reference=None, custom_headers=None): + def create(cls, request_bytes, monetary_account_id=None, custom_headers=None): """ - Create a new Payment. + Create a new monetary account attachment. Create a POST request with a + payload that contains the binary representation of the file, without any + JSON wrapping. Make sure you define the MIME type (i.e. image/jpeg) in + the Content-Type header. You are required to provide a description of + the attachment using the X-Bunq-Attachment-Description header. :type user_id: int :type monetary_account_id: int - :param amount: The Amount to transfer with the Payment. Must be bigger - than 0 and smaller than the MonetaryAccount's balance. - :type amount: object_.Amount - :param counterparty_alias: The Alias of the party we are transferring - the money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq - MonetaryAccounts or bunq.to payments) or IBAN (for external bank - account). - :type counterparty_alias: object_.Pointer - :param description: The description for the Payment. Maximum 140 - characters for Payments to external IBANs, 9000 characters for Payments - to only other bunq MonetaryAccounts. Field is required but can be an - empty string. - :type description: str - :param attachment: The Attachments to attach to the Payment. - :type attachment: list[object_.AttachmentMonetaryAccountPayment] - :param merchant_reference: Optional data to be included with the Payment - specific to the merchant. - :type merchant_reference: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -2231,93 +1867,141 @@ def create(cls, amount, counterparty_alias, description, if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_AMOUNT: amount, - cls.FIELD_COUNTERPARTY_ALIAS: counterparty_alias, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT: attachment, - cls.FIELD_MERCHANT_REFERENCE: merchant_reference - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) + @property + def attachment(self): + """ + :rtype: object_.Attachment + """ + + return self._attachment + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._attachment is not None: + return False + + if self._id_ is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AttachmentMonetaryAccountApiObject + """ + + return converter.json_to_class(AttachmentMonetaryAccountApiObject, json_str) + + +class AttachmentPublicApiObject(BunqModel): + """ + This call is used to upload an attachment that can be referenced to as an + avatar (through the Avatar endpoint) or in a tab sent. Attachments supported + are png, jpg and gif. + + :param _uuid: The UUID of the attachment. + :type _uuid: str + :param _created: The timestamp of the attachment's creation. + :type _created: str + :param _updated: The timestamp of the attachment's last update. + :type _updated: str + :param _attachment: The attachment. + :type _attachment: object_.Attachment + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "attachment-public" + _ENDPOINT_URL_READ = "attachment-public/{}" + + # Object type. + _OBJECT_TYPE_POST = "Uuid" + _OBJECT_TYPE_GET = "AttachmentPublic" + + _uuid = None + _created = None + _updated = None + _attachment = None + @classmethod - def get(cls, payment_id, monetary_account_id=None, custom_headers=None): + def create(cls, request_bytes, custom_headers=None): """ - Get a specific previous Payment. + Create a new public attachment. Create a POST request with a payload + that contains a binary representation of the file, without any JSON + wrapping. Make sure you define the MIME type (i.e. image/jpeg, or + image/png) in the Content-Type header. You are required to provide a + description of the attachment using the X-Bunq-Attachment-Description + header. - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponsePayment + :rtype: BunqResponseStr """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return BunqResponsePayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseStr.cast_from_bunq_response( + cls._process_for_uuid(response_raw) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def get(cls, attachment_public_uuid, custom_headers=None): """ - Get a listing of all Payments performed on a given MonetaryAccount - (incoming and outgoing). + Get a specific attachment's metadata through its UUID. The Content-Type + header of the response will describe the MIME type of the attachment + file. - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None + :type api_context: ApiContext + :type attachment_public_uuid: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponsePaymentList + :rtype: BunqResponseAttachmentPublic """ - if params is None: - params = {} - if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(attachment_public_uuid) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponsePaymentList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseAttachmentPublic.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @property - def id_(self): + def uuid(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._uuid @property def created(self): @@ -2336,248 +2020,274 @@ def updated(self): return self._updated @property - def monetary_account_id(self): + def attachment(self): """ - :rtype: int + :rtype: object_.Attachment """ - return self._monetary_account_id + return self._attachment - @property - def amount(self): + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._amount + if self._uuid is not None: + return False - @property - def alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ + if self._created is not None: + return False - return self._alias + if self._updated is not None: + return False - @property - def counterparty_alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ + if self._attachment is not None: + return False - return self._counterparty_alias + return True - @property - def description(self): + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: AttachmentPublicApiObject """ - return self._description + return converter.json_to_class(AttachmentPublicApiObject, json_str) - @property - def type_(self): - """ - :rtype: str - """ - return self._type_ +class AttachmentUserApiObject(BunqModel): + """ + This call is used to upload an attachment that is accessible only by a + specific user. This can be used for example to upload passport scans or + other documents. Attachments supported are png, jpg and gif. + + :param _id_: The id of the attachment. + :type _id_: int + :param _created: The timestamp of the attachment's creation. + :type _created: str + :param _updated: The timestamp of the attachment's last update. + :type _updated: str + :param _attachment: The attachment. + :type _attachment: object_.Attachment + """ - @property - def sub_type(self): - """ - :rtype: str - """ + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/attachment/{}" - return self._sub_type + # Object type. + _OBJECT_TYPE_GET = "AttachmentUser" - @property - def bunqto_status(self): + _id_ = None + _created = None + _updated = None + _attachment = None + + @classmethod + def get(cls, attachment_user_id, custom_headers=None): """ - :rtype: str + Get a specific attachment. The header of the response contains the + content-type of the attachment. + + :type api_context: ApiContext + :type user_id: int + :type attachment_user_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseAttachmentUser """ - return self._bunqto_status + if custom_headers is None: + custom_headers = {} - @property - def bunqto_sub_status(self): - """ - :rtype: str - """ + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), attachment_user_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return self._bunqto_sub_status + return BunqResponseAttachmentUser.cast_from_bunq_response( + cls._from_json(response_raw) + ) @property - def bunqto_share_url(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._bunqto_share_url + return self._id_ @property - def bunqto_expiry(self): + def created(self): """ :rtype: str """ - return self._bunqto_expiry + return self._created @property - def bunqto_time_responded(self): + def updated(self): """ :rtype: str """ - return self._bunqto_time_responded + return self._updated @property def attachment(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: object_.Attachment """ return self._attachment - @property - def merchant_reference(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._merchant_reference + if self._id_ is not None: + return False - @property - def batch_id(self): - """ - :rtype: int - """ + if self._created is not None: + return False - return self._batch_id + if self._updated is not None: + return False - @property - def scheduled_id(self): - """ - :rtype: int - """ + if self._attachment is not None: + return False - return self._scheduled_id + return True - @property - def address_shipping(self): + @staticmethod + def from_json(json_str): """ - :rtype: object_.Address + :type json_str: str + + :rtype: AttachmentUserApiObject """ - return self._address_shipping + return converter.json_to_class(AttachmentUserApiObject, json_str) - @property - def address_billing(self): - """ - :rtype: object_.Address - """ - return self._address_billing +class AvatarApiObject(BunqModel): + """ + Avatars are public images used to represent you or your company. Avatars are + used to represent users, monetary accounts and cash registers. Avatars + cannot be deleted, only replaced. Avatars can be updated after uploading the + image you would like to use through AttachmentPublic. Using the + attachment_public_uuid which is returned you can update your Avatar. Avatars + used for cash registers and company accounts will be reviewed by bunq. + + :param _attachment_public_uuid: The public UUID of the public attachment + from which an avatar image must be created. + :type _attachment_public_uuid: str + :param _uuid: The UUID of the created avatar. + :type _uuid: str + :param _image: The content type of the image. + :type _image: list[object_.Image] + """ - @property - def geolocation(self): - """ - :rtype: object_.Geolocation - """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "avatar" + _ENDPOINT_URL_READ = "avatar/{}" - return self._geolocation + # Field constants. + FIELD_ATTACHMENT_PUBLIC_UUID = "attachment_public_uuid" - @property - def allow_chat(self): - """ - :rtype: bool - """ + # Object type. + _OBJECT_TYPE_POST = "Uuid" + _OBJECT_TYPE_GET = "Avatar" - return self._allow_chat + _uuid = None + _image = None + _attachment_public_uuid_field_for_request = None - @property - def request_reference_split_the_bill(self): + def __init__(self, attachment_public_uuid): """ - :rtype: list[object_.RequestInquiryReference] + :param attachment_public_uuid: The public UUID of the public attachment from + which an avatar image must be created. + :type attachment_public_uuid: str """ - return self._request_reference_split_the_bill + self._attachment_public_uuid_field_for_request = attachment_public_uuid - def is_all_field_none(self): + @classmethod + def create(cls,attachment_public_uuid, custom_headers=None): """ - :rtype: bool + :param attachment_public_uuid: The public UUID of the public attachment + from which an avatar image must be created. + :type attachment_public_uuid: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseStr """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._monetary_account_id is not None: - return False - - if self._amount is not None: - return False - - if self._alias is not None: - return False - - if self._counterparty_alias is not None: - return False - - if self._description is not None: - return False - - if self._type_ is not None: - return False - - if self._sub_type is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._bunqto_status is not None: - return False + request_map = { +cls.FIELD_ATTACHMENT_PUBLIC_UUID : attachment_public_uuid +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - if self._bunqto_sub_status is not None: - return False + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - if self._bunqto_share_url is not None: - return False + return BunqResponseStr.cast_from_bunq_response( + cls._process_for_uuid(response_raw) + ) - if self._bunqto_expiry is not None: - return False + @classmethod + def get(cls, avatar_uuid, custom_headers=None): + """ + :type api_context: ApiContext + :type avatar_uuid: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseAvatar + """ - if self._bunqto_time_responded is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._attachment is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(avatar_uuid) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - if self._merchant_reference is not None: - return False + return BunqResponseAvatar.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) - if self._batch_id is not None: - return False + @property + def uuid(self): + """ + :rtype: str + """ - if self._scheduled_id is not None: - return False + return self._uuid - if self._address_shipping is not None: - return False + @property + def image(self): + """ + :rtype: list[object_.Image] + """ - if self._address_billing is not None: - return False + return self._image - if self._geolocation is not None: - return False + def is_all_field_none(self): + """ + :rtype: bool + """ - if self._allow_chat is not None: + if self._uuid is not None: return False - if self._request_reference_split_the_bill is not None: + if self._image is not None: return False return True @@ -2587,86 +2297,80 @@ def from_json(json_str): """ :type json_str: str - :rtype: Payment + :rtype: AvatarApiObject """ - return converter.json_to_class(Payment, json_str) + return converter.json_to_class(AvatarApiObject, json_str) -class CardBatch(core.BunqModel): +class BankSwitchServiceNetherlandsIncomingPaymentApiObject(BunqModel): """ - Used to update multiple cards in a batch. + An incoming payment made towards an account of an external bank and + redirected to a bunq account via switch service. - :param _cards: The cards that need to be updated. - :type _cards: list[object_.CardBatchEntry] - :param _updated_card_ids: The ids of the cards that have been updated. - :type _updated_card_ids: list[object_.BunqId] + :param _bank_switch_service: The bank switch service details. + :type _bank_switch_service: BankSwitchServiceNetherlandsIncoming + :param _payment: The payment made using bank switch service. + :type _payment: Payment """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/card-batch" - - # Field constants. - FIELD_CARDS = "cards" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/switch-service-payment/{}" # Object type. - _OBJECT_TYPE_POST = "CardBatch" + _OBJECT_TYPE_GET = "BankSwitchServiceNetherlandsIncomingPayment" - _updated_card_ids = None - _cards_field_for_request = None - - def __init__(self, cards): - """ - :param cards: The cards that need to be updated. - :type cards: list[object_.CardBatchEntry] - """ - - self._cards_field_for_request = cards + _bank_switch_service = None + _payment = None @classmethod - def create(cls, cards, custom_headers=None): + def get(cls, bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int - :param cards: The cards that need to be updated. - :type cards: list[object_.CardBatchEntry] + :type monetary_account_id: int + :type bank_switch_service_netherlands_incoming_payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCardBatch + :rtype: BunqResponseBankSwitchServiceNetherlandsIncomingPayment """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_CARDS: cards - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseCardBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + return BunqResponseBankSwitchServiceNetherlandsIncomingPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @property - def updated_card_ids(self): + def bank_switch_service(self): """ - :rtype: list[object_.BunqId] + :rtype: BankSwitchServiceNetherlandsIncoming """ - return self._updated_card_ids + return self._bank_switch_service + + @property + def payment(self): + """ + :rtype: Payment + """ + + return self._payment def is_all_field_none(self): """ :rtype: bool """ - if self._updated_card_ids is not None: + if self._bank_switch_service is not None: + return False + + if self._payment is not None: return False return True @@ -2676,426 +2380,238 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardBatch + :rtype: BankSwitchServiceNetherlandsIncomingPaymentApiObject """ - return converter.json_to_class(CardBatch, json_str) + return converter.json_to_class(BankSwitchServiceNetherlandsIncomingPaymentApiObject, json_str) -class CardDebit(core.BunqModel): +class BankSwitchServiceNetherlandsIncomingApiObject(BunqModel): """ - With bunq it is possible to order debit cards that can then be connected - with each one of the monetary accounts the user has access to (including - connected accounts). + Endpoint for using the Equens Bank Switch Service. - :param _second_line: The second line of text on the card - :type _second_line: str - :param _name_on_card: The user's name as will be on the card - :type _name_on_card: str - :param _alias: The label for the user who requested the card. - :type _alias: object_.LabelUser - :param _type_: The type of the card. Can be MAESTRO, MASTERCARD. - :type _type_: str - :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to - the card. - :type _pin_code_assignment: list[object_.CardPinAssignment] - :param _monetary_account_id_fallback: ID of the MA to be used as fallback - for this card if insufficient balance. Fallback account is removed if not - supplied. - :type _monetary_account_id_fallback: int - :param _id_: The id of the card. - :type _id_: int - :param _created: The timestamp when the card was crated. - :type _created: str - :param _updated: The timestamp when the card was last updated. - :type _updated: str - :param _public_uuid: The public UUID of the card. - :type _public_uuid: str - :param _sub_type: The sub_type of card. - :type _sub_type: str - :param _primary_account_number_four_digit: The last 4 digits of the PAN of - the card. - :type _primary_account_number_four_digit: str - :param _status: The status to set for the card. After ordering the card it - will be DEACTIVATED. + :param _alias: The label of the monetary of this switch service. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The IBAN alias that's displayed for this switch + service. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _status: The status of the switch service. :type _status: str - :param _order_status: The order status of the card. After ordering the card - it will be NEW_CARD_REQUEST_RECEIVED. - :type _order_status: str - :param _expiry_date: The expiry date of the card. - :type _expiry_date: str - :param _limit: The limits to define for the card (e.g. 25 EUR for - CARD_LIMIT_CONTACTLESS). - :type _limit: list[object_.CardLimit] - :param _country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type _country_permission: list[object_.CardCountryPermission] - :param _label_monetary_account_ordered: The monetary account this card was - ordered on and the label user that owns the card. - :type _label_monetary_account_ordered: object_.MonetaryAccountReference - :param _label_monetary_account_current: The monetary account that this card - is currently linked to and the label user viewing it. - :type _label_monetary_account_current: object_.MonetaryAccountReference - :param _country: The country that is domestic to the card. Defaults to - country of residence of user. - :type _country: str + :param _user_alias: The label of the user creator of this switch service. + :type _user_alias: object_.LabelUser + :param _sub_status: The sub status of the switch service. + :type _sub_status: str + :param _time_start_desired: The timestamp when the switch service desired to + be start. + :type _time_start_desired: str + :param _time_start_actual: The timestamp when the switch service actually + starts. + :type _time_start_actual: str + :param _time_end: The timestamp when the switch service ends. + :type _time_end: str + :param _attachment: Reference to the bank transfer form for this + switch-service. + :type _attachment: object_.Attachment + :param _rejection_reason: Rejection reason enum. + :type _rejection_reason: str + :param _rejection_reason_description: Rejection reason description to be + shown to the user. + :type _rejection_reason_description: str + :param _rejection_reason_description_translated: Rejection reason + description to be shown to the user, translated. + :type _rejection_reason_description_translated: str + :param _rejection_reason_together_url: Rejection reason together URL. + :type _rejection_reason_together_url: str """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/card-debit" - # Field constants. - FIELD_SECOND_LINE = "second_line" - FIELD_NAME_ON_CARD = "name_on_card" FIELD_ALIAS = "alias" - FIELD_TYPE = "type" - FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" - FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback" + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" + FIELD_STATUS = "status" - # Object type. - _OBJECT_TYPE_POST = "CardDebit" - _id_ = None - _created = None - _updated = None - _public_uuid = None - _type_ = None - _sub_type = None - _second_line = None - _name_on_card = None - _primary_account_number_four_digit = None - _status = None - _order_status = None - _expiry_date = None - _limit = None - _country_permission = None - _label_monetary_account_ordered = None - _label_monetary_account_current = None + _user_alias = None _alias = None - _pin_code_assignment = None - _monetary_account_id_fallback = None - _country = None - _second_line_field_for_request = None - _name_on_card_field_for_request = None + _counterparty_alias = None + _status = None + _sub_status = None + _time_start_desired = None + _time_start_actual = None + _time_end = None + _attachment = None + _rejection_reason = None + _rejection_reason_description = None + _rejection_reason_description_translated = None + _rejection_reason_together_url = None _alias_field_for_request = None - _type__field_for_request = None - _pin_code_assignment_field_for_request = None - _monetary_account_id_fallback_field_for_request = None + _counterparty_alias_field_for_request = None + _status_field_for_request = None - def __init__(self, second_line, name_on_card, alias=None, type_=None, - pin_code_assignment=None, monetary_account_id_fallback=None): + def __init__(self, alias, counterparty_alias, status=None): """ - :param second_line: The second line of text on the card, used as - name/description for it. It can contain at most 17 characters and it can be - empty. - :type second_line: str - :param name_on_card: The user's name as it will be on the card. Check - 'card-name' for the available card names for a user. - :type name_on_card: str - :param alias: The pointer to the monetary account that will be connected at - first with the card. Its IBAN code is also the one that will be printed on - the card itself. The pointer must be of type IBAN. + :param alias: The alias of the Monetary Account this switch service is for. :type alias: object_.Pointer - :param type_: The type of card to order. Can be MAESTRO or MASTERCARD. - :type type_: str - :param pin_code_assignment: Array of Types, PINs, account IDs assigned to - the card. - :type pin_code_assignment: list[object_.CardPinAssignment] - :param monetary_account_id_fallback: ID of the MA to be used as fallback for - this card if insufficient balance. Fallback account is removed if not - supplied. - :type monetary_account_id_fallback: int + :param counterparty_alias: The Alias of the party we are switching from. Can + only be an Alias of type IBAN (external bank account). + :type counterparty_alias: object_.Pointer + :param status: The status of the switch service. Ignored in POST requests + (always set to REQUESTED) can be CANCELLED in PUT requests to cancel the + switch service. Admin can set this to ACCEPTED, or REJECTED. + :type status: str """ - self._second_line_field_for_request = second_line - self._name_on_card_field_for_request = name_on_card self._alias_field_for_request = alias - self._type__field_for_request = type_ - self._pin_code_assignment_field_for_request = pin_code_assignment - self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback - - @classmethod - def create(cls, second_line, name_on_card, alias=None, type_=None, - pin_code_assignment=None, monetary_account_id_fallback=None, - custom_headers=None): - """ - Create a new debit card request. - - :type user_id: int - :param second_line: The second line of text on the card, used as - name/description for it. It can contain at most 17 characters and it can - be empty. - :type second_line: str - :param name_on_card: The user's name as it will be on the card. Check - 'card-name' for the available card names for a user. - :type name_on_card: str - :param alias: The pointer to the monetary account that will be connected - at first with the card. Its IBAN code is also the one that will be - printed on the card itself. The pointer must be of type IBAN. - :type alias: object_.Pointer - :param type_: The type of card to order. Can be MAESTRO or MASTERCARD. - :type type_: str - :param pin_code_assignment: Array of Types, PINs, account IDs assigned - to the card. - :type pin_code_assignment: list[object_.CardPinAssignment] - :param monetary_account_id_fallback: ID of the MA to be used as fallback - for this card if insufficient balance. Fallback account is removed if - not supplied. - :type monetary_account_id_fallback: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCardDebit - """ - - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_SECOND_LINE: second_line, - cls.FIELD_NAME_ON_CARD: name_on_card, - cls.FIELD_ALIAS: alias, - cls.FIELD_TYPE: type_, - cls.FIELD_PIN_CODE_ASSIGNMENT: pin_code_assignment, - cls.FIELD_MONETARY_ACCOUNT_ID_FALLBACK: monetary_account_id_fallback - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + self._counterparty_alias_field_for_request = counterparty_alias + self._status_field_for_request = status - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - request_bytes = security.encrypt(cls._get_api_context(), request_bytes, - custom_headers) - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - return BunqResponseCardDebit.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_POST) - ) @property - def id_(self): + def user_alias(self): """ - :rtype: int + :rtype: object_.LabelUser """ - return self._id_ + return self._user_alias @property - def created(self): + def alias(self): """ - :rtype: str + :rtype: object_.MonetaryAccountReference """ - return self._created + return self._alias @property - def updated(self): + def counterparty_alias(self): """ - :rtype: str + :rtype: object_.MonetaryAccountReference """ - return self._updated + return self._counterparty_alias @property - def public_uuid(self): + def status(self): """ :rtype: str """ - return self._public_uuid + return self._status @property - def type_(self): + def sub_status(self): """ :rtype: str """ - return self._type_ + return self._sub_status @property - def sub_type(self): + def time_start_desired(self): """ :rtype: str """ - return self._sub_type + return self._time_start_desired @property - def second_line(self): + def time_start_actual(self): """ :rtype: str """ - return self._second_line + return self._time_start_actual @property - def name_on_card(self): + def time_end(self): """ :rtype: str """ - return self._name_on_card + return self._time_end @property - def primary_account_number_four_digit(self): + def attachment(self): """ - :rtype: str + :rtype: object_.Attachment """ - return self._primary_account_number_four_digit + return self._attachment @property - def status(self): + def rejection_reason(self): """ :rtype: str """ - return self._status + return self._rejection_reason @property - def order_status(self): + def rejection_reason_description(self): """ :rtype: str """ - return self._order_status + return self._rejection_reason_description @property - def expiry_date(self): + def rejection_reason_description_translated(self): """ :rtype: str """ - return self._expiry_date - - @property - def limit(self): - """ - :rtype: list[object_.CardLimit] - """ - - return self._limit - - @property - def country_permission(self): - """ - :rtype: list[object_.CardCountryPermission] - """ - - return self._country_permission - - @property - def label_monetary_account_ordered(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._label_monetary_account_ordered - - @property - def label_monetary_account_current(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._label_monetary_account_current - - @property - def alias(self): - """ - :rtype: object_.LabelUser - """ - - return self._alias - - @property - def pin_code_assignment(self): - """ - :rtype: list[object_.CardPinAssignment] - """ - - return self._pin_code_assignment - - @property - def monetary_account_id_fallback(self): - """ - :rtype: int - """ - - return self._monetary_account_id_fallback + return self._rejection_reason_description_translated @property - def country(self): + def rejection_reason_together_url(self): """ :rtype: str """ - return self._country + return self._rejection_reason_together_url def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._public_uuid is not None: - return False - - if self._type_ is not None: - return False - - if self._sub_type is not None: - return False - - if self._second_line is not None: + if self._user_alias is not None: return False - if self._name_on_card is not None: + if self._alias is not None: return False - if self._primary_account_number_four_digit is not None: + if self._counterparty_alias is not None: return False if self._status is not None: return False - if self._order_status is not None: - return False - - if self._expiry_date is not None: + if self._sub_status is not None: return False - if self._limit is not None: + if self._time_start_desired is not None: return False - if self._country_permission is not None: + if self._time_start_actual is not None: return False - if self._label_monetary_account_ordered is not None: + if self._time_end is not None: return False - if self._label_monetary_account_current is not None: + if self._attachment is not None: return False - if self._alias is not None: + if self._rejection_reason is not None: return False - if self._pin_code_assignment is not None: + if self._rejection_reason_description is not None: return False - if self._monetary_account_id_fallback is not None: + if self._rejection_reason_description_translated is not None: return False - if self._country is not None: + if self._rejection_reason_together_url is not None: return False return True @@ -3105,71 +2621,212 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardDebit + :rtype: BankSwitchServiceNetherlandsIncomingApiObject """ - return converter.json_to_class(CardDebit, json_str) + return converter.json_to_class(BankSwitchServiceNetherlandsIncomingApiObject, json_str) -class CardGeneratedCvc2(core.BunqModel): +class PaymentApiObject(BunqModel): """ - Endpoint for generating and retrieving a new CVC2 code. + Using Payment, you can send payments to bunq and non-bunq users from your + bunq MonetaryAccounts. This can be done using bunq Aliases or IBAN Aliases. + When transferring money to other bunq MonetaryAccounts you can also refer to + Attachments. These will be received by the counter-party as part of the + Payment. You can also retrieve a single Payment or all executed Payments of + a specific monetary account. - :param _type_: The type of generated cvc2. Can be STATIC or GENERATED. - :type _type_: str - :param _id_: The id of the cvc code. + :param _amount: The Amount transferred by the Payment. Will be negative for + outgoing Payments and positive for incoming Payments (relative to the + MonetaryAccount indicated by monetary_account_id). + :type _amount: object_.Amount + :param _counterparty_alias: The LabelMonetaryAccount containing the public + information of the other (counterparty) side of the Payment. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description for the Payment. Maximum 140 characters + for Payments to external IBANs, 9000 characters for Payments to only other + bunq MonetaryAccounts. + :type _description: str + :param _attachment: The Attachments attached to the Payment. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _merchant_reference: Optional data included with the Payment specific + to the merchant. + :type _merchant_reference: str + :param _allow_bunqto: Whether or not sending a bunq.to payment is allowed. + :type _allow_bunqto: bool + :param _id_: The id of the created Payment. :type _id_: int - :param _created: The timestamp of the cvc code's creation. + :param _created: The timestamp when the Payment was done. :type _created: str - :param _updated: The timestamp of the cvc code's last update. + :param _updated: The timestamp when the Payment was last updated (will be + updated when chat messages are received). :type _updated: str - :param _cvc2: The cvc2 code. - :type _cvc2: str - :param _status: The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, - BLOCKED. - :type _status: str - :param _expiry_time: Expiry time of the cvc2. - :type _expiry_time: str + :param _monetary_account_id: The id of the MonetaryAccount the Payment was + made to or from (depending on whether this is an incoming or outgoing + Payment). + :type _monetary_account_id: int + :param _alias: The LabelMonetaryAccount containing the public information of + 'this' (party) side of the Payment. + :type _alias: object_.MonetaryAccountReference + :param _type_: The type of Payment, can be BUNQ, EBA_SCT, EBA_SDD, IDEAL, + SWIFT or FIS (card). + :type _type_: str + :param _sub_type: The sub-type of the Payment, can be PAYMENT, WITHDRAWAL, + REVERSAL, REQUEST, BILLING, SCT, SDD or NLO. + :type _sub_type: str + :param _payment_arrival_expected: Information about the expected arrival of + the payment. + :type _payment_arrival_expected: object_.PaymentArrivalExpected + :param _bunqto_status: The status of the bunq.to payment. + :type _bunqto_status: str + :param _bunqto_sub_status: The sub status of the bunq.to payment. + :type _bunqto_sub_status: str + :param _bunqto_share_url: The status of the bunq.to payment. + :type _bunqto_share_url: str + :param _bunqto_expiry: When bunq.to payment is about to expire. + :type _bunqto_expiry: str + :param _bunqto_time_responded: The timestamp of when the bunq.to payment was + responded to. + :type _bunqto_time_responded: str + :param _batch_id: The id of the PaymentBatch if this Payment was part of + one. + :type _batch_id: int + :param _scheduled_id: The id of the JobScheduled if the Payment was + scheduled. + :type _scheduled_id: int + :param _address_shipping: A shipping Address provided with the Payment, + currently unused. + :type _address_shipping: object_.Address + :param _address_billing: A billing Address provided with the Payment, + currently unused. + :type _address_billing: object_.Address + :param _geolocation: The Geolocation where the Payment was done from. + :type _geolocation: object_.Geolocation + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] + :param _balance_after_mutation: The new balance of the monetary account + after the mutation. + :type _balance_after_mutation: object_.Amount + :param _payment_auto_allocate_instance: A reference to the + PaymentAutoAllocateInstance if it exists. + :type _payment_auto_allocate_instance: PaymentAutoAllocateInstance + :param _payment_suspended_outgoing: A reference to the + PaymentSuspendedOutgoing if it exists. + :type _payment_suspended_outgoing: PaymentSuspendedOutgoing + :param _payment_fee: Incurred fee for the payment. + :type _payment_fee: object_.PaymentFee """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/card/{}/generated-cvc2" - _ENDPOINT_URL_READ = "user/{}/card/{}/generated-cvc2/{}" - _ENDPOINT_URL_UPDATE = "user/{}/card/{}/generated-cvc2/{}" - _ENDPOINT_URL_LISTING = "user/{}/card/{}/generated-cvc2" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment" # Field constants. - FIELD_TYPE = "type" + FIELD_AMOUNT = "amount" + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT = "attachment" + FIELD_MERCHANT_REFERENCE = "merchant_reference" + FIELD_ALLOW_BUNQTO = "allow_bunqto" # Object type. - _OBJECT_TYPE_GET = "CardGeneratedCvc2" + _OBJECT_TYPE_GET = "Payment" _id_ = None _created = None _updated = None + _monetary_account_id = None + _amount = None + _alias = None + _counterparty_alias = None + _description = None _type_ = None - _cvc2 = None - _status = None - _expiry_time = None - _type__field_for_request = None + _sub_type = None + _payment_arrival_expected = None + _bunqto_status = None + _bunqto_sub_status = None + _bunqto_share_url = None + _bunqto_expiry = None + _bunqto_time_responded = None + _attachment = None + _merchant_reference = None + _batch_id = None + _scheduled_id = None + _address_shipping = None + _address_billing = None + _geolocation = None + _request_reference_split_the_bill = None + _balance_after_mutation = None + _payment_auto_allocate_instance = None + _payment_suspended_outgoing = None + _payment_fee = None + _amount_field_for_request = None + _counterparty_alias_field_for_request = None + _description_field_for_request = None + _attachment_field_for_request = None + _merchant_reference_field_for_request = None + _allow_bunqto_field_for_request = None - def __init__(self, type_=None): + def __init__(self, amount, counterparty_alias, description, attachment=None, merchant_reference=None, allow_bunqto=None): """ - :param type_: The type of generated cvc2. Can be STATIC or GENERATED. - :type type_: str + :param amount: The Amount to transfer with the Payment. Must be bigger than + 0 and smaller than the MonetaryAccount's balance. + :type amount: object_.Amount + :param counterparty_alias: The Alias of the party we are transferring the + money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq + MonetaryAccounts or bunq.to payments) or IBAN (for external bank account). + :type counterparty_alias: object_.Pointer + :param description: The description for the Payment. Maximum 140 characters + for Payments to external IBANs, 9000 characters for Payments to only other + bunq MonetaryAccounts. Field is required but can be an empty string. + :type description: str + :param attachment: The Attachments to attach to the Payment. + :type attachment: list[object_.AttachmentMonetaryAccountPayment] + :param merchant_reference: Optional data to be included with the Payment + specific to the merchant. + :type merchant_reference: str + :param allow_bunqto: Whether or not sending a bunq.to payment is allowed. + :type allow_bunqto: bool """ - self._type__field_for_request = type_ + self._amount_field_for_request = amount + self._counterparty_alias_field_for_request = counterparty_alias + self._description_field_for_request = description + self._attachment_field_for_request = attachment + self._merchant_reference_field_for_request = merchant_reference + self._allow_bunqto_field_for_request = allow_bunqto @classmethod - def create(cls, card_id, type_=None, custom_headers=None): + def create(cls,amount, counterparty_alias, description, monetary_account_id=None, attachment=None, merchant_reference=None, allow_bunqto=None, custom_headers=None): """ - Generate a new CVC2 code for a card. + Create a new Payment. :type user_id: int - :type card_id: int - :param type_: The type of generated cvc2. Can be STATIC or GENERATED. - :type type_: str + :type monetary_account_id: int + :param amount: The Amount to transfer with the Payment. Must be bigger + than 0 and smaller than the MonetaryAccount's balance. + :type amount: object_.Amount + :param counterparty_alias: The Alias of the party we are transferring + the money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq + MonetaryAccounts or bunq.to payments) or IBAN (for external bank + account). + :type counterparty_alias: object_.Pointer + :param description: The description for the Payment. Maximum 140 + characters for Payments to external IBANs, 9000 characters for Payments + to only other bunq MonetaryAccounts. Field is required but can be an + empty string. + :type description: str + :param attachment: The Attachments to attach to the Payment. + :type attachment: list[object_.AttachmentMonetaryAccountPayment] + :param merchant_reference: Optional data to be included with the Payment + specific to the merchant. + :type merchant_reference: str + :param allow_bunqto: Whether or not sending a bunq.to payment is + allowed. + :type allow_bunqto: bool :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -3179,100 +2836,62 @@ def create(cls, card_id, type_=None, custom_headers=None): custom_headers = {} request_map = { - cls.FIELD_TYPE: type_ - } +cls.FIELD_AMOUNT : amount, +cls.FIELD_COUNTERPARTY_ALIAS : counterparty_alias, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT : attachment, +cls.FIELD_MERCHANT_REFERENCE : merchant_reference, +cls.FIELD_ALLOW_BUNQTO : allow_bunqto +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - request_bytes = security.encrypt(cls._get_api_context(), request_bytes, - custom_headers) - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - card_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, card_id, card_generated_cvc2_id, custom_headers=None): + def get(cls, payment_id, monetary_account_id=None, custom_headers=None): """ - Get the details for a specific generated CVC2 code. + Get a specific previous Payment. - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int - :type card_id: int - :type card_generated_cvc2_id: int + :type monetary_account_id: int + :type payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCardGeneratedCvc2 + :rtype: BunqResponsePayment """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - card_id, - card_generated_cvc2_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseCardGeneratedCvc2.cast_from_bunq_response( + return BunqResponsePayment.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, card_id, card_generated_cvc2_id, type_=None, - custom_headers=None): - """ - :type user_id: int - :type card_id: int - :type card_generated_cvc2_id: int - :param type_: The type of generated cvc2. Can be STATIC or GENERATED. - :type type_: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_TYPE: type_ - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - request_bytes = security.encrypt(cls._get_api_context(), request_bytes, - custom_headers) - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - card_id, - card_generated_cvc2_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def list(cls, card_id, params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Get all generated CVC2 codes for a card. + Get a listing of all Payments performed on a given MonetaryAccount + (incoming and outgoing). :type user_id: int - :type card_id: int + :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCardGeneratedCvc2List + :rtype: BunqResponsePaymentList """ if params is None: @@ -3281,12 +2900,11 @@ def list(cls, card_id, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), card_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCardGeneratedCvc2List.cast_from_bunq_response( + return BunqResponsePaymentList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @@ -3315,254 +2933,204 @@ def updated(self): return self._updated @property - def type_(self): + def monetary_account_id(self): """ - :rtype: str + :rtype: int """ - return self._type_ + return self._monetary_account_id @property - def cvc2(self): + def amount(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._cvc2 + return self._amount @property - def status(self): + def alias(self): """ - :rtype: str + :rtype: object_.MonetaryAccountReference """ - return self._status + return self._alias @property - def expiry_time(self): + def counterparty_alias(self): """ - :rtype: str + :rtype: object_.MonetaryAccountReference """ - return self._expiry_time + return self._counterparty_alias - def is_all_field_none(self): + @property + def description(self): """ - :rtype: bool + :rtype: str """ - if self._id_ is not None: - return False - - if self._created is not None: - return False + return self._description - if self._updated is not None: - return False + @property + def type_(self): + """ + :rtype: str + """ - if self._type_ is not None: - return False + return self._type_ - if self._cvc2 is not None: - return False + @property + def sub_type(self): + """ + :rtype: str + """ - if self._status is not None: - return False + return self._sub_type - if self._expiry_time is not None: - return False + @property + def payment_arrival_expected(self): + """ + :rtype: object_.PaymentArrivalExpected + """ - return True + return self._payment_arrival_expected - @staticmethod - def from_json(json_str): + @property + def bunqto_status(self): """ - :type json_str: str - - :rtype: CardGeneratedCvc2 + :rtype: str """ - return converter.json_to_class(CardGeneratedCvc2, json_str) + return self._bunqto_status + @property + def bunqto_sub_status(self): + """ + :rtype: str + """ -class CardName(core.BunqModel): - """ - Endpoint for getting all the accepted card names for a user. As bunq do not - allow total freedom in choosing the name that is going to be printed on the - card, the following formats are accepted: Name Surname, N. Surname, N - Surname or Surname. - - :param _possible_card_name_array: All possible variations (of suitable - length) of user's legal name for the debit card. - :type _possible_card_name_array: list[str] - """ + return self._bunqto_sub_status - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/card-name" + @property + def bunqto_share_url(self): + """ + :rtype: str + """ - # Object type. - _OBJECT_TYPE_GET = "CardUserNameArray" + return self._bunqto_share_url - _possible_card_name_array = None + @property + def bunqto_expiry(self): + """ + :rtype: str + """ - @classmethod - def list(cls, params=None, custom_headers=None): + return self._bunqto_expiry + + @property + def bunqto_time_responded(self): """ - Return all the accepted card names for a specific user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCardNameList + :rtype: str """ - if params is None: - params = {} + return self._bunqto_time_responded - if custom_headers is None: - custom_headers = {} + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._attachment - return BunqResponseCardNameList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def merchant_reference(self): + """ + :rtype: str + """ + + return self._merchant_reference @property - def possible_card_name_array(self): + def batch_id(self): """ - :rtype: list[str] + :rtype: int """ - return self._possible_card_name_array + return self._batch_id - def is_all_field_none(self): + @property + def scheduled_id(self): """ - :rtype: bool + :rtype: int """ - if self._possible_card_name_array is not None: - return False + return self._scheduled_id - return True + @property + def address_shipping(self): + """ + :rtype: object_.Address + """ - @staticmethod - def from_json(json_str): + return self._address_shipping + + @property + def address_billing(self): """ - :type json_str: str - - :rtype: CardName + :rtype: object_.Address """ - return converter.json_to_class(CardName, json_str) + return self._address_billing + @property + def geolocation(self): + """ + :rtype: object_.Geolocation + """ -class CardReplace(core.BunqModel): - """ - It is possible to order a card replacement with the bunq API.

You - can order up to one free card replacement per year. Additional replacement - requests will be billed.

The card replacement will have the same - expiry date and the same pricing as the old card, but it will have a new - card number. You can change the description and optional the PIN through the - card replacement endpoint. - - :param _name_on_card: The user's name as it will be on the card. Check - 'card-name' for the available card names for a user. - :type _name_on_card: str - :param _pin_code: The plaintext pin code. Requests require encryption to be - enabled. - :type _pin_code: str - :param _second_line: The second line on the card. - :type _second_line: str - :param _id_: The id of the new card. - :type _id_: int - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/card/{}/replace" + return self._geolocation - # Field constants. - FIELD_NAME_ON_CARD = "name_on_card" - FIELD_PIN_CODE = "pin_code" - FIELD_SECOND_LINE = "second_line" + @property + def request_reference_split_the_bill(self): + """ + :rtype: list[object_.RequestInquiryReference] + """ - _id_ = None - _name_on_card_field_for_request = None - _pin_code_field_for_request = None - _second_line_field_for_request = None + return self._request_reference_split_the_bill - def __init__(self, name_on_card=None, pin_code=None, second_line=None): + @property + def balance_after_mutation(self): """ - :param name_on_card: The user's name as it will be on the card. Check - 'card-name' for the available card names for a user. - :type name_on_card: str - :param pin_code: The plaintext pin code. Requests require encryption to be - enabled. - :type pin_code: str - :param second_line: The second line on the card. - :type second_line: str + :rtype: object_.Amount """ - self._name_on_card_field_for_request = name_on_card - self._pin_code_field_for_request = pin_code - self._second_line_field_for_request = second_line + return self._balance_after_mutation - @classmethod - def create(cls, card_id, name_on_card=None, pin_code=None, second_line=None, - custom_headers=None): + @property + def payment_auto_allocate_instance(self): """ - Request a card replacement. - - :type user_id: int - :type card_id: int - :param name_on_card: The user's name as it will be on the card. Check - 'card-name' for the available card names for a user. - :type name_on_card: str - :param pin_code: The plaintext pin code. Requests require encryption to - be enabled. - :type pin_code: str - :param second_line: The second line on the card. - :type second_line: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: PaymentAutoAllocateInstance """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_NAME_ON_CARD: name_on_card, - cls.FIELD_PIN_CODE: pin_code, - cls.FIELD_SECOND_LINE: second_line - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._payment_auto_allocate_instance - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - request_bytes = security.encrypt(cls._get_api_context(), request_bytes, - custom_headers) - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - card_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def payment_suspended_outgoing(self): + """ + :rtype: PaymentSuspendedOutgoing + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._payment_suspended_outgoing @property - def id_(self): + def payment_fee(self): """ - :rtype: int + :rtype: object_.PaymentFee """ - return self._id_ + return self._payment_fee def is_all_field_none(self): """ @@ -3572,6 +3140,87 @@ def is_all_field_none(self): if self._id_ is not None: return False + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._monetary_account_id is not None: + return False + + if self._amount is not None: + return False + + if self._alias is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._type_ is not None: + return False + + if self._sub_type is not None: + return False + + if self._payment_arrival_expected is not None: + return False + + if self._bunqto_status is not None: + return False + + if self._bunqto_sub_status is not None: + return False + + if self._bunqto_share_url is not None: + return False + + if self._bunqto_expiry is not None: + return False + + if self._bunqto_time_responded is not None: + return False + + if self._attachment is not None: + return False + + if self._merchant_reference is not None: + return False + + if self._batch_id is not None: + return False + + if self._scheduled_id is not None: + return False + + if self._address_shipping is not None: + return False + + if self._address_billing is not None: + return False + + if self._geolocation is not None: + return False + + if self._request_reference_split_the_bill is not None: + return False + + if self._balance_after_mutation is not None: + return False + + if self._payment_auto_allocate_instance is not None: + return False + + if self._payment_suspended_outgoing is not None: + return False + + if self._payment_fee is not None: + return False + return True @staticmethod @@ -3579,327 +3228,110 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardReplace + :rtype: PaymentApiObject """ - return converter.json_to_class(CardReplace, json_str) + return converter.json_to_class(PaymentApiObject, json_str) -class Card(core.BunqModel): +class PaymentAutoAllocateInstanceApiObject(BunqModel): """ - Endpoint for retrieving details for the cards the user has access to. + List all the times a users payment was automatically allocated. - :param _pin_code: The plaintext pin code. Requests require encryption to be - enabled. - :type _pin_code: str - :param _activation_code: The activation code required to set status to - ACTIVE initially. Can only set status to ACTIVE using activation code when - order_status is ACCEPTED_FOR_PRODUCTION and status is DEACTIVATED. - :type _activation_code: str - :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, - LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED. - :type _status: str - :param _card_limit: The spending limit for the cards - :type _card_limit: object_.Amount - :param _limit: DEPRECATED: The limits to define for the card, among - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_ATM, CARD_LIMIT_DIPPING and - CARD_LIMIT_POS_ICC (e.g. 25 EUR for CARD_LIMIT_CONTACTLESS) - :type _limit: list[object_.CardLimit] - :param _mag_stripe_permission: The countries for which to grant (temporary) - permissions to use the card. - :type _mag_stripe_permission: object_.CardMagStripePermission - :param _country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type _country_permission: list[object_.CardCountryPermission] - :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to - the card. - :type _pin_code_assignment: list[object_.CardPinAssignment] - :param _monetary_account_id_fallback: ID of the MA to be used as fallback - for this card if insufficient balance. Fallback account is removed if not - supplied. - :type _monetary_account_id_fallback: int - :param _id_: The id of the card. + :param _id_: The id of the PaymentAutoAllocateInstance. :type _id_: int - :param _created: The timestamp of the card's creation. + :param _created: The timestamp when the PaymentAutoAllocateInstance was + created. :type _created: str - :param _updated: The timestamp of the card's last update. + :param _updated: The timestamp when the PaymentAutoAllocateInstance was last + updated. :type _updated: str - :param _public_uuid: The public UUID of the card. - :type _public_uuid: str - :param _type_: The type of the card. Can be MAESTRO, MASTERCARD. - :type _type_: str - :param _sub_type: The sub-type of the card. - :type _sub_type: str - :param _second_line: The second line of text on the card - :type _second_line: str - :param _sub_status: The sub-status of the card. Can be NONE or REPLACED. - :type _sub_status: str - :param _order_status: The order status of the card. Can be - CARD_UPDATE_REQUESTED, CARD_UPDATE_SENT, CARD_UPDATE_ACCEPTED, - ACCEPTED_FOR_PRODUCTION or DELIVERED_TO_CUSTOMER. - :type _order_status: str - :param _expiry_date: Expiry date of the card. - :type _expiry_date: str - :param _name_on_card: The user's name on the card. - :type _name_on_card: str - :param _primary_account_number_four_digit: The last 4 digits of the PAN of - the card. - :type _primary_account_number_four_digit: str - :param _label_monetary_account_ordered: The monetary account this card was - ordered on and the label user that owns the card. - :type _label_monetary_account_ordered: object_.MonetaryAccountReference - :param _label_monetary_account_current: The monetary account that this card - is currently linked to and the label user viewing it. - :type _label_monetary_account_current: object_.MonetaryAccountReference - :param _country: The country that is domestic to the card. Defaults to - country of residence of user. - :type _country: str + :param _payment_auto_allocate_id: The ID of the payment auto allocate this + instance belongs to. + :type _payment_auto_allocate_id: int + :param _status: The status of the payment auto allocate instance. SUCCEEDED + or FAILED. + :type _status: str + :param _error_message: The error message, if the payment auto allocating + failed. + :type _error_message: list[object_.Error] + :param _payment_batch: The payment batch allocating all the payments. + :type _payment_batch: PaymentBatch + :param _payment_id: The ID of the payment that triggered the allocating of + the payments. + :type _payment_id: int + :param _all_ginmon_transaction_order: All Ginmon transaction orders executed + with this instance. + :type _all_ginmon_transaction_order: list[GinmonTransaction] """ # Endpoint constants. - _ENDPOINT_URL_UPDATE = "user/{}/card/{}" - _ENDPOINT_URL_READ = "user/{}/card/{}" - _ENDPOINT_URL_LISTING = "user/{}/card" - - # Field constants. - FIELD_PIN_CODE = "pin_code" - FIELD_ACTIVATION_CODE = "activation_code" - FIELD_STATUS = "status" - FIELD_CARD_LIMIT = "card_limit" - FIELD_LIMIT = "limit" - FIELD_MAG_STRIPE_PERMISSION = "mag_stripe_permission" - FIELD_COUNTRY_PERMISSION = "country_permission" - FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" - FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-auto-allocate/{}/instance" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-auto-allocate/{}/instance/{}" # Object type. - _OBJECT_TYPE_PUT = "CardDebit" - _OBJECT_TYPE_GET = "CardDebit" + _OBJECT_TYPE_GET = "PaymentAutoAllocateInstance" _id_ = None _created = None _updated = None - _public_uuid = None - _type_ = None - _sub_type = None - _second_line = None + _payment_auto_allocate_id = None _status = None - _sub_status = None - _order_status = None - _expiry_date = None - _name_on_card = None - _primary_account_number_four_digit = None - _card_limit = None - _limit = None - _mag_stripe_permission = None - _country_permission = None - _label_monetary_account_ordered = None - _label_monetary_account_current = None - _pin_code_assignment = None - _monetary_account_id_fallback = None - _country = None - _pin_code_field_for_request = None - _activation_code_field_for_request = None - _status_field_for_request = None - _card_limit_field_for_request = None - _limit_field_for_request = None - _mag_stripe_permission_field_for_request = None - _country_permission_field_for_request = None - _pin_code_assignment_field_for_request = None - _monetary_account_id_fallback_field_for_request = None - - def __init__(self, pin_code=None, activation_code=None, status=None, - card_limit=None, limit=None, mag_stripe_permission=None, - country_permission=None, pin_code_assignment=None, - monetary_account_id_fallback=None): - """ - :param pin_code: The plaintext pin code. Requests require encryption to be - enabled. - :type pin_code: str - :param activation_code: The activation code required to set status to ACTIVE - initially. Can only set status to ACTIVE using activation code when - order_status is ACCEPTED_FOR_PRODUCTION and status is DEACTIVATED. - :type activation_code: str - :param status: The status to set for the card. Can be ACTIVE, DEACTIVATED, - LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when - order status is - ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Can only be set to DEACTIVATED after initial activation, i.e. order_status - is - DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are - permanent and cannot be changed after. - :type status: str - :param card_limit: The spending limit for the card. - :type card_limit: object_.Amount - :param limit: DEPRECATED: The limits to define for the card, among - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_ATM, CARD_LIMIT_DIPPING and - CARD_LIMIT_POS_ICC (e.g. 25 EUR for CARD_LIMIT_CONTACTLESS). All the limits - must be provided on update. - :type limit: list[object_.CardLimit] - :param mag_stripe_permission: Whether or not it is allowed to use the mag - stripe for the card. - :type mag_stripe_permission: object_.CardMagStripePermission - :param country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type country_permission: list[object_.CardCountryPermission] - :param pin_code_assignment: Array of Types, PINs, account IDs assigned to - the card. - :type pin_code_assignment: list[object_.CardPinAssignment] - :param monetary_account_id_fallback: ID of the MA to be used as fallback for - this card if insufficient balance. Fallback account is removed if not - supplied. - :type monetary_account_id_fallback: int - """ - - self._pin_code_field_for_request = pin_code - self._activation_code_field_for_request = activation_code - self._status_field_for_request = status - self._card_limit_field_for_request = card_limit - self._limit_field_for_request = limit - self._mag_stripe_permission_field_for_request = mag_stripe_permission - self._country_permission_field_for_request = country_permission - self._pin_code_assignment_field_for_request = pin_code_assignment - self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback + _error_message = None + _payment_batch = None + _payment_id = None + _all_ginmon_transaction_order = None @classmethod - def update(cls, card_id, pin_code=None, activation_code=None, status=None, - card_limit=None, limit=None, mag_stripe_permission=None, - country_permission=None, pin_code_assignment=None, - monetary_account_id_fallback=None, custom_headers=None): + def list(cls,payment_auto_allocate_id, monetary_account_id=None, params=None, custom_headers=None): """ - Update the card details. Allow to change pin code, status, limits, - country permissions and the monetary account connected to the card. When - the card has been received, it can be also activated through this - endpoint. - :type user_id: int - :type card_id: int - :param pin_code: The plaintext pin code. Requests require encryption to - be enabled. - :type pin_code: str - :param activation_code: The activation code required to set status to - ACTIVE initially. Can only set status to ACTIVE using activation code - when order_status is ACCEPTED_FOR_PRODUCTION and status is DEACTIVATED. - :type activation_code: str - :param status: The status to set for the card. Can be ACTIVE, - DEACTIVATED, LOST, STOLEN or CANCELLED, and can only be set to - LOST/STOLEN/CANCELLED when order status is - ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Can only be set to DEACTIVATED after initial activation, i.e. - order_status is - DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) - are permanent and cannot be changed after. - :type status: str - :param card_limit: The spending limit for the card. - :type card_limit: object_.Amount - :param limit: DEPRECATED: The limits to define for the card, among - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_ATM, CARD_LIMIT_DIPPING and - CARD_LIMIT_POS_ICC (e.g. 25 EUR for CARD_LIMIT_CONTACTLESS). All the - limits must be provided on update. - :type limit: list[object_.CardLimit] - :param mag_stripe_permission: Whether or not it is allowed to use the - mag stripe for the card. - :type mag_stripe_permission: object_.CardMagStripePermission - :param country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type country_permission: list[object_.CardCountryPermission] - :param pin_code_assignment: Array of Types, PINs, account IDs assigned - to the card. - :type pin_code_assignment: list[object_.CardPinAssignment] - :param monetary_account_id_fallback: ID of the MA to be used as fallback - for this card if insufficient balance. Fallback account is removed if - not supplied. - :type monetary_account_id_fallback: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCard + :rtype: BunqResponsePaymentAutoAllocateInstanceList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_PIN_CODE: pin_code, - cls.FIELD_ACTIVATION_CODE: activation_code, - cls.FIELD_STATUS: status, - cls.FIELD_CARD_LIMIT: card_limit, - cls.FIELD_LIMIT: limit, - cls.FIELD_MAG_STRIPE_PERMISSION: mag_stripe_permission, - cls.FIELD_COUNTRY_PERMISSION: country_permission, - cls.FIELD_PIN_CODE_ASSIGNMENT: pin_code_assignment, - cls.FIELD_MONETARY_ACCOUNT_ID_FALLBACK: monetary_account_id_fallback - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - request_bytes = security.encrypt(cls._get_api_context(), request_bytes, - custom_headers) - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - card_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCard.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) + return BunqResponsePaymentAutoAllocateInstanceList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, card_id, custom_headers=None): + def get(cls, payment_auto_allocate_id, payment_auto_allocate_instance_id, monetary_account_id=None, custom_headers=None): """ - Return the details of a specific card. - - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int - :type card_id: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :type payment_auto_allocate_instance_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCard + :rtype: BunqResponsePaymentAutoAllocateInstance """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - card_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id, payment_auto_allocate_instance_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseCard.cast_from_bunq_response( + return BunqResponsePaymentAutoAllocateInstance.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def list(cls, params=None, custom_headers=None): - """ - Return all the cards available to the user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCardList - """ - - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseCardList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -3925,36 +3357,12 @@ def updated(self): return self._updated @property - def public_uuid(self): - """ - :rtype: str - """ - - return self._public_uuid - - @property - def type_(self): - """ - :rtype: str - """ - - return self._type_ - - @property - def sub_type(self): - """ - :rtype: str - """ - - return self._sub_type - - @property - def second_line(self): + def payment_auto_allocate_id(self): """ - :rtype: str + :rtype: int """ - return self._second_line + return self._payment_auto_allocate_id @property def status(self): @@ -3965,116 +3373,36 @@ def status(self): return self._status @property - def sub_status(self): - """ - :rtype: str - """ - - return self._sub_status - - @property - def order_status(self): - """ - :rtype: str - """ - - return self._order_status - - @property - def expiry_date(self): - """ - :rtype: str - """ - - return self._expiry_date - - @property - def name_on_card(self): - """ - :rtype: str - """ - - return self._name_on_card - - @property - def primary_account_number_four_digit(self): - """ - :rtype: str - """ - - return self._primary_account_number_four_digit - - @property - def card_limit(self): - """ - :rtype: object_.Amount - """ - - return self._card_limit - - @property - def limit(self): - """ - :rtype: list[object_.CardLimit] - """ - - return self._limit - - @property - def mag_stripe_permission(self): - """ - :rtype: object_.CardMagStripePermission - """ - - return self._mag_stripe_permission - - @property - def country_permission(self): - """ - :rtype: list[object_.CardCountryPermission] - """ - - return self._country_permission - - @property - def label_monetary_account_ordered(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._label_monetary_account_ordered - - @property - def label_monetary_account_current(self): + def error_message(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: list[object_.Error] """ - return self._label_monetary_account_current + return self._error_message @property - def pin_code_assignment(self): + def payment_batch(self): """ - :rtype: list[object_.CardPinAssignment] + :rtype: PaymentBatch """ - return self._pin_code_assignment + return self._payment_batch @property - def monetary_account_id_fallback(self): + def payment_id(self): """ :rtype: int """ - return self._monetary_account_id_fallback + return self._payment_id @property - def country(self): + def all_ginmon_transaction_order(self): """ - :rtype: str + :rtype: list[GinmonTransaction] """ - return self._country + return self._all_ginmon_transaction_order def is_all_field_none(self): """ @@ -4090,204 +3418,78 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._public_uuid is not None: - return False - - if self._type_ is not None: - return False - - if self._sub_type is not None: - return False - - if self._second_line is not None: + if self._payment_auto_allocate_id is not None: return False if self._status is not None: return False - if self._sub_status is not None: + if self._error_message is not None: return False - if self._order_status is not None: + if self._payment_batch is not None: return False - if self._expiry_date is not None: + if self._payment_id is not None: return False - if self._name_on_card is not None: + if self._all_ginmon_transaction_order is not None: return False - if self._primary_account_number_four_digit is not None: - return False + return True - if self._card_limit is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentAutoAllocateInstanceApiObject + """ - if self._limit is not None: - return False + return converter.json_to_class(PaymentAutoAllocateInstanceApiObject, json_str) - if self._mag_stripe_permission is not None: - return False - if self._country_permission is not None: - return False - - if self._label_monetary_account_ordered is not None: - return False - - if self._label_monetary_account_current is not None: - return False - - if self._pin_code_assignment is not None: - return False - - if self._monetary_account_id_fallback is not None: - return False - - if self._country is not None: - return False - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: Card - """ - - return converter.json_to_class(Card, json_str) - - -class CashRegisterQrCodeContent(core.BunqModel): - """ - Show the raw contents of a QR code. First you need to created a QR code - using ../cash-register/{id}/qr-code. - """ - - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/qr-code/{}/content" - - # Object type. - _OBJECT_TYPE_GET = "CashRegisterQrCodeContent" - - @classmethod - def list(cls, cash_register_id, qr_code_id, monetary_account_id=None, - custom_headers=None): - """ - Show the raw contents of a QR code - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type qr_code_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id, qr_code_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) - - def is_all_field_none(self): - """ - :rtype: bool - """ - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: CashRegisterQrCodeContent - """ - - return converter.json_to_class(CashRegisterQrCodeContent, json_str) - - -class CashRegisterQrCode(core.BunqModel): - """ - Once your CashRegister has been activated you can create a QR code for it. - The visibility of a tab can be modified to be linked to this QR code. If a - user of the bunq app scans this QR code, the linked tab will be shown on his - device. - - :param _status: The status of this QR code. If the status is "ACTIVE" the QR - code can be scanned to see the linked CashRegister and tab. If the status is - "INACTIVE" the QR code does not link to a anything. - :type _status: str - :param _id_: The id of the created QR code. Use this id to get the RAW - content of the QR code with: ../qr-code/{id}/content - :type _id_: int - :param _created: The timestamp of the QR code's creation. - :type _created: str - :param _updated: The timestamp of the TokenQrCashRegister's last update. - :type _updated: str - :param _cash_register: The CashRegister that is linked to the token. - :type _cash_register: CashRegister - :param _tab_object: Holds the Tab object. Can be TabUsageSingle, - TabUsageMultiple or null - :type _tab_object: Tab - """ +class PaymentBatchApiObject(BunqModel): + """ + Create a payment batch, or show the payment batches of a monetary account. + + :param _payments: The list of mutations that were made. + :type _payments: list[Payment] + """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register/{}/qr-code" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/cash-register/{}/qr-code/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/qr-code/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/qr-code" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch" # Field constants. - FIELD_STATUS = "status" + FIELD_PAYMENTS = "payments" # Object type. - _OBJECT_TYPE_GET = "TokenQrCashRegister" + _OBJECT_TYPE_GET = "PaymentBatch" - _id_ = None - _created = None - _updated = None - _status = None - _cash_register = None - _tab_object = None - _status_field_for_request = None + _payments = None + _payments_field_for_request = None - def __init__(self, status=None): + def __init__(self, payments): """ - :param status: The status of the QR code. ACTIVE or INACTIVE. Only one QR - code can be ACTIVE for a CashRegister at any time. Setting a QR code to - ACTIVE will deactivate any other CashRegister QR codes. - :type status: str + :param payments: The list of payments we want to send in a single batch. + :type payments: list[Payment] """ - self._status_field_for_request = status + self._payments_field_for_request = payments @classmethod - def create(cls, cash_register_id, status, monetary_account_id=None, - custom_headers=None): + def create(cls,payments, monetary_account_id=None, custom_headers=None): """ - Create a new QR code for this CashRegister. You can only have one ACTIVE - CashRegister QR code at the time. + Create a payment batch by sending an array of single payment objects, + that will become part of the batch. :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :param status: The status of the QR code. ACTIVE or INACTIVE. Only one - QR code can be ACTIVE for a CashRegister at any time. Setting a QR code - to ACTIVE will deactivate any other CashRegister QR codes. - :type status: str + :param payments: The list of payments we want to send in a single batch. + :type payments: list[Payment] :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -4297,39 +3499,29 @@ def create(cls, cash_register_id, status, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_STATUS: status - } +cls.FIELD_PAYMENTS : payments +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, cash_register_id, cash_register_qr_code_id, - monetary_account_id=None, status=None, custom_headers=None): + def update(cls, payment_batch_id, monetary_account_id=None, custom_headers=None): """ - Modify a QR code in a given CashRegister. You can only have one ACTIVE - CashRegister QR code at the time. + Revoke a bunq.to payment batch. The status of all the payments will be + set to REVOKED. :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type cash_register_qr_code_id: int - :param status: The status of the QR code. ACTIVE or INACTIVE. Only one - QR code can be ACTIVE for a CashRegister at any time. Setting a QR code - to ACTIVE will deactivate any other CashRegister QR codes. - :type status: str + :type payment_batch_id: int :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -4338,72 +3530,58 @@ def update(cls, cash_register_id, cash_register_qr_code_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_STATUS: status - } + +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - cash_register_qr_code_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, cash_register_id, cash_register_qr_code_id, - monetary_account_id=None, custom_headers=None): + def get(cls, payment_batch_id, monetary_account_id=None, custom_headers=None): """ - Get the information of a specific QR code. To get the RAW content of the - QR code use ../qr-code/{id}/content + Return the details of a specific payment batch. - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type cash_register_qr_code_id: int + :type payment_batch_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCashRegisterQrCode + :rtype: BunqResponsePaymentBatch """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - cash_register_qr_code_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseCashRegisterQrCode.cast_from_bunq_response( + return BunqResponsePaymentBatch.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, cash_register_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Get a collection of QR code information from a given CashRegister + Return all the payment batches for a monetary account. :type user_id: int :type monetary_account_id: int - :type cash_register_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCashRegisterQrCodeList + :rtype: BunqResponsePaymentBatchList """ if params is None: @@ -4412,86 +3590,210 @@ def list(cls, cash_register_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCashRegisterQrCodeList.cast_from_bunq_response( + return BunqResponsePaymentBatchList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def id_(self): + def payments(self): """ - :rtype: int + :rtype: list[Payment] """ - return self._id_ + return self._payments + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._payments is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentBatchApiObject + """ + + return converter.json_to_class(PaymentBatchApiObject, json_str) + + +class GinmonTransactionApiObject(BunqModel): + """ + Endpoint for reading Ginmon transactions. + + :param _status: The status of the transaction. + :type _status: str + :param _status_description: The status of the transaction. + :type _status_description: str + :param _status_description_translated: The translated status of the + transaction. + :type _status_description_translated: str + :param _amount_billing: The final amount the user will pay or receive. + :type _amount_billing: object_.Amount + :param _amount_billing_original: The estimated amount the user will pay or + receive. + :type _amount_billing_original: object_.Amount + :param _isin: The ISIN of the security. + :type _isin: str + :param _external_identifier: External identifier of this order at Ginmon. + :type _external_identifier: str + :param _label_user: The label of the user. + :type _label_user: object_.LabelUser + :param _label_monetary_account: The label of the monetary account. + :type _label_monetary_account: object_.MonetaryAccountReference + :param _counter_label_monetary_account: The label of the counter monetary + account. + :type _counter_label_monetary_account: object_.MonetaryAccountReference + :param _event_id: The id of the event of transaction. + :type _event_id: int + """ + + _status = None + _status_description = None + _status_description_translated = None + _amount_billing = None + _amount_billing_original = None + _isin = None + _external_identifier = None + _label_user = None + _label_monetary_account = None + _counter_label_monetary_account = None + _event_id = None @property - def created(self): + def status(self): """ :rtype: str """ - return self._created + return self._status @property - def updated(self): + def status_description(self): """ :rtype: str """ - return self._updated + return self._status_description @property - def status(self): + def status_description_translated(self): """ :rtype: str """ - return self._status + return self._status_description_translated + + @property + def amount_billing(self): + """ + :rtype: object_.Amount + """ + + return self._amount_billing + + @property + def amount_billing_original(self): + """ + :rtype: object_.Amount + """ + + return self._amount_billing_original + + @property + def isin(self): + """ + :rtype: str + """ + + return self._isin + + @property + def external_identifier(self): + """ + :rtype: str + """ + + return self._external_identifier + + @property + def label_user(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user + + @property + def label_monetary_account(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._label_monetary_account @property - def cash_register(self): + def counter_label_monetary_account(self): """ - :rtype: CashRegister + :rtype: object_.MonetaryAccountReference """ - return self._cash_register + return self._counter_label_monetary_account @property - def tab_object(self): + def event_id(self): """ - :rtype: Tab + :rtype: int """ - return self._tab_object + return self._event_id def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._status is not None: return False - if self._created is not None: + if self._status_description is not None: return False - if self._updated is not None: + if self._status_description_translated is not None: return False - if self._status is not None: + if self._amount_billing is not None: + return False + + if self._amount_billing_original is not None: + return False + + if self._isin is not None: return False - if self._cash_register is not None: + if self._external_identifier is not None: return False - if self._tab_object is not None: + if self._label_user is not None: + return False + + if self._label_monetary_account is not None: + return False + + if self._counter_label_monetary_account is not None: + return False + + if self._event_id is not None: return False return True @@ -4501,279 +3803,228 @@ def from_json(json_str): """ :type json_str: str - :rtype: CashRegisterQrCode + :rtype: GinmonTransactionApiObject """ - return converter.json_to_class(CashRegisterQrCode, json_str) + return converter.json_to_class(GinmonTransactionApiObject, json_str) -class CashRegister(core.BunqModel): +class PaymentSuspendedOutgoingApiObject(BunqModel): """ - CashRegisters are virtual points of sale. They have a specific name and - avatar, and optionally, a location.
With a CashRegister you can create a - Tab and then use a QR code to receive payments.
Check out our Quickstart - example to learn how you can easily create Tab - payments.

Notification filters can be set on a CashRegister to - receive callbacks. For more information check the dedicated callbacks page. + Suspended outgoing payments. - :param _name: The name of the CashRegister. - :type _name: str - :param _status: The status of the CashRegister. Can be PENDING_APPROVAL, - ACTIVE, DENIED or CLOSED. + :param _status: The status of the payment. :type _status: str - :param _avatar_uuid: The UUID of the avatar of the CashRegister. Use the - calls /attachment-public and /avatar to create a new Avatar and get its - UUID. - :type _avatar_uuid: str - :param _location: The geolocation of the CashRegister. Can be null. - :type _location: object_.Geolocation - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this CashRegister. - :type _notification_filters: list[object_.NotificationFilter] - :param _tab_text_waiting_screen: The tab text for waiting screen of - CashRegister. - :type _tab_text_waiting_screen: list[object_.TabTextWaitingScreen] - :param _id_: The id of the created CashRegister. - :type _id_: int - :param _created: The timestamp of the CashRegister's creation. - :type _created: str - :param _updated: The timestamp of the CashRegister's last update. - :type _updated: str - :param _avatar: The Avatar of the CashRegister. - :type _avatar: object_.Avatar + :param _monetary_account_id: The ID of the monetary account the payment was + sent from. + :type _monetary_account_id: str + :param _time_execution: The time this payment should be executed. + :type _time_execution: str """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/cash-register/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register" - # Field constants. - FIELD_NAME = "name" FIELD_STATUS = "status" - FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_LOCATION = "location" - FIELD_NOTIFICATION_FILTERS = "notification_filters" - FIELD_TAB_TEXT_WAITING_SCREEN = "tab_text_waiting_screen" - # Object type. - _OBJECT_TYPE_GET = "CashRegister" - _id_ = None - _created = None - _updated = None - _name = None + _monetary_account_id = None _status = None - _avatar = None - _location = None - _notification_filters = None - _tab_text_waiting_screen = None - _name_field_for_request = None + _time_execution = None _status_field_for_request = None - _avatar_uuid_field_for_request = None - _location_field_for_request = None - _notification_filters_field_for_request = None - _tab_text_waiting_screen_field_for_request = None - def __init__(self, name=None, status=None, avatar_uuid=None, location=None, - notification_filters=None, tab_text_waiting_screen=None): + def __init__(self, status=None): """ - :param name: The name of the CashRegister. Must be unique for this - MonetaryAccount. - :type name: str - :param status: The status of the CashRegister. Can only be created or - updated with PENDING_APPROVAL or CLOSED. + :param status: The status to update to. :type status: str - :param avatar_uuid: The UUID of the avatar of the CashRegister. Use the - calls /attachment-public and /avatar to create a new Avatar and get its - UUID. - :type avatar_uuid: str - :param location: The geolocation of the CashRegister. - :type location: object_.Geolocation - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this CashRegister. - :type notification_filters: list[object_.NotificationFilter] - :param tab_text_waiting_screen: The tab text for waiting screen of - CashRegister. - :type tab_text_waiting_screen: list[object_.TabTextWaitingScreen] """ - self._name_field_for_request = name self._status_field_for_request = status - self._avatar_uuid_field_for_request = avatar_uuid - self._location_field_for_request = location - self._notification_filters_field_for_request = notification_filters - self._tab_text_waiting_screen_field_for_request = tab_text_waiting_screen - @classmethod - def create(cls, name, status, avatar_uuid, monetary_account_id=None, - location=None, notification_filters=None, - tab_text_waiting_screen=None, custom_headers=None): + + + @property + def monetary_account_id(self): """ - Create a new CashRegister. Only an UserCompany can create a - CashRegisters. They need to be created with status PENDING_APPROVAL, an - bunq admin has to approve your CashRegister before you can use it. In - the sandbox testing environment an CashRegister will be automatically - approved immediately after creation. - - :type user_id: int - :type monetary_account_id: int - :param name: The name of the CashRegister. Must be unique for this - MonetaryAccount. - :type name: str - :param status: The status of the CashRegister. Can only be created or - updated with PENDING_APPROVAL or CLOSED. - :type status: str - :param avatar_uuid: The UUID of the avatar of the CashRegister. Use the - calls /attachment-public and /avatar to create a new Avatar and get its - UUID. - :type avatar_uuid: str - :param location: The geolocation of the CashRegister. - :type location: object_.Geolocation - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this CashRegister. - :type notification_filters: list[object_.NotificationFilter] - :param tab_text_waiting_screen: The tab text for waiting screen of - CashRegister. - :type tab_text_waiting_screen: list[object_.TabTextWaitingScreen] - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._monetary_account_id - request_map = { - cls.FIELD_NAME: name, - cls.FIELD_STATUS: status, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_LOCATION: location, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_TAB_TEXT_WAITING_SCREEN: tab_text_waiting_screen - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + @property + def status(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + return self._status - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + @property + def time_execution(self): + """ + :rtype: str + """ - @classmethod - def get(cls, cash_register_id, monetary_account_id=None, - custom_headers=None): + return self._time_execution + + def is_all_field_none(self): """ - Get a specific CashRegister. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCashRegister + :rtype: bool """ - if custom_headers is None: - custom_headers = {} + if self._monetary_account_id is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + if self._status is not None: + return False - return BunqResponseCashRegister.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + if self._time_execution is not None: + return False - @classmethod - def update(cls, cash_register_id, monetary_account_id=None, name=None, - status=None, avatar_uuid=None, location=None, - notification_filters=None, tab_text_waiting_screen=None, - custom_headers=None): + return True + + @staticmethod + def from_json(json_str): """ - Modify or close an existing CashRegister. You must set the status back - to PENDING_APPROVAL if you modify the name, avatar or location of a - CashRegister. To close a cash register put its status to CLOSED. + :type json_str: str - :type user_id: int + :rtype: PaymentSuspendedOutgoingApiObject + """ + + return converter.json_to_class(PaymentSuspendedOutgoingApiObject, json_str) + + +class BunqMeFundraiserProfileUserApiObject(BunqModel): + """ + bunq.me public profile of the user. + + :param _monetary_account_id: Id of the monetary account on which you want to + receive bunq.me payments. + :type _monetary_account_id: int + :param _color: The color chosen for the bunq.me fundraiser profile in + hexadecimal format. + :type _color: str + :param _description: The description of the bunq.me fundraiser profile. + :type _description: str + :param _attachment_public_uuid: The public UUID of the public attachment + from which an avatar image must be created. + :type _attachment_public_uuid: str + :param _pointer: The pointer (url) which will be used to access the bunq.me + fundraiser profile. + :type _pointer: object_.MonetaryAccountReference + :param _redirect_url: The URL which the user is sent to when a payment is + completed. + :type _redirect_url: str + :param _status: The status of the bunq.me fundraiser profile, can be ACTIVE + or DEACTIVATED. + :type _status: str + :param _owner_user_id: Id of the user owning the profile. + :type _owner_user_id: int + :param _alias: The LabelMonetaryAccount with the public information of the + User and the MonetaryAccount that created the bunq.me fundraiser profile. + :type _alias: object_.MonetaryAccountReference + :param _currency: The currency of the MonetaryAccount that created the + bunq.me fundraiser profile. + :type _currency: str + :param _attachment: The attachment used for the background of the bunq.me + fundraiser profile. + :type _attachment: object_.AttachmentPublic + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/bunqme-fundraiser-profile/{}" + _ENDPOINT_URL_LISTING = "user/{}/bunqme-fundraiser-profile" + + # Field constants. + FIELD_MONETARY_ACCOUNT_ID = "monetary_account_id" + FIELD_COLOR = "color" + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_PUBLIC_UUID = "attachment_public_uuid" + FIELD_POINTER = "pointer" + FIELD_REDIRECT_URL = "redirect_url" + FIELD_STATUS = "status" + + # Object type. + _OBJECT_TYPE_GET = "BunqMeFundraiserProfile" + + _monetary_account_id = None + _owner_user_id = None + _color = None + _alias = None + _currency = None + _description = None + _attachment = None + _pointer = None + _redirect_url = None + _status = None + _monetary_account_id_field_for_request = None + _color_field_for_request = None + _description_field_for_request = None + _attachment_public_uuid_field_for_request = None + _pointer_field_for_request = None + _redirect_url_field_for_request = None + _status_field_for_request = None + + def __init__(self, monetary_account_id=None, description=None, pointer=None, color=None, attachment_public_uuid=None, redirect_url=None, status=None): + """ + :param monetary_account_id: ID of the monetary account on which you want to + receive bunq.me fundraiser payments. :type monetary_account_id: int - :type cash_register_id: int - :param name: The name of the CashRegister. Must be unique for this - MonetaryAccount. - :type name: str - :param status: The status of the CashRegister. Can only be created or - updated with PENDING_APPROVAL or CLOSED. + :param description: The description of the bunq.me fundraiser profile. + Maximum 9000 characters. Field is required but can be an empty string. + :type description: str + :param pointer: The pointer (url) which will be used to access the bunq.me + fundraiser profile. + :type pointer: object_.Pointer + :param color: The color chosen for the bunq.me fundraiser profile in + hexadecimal format. + :type color: str + :param attachment_public_uuid: The public UUID of the public attachment from + which an avatar image must be created. + :type attachment_public_uuid: str + :param redirect_url: The URL which the user is sent to when a payment is + completed. + :type redirect_url: str + :param status: The status of the bunq.me fundraiser profile. :type status: str - :param avatar_uuid: The UUID of the avatar of the CashRegister. Use the - calls /attachment-public and /avatar to create a new Avatar and get its - UUID. - :type avatar_uuid: str - :param location: The geolocation of the CashRegister. - :type location: object_.Geolocation - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this CashRegister. - :type notification_filters: list[object_.NotificationFilter] - :param tab_text_waiting_screen: The tab text for waiting screen of - CashRegister. - :type tab_text_waiting_screen: list[object_.TabTextWaitingScreen] + """ + + self._monetary_account_id_field_for_request = monetary_account_id + self._description_field_for_request = description + self._pointer_field_for_request = pointer + self._color_field_for_request = color + self._attachment_public_uuid_field_for_request = attachment_public_uuid + self._redirect_url_field_for_request = redirect_url + self._status_field_for_request = status + + @classmethod + def get(cls, bunq_me_fundraiser_profile_user_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type bunq_me_fundraiser_profile_user_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseBunqMeFundraiserProfileUser """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_NAME: name, - cls.FIELD_STATUS: status, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_LOCATION: location, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_TAB_TEXT_WAITING_SCREEN: tab_text_waiting_screen - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), bunq_me_fundraiser_profile_user_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseBunqMeFundraiserProfileUser.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Get a collection of CashRegister for a given user and monetary account. - :type user_id: int - :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCashRegisterList + :rtype: BunqResponseBunqMeFundraiserProfileUserList """ if params is None: @@ -4782,118 +4033,127 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCashRegisterList.cast_from_bunq_response( + return BunqResponseBunqMeFundraiserProfileUserList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def id_(self): + def monetary_account_id(self): """ :rtype: int """ - return self._id_ + return self._monetary_account_id @property - def created(self): + def owner_user_id(self): """ - :rtype: str + :rtype: int """ - return self._created + return self._owner_user_id @property - def updated(self): + def color(self): """ :rtype: str """ - return self._updated + return self._color @property - def name(self): + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._alias + + @property + def currency(self): """ :rtype: str """ - return self._name + return self._currency @property - def status(self): + def description(self): """ :rtype: str """ - return self._status + return self._description @property - def avatar(self): + def attachment(self): """ - :rtype: object_.Avatar + :rtype: object_.AttachmentPublic """ - return self._avatar + return self._attachment @property - def location(self): + def pointer(self): """ - :rtype: object_.Geolocation + :rtype: object_.MonetaryAccountReference """ - return self._location + return self._pointer @property - def notification_filters(self): + def redirect_url(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: str """ - return self._notification_filters + return self._redirect_url @property - def tab_text_waiting_screen(self): + def status(self): """ - :rtype: list[object_.TabTextWaitingScreen] + :rtype: str """ - return self._tab_text_waiting_screen + return self._status def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._monetary_account_id is not None: return False - if self._created is not None: + if self._owner_user_id is not None: return False - if self._updated is not None: + if self._color is not None: return False - if self._name is not None: + if self._alias is not None: return False - if self._status is not None: + if self._currency is not None: return False - if self._avatar is not None: + if self._description is not None: return False - if self._location is not None: + if self._attachment is not None: return False - if self._notification_filters is not None: + if self._pointer is not None: + return False + + if self._redirect_url is not None: return False - if self._tab_text_waiting_screen is not None: + if self._status is not None: return False return True @@ -4903,142 +4163,310 @@ def from_json(json_str): """ :type json_str: str - :rtype: CashRegister + :rtype: BunqMeFundraiserProfileUserApiObject """ - return converter.json_to_class(CashRegister, json_str) + return converter.json_to_class(BunqMeFundraiserProfileUserApiObject, json_str) -class Tab(core.BunqModel, core.AnchoredObjectInterface): +class BunqMeFundraiserResultApiObject(BunqModel): """ - Once your CashRegister has been activated you can use it to create Tabs. A - Tab is a template for a payment. In contrast to requests a Tab is not - pointed towards a specific user. Any user can pay the Tab as long as it is - made visible by you. The creation of a Tab happens with /tab-usage-single or - /tab-usage-multiple. A TabUsageSingle is a Tab that can be paid once. A - TabUsageMultiple is a Tab that can be paid multiple times by different - users. + bunq.me fundraiser result containing all payments. - :param _TabUsageSingle: - :type _TabUsageSingle: TabUsageSingle - :param _TabUsageMultiple: - :type _TabUsageMultiple: TabUsageMultiple + :param _id_: The id of the bunq.me. + :type _id_: int + :param _created: The timestamp when the bunq.me was created. + :type _created: str + :param _updated: The timestamp when the bunq.me was last updated. + :type _updated: str + :param _bunqme_fundraiser_profile: The bunq.me fundraiser profile. + :type _bunqme_fundraiser_profile: BunqMeFundraiserProfile + :param _payments: The list of payments, paid to the bunq.me fundraiser + profile. + :type _payments: list[Payment] """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/tab/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}" # Object type. - _OBJECT_TYPE_GET = "Tab" + _OBJECT_TYPE_GET = "BunqMeFundraiserResult" - _TabUsageSingle = None - _TabUsageMultiple = None + _id_ = None + _created = None + _updated = None + _bunqme_fundraiser_profile = None + _payments = None @classmethod - def get(cls, cash_register_id, tab_uuid, monetary_account_id=None, - custom_headers=None): + def get(cls, bunq_me_fundraiser_result_id, monetary_account_id=None, custom_headers=None): """ - Get a specific tab. This returns a TabUsageSingle or TabUsageMultiple. - - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str + :type bunq_me_fundraiser_result_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseTab + :rtype: BunqResponseBunqMeFundraiserResult """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, tab_uuid) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunq_me_fundraiser_result_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseTab.cast_from_bunq_response( - cls._from_json(response_raw) + return BunqResponseBunqMeFundraiserResult.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def list(cls, cash_register_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def id_(self): """ - Get a collection of tabs. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabList + :rtype: int """ - if params is None: - params = {} + return self._id_ - if custom_headers is None: - custom_headers = {} + @property + def created(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._created - return BunqResponseTabList.cast_from_bunq_response( - cls._from_json_list(response_raw) - ) + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated @property - def TabUsageSingle(self): + def bunqme_fundraiser_profile(self): """ - :rtype: TabUsageSingle + :rtype: BunqMeFundraiserProfile """ - return self._TabUsageSingle + return self._bunqme_fundraiser_profile @property - def TabUsageMultiple(self): + def payments(self): """ - :rtype: TabUsageMultiple + :rtype: list[Payment] """ - return self._TabUsageMultiple + return self._payments - def get_referenced_object(self): + def is_all_field_none(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._bunqme_fundraiser_profile is not None: + return False + + if self._payments is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: BunqMeFundraiserResultApiObject + """ + + return converter.json_to_class(BunqMeFundraiserResultApiObject, json_str) + + +class BunqMeFundraiserProfileApiObject(BunqModel): + """ + bunq.me public profile of the user. + + :param _pointer: The pointer (url) which will be used to access the bunq.me + fundraiser profile. + :type _pointer: object_.MonetaryAccountReference + :param _color: The color chosen for the bunq.me fundraiser profile in + hexadecimal format. + :type _color: str + :param _alias: The LabelMonetaryAccount with the public information of the + User and the MonetaryAccount that created the bunq.me fundraiser profile. + :type _alias: object_.MonetaryAccountReference + :param _currency: The currency of the MonetaryAccount that created the + bunq.me fundraiser profile. + :type _currency: str + :param _description: The description of the bunq.me fundraiser profile. + :type _description: str + :param _attachment: The attachment attached to the fundraiser profile. + :type _attachment: object_.AttachmentPublic + :param _status: The status of the bunq.me fundraiser profile, can be ACTIVE + or DEACTIVATED. + :type _status: str + :param _redirect_url: The URL which the user is sent to when a payment is + completed. + :type _redirect_url: str + :param _invite_profile_name: Provided if the user has enabled their invite + link. + :type _invite_profile_name: str + :param _merchant_available: List of available merchants. + :type _merchant_available: list[object_.BunqMeMerchantAvailable] + """ + + # Field constants. + FIELD_POINTER = "pointer" + + + _color = None + _alias = None + _currency = None + _description = None + _attachment = None + _pointer = None + _status = None + _redirect_url = None + _invite_profile_name = None + _merchant_available = None + _pointer_field_for_request = None + + def __init__(self, pointer): + """ + :param pointer: The pointer (url) which will be used to access the bunq.me + fundraiser profile. + :type pointer: object_.Pointer + """ + + self._pointer_field_for_request = pointer + + + + @property + def color(self): + """ + :rtype: str + """ + + return self._color + + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._alias + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str """ - if self._TabUsageSingle is not None: - return self._TabUsageSingle + return self._description + + @property + def attachment(self): + """ + :rtype: object_.AttachmentPublic + """ + + return self._attachment + + @property + def pointer(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._pointer + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def redirect_url(self): + """ + :rtype: str + """ + + return self._redirect_url + + @property + def invite_profile_name(self): + """ + :rtype: str + """ - if self._TabUsageMultiple is not None: - return self._TabUsageMultiple + return self._invite_profile_name + + @property + def merchant_available(self): + """ + :rtype: list[object_.BunqMeMerchantAvailable] + """ - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._merchant_available def is_all_field_none(self): """ :rtype: bool """ - if self._TabUsageSingle is not None: + if self._color is not None: + return False + + if self._alias is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + if self._pointer is not None: + return False + + if self._status is not None: + return False + + if self._redirect_url is not None: + return False + + if self._invite_profile_name is not None: return False - if self._TabUsageMultiple is not None: + if self._merchant_available is not None: return False return True @@ -5048,479 +4476,302 @@ def from_json(json_str): """ :type json_str: str - :rtype: Tab + :rtype: BunqMeFundraiserProfileApiObject """ - return converter.json_to_class(Tab, json_str) + return converter.json_to_class(BunqMeFundraiserProfileApiObject, json_str) -class TabUsageSingle(core.BunqModel): +class BunqMeTabResultResponseApiObject(BunqModel): """ - TabUsageSingle is a Tab that can be paid once. The TabUsageSingle is created - with the status OPEN. Optionally you can add TabItems to the tab using - /tab/_/tab-item, TabItems don't affect the total amount of the Tab. However, - if you've created any TabItems for a Tab the sum of the amounts of these - items must be equal to the total_amount of the Tab when you change its - status to WAITING_FOR_PAYMENT. By setting the visibility object a - TabUsageSingle with the status OPEN or WAITING_FOR_PAYMENT can be made - visible to customers. As soon as a customer pays the TabUsageSingle its - status changes to PAID, and it can't be paid again. + Used to view bunq.me TabResultResponse objects belonging to a tab. A + TabResultResponse is an object that holds details on a tab which has been + paid from the provided monetary account. - :param _merchant_reference: The merchant reference of the Tab, as defined by - the owner. - :type _merchant_reference: str - :param _description: The description of the TabUsageMultiple. Maximum 9000 - characters. - :type _description: str - :param _status: The status of the Tab. Can be OPEN, WAITING_FOR_PAYMENT, - PAID or CANCELED. + :param _payment: The payment made for the bunq.me tab. + :type _payment: Payment + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-tab-result-response/{}" + + # Object type. + _OBJECT_TYPE_GET = "BunqMeTabResultResponse" + + _payment = None + + @classmethod + def get(cls, bunq_me_tab_result_response_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type bunq_me_tab_result_response_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBunqMeTabResultResponse + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunq_me_tab_result_response_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBunqMeTabResultResponse.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def payment(self): + """ + :rtype: Payment + """ + + return self._payment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._payment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: BunqMeTabResultResponseApiObject + """ + + return converter.json_to_class(BunqMeTabResultResponseApiObject, json_str) + + +class BunqMeTabApiObject(BunqModel): + """ + bunq.me tabs allows you to create a payment request and share the link + through e-mail, chat, etc. Multiple persons are able to respond to the + payment request and pay through bunq, iDeal or SOFORT. + + :param _bunqme_tab_entry: The bunq.me entry containing the payment + information. + :type _bunqme_tab_entry: BunqMeTabEntry + :param _status: The status of the bunq.me. Can be WAITING_FOR_PAYMENT, + CANCELLED or EXPIRED. :type _status: str - :param _amount_total: The total amount of the Tab. - :type _amount_total: object_.Amount - :param _allow_amount_higher: [DEPRECATED] Whether or not a higher amount can - be paid. - :type _allow_amount_higher: bool - :param _allow_amount_lower: [DEPRECATED] Whether or not a lower amount can - be paid. - :type _allow_amount_lower: bool - :param _want_tip: [DEPRECATED] Whether or not the user paying the Tab should - be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must be - false. - :type _want_tip: bool - :param _minimum_age: The minimum age of the user paying the Tab. - :type _minimum_age: bool - :param _require_address: Whether or not an billing and shipping address must - be provided when paying the Tab. - :type _require_address: str - :param _redirect_url: The URL which the user is sent to after paying the - Tab. - :type _redirect_url: str - :param _visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type _visibility: object_.TabVisibility - :param _expiration: The moment when this Tab expires. - :type _expiration: str - :param _tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type _tab_attachment: list[object_.BunqId] - :param _uuid: The uuid of the created TabUsageSingle. - :type _uuid: str - :param _created: The timestamp of the Tab's creation. + :param _event_id: The ID of the related event if the bunqMeTab made by + 'split' functionality. + :type _event_id: int + :param _id_: The id of the created bunq.me. + :type _id_: int + :param _created: The timestamp when the bunq.me was created. :type _created: str - :param _updated: The timestamp of the Tab's last update. + :param _updated: The timestamp when the bunq.me was last updated. :type _updated: str - :param _amount_paid: The amount that has been paid for this Tab. - :type _amount_paid: object_.Amount - :param _qr_code_token: The token used to redirect mobile devices directly to - the bunq app. Because they can't scan a QR code. - :type _qr_code_token: str - :param _tab_url: The URL redirecting user to the tab payment in the bunq - app. Only works on mobile devices. - :type _tab_url: str - :param _alias: The alias of the party that owns this tab. - :type _alias: object_.MonetaryAccountReference - :param _cash_register_location: The location of the cash register that - created this tab. - :type _cash_register_location: object_.Geolocation - :param _tab_item: The tab items of this tab. - :type _tab_item: list[TabItem] + :param _time_expiry: The timestamp of when the bunq.me expired or will + expire. + :type _time_expiry: str + :param _monetary_account_id: The id of the MonetaryAccount the bunq.me was + sent from. + :type _monetary_account_id: int + :param _type_: The type of the bunq.me Tab. Should be BUNQ_ME + :type _type_: str + :param _alias_monetary_account: The LabelMonetaryAccount with the public + information of the User and the MonetaryAccount that created the bunq.me + link. + :type _alias_monetary_account: object_.MonetaryAccountReference + :param _bunqme_tab_share_url: The url that points to the bunq.me page. + :type _bunqme_tab_share_url: str + :param _bunqme_tab_entries: The bunq.me tab entries attached to this bunq.me + Tab. + :type _bunqme_tab_entries: list[BunqMeTabEntry] + :param _result_inquiries: The list of bunq.me result Inquiries successfully + made and paid. + :type _result_inquiries: list[BunqMeTabResultInquiry] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-single" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-single/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-single/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-single/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-single" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-tab" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-tab/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-tab" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-tab/{}" # Field constants. - FIELD_MERCHANT_REFERENCE = "merchant_reference" - FIELD_DESCRIPTION = "description" + FIELD_BUNQME_TAB_ENTRY = "bunqme_tab_entry" FIELD_STATUS = "status" - FIELD_AMOUNT_TOTAL = "amount_total" - FIELD_ALLOW_AMOUNT_HIGHER = "allow_amount_higher" - FIELD_ALLOW_AMOUNT_LOWER = "allow_amount_lower" - FIELD_WANT_TIP = "want_tip" - FIELD_MINIMUM_AGE = "minimum_age" - FIELD_REQUIRE_ADDRESS = "require_address" - FIELD_REDIRECT_URL = "redirect_url" - FIELD_VISIBILITY = "visibility" - FIELD_EXPIRATION = "expiration" - FIELD_TAB_ATTACHMENT = "tab_attachment" + FIELD_EVENT_ID = "event_id" # Object type. - _OBJECT_TYPE_POST = "Uuid" - _OBJECT_TYPE_PUT = "Uuid" - _OBJECT_TYPE_GET = "TabUsageSingle" + _OBJECT_TYPE_GET = "BunqMeTab" - _uuid = None + _id_ = None _created = None _updated = None - _merchant_reference = None - _description = None + _time_expiry = None + _monetary_account_id = None _status = None - _amount_total = None - _amount_paid = None - _qr_code_token = None - _tab_url = None - _visibility = None - _minimum_age = None - _require_address = None - _redirect_url = None - _expiration = None - _alias = None - _cash_register_location = None - _tab_item = None - _tab_attachment = None - _merchant_reference_field_for_request = None - _description_field_for_request = None + _type_ = None + _alias_monetary_account = None + _bunqme_tab_share_url = None + _bunqme_tab_entry = None + _bunqme_tab_entries = None + _result_inquiries = None + _bunqme_tab_entry_field_for_request = None _status_field_for_request = None - _amount_total_field_for_request = None - _allow_amount_higher_field_for_request = None - _allow_amount_lower_field_for_request = None - _want_tip_field_for_request = None - _minimum_age_field_for_request = None - _require_address_field_for_request = None - _redirect_url_field_for_request = None - _visibility_field_for_request = None - _expiration_field_for_request = None - _tab_attachment_field_for_request = None - - def __init__(self, description, status=None, amount_total=None, - merchant_reference=None, allow_amount_higher=None, - allow_amount_lower=None, want_tip=None, minimum_age=None, - require_address=None, redirect_url=None, visibility=None, - expiration=None, tab_attachment=None): - """ - :param description: The description of the Tab. Maximum 9000 characters. - Field is required but can be an empty string. - :type description: str - :param status: The status of the Tab. On creation the status must be set to - OPEN. You can change the status from OPEN to WAITING_FOR_PAYMENT. + _event_id_field_for_request = None + + def __init__(self, bunqme_tab_entry, status=None, event_id=None): + """ + :param bunqme_tab_entry: The bunq.me entry containing the payment + information. + :type bunqme_tab_entry: BunqMeTabEntry + :param status: The status of the bunq.me. Ignored in POST requests but can + be used for cancelling the bunq.me by setting status as CANCELLED with a PUT + request. :type status: str - :param amount_total: The total amount of the Tab. Must be a positive amount. - As long as the tab has the status OPEN you can change the total amount. This - amount is not affected by the amounts of the TabItems. However, if you've - created any TabItems for a Tab the sum of the amounts of these items must be - equal to the total_amount of the Tab when you change its status to - WAITING_FOR_PAYMENT. - :type amount_total: object_.Amount - :param merchant_reference: The reference of the Tab, as defined by the - owner. This reference will be set for any payment that is generated by this - tab. Must be unique among all the owner's tabs for the used monetary - account. - :type merchant_reference: str - :param allow_amount_higher: [DEPRECATED] Whether or not a higher amount can - be paid. - :type allow_amount_higher: bool - :param allow_amount_lower: [DEPRECATED] Whether or not a lower amount can be - paid. - :type allow_amount_lower: bool - :param want_tip: [DEPRECATED] Whether or not the user paying the Tab should - be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must be - false. - :type want_tip: bool - :param minimum_age: The minimum age of the user paying the Tab. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the Tab. Possible values are: BILLING, SHIPPING, - BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param redirect_url: The URL which the user is sent to after paying the Tab. - :type redirect_url: str - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 1 hour - into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] + :param event_id: The ID of the related event if the bunqMeTab made by + 'split' functionality. + :type event_id: int """ - self._description_field_for_request = description + self._bunqme_tab_entry_field_for_request = bunqme_tab_entry self._status_field_for_request = status - self._amount_total_field_for_request = amount_total - self._merchant_reference_field_for_request = merchant_reference - self._allow_amount_higher_field_for_request = allow_amount_higher - self._allow_amount_lower_field_for_request = allow_amount_lower - self._want_tip_field_for_request = want_tip - self._minimum_age_field_for_request = minimum_age - self._require_address_field_for_request = require_address - self._redirect_url_field_for_request = redirect_url - self._visibility_field_for_request = visibility - self._expiration_field_for_request = expiration - self._tab_attachment_field_for_request = tab_attachment + self._event_id_field_for_request = event_id @classmethod - def create(cls, cash_register_id, description, status, amount_total, - monetary_account_id=None, merchant_reference=None, - allow_amount_higher=None, allow_amount_lower=None, want_tip=None, - minimum_age=None, require_address=None, redirect_url=None, - visibility=None, expiration=None, tab_attachment=None, - custom_headers=None): + def create(cls,bunqme_tab_entry, monetary_account_id=None, status=None, event_id=None, custom_headers=None): """ - Create a TabUsageSingle. The initial status must be OPEN - :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :param description: The description of the Tab. Maximum 9000 characters. - Field is required but can be an empty string. - :type description: str - :param status: The status of the Tab. On creation the status must be set - to OPEN. You can change the status from OPEN to WAITING_FOR_PAYMENT. + :param bunqme_tab_entry: The bunq.me entry containing the payment + information. + :type bunqme_tab_entry: BunqMeTabEntry + :param status: The status of the bunq.me. Ignored in POST requests but + can be used for cancelling the bunq.me by setting status as CANCELLED + with a PUT request. :type status: str - :param amount_total: The total amount of the Tab. Must be a positive - amount. As long as the tab has the status OPEN you can change the total - amount. This amount is not affected by the amounts of the TabItems. - However, if you've created any TabItems for a Tab the sum of the amounts - of these items must be equal to the total_amount of the Tab when you - change its status to WAITING_FOR_PAYMENT. - :type amount_total: object_.Amount - :param merchant_reference: The reference of the Tab, as defined by the - owner. This reference will be set for any payment that is generated by - this tab. Must be unique among all the owner's tabs for the used - monetary account. - :type merchant_reference: str - :param allow_amount_higher: [DEPRECATED] Whether or not a higher amount - can be paid. - :type allow_amount_higher: bool - :param allow_amount_lower: [DEPRECATED] Whether or not a lower amount - can be paid. - :type allow_amount_lower: bool - :param want_tip: [DEPRECATED] Whether or not the user paying the Tab - should be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must - be false. - :type want_tip: bool - :param minimum_age: The minimum age of the user paying the Tab. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the Tab. Possible values are: BILLING, SHIPPING, - BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param redirect_url: The URL which the user is sent to after paying the - Tab. - :type redirect_url: str - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 1 - hour into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] + :param event_id: The ID of the related event if the bunqMeTab made by + 'split' functionality. + :type event_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseStr + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} request_map = { - cls.FIELD_MERCHANT_REFERENCE: merchant_reference, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_STATUS: status, - cls.FIELD_AMOUNT_TOTAL: amount_total, - cls.FIELD_ALLOW_AMOUNT_HIGHER: allow_amount_higher, - cls.FIELD_ALLOW_AMOUNT_LOWER: allow_amount_lower, - cls.FIELD_WANT_TIP: want_tip, - cls.FIELD_MINIMUM_AGE: minimum_age, - cls.FIELD_REQUIRE_ADDRESS: require_address, - cls.FIELD_REDIRECT_URL: redirect_url, - cls.FIELD_VISIBILITY: visibility, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_TAB_ATTACHMENT: tab_attachment - } +cls.FIELD_BUNQME_TAB_ENTRY : bunqme_tab_entry, +cls.FIELD_STATUS : status, +cls.FIELD_EVENT_ID : event_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) @classmethod - def update(cls, cash_register_id, tab_usage_single_uuid, - monetary_account_id=None, status=None, amount_total=None, - visibility=None, expiration=None, tab_attachment=None, - custom_headers=None): + def update(cls, bunq_me_tab_id, monetary_account_id=None, status=None, custom_headers=None): """ - Modify a specific TabUsageSingle. You can change the amount_total, - status and visibility. Once you change the status to WAITING_FOR_PAYMENT - the TabUsageSingle will expire after 5 minutes (default) or up to 1 hour - if a different expiration is provided. - :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_single_uuid: str - :param status: The status of the Tab. On creation the status must be set - to OPEN. You can change the status from OPEN to WAITING_FOR_PAYMENT. + :type bunq_me_tab_id: int + :param status: The status of the bunq.me. Ignored in POST requests but + can be used for cancelling the bunq.me by setting status as CANCELLED + with a PUT request. :type status: str - :param amount_total: The total amount of the Tab. Must be a positive - amount. As long as the tab has the status OPEN you can change the total - amount. This amount is not affected by the amounts of the TabItems. - However, if you've created any TabItems for a Tab the sum of the amounts - of these items must be equal to the total_amount of the Tab when you - change its status to WAITING_FOR_PAYMENT. - :type amount_total: object_.Amount - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 1 - hour into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] :type custom_headers: dict[str, str]|None - :rtype: BunqResponseStr + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_AMOUNT_TOTAL: amount_total, - cls.FIELD_VISIBILITY: visibility, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_TAB_ATTACHMENT: tab_attachment - } +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_single_uuid) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunq_me_tab_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) @classmethod - def delete(cls, cash_register_id, tab_usage_single_uuid, - monetary_account_id=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Cancel a specific TabUsageSingle. - :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_single_uuid: str + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseBunqMeTabList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_single_uuid) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseBunqMeTabList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, cash_register_id, tab_usage_single_uuid, - monetary_account_id=None, custom_headers=None): + def get(cls, bunq_me_tab_id, monetary_account_id=None, custom_headers=None): """ - Get a specific TabUsageSingle. - - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_single_uuid: str + :type bunq_me_tab_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseTabUsageSingle + :rtype: BunqResponseBunqMeTab """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_single_uuid) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunq_me_tab_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseTabUsageSingle.cast_from_bunq_response( + return BunqResponseBunqMeTab.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def list(cls, cash_register_id, monetary_account_id=None, params=None, - custom_headers=None): - """ - Get a collection of TabUsageSingle. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabUsageSingleList - """ - - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseTabUsageSingleList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) - @property - def uuid(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._uuid + return self._id_ @property def created(self): @@ -5539,20 +4790,20 @@ def updated(self): return self._updated @property - def merchant_reference(self): + def time_expiry(self): """ :rtype: str """ - return self._merchant_reference + return self._time_expiry @property - def description(self): + def monetary_account_id(self): """ - :rtype: str + :rtype: int """ - return self._description + return self._monetary_account_id @property def status(self): @@ -5563,169 +4814,92 @@ def status(self): return self._status @property - def amount_total(self): + def type_(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount_total + return self._type_ @property - def amount_paid(self): + def alias_monetary_account(self): """ - :rtype: object_.Amount + :rtype: object_.MonetaryAccountReference """ - return self._amount_paid + return self._alias_monetary_account @property - def qr_code_token(self): + def bunqme_tab_share_url(self): """ :rtype: str """ - return self._qr_code_token + return self._bunqme_tab_share_url @property - def tab_url(self): + def bunqme_tab_entry(self): """ - :rtype: str + :rtype: BunqMeTabEntry """ - return self._tab_url + return self._bunqme_tab_entry @property - def visibility(self): + def bunqme_tab_entries(self): """ - :rtype: object_.TabVisibility + :rtype: list[BunqMeTabEntry] """ - return self._visibility + return self._bunqme_tab_entries @property - def minimum_age(self): + def result_inquiries(self): """ - :rtype: bool + :rtype: list[BunqMeTabResultInquiry] """ - return self._minimum_age + return self._result_inquiries - @property - def require_address(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._require_address + if self._id_ is not None: + return False - @property - def redirect_url(self): - """ - :rtype: str - """ + if self._created is not None: + return False - return self._redirect_url + if self._updated is not None: + return False - @property - def expiration(self): - """ - :rtype: str - """ + if self._time_expiry is not None: + return False - return self._expiration - - @property - def alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._alias - - @property - def cash_register_location(self): - """ - :rtype: object_.Geolocation - """ - - return self._cash_register_location - - @property - def tab_item(self): - """ - :rtype: list[TabItem] - """ - - return self._tab_item - - @property - def tab_attachment(self): - """ - :rtype: list[object_.BunqId] - """ - - return self._tab_attachment - - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._uuid is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._merchant_reference is not None: - return False - - if self._description is not None: - return False + if self._monetary_account_id is not None: + return False if self._status is not None: return False - if self._amount_total is not None: - return False - - if self._amount_paid is not None: - return False - - if self._qr_code_token is not None: - return False - - if self._tab_url is not None: - return False - - if self._visibility is not None: - return False - - if self._minimum_age is not None: - return False - - if self._require_address is not None: - return False - - if self._redirect_url is not None: + if self._type_ is not None: return False - if self._expiration is not None: + if self._alias_monetary_account is not None: return False - if self._alias is not None: + if self._bunqme_tab_share_url is not None: return False - if self._cash_register_location is not None: + if self._bunqme_tab_entry is not None: return False - if self._tab_item is not None: + if self._bunqme_tab_entries is not None: return False - if self._tab_attachment is not None: + if self._result_inquiries is not None: return False return True @@ -5735,122 +4909,168 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabUsageSingle + :rtype: BunqMeTabApiObject """ - return converter.json_to_class(TabUsageSingle, json_str) + return converter.json_to_class(BunqMeTabApiObject, json_str) -class TabItem(core.BunqModel): +class BunqMeTabEntryApiObject(BunqModel): """ - Used to get items on a tab. + bunq.me tabs allows you to create a payment request and share the link + through e-mail, chat, etc. Multiple persons are able to respond to the + payment request and pay through bunq, iDeal or SOFORT. - :param _id_: The id of the tab item. - :type _id_: int - :param _description: The item's brief description. + :param _amount_inquired: The requested Amount. + :type _amount_inquired: object_.Amount + :param _description: The description for the bunq.me. Maximum 9000 + characters. :type _description: str - :param _ean_code: The item's EAN code. - :type _ean_code: str - :param _avatar_attachment: A struct with an AttachmentPublic UUID that used - as an avatar for the TabItem. - :type _avatar_attachment: object_.AttachmentPublic - :param _tab_attachment: A list of AttachmentTab attached to the TabItem. - :type _tab_attachment: list[object_.AttachmentTab] - :param _quantity: The quantity of the item. Formatted as a number containing - up to 15 digits, up to 15 decimals and using a dot. - :type _quantity: str - :param _amount: The money amount of the item. - :type _amount: object_.Amount + :param _redirect_url: The URL which the user is sent to when a payment is + completed. + :type _redirect_url: str + :param _uuid: The uuid of the bunq.me. + :type _uuid: str + :param _alias: The LabelMonetaryAccount with the public information of the + User and the MonetaryAccount that created the bunq.me link. + :type _alias: object_.MonetaryAccountReference + :param _status: The status of the bunq.me. Can be WAITING_FOR_PAYMENT, + CANCELLED or EXPIRED. + :type _status: str + :param _merchant_available: List of available merchants. + :type _merchant_available: list[object_.BunqMeMerchantAvailable] + :param _invite_profile_name: Provided if the user has enabled their invite + link. + :type _invite_profile_name: str """ - _id_ = None + # Field constants. + FIELD_AMOUNT_INQUIRED = "amount_inquired" + FIELD_DESCRIPTION = "description" + FIELD_REDIRECT_URL = "redirect_url" + + + _uuid = None + _amount_inquired = None + _alias = None _description = None - _ean_code = None - _avatar_attachment = None - _tab_attachment = None - _quantity = None - _amount = None + _status = None + _redirect_url = None + _merchant_available = None + _invite_profile_name = None + _amount_inquired_field_for_request = None + _description_field_for_request = None + _redirect_url_field_for_request = None - @property - def id_(self): + def __init__(self, amount_inquired, description, redirect_url=None): """ - :rtype: int + :param amount_inquired: The Amount requested to be paid. Can be optional. + :type amount_inquired: object_.Amount + :param description: The description for the bunq.me. Maximum 9000 + characters. Field is required but can be an empty string. + :type description: str + :param redirect_url: The URL which the user is sent to after making a + payment. + :type redirect_url: str """ - return self._id_ + self._amount_inquired_field_for_request = amount_inquired + self._description_field_for_request = description + self._redirect_url_field_for_request = redirect_url + + @property - def description(self): + def uuid(self): """ :rtype: str """ - return self._description + return self._uuid @property - def ean_code(self): + def amount_inquired(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._ean_code + return self._amount_inquired @property - def avatar_attachment(self): + def alias(self): """ - :rtype: object_.AttachmentPublic + :rtype: object_.MonetaryAccountReference """ - return self._avatar_attachment + return self._alias @property - def tab_attachment(self): + def description(self): """ - :rtype: list[object_.AttachmentTab] + :rtype: str """ - return self._tab_attachment + return self._description @property - def quantity(self): + def status(self): """ :rtype: str """ - return self._quantity + return self._status @property - def amount(self): + def redirect_url(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount + return self._redirect_url + + @property + def merchant_available(self): + """ + :rtype: list[object_.BunqMeMerchantAvailable] + """ + + return self._merchant_available + + @property + def invite_profile_name(self): + """ + :rtype: str + """ + + return self._invite_profile_name def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._uuid is not None: return False - if self._description is not None: + if self._amount_inquired is not None: return False - if self._ean_code is not None: + if self._alias is not None: return False - if self._avatar_attachment is not None: + if self._description is not None: return False - if self._tab_attachment is not None: + if self._status is not None: return False - if self._quantity is not None: + if self._redirect_url is not None: return False - if self._amount is not None: + if self._merchant_available is not None: + return False + + if self._invite_profile_name is not None: return False return True @@ -5860,1185 +5080,943 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabItem + :rtype: BunqMeTabEntryApiObject """ - return converter.json_to_class(TabItem, json_str) + return converter.json_to_class(BunqMeTabEntryApiObject, json_str) -class TabUsageMultiple(core.BunqModel): +class BunqMeTabResultInquiryApiObject(BunqModel): """ - TabUsageMultiple is a Tab that can be paid by multiple users. Just like the - TabUsageSingle it is created with the status OPEN, the visibility can be - defined in the visibility object and TabItems can be added as long as the - status is OPEN. When you change the status to PAYABLE any bunq user can use - the tab to make a payment to your account. After an user has paid your - TabUsageMultiple the status will not change, it will stay PAYABLE. For - example: you can create a TabUsageMultiple with require_address set to true. - Now show the QR code of this Tab on your webshop, and any bunq user can - instantly pay and order something from your webshop. + Used to view bunq.me TabResultInquiry objects belonging to a tab. A + TabResultInquiry is an object that holds details on both the tab and a + single payment made for that tab. - :param _description: The description of the TabUsageMultiple. Maximum 9000 - characters. - :type _description: str - :param _status: The status of the Tab. Can be OPEN, PAYABLE or CLOSED. - :type _status: str - :param _amount_total: The total amount of the Tab. - :type _amount_total: object_.Amount - :param _allow_amount_higher: [DEPRECATED] Whether or not a higher amount can - be paid. - :type _allow_amount_higher: bool - :param _allow_amount_lower: [DEPRECATED] Whether or not a lower amount can - be paid. - :type _allow_amount_lower: bool - :param _want_tip: [DEPRECATED] Whether or not the user paying the Tab should - be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must be - false. - :type _want_tip: bool - :param _minimum_age: The minimum age of the user paying the Tab. - :type _minimum_age: bool - :param _require_address: Whether or not an billing and shipping address must - be provided when paying the Tab. - :type _require_address: str - :param _redirect_url: The URL which the user is sent to after paying the - Tab. - :type _redirect_url: str - :param _visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type _visibility: object_.TabVisibility - :param _expiration: The moment when this Tab expires. - :type _expiration: str - :param _tab_attachment: An array of attachments that describe the tab. - Viewable through the GET /tab/{tabid}/attachment/{attachmentid}/content - endpoint. - :type _tab_attachment: list[object_.BunqId] - :param _uuid: The uuid of the created TabUsageMultiple. - :type _uuid: str - :param _created: The timestamp of the Tab's creation. - :type _created: str - :param _updated: The timestamp of the Tab's last update. - :type _updated: str - :param _qr_code_token: The token used to redirect mobile devices directly to - the bunq app. Because they can't scan a QR code. - :type _qr_code_token: str - :param _tab_url: The URL redirecting user to the tab payment in the bunq - app. Only works on mobile devices. - :type _tab_url: str - :param _alias: The alias of the party that owns this tab. - :type _alias: object_.MonetaryAccountReference - :param _cash_register_location: The location of the cash register that - created this tab. - :type _cash_register_location: object_.Geolocation - :param _tab_item: The tab items of this tab. - :type _tab_item: list[TabItem] + :param _payment: The payment made for the Tab. + :type _payment: Payment + :param _bunq_me_tab_id: The Id of the bunq.me tab that this + BunqMeTabResultInquiry belongs to. + :type _bunq_me_tab_id: int """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-multiple" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-multiple/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-multiple/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-multiple/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab-usage-multiple" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_STATUS = "status" - FIELD_AMOUNT_TOTAL = "amount_total" - FIELD_ALLOW_AMOUNT_HIGHER = "allow_amount_higher" - FIELD_ALLOW_AMOUNT_LOWER = "allow_amount_lower" - FIELD_WANT_TIP = "want_tip" - FIELD_MINIMUM_AGE = "minimum_age" - FIELD_REQUIRE_ADDRESS = "require_address" - FIELD_REDIRECT_URL = "redirect_url" - FIELD_VISIBILITY = "visibility" - FIELD_EXPIRATION = "expiration" - FIELD_TAB_ATTACHMENT = "tab_attachment" + _payment = None + _bunq_me_tab_id = None - # Object type. - _OBJECT_TYPE_POST = "Uuid" - _OBJECT_TYPE_PUT = "Uuid" - _OBJECT_TYPE_GET = "TabUsageMultiple" + @property + def payment(self): + """ + :rtype: Payment + """ - _uuid = None - _created = None - _updated = None - _description = None - _status = None - _amount_total = None - _qr_code_token = None - _tab_url = None - _visibility = None - _minimum_age = None - _require_address = None - _redirect_url = None - _expiration = None - _alias = None - _cash_register_location = None - _tab_item = None - _tab_attachment = None - _description_field_for_request = None - _status_field_for_request = None - _amount_total_field_for_request = None - _allow_amount_higher_field_for_request = None - _allow_amount_lower_field_for_request = None - _want_tip_field_for_request = None - _minimum_age_field_for_request = None - _require_address_field_for_request = None - _redirect_url_field_for_request = None - _visibility_field_for_request = None - _expiration_field_for_request = None - _tab_attachment_field_for_request = None + return self._payment - def __init__(self, description, status=None, amount_total=None, - allow_amount_higher=None, allow_amount_lower=None, - want_tip=None, minimum_age=None, require_address=None, - redirect_url=None, visibility=None, expiration=None, - tab_attachment=None): + @property + def bunq_me_tab_id(self): """ - :param description: The description of the TabUsageMultiple. Maximum 9000 - characters. Field is required but can be an empty string. - :type description: str - :param status: The status of the TabUsageMultiple. On creation the status - must be set to OPEN. You can change the status from OPEN to PAYABLE. If the - TabUsageMultiple gets paid the status will remain PAYABLE. - :type status: str - :param amount_total: The total amount of the Tab. Must be a positive amount. - As long as the tab has the status OPEN you can change the total amount. This - amount is not affected by the amounts of the TabItems. However, if you've - created any TabItems for a Tab the sum of the amounts of these items must be - equal to the total_amount of the Tab when you change its status to PAYABLE - :type amount_total: object_.Amount - :param allow_amount_higher: [DEPRECATED] Whether or not a higher amount can - be paid. - :type allow_amount_higher: bool - :param allow_amount_lower: [DEPRECATED] Whether or not a lower amount can be - paid. - :type allow_amount_lower: bool - :param want_tip: [DEPRECATED] Whether or not the user paying the Tab should - be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must be - false. - :type want_tip: bool - :param minimum_age: The minimum age of the user paying the Tab. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the Tab. Possible values are: BILLING, SHIPPING, - BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param redirect_url: The URL which the user is sent to after paying the Tab. - :type redirect_url: str - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 365 days - into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] + :rtype: int """ - self._description_field_for_request = description - self._status_field_for_request = status - self._amount_total_field_for_request = amount_total - self._allow_amount_higher_field_for_request = allow_amount_higher - self._allow_amount_lower_field_for_request = allow_amount_lower - self._want_tip_field_for_request = want_tip - self._minimum_age_field_for_request = minimum_age - self._require_address_field_for_request = require_address - self._redirect_url_field_for_request = redirect_url - self._visibility_field_for_request = visibility - self._expiration_field_for_request = expiration - self._tab_attachment_field_for_request = tab_attachment + return self._bunq_me_tab_id - @classmethod - def create(cls, cash_register_id, description, status, amount_total, - monetary_account_id=None, allow_amount_higher=None, - allow_amount_lower=None, want_tip=None, minimum_age=None, - require_address=None, redirect_url=None, visibility=None, - expiration=None, tab_attachment=None, custom_headers=None): + def is_all_field_none(self): """ - Create a TabUsageMultiple. On creation the status must be set to OPEN - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :param description: The description of the TabUsageMultiple. Maximum - 9000 characters. Field is required but can be an empty string. - :type description: str - :param status: The status of the TabUsageMultiple. On creation the - status must be set to OPEN. You can change the status from OPEN to - PAYABLE. If the TabUsageMultiple gets paid the status will remain - PAYABLE. - :type status: str - :param amount_total: The total amount of the Tab. Must be a positive - amount. As long as the tab has the status OPEN you can change the total - amount. This amount is not affected by the amounts of the TabItems. - However, if you've created any TabItems for a Tab the sum of the amounts - of these items must be equal to the total_amount of the Tab when you - change its status to PAYABLE - :type amount_total: object_.Amount - :param allow_amount_higher: [DEPRECATED] Whether or not a higher amount - can be paid. - :type allow_amount_higher: bool - :param allow_amount_lower: [DEPRECATED] Whether or not a lower amount - can be paid. - :type allow_amount_lower: bool - :param want_tip: [DEPRECATED] Whether or not the user paying the Tab - should be asked if he wants to give a tip. When want_tip is set to true, - allow_amount_higher must also be set to true and allow_amount_lower must - be false. - :type want_tip: bool - :param minimum_age: The minimum age of the user paying the Tab. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the Tab. Possible values are: BILLING, SHIPPING, - BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param redirect_url: The URL which the user is sent to after paying the - Tab. - :type redirect_url: str - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 365 - days into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseStr + :rtype: bool """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_STATUS: status, - cls.FIELD_AMOUNT_TOTAL: amount_total, - cls.FIELD_ALLOW_AMOUNT_HIGHER: allow_amount_higher, - cls.FIELD_ALLOW_AMOUNT_LOWER: allow_amount_lower, - cls.FIELD_WANT_TIP: want_tip, - cls.FIELD_MINIMUM_AGE: minimum_age, - cls.FIELD_REQUIRE_ADDRESS: require_address, - cls.FIELD_REDIRECT_URL: redirect_url, - cls.FIELD_VISIBILITY: visibility, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_TAB_ATTACHMENT: tab_attachment - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._payment is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._bunq_me_tab_id is not None: + return False - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) - ) + return True - @classmethod - def update(cls, cash_register_id, tab_usage_multiple_uuid, - monetary_account_id=None, status=None, amount_total=None, - visibility=None, expiration=None, tab_attachment=None, - custom_headers=None): + @staticmethod + def from_json(json_str): """ - Modify a specific TabUsageMultiple. You can change the amount_total, - status and visibility. Once you change the status to PAYABLE the - TabUsageMultiple will expire after a year (default). If you've created - any TabItems for a Tab the sum of the amounts of these items must be - equal to the total_amount of the Tab when you change its status to - PAYABLE. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_multiple_uuid: str - :param status: The status of the TabUsageMultiple. On creation the - status must be set to OPEN. You can change the status from OPEN to - PAYABLE. If the TabUsageMultiple gets paid the status will remain - PAYABLE. - :type status: str - :param amount_total: The total amount of the Tab. Must be a positive - amount. As long as the tab has the status OPEN you can change the total - amount. This amount is not affected by the amounts of the TabItems. - However, if you've created any TabItems for a Tab the sum of the amounts - of these items must be equal to the total_amount of the Tab when you - change its status to PAYABLE - :type amount_total: object_.Amount - :param visibility: The visibility of a Tab. A Tab can be visible trough - NearPay, the QR code of the CashRegister and its own QR code. - :type visibility: object_.TabVisibility - :param expiration: The moment when this Tab expires. Can be at most 365 - days into the future. - :type expiration: str - :param tab_attachment: An array of attachments that describe the tab. - Uploaded through the POST /user/{userid}/attachment-tab endpoint. - :type tab_attachment: list[object_.BunqId] - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseStr + :rtype: BunqMeTabResultInquiryApiObject """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_AMOUNT_TOTAL: amount_total, - cls.FIELD_VISIBILITY: visibility, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_TAB_ATTACHMENT: tab_attachment - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return converter.json_to_class(BunqMeTabResultInquiryApiObject, json_str) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_multiple_uuid) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - return BunqResponseStr.cast_from_bunq_response( - cls._process_for_uuid(response_raw) - ) +class CardBatchReplaceApiObject(BunqModel): + """ + Used to replace multiple cards in a batch. + + :param _cards: The cards that need to be replaced. + :type _cards: list[object_.CardBatchReplaceEntry] + :param _updated_card_ids: The ids of the cards that have been replaced. + :type _updated_card_ids: list[object_.BunqId] + """ - @classmethod - def delete(cls, cash_register_id, tab_usage_multiple_uuid, - monetary_account_id=None, custom_headers=None): - """ - Close a specific TabUsageMultiple. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_multiple_uuid: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/card-batch-replace" - if custom_headers is None: - custom_headers = {} + # Field constants. + FIELD_CARDS = "cards" - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_multiple_uuid) - response_raw = api_client.delete(endpoint_url, custom_headers) + # Object type. + _OBJECT_TYPE_POST = "CardBatchReplace" - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + _updated_card_ids = None + _cards_field_for_request = None - @classmethod - def get(cls, cash_register_id, tab_usage_multiple_uuid, - monetary_account_id=None, custom_headers=None): + def __init__(self, cards): """ - Get a specific TabUsageMultiple. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_usage_multiple_uuid: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabUsageMultiple + :param cards: The cards that need to be replaced. + :type cards: list[object_.CardBatchReplaceEntry] """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_usage_multiple_uuid) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseTabUsageMultiple.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + self._cards_field_for_request = cards @classmethod - def list(cls, cash_register_id, monetary_account_id=None, params=None, - custom_headers=None): + def create(cls,cards, custom_headers=None): """ - Get a collection of TabUsageMultiple. - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type params: dict[str, str]|None + :param cards: The cards that need to be replaced. + :type cards: list[object_.CardBatchReplaceEntry] :type custom_headers: dict[str, str]|None - :rtype: BunqResponseTabUsageMultipleList + :rtype: BunqResponseCardBatchReplace """ - if params is None: - params = {} - if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseTabUsageMultipleList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + request_map = { +cls.FIELD_CARDS : cards +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - @property - def uuid(self): - """ - :rtype: str - """ + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return self._uuid + return BunqResponseCardBatchReplace.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) @property - def created(self): + def updated_card_ids(self): """ - :rtype: str + :rtype: list[object_.BunqId] """ - return self._created + return self._updated_card_ids - @property - def updated(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._updated - - @property - def description(self): - """ - :rtype: str - """ + if self._updated_card_ids is not None: + return False - return self._description + return True - @property - def status(self): + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: CardBatchReplaceApiObject """ - return self._status + return converter.json_to_class(CardBatchReplaceApiObject, json_str) - @property - def amount_total(self): - """ - :rtype: object_.Amount - """ - return self._amount_total +class CardBatchApiObject(BunqModel): + """ + Used to update multiple cards in a batch. + + :param _cards: The cards that need to be updated. + :type _cards: list[object_.CardBatchEntry] + :param _updated_card_ids: The ids of the cards that have been updated. + :type _updated_card_ids: list[object_.BunqId] + """ - @property - def qr_code_token(self): - """ - :rtype: str - """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/card-batch" - return self._qr_code_token + # Field constants. + FIELD_CARDS = "cards" - @property - def tab_url(self): - """ - :rtype: str - """ + # Object type. + _OBJECT_TYPE_POST = "CardBatch" - return self._tab_url + _updated_card_ids = None + _cards_field_for_request = None - @property - def visibility(self): + def __init__(self, cards): """ - :rtype: object_.TabVisibility + :param cards: The cards that need to be updated. + :type cards: list[object_.CardBatchEntry] """ - return self._visibility + self._cards_field_for_request = cards - @property - def minimum_age(self): + @classmethod + def create(cls,cards, custom_headers=None): """ - :rtype: bool + :type user_id: int + :param cards: The cards that need to be updated. + :type cards: list[object_.CardBatchEntry] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCardBatch """ - return self._minimum_age - - @property - def require_address(self): - """ - :rtype: str - """ + if custom_headers is None: + custom_headers = {} - return self._require_address + request_map = { +cls.FIELD_CARDS : cards +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - @property - def redirect_url(self): - """ - :rtype: str - """ + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return self._redirect_url + return BunqResponseCardBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) @property - def expiration(self): + def updated_card_ids(self): """ - :rtype: str + :rtype: list[object_.BunqId] """ - return self._expiration + return self._updated_card_ids - @property - def alias(self): + def is_all_field_none(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: bool """ - return self._alias - - @property - def cash_register_location(self): - """ - :rtype: object_.Geolocation - """ + if self._updated_card_ids is not None: + return False - return self._cash_register_location + return True - @property - def tab_item(self): + @staticmethod + def from_json(json_str): """ - :rtype: list[TabItem] + :type json_str: str + + :rtype: CardBatchApiObject """ - return self._tab_item - - @property - def tab_attachment(self): - """ - :rtype: list[object_.BunqId] - """ + return converter.json_to_class(CardBatchApiObject, json_str) - return self._tab_attachment - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._uuid is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._description is not None: - return False - - if self._status is not None: - return False - - if self._amount_total is not None: - return False - - if self._qr_code_token is not None: - return False - - if self._tab_url is not None: - return False - - if self._visibility is not None: - return False - - if self._minimum_age is not None: - return False - - if self._require_address is not None: - return False - - if self._redirect_url is not None: - return False - - if self._expiration is not None: - return False - - if self._alias is not None: - return False - - if self._cash_register_location is not None: - return False - - if self._tab_item is not None: - return False - - if self._tab_attachment is not None: - return False - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: TabUsageMultiple - """ - - return converter.json_to_class(TabUsageMultiple, json_str) - - -class CertificatePinned(core.BunqModel): +class CardCreditApiObject(BunqModel): """ - This endpoint allow you to pin the certificate chains to your account. These - certificate chains are used for SSL validation whenever a callback is - initiated to one of your https callback urls. + With bunq it is possible to order credit cards that can then be connected + with each one of the monetary accounts the user has access to (including + connected accounts). - :param _certificate_chain: The certificate chain in .PEM format. - Certificates are glued with newline characters. - :type _certificate_chain: str - :param _id_: The id generated for the pinned certificate chain. + :param _first_line: The first line of text on the card + :type _first_line: str + :param _second_line: The second line of text on the card + :type _second_line: str + :param _name_on_card: The user's name on the card. + :type _name_on_card: str + :param _preferred_name_on_card: The user's preferred name on the card. + :type _preferred_name_on_card: str + :param _alias: The pointer to the monetary account that will be connected at + first with the card. Its IBAN code is also the one that will be printed on + the card itself. The pointer must be of type IBAN. + :type _alias: object_.Pointer + :param _type_: The type of the card. Can be MAESTRO, MASTERCARD. + :type _type_: str + :param _product_type: The product type of the card. + :type _product_type: str + :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type _pin_code_assignment: list[object_.CardPinAssignment] + :param _monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if not + supplied. + :type _monetary_account_id_fallback: int + :param _order_status: The order status of the card. Can be + NEW_CARD_REQUEST_RECEIVED, CARD_REQUEST_PENDING, SENT_FOR_PRODUCTION, + ACCEPTED_FOR_PRODUCTION, DELIVERED_TO_CUSTOMER, CARD_UPDATE_REQUESTED, + CARD_UPDATE_PENDING, CARD_UPDATE_SENT, CARD_UPDATE_ACCEPTED, + VIRTUAL_DELIVERY, NEW_CARD_REQUEST_PENDING_USER_APPROVAL, SENT_FOR_DELIVERY + or NEW_CARD_REQUEST_CANCELLED. + :type _order_status: str + :param _id_: The id of the card. :type _id_: int + :param _created: The timestamp of the card's creation. + :type _created: str + :param _updated: The timestamp of the card's last update. + :type _updated: str + :param _public_uuid: The public UUID of the card. + :type _public_uuid: str + :param _user_id: DEPRECATED. ID of the user who is owner of the card. + :type _user_id: int + :param _user_owner_id: ID of the user who is owner of the card. + :type _user_owner_id: int + :param _user_holder_id: ID of the user who is holder of the card. + :type _user_holder_id: int + :param _sub_type: The sub-type of the card. + :type _sub_type: str + :param _product_sub_type: The product sub-type of the card. + :type _product_sub_type: str + :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED. + :type _status: str + :param _sub_status: The sub-status of the card. Can be NONE or REPLACED. + :type _sub_status: str + :param _expiry_date: Expiry date of the card. + :type _expiry_date: str + :param _primary_account_numbers: Array of PANs and their attributes. + :type _primary_account_numbers: list[object_.CardPrimaryAccountNumber] + :param _payment_account_reference: The payment account reference number + associated with the card. + :type _payment_account_reference: str + :param _card_limit: The spending limit for the card. + :type _card_limit: object_.Amount + :param _card_limit_atm: The ATM spending limit for the card. + :type _card_limit_atm: object_.Amount + :param _country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type _country_permission: list[object_.CardCountryPermission] + :param _label_monetary_account_ordered: The monetary account this card was + ordered on and the label user that owns the card. + :type _label_monetary_account_ordered: object_.MonetaryAccountReference + :param _label_monetary_account_current: The monetary account that this card + is currently linked to and the label user viewing it. + :type _label_monetary_account_current: object_.MonetaryAccountReference + :param _monetary_account: Current monetary account (only for prepaid credit + cards). + :type _monetary_account: MonetaryAccount + :param _country: The country that is domestic to the card. Defaults to + country of residence of user. + :type _country: str + :param _card_shipment_tracking_url: A tracking link provided by our shipment + provider. + :type _card_shipment_tracking_url: str + :param _is_card_eligible_for_free_replacement: Whether this card is eligible + for a free replacement. + :type _is_card_eligible_for_free_replacement: bool + :param _card_replacement: The card replacement for this card. + :type _card_replacement: CardReplacement + :param _card_generated_cvc2: The generated CVC2 code for this card. + :type _card_generated_cvc2: CardGeneratedCvc2 + :param _is_limited_edition: Whether this card is a limited edition metal + card. + :type _is_limited_edition: bool + :param _card_metal_member_since_date: The date for the member since field on + the black metal card. + :type _card_metal_member_since_date: str + :param _company_employee_card: Details of this card belonging to a company, + if applicable. + :type _company_employee_card: CompanyEmployeeCard """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/certificate-pinned" - _ENDPOINT_URL_DELETE = "user/{}/certificate-pinned/{}" - _ENDPOINT_URL_LISTING = "user/{}/certificate-pinned" - _ENDPOINT_URL_READ = "user/{}/certificate-pinned/{}" + _ENDPOINT_URL_CREATE = "user/{}/card-credit" # Field constants. - FIELD_CERTIFICATE_CHAIN = "certificate_chain" + FIELD_FIRST_LINE = "first_line" + FIELD_SECOND_LINE = "second_line" + FIELD_NAME_ON_CARD = "name_on_card" + FIELD_PREFERRED_NAME_ON_CARD = "preferred_name_on_card" + FIELD_ALIAS = "alias" + FIELD_TYPE = "type" + FIELD_PRODUCT_TYPE = "product_type" + FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" + FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback" + FIELD_ORDER_STATUS = "order_status" # Object type. - _OBJECT_TYPE_GET = "CertificatePinned" + _OBJECT_TYPE_POST = "CardCredit" - _certificate_chain = None _id_ = None - _certificate_chain_field_for_request = None + _created = None + _updated = None + _public_uuid = None + _user_id = None + _user_owner_id = None + _user_holder_id = None + _type_ = None + _sub_type = None + _product_type = None + _product_sub_type = None + _first_line = None + _second_line = None + _status = None + _sub_status = None + _order_status = None + _expiry_date = None + _name_on_card = None + _preferred_name_on_card = None + _primary_account_numbers = None + _payment_account_reference = None + _card_limit = None + _card_limit_atm = None + _country_permission = None + _label_monetary_account_ordered = None + _label_monetary_account_current = None + _monetary_account = None + _pin_code_assignment = None + _monetary_account_id_fallback = None + _country = None + _card_shipment_tracking_url = None + _is_card_eligible_for_free_replacement = None + _card_replacement = None + _card_generated_cvc2 = None + _is_limited_edition = None + _card_metal_member_since_date = None + _company_employee_card = None + _first_line_field_for_request = None + _second_line_field_for_request = None + _name_on_card_field_for_request = None + _preferred_name_on_card_field_for_request = None + _alias_field_for_request = None + _type__field_for_request = None + _product_type_field_for_request = None + _pin_code_assignment_field_for_request = None + _monetary_account_id_fallback_field_for_request = None + _order_status_field_for_request = None - def __init__(self, certificate_chain): + def __init__(self, second_line, name_on_card, type_, product_type, first_line=None, preferred_name_on_card=None, alias=None, pin_code_assignment=None, monetary_account_id_fallback=None, order_status=None): """ - :param certificate_chain: The certificate chain in .PEM format. - :type certificate_chain: list[object_.Certificate] + :param second_line: The second line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can be + empty. + :type second_line: str + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param type_: The type of card to order. Can be MASTERCARD. + :type type_: str + :param product_type: The product type of the card to order. + :type product_type: str + :param first_line: The first line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can be + empty. + :type first_line: str + :param preferred_name_on_card: The user's preferred name that can be put on + the card. + :type preferred_name_on_card: str + :param alias: The pointer to the monetary account that will be connected at + first with the card. Its IBAN code is also the one that will be printed on + the card itself. The pointer must be of type IBAN. + :type alias: object_.Pointer + :param pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param monetary_account_id_fallback: ID of the MA to be used as fallback for + this card if insufficient balance. Fallback account is removed if not + supplied. + :type monetary_account_id_fallback: int + :param order_status: The order status of this card. Can be + CARD_REQUEST_PENDING or VIRTUAL_DELIVERY. + :type order_status: str """ - self._certificate_chain_field_for_request = certificate_chain + self._second_line_field_for_request = second_line + self._name_on_card_field_for_request = name_on_card + self._type__field_for_request = type_ + self._product_type_field_for_request = product_type + self._first_line_field_for_request = first_line + self._preferred_name_on_card_field_for_request = preferred_name_on_card + self._alias_field_for_request = alias + self._pin_code_assignment_field_for_request = pin_code_assignment + self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback + self._order_status_field_for_request = order_status @classmethod - def create(cls, certificate_chain, custom_headers=None): + def create(cls,second_line, name_on_card, type_, product_type, first_line=None, preferred_name_on_card=None, alias=None, pin_code_assignment=None, monetary_account_id_fallback=None, order_status=None, custom_headers=None): """ - Pin the certificate chain. + Create a new credit card request. :type user_id: int - :param certificate_chain: The certificate chain in .PEM format. - :type certificate_chain: list[object_.Certificate] + :param second_line: The second line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can + be empty. + :type second_line: str + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param type_: The type of card to order. Can be MASTERCARD. + :type type_: str + :param product_type: The product type of the card to order. + :type product_type: str + :param first_line: The first line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can + be empty. + :type first_line: str + :param preferred_name_on_card: The user's preferred name that can be put + on the card. + :type preferred_name_on_card: str + :param alias: The pointer to the monetary account that will be connected + at first with the card. Its IBAN code is also the one that will be + printed on the card itself. The pointer must be of type IBAN. + :type alias: object_.Pointer + :param pin_code_assignment: Array of Types, PINs, account IDs assigned + to the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if + not supplied. + :type monetary_account_id_fallback: int + :param order_status: The order status of this card. Can be + CARD_REQUEST_PENDING or VIRTUAL_DELIVERY. + :type order_status: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseCardCredit """ if custom_headers is None: custom_headers = {} request_map = { - cls.FIELD_CERTIFICATE_CHAIN: certificate_chain - } +cls.FIELD_FIRST_LINE : first_line, +cls.FIELD_SECOND_LINE : second_line, +cls.FIELD_NAME_ON_CARD : name_on_card, +cls.FIELD_PREFERRED_NAME_ON_CARD : preferred_name_on_card, +cls.FIELD_ALIAS : alias, +cls.FIELD_TYPE : type_, +cls.FIELD_PRODUCT_TYPE : product_type, +cls.FIELD_PIN_CODE_ASSIGNMENT : pin_code_assignment, +cls.FIELD_MONETARY_ACCOUNT_ID_FALLBACK : monetary_account_id_fallback, +cls.FIELD_ORDER_STATUS : order_status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseCardCredit.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) ) - @classmethod - def delete(cls, certificate_pinned_id, custom_headers=None): + @property + def id_(self): """ - Remove the pinned certificate chain with the specific ID. - - :type user_id: int - :type certificate_pinned_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - certificate_pinned_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._id_ - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def created(self): """ - List all the pinned certificate chain for the given user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCertificatePinnedList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseCertificatePinnedList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._created - @classmethod - def get(cls, certificate_pinned_id, custom_headers=None): + @property + def updated(self): """ - Get the pinned certificate chain with the specified ID. - - :type api_context: context.ApiContext - :type user_id: int - :type certificate_pinned_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseCertificatePinned + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - certificate_pinned_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseCertificatePinned.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._updated @property - def certificate_chain(self): + def public_uuid(self): """ :rtype: str """ - return self._certificate_chain + return self._public_uuid @property - def id_(self): + def user_id(self): """ :rtype: int """ - return self._id_ + return self._user_id - def is_all_field_none(self): + @property + def user_owner_id(self): """ - :rtype: bool + :rtype: int """ - if self._certificate_chain is not None: - return False - - if self._id_ is not None: - return False - - return True + return self._user_owner_id - @staticmethod - def from_json(json_str): + @property + def user_holder_id(self): """ - :type json_str: str - - :rtype: CertificatePinned + :rtype: int """ - return converter.json_to_class(CertificatePinned, json_str) - - -class DeviceServer(core.BunqModel): - """ - After having created an Installation you can now create a DeviceServer. A - DeviceServer is needed to do a login call with session-server. - - :param _description: The description of the DeviceServer. - :type _description: str - :param _secret: The API key. You can request an API key in the bunq app. - :type _secret: str - :param _permitted_ips: An array of IPs (v4 or v6) this DeviceServer will be - able to do calls from. These will be linked to the API key. - :type _permitted_ips: list[str] - :param _id_: The id of the DeviceServer as created on the server. - :type _id_: int - :param _created: The timestamp of the DeviceServer's creation. - :type _created: str - :param _updated: The timestamp of the DeviceServer's last update. - :type _updated: str - :param _ip: The ip address which was used to create the DeviceServer. - :type _ip: str - :param _status: The status of the DeviceServer. Can be ACTIVE, BLOCKED, - NEEDS_CONFIRMATION or OBSOLETE. - :type _status: str - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "device-server" - _ENDPOINT_URL_READ = "device-server/{}" - _ENDPOINT_URL_LISTING = "device-server" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_SECRET = "secret" - FIELD_PERMITTED_IPS = "permitted_ips" - - # Object type. - _OBJECT_TYPE_GET = "DeviceServer" - - _id_ = None - _created = None - _updated = None - _description = None - _ip = None - _status = None - _description_field_for_request = None - _secret_field_for_request = None - _permitted_ips_field_for_request = None + return self._user_holder_id - def __init__(self, description, secret, permitted_ips=None): + @property + def type_(self): """ - :param description: The description of the DeviceServer. This is only for - your own reference when reading the DeviceServer again. - :type description: str - :param secret: The API key. You can request an API key in the bunq app. - :type secret: str - :param permitted_ips: An array of IPs (v4 or v6) this DeviceServer will be - able to do calls from. These will be linked to the API key. - :type permitted_ips: list[str] + :rtype: str """ - self._description_field_for_request = description - self._secret_field_for_request = secret - self._permitted_ips_field_for_request = permitted_ips + return self._type_ - @classmethod - def create(cls, description, secret, permitted_ips=None, - custom_headers=None): + @property + def sub_type(self): """ - Create a new DeviceServer providing the installation token in the header - and signing the request with the private part of the key you used to - create the installation. The API Key that you are using will be bound to - the IP address of the DeviceServer which you have - created.

Using a Wildcard API Key gives you the freedom to make - API calls even if the IP address has changed after the POST - device-server.

Find out more at this link https://bunq.com/en/apikey-dynamic-ip. - - :param description: The description of the DeviceServer. This is only - for your own reference when reading the DeviceServer again. - :type description: str - :param secret: The API key. You can request an API key in the bunq app. - :type secret: str - :param permitted_ips: An array of IPs (v4 or v6) this DeviceServer will - be able to do calls from. These will be linked to the API key. - :type permitted_ips: list[str] - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_SECRET: secret, - cls.FIELD_PERMITTED_IPS: permitted_ips - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._sub_type - @classmethod - def get(cls, device_server_id, custom_headers=None): + @property + def product_type(self): """ - Get one of your DeviceServers. - - :type api_context: context.ApiContext - :type device_server_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDeviceServer + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._product_type - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(device_server_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def product_sub_type(self): + """ + :rtype: str + """ - return BunqResponseDeviceServer.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._product_sub_type - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def first_line(self): """ - Get a collection of all the DeviceServers you have created. - - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDeviceServerList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._first_line - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def second_line(self): + """ + :rtype: str + """ - return BunqResponseDeviceServerList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._second_line @property - def id_(self): + def status(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._status @property - def created(self): + def sub_status(self): """ :rtype: str """ - return self._created + return self._sub_status @property - def updated(self): + def order_status(self): """ :rtype: str """ - return self._updated + return self._order_status @property - def description(self): + def expiry_date(self): """ :rtype: str """ - return self._description + return self._expiry_date @property - def ip(self): + def name_on_card(self): """ :rtype: str """ - return self._ip + return self._name_on_card @property - def status(self): + def preferred_name_on_card(self): """ :rtype: str """ - return self._status + return self._preferred_name_on_card - def is_all_field_none(self): + @property + def primary_account_numbers(self): """ - :rtype: bool + :rtype: list[object_.CardPrimaryAccountNumber] """ - if self._id_ is not None: - return False + return self._primary_account_numbers - if self._created is not None: - return False + @property + def payment_account_reference(self): + """ + :rtype: str + """ - if self._updated is not None: - return False + return self._payment_account_reference - if self._description is not None: - return False + @property + def card_limit(self): + """ + :rtype: object_.Amount + """ - if self._ip is not None: - return False + return self._card_limit - if self._status is not None: - return False + @property + def card_limit_atm(self): + """ + :rtype: object_.Amount + """ - return True + return self._card_limit_atm - @staticmethod - def from_json(json_str): + @property + def country_permission(self): """ - :type json_str: str - - :rtype: DeviceServer + :rtype: list[object_.CardCountryPermission] """ - return converter.json_to_class(DeviceServer, json_str) + return self._country_permission + @property + def label_monetary_account_ordered(self): + """ + :rtype: object_.MonetaryAccountReference + """ -class Device(core.BunqModel, core.AnchoredObjectInterface): - """ - Used to get a Device or a listing of Devices. Creating a DeviceServer should - happen via /device-server - - :param _DeviceServer: - :type _DeviceServer: DeviceServer - """ + return self._label_monetary_account_ordered - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + @property + def label_monetary_account_current(self): + """ + :rtype: object_.MonetaryAccountReference + """ - # Endpoint constants. - _ENDPOINT_URL_READ = "device/{}" - _ENDPOINT_URL_LISTING = "device" + return self._label_monetary_account_current - # Object type. - _OBJECT_TYPE_GET = "Device" + @property + def monetary_account(self): + """ + :rtype: MonetaryAccount + """ - _DeviceServer = None + return self._monetary_account - @classmethod - def get(cls, device_id, custom_headers=None): + @property + def pin_code_assignment(self): """ - Get a single Device. A Device is either a DevicePhone or a DeviceServer. - - :type api_context: context.ApiContext - :type device_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDevice + :rtype: list[object_.CardPinAssignment] """ - if custom_headers is None: - custom_headers = {} + return self._pin_code_assignment - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(device_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def monetary_account_id_fallback(self): + """ + :rtype: int + """ - return BunqResponseDevice.cast_from_bunq_response( - cls._from_json(response_raw) - ) + return self._monetary_account_id_fallback - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def country(self): """ - Get a collection of Devices. A Device is either a DevicePhone or a - DeviceServer. - - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDeviceList + :rtype: str """ - if params is None: - params = {} + return self._country - if custom_headers is None: - custom_headers = {} + @property + def card_shipment_tracking_url(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._card_shipment_tracking_url - return BunqResponseDeviceList.cast_from_bunq_response( - cls._from_json_list(response_raw) - ) + @property + def is_card_eligible_for_free_replacement(self): + """ + :rtype: bool + """ + + return self._is_card_eligible_for_free_replacement @property - def DeviceServer(self): + def card_replacement(self): """ - :rtype: DeviceServer + :rtype: CardReplacement """ - return self._DeviceServer + return self._card_replacement - def get_referenced_object(self): + @property + def card_generated_cvc2(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: CardGeneratedCvc2 """ - if self._DeviceServer is not None: - return self._DeviceServer + return self._card_generated_cvc2 - raise exception.BunqException(self._ERROR_NULL_FIELDS) + @property + def is_limited_edition(self): + """ + :rtype: bool + """ + + return self._is_limited_edition + + @property + def card_metal_member_since_date(self): + """ + :rtype: str + """ + + return self._card_metal_member_since_date + + @property + def company_employee_card(self): + """ + :rtype: CompanyEmployeeCard + """ + + return self._company_employee_card def is_all_field_none(self): """ :rtype: bool """ - if self._DeviceServer is not None: + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._public_uuid is not None: + return False + + if self._user_id is not None: + return False + + if self._user_owner_id is not None: + return False + + if self._user_holder_id is not None: + return False + + if self._type_ is not None: + return False + + if self._sub_type is not None: + return False + + if self._product_type is not None: + return False + + if self._product_sub_type is not None: + return False + + if self._first_line is not None: + return False + + if self._second_line is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._order_status is not None: + return False + + if self._expiry_date is not None: + return False + + if self._name_on_card is not None: + return False + + if self._preferred_name_on_card is not None: + return False + + if self._primary_account_numbers is not None: + return False + + if self._payment_account_reference is not None: + return False + + if self._card_limit is not None: + return False + + if self._card_limit_atm is not None: + return False + + if self._country_permission is not None: + return False + + if self._label_monetary_account_ordered is not None: + return False + + if self._label_monetary_account_current is not None: + return False + + if self._monetary_account is not None: + return False + + if self._pin_code_assignment is not None: + return False + + if self._monetary_account_id_fallback is not None: + return False + + if self._country is not None: + return False + + if self._card_shipment_tracking_url is not None: + return False + + if self._is_card_eligible_for_free_replacement is not None: + return False + + if self._card_replacement is not None: + return False + + if self._card_generated_cvc2 is not None: + return False + + if self._is_limited_edition is not None: + return False + + if self._card_metal_member_since_date is not None: + return False + + if self._company_employee_card is not None: return False return True @@ -7048,122 +6026,168 @@ def from_json(json_str): """ :type json_str: str - :rtype: Device + :rtype: CardCreditApiObject """ - return converter.json_to_class(Device, json_str) + return converter.json_to_class(CardCreditApiObject, json_str) -class DraftPayment(core.BunqModel): +class CardReplacementApiObject(BunqModel): """ - A DraftPayment is like a regular Payment, but it needs to be accepted by the - sending party before the actual Payment is done. + Endpoint for getting the Card Replacement of a card. - :param _status: The status of the DraftPayment. + :param _status: The status of the CardReplacement. :type _status: str - :param _entries: The entries in the DraftPayment. - :type _entries: list[object_.DraftPaymentEntry] - :param _previous_updated_timestamp: The last updated_timestamp that you - received for this DraftPayment. This needs to be provided to prevent race - conditions. - :type _previous_updated_timestamp: str - :param _number_of_required_accepts: The number of accepts that are required - for the draft payment to receive status ACCEPTED. Currently only 1 is valid. - :type _number_of_required_accepts: int - :param _id_: The id of the created DrafPayment. - :type _id_: int - :param _monetary_account_id: The id of the MonetaryAccount the DraftPayment - applies to. - :type _monetary_account_id: int - :param _user_alias_created: The label of the User who created the - DraftPayment. - :type _user_alias_created: object_.LabelUser - :param _responses: All responses to this draft payment. - :type _responses: list[object_.DraftPaymentResponse] - :param _type_: The type of the DraftPayment. + :param _address_main: The user's main address. + :type _address_main: object_.Address + :param _address_postal: The user's postal address. + :type _address_postal: object_.Address + :param _card_id: The original card that belongs to the CardReplacement. + :type _card_id: int + :param _card_new_id: The new card that replaces the original card in the + CardReplacement. + :type _card_new_id: int + """ + + # Field constants. + FIELD_STATUS = "status" + FIELD_ADDRESS_MAIN = "address_main" + FIELD_ADDRESS_POSTAL = "address_postal" + + + _status = None + _card_id = None + _card_new_id = None + _status_field_for_request = None + _address_main_field_for_request = None + _address_postal_field_for_request = None + + def __init__(self, status=None, address_main=None, address_postal=None): + """ + :param status: The status of the CardReplacement. + :type status: str + :param address_main: The user's main address. + :type address_main: object_.Address + :param address_postal: The user's postal address. + :type address_postal: object_.Address + """ + + self._status_field_for_request = status + self._address_main_field_for_request = address_main + self._address_postal_field_for_request = address_postal + + + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def card_id(self): + """ + :rtype: int + """ + + return self._card_id + + @property + def card_new_id(self): + """ + :rtype: int + """ + + return self._card_new_id + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._status is not None: + return False + + if self._card_id is not None: + return False + + if self._card_new_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: CardReplacementApiObject + """ + + return converter.json_to_class(CardReplacementApiObject, json_str) + + +class CardGeneratedCvc2ApiObject(BunqModel): + """ + Endpoint for generating and retrieving a new CVC2 code. + + :param _type_: The type of generated cvc2. Can be STATIC or GENERATED. :type _type_: str - :param _object_: The Payment or PaymentBatch. This will only be present - after the DraftPayment has been accepted. - :type _object_: object_.DraftPaymentAnchorObject - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] + :param _id_: The id of the cvc code. + :type _id_: int + :param _created: The timestamp of the cvc code's creation. + :type _created: str + :param _updated: The timestamp of the cvc code's last update. + :type _updated: str + :param _cvc2: The cvc2 code. + :type _cvc2: str + :param _status: The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, + BLOCKED. + :type _status: str + :param _expiry_time: Expiry time of the cvc2. + :type _expiry_time: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}" + _ENDPOINT_URL_CREATE = "user/{}/card/{}/generated-cvc2" + _ENDPOINT_URL_READ = "user/{}/card/{}/generated-cvc2/{}" + _ENDPOINT_URL_UPDATE = "user/{}/card/{}/generated-cvc2/{}" + _ENDPOINT_URL_LISTING = "user/{}/card/{}/generated-cvc2" # Field constants. - FIELD_STATUS = "status" - FIELD_ENTRIES = "entries" - FIELD_PREVIOUS_UPDATED_TIMESTAMP = "previous_updated_timestamp" - FIELD_NUMBER_OF_REQUIRED_ACCEPTS = "number_of_required_accepts" + FIELD_TYPE = "type" # Object type. - _OBJECT_TYPE_GET = "DraftPayment" + _OBJECT_TYPE_GET = "CardGeneratedCvc2" _id_ = None - _monetary_account_id = None - _user_alias_created = None - _responses = None - _status = None + _created = None + _updated = None _type_ = None - _entries = None - _object_ = None - _request_reference_split_the_bill = None - _status_field_for_request = None - _entries_field_for_request = None - _previous_updated_timestamp_field_for_request = None - _number_of_required_accepts_field_for_request = None + _cvc2 = None + _status = None + _expiry_time = None + _type__field_for_request = None - def __init__(self, number_of_required_accepts, entries=None, status=None, - previous_updated_timestamp=None): + def __init__(self, type_=None): """ - :param entries: The list of entries in the DraftPayment. Each entry will - result in a payment when the DraftPayment is accepted. - :type entries: list[object_.DraftPaymentEntry] - :param number_of_required_accepts: The number of accepts that are required - for the draft payment to receive status ACCEPTED. Currently only 1 is valid. - :type number_of_required_accepts: int - :param status: The status of the DraftPayment. - :type status: str - :param previous_updated_timestamp: The last updated_timestamp that you - received for this DraftPayment. This needs to be provided to prevent race - conditions. - :type previous_updated_timestamp: str + :param type_: The type of generated cvc2. Can be STATIC or GENERATED. + :type type_: str """ - self._entries_field_for_request = entries - self._number_of_required_accepts_field_for_request = number_of_required_accepts - self._status_field_for_request = status - self._previous_updated_timestamp_field_for_request = previous_updated_timestamp + self._type__field_for_request = type_ @classmethod - def create(cls, entries, number_of_required_accepts, - monetary_account_id=None, status=None, - previous_updated_timestamp=None, custom_headers=None): + def create(cls,card_id, type_=None, custom_headers=None): """ - Create a new DraftPayment. + Generate a new CVC2 code for a card. :type user_id: int - :type monetary_account_id: int - :param entries: The list of entries in the DraftPayment. Each entry will - result in a payment when the DraftPayment is accepted. - :type entries: list[object_.DraftPaymentEntry] - :param number_of_required_accepts: The number of accepts that are - required for the draft payment to receive status ACCEPTED. Currently - only 1 is valid. - :type number_of_required_accepts: int - :param status: The status of the DraftPayment. - :type status: str - :param previous_updated_timestamp: The last updated_timestamp that you - received for this DraftPayment. This needs to be provided to prevent - race conditions. - :type previous_updated_timestamp: str + :type card_id: int + :param type_: The type of generated cvc2. Can be STATIC or GENERATED. + :type type_: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -7173,45 +6197,53 @@ def create(cls, entries, number_of_required_accepts, custom_headers = {} request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_ENTRIES: entries, - cls.FIELD_PREVIOUS_UPDATED_TIMESTAMP: previous_updated_timestamp, - cls.FIELD_NUMBER_OF_REQUIRED_ACCEPTS: number_of_required_accepts - } +cls.FIELD_TYPE : type_ +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), card_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, draft_payment_id, monetary_account_id=None, status=None, - entries=None, previous_updated_timestamp=None, - custom_headers=None): + def get(cls, card_id, card_generated_cvc2_id, custom_headers=None): """ - Update a DraftPayment. + Get the details for a specific generated CVC2 code. + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type draft_payment_id: int - :param status: The status of the DraftPayment. - :type status: str - :param entries: The list of entries in the DraftPayment. Each entry will - result in a payment when the DraftPayment is accepted. - :type entries: list[object_.DraftPaymentEntry] - :param previous_updated_timestamp: The last updated_timestamp that you - received for this DraftPayment. This needs to be provided to prevent - race conditions. - :type previous_updated_timestamp: str + :type card_id: int + :type card_generated_cvc2_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCardGeneratedCvc2 + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), card_id, card_generated_cvc2_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseCardGeneratedCvc2.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, card_id, card_generated_cvc2_id, type_=None, custom_headers=None): + """ + :type user_id: int + :type card_id: int + :type card_generated_cvc2_id: int + :param type_: The type of generated cvc2. Can be STATIC or GENERATED. + :type type_: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -7220,39 +6252,33 @@ def update(cls, draft_payment_id, monetary_account_id=None, status=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_ENTRIES: entries, - cls.FIELD_PREVIOUS_UPDATED_TIMESTAMP: previous_updated_timestamp - } +cls.FIELD_TYPE : type_ +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), card_id, card_generated_cvc2_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls,card_id, params=None, custom_headers=None): """ - Get a listing of all DraftPayments from a given MonetaryAccount. + Get all generated CVC2 codes for a card. :type user_id: int - :type monetary_account_id: int + :type card_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseDraftPaymentList + :rtype: BunqResponseCardGeneratedCvc2List """ if params is None: @@ -7261,45 +6287,14 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), card_id) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseDraftPaymentList.cast_from_bunq_response( + return BunqResponseCardGeneratedCvc2List.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, draft_payment_id, monetary_account_id=None, - custom_headers=None): - """ - Get a specific DraftPayment. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type draft_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDraftPayment - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseDraftPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -7309,36 +6304,20 @@ def id_(self): return self._id_ @property - def monetary_account_id(self): - """ - :rtype: int - """ - - return self._monetary_account_id - - @property - def user_alias_created(self): - """ - :rtype: object_.LabelUser - """ - - return self._user_alias_created - - @property - def responses(self): + def created(self): """ - :rtype: list[object_.DraftPaymentResponse] + :rtype: str """ - return self._responses + return self._created @property - def status(self): + def updated(self): """ :rtype: str """ - return self._status + return self._updated @property def type_(self): @@ -7349,28 +6328,28 @@ def type_(self): return self._type_ @property - def entries(self): + def cvc2(self): """ - :rtype: list[object_.DraftPaymentEntry] + :rtype: str """ - return self._entries + return self._cvc2 @property - def object_(self): + def status(self): """ - :rtype: object_.DraftPaymentAnchorObject + :rtype: str """ - return self._object_ + return self._status @property - def request_reference_split_the_bill(self): + def expiry_time(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: str """ - return self._request_reference_split_the_bill + return self._expiry_time def is_all_field_none(self): """ @@ -7380,28 +6359,22 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._monetary_account_id is not None: - return False - - if self._user_alias_created is not None: - return False - - if self._responses is not None: + if self._created is not None: return False - if self._status is not None: + if self._updated is not None: return False if self._type_ is not None: return False - if self._entries is not None: + if self._cvc2 is not None: return False - if self._object_ is not None: + if self._status is not None: return False - if self._request_reference_split_the_bill is not None: + if self._expiry_time is not None: return False return True @@ -7411,602 +6384,790 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftPayment + :rtype: CardGeneratedCvc2ApiObject """ - return converter.json_to_class(DraftPayment, json_str) + return converter.json_to_class(CardGeneratedCvc2ApiObject, json_str) -class PaymentBatch(core.BunqModel): +class CardDebitApiObject(BunqModel): """ - Create a payment batch, or show the payment batches of a monetary account. + With bunq it is possible to order debit cards that can then be connected + with each one of the monetary accounts the user has access to (including + connected accounts). - :param _payments: The list of mutations that were made. - :type _payments: list[Payment] + :param _second_line: The second line of text on the card + :type _second_line: str + :param _name_on_card: The user's name on the card. + :type _name_on_card: str + :param _preferred_name_on_card: The user's preferred name on the card. + :type _preferred_name_on_card: str + :param _alias: The pointer to the monetary account that will be connected at + first with the card. Its IBAN code is also the one that will be printed on + the card itself. The pointer must be of type IBAN. + :type _alias: object_.Pointer + :param _type_: The type of the card. Can be MAESTRO, MASTERCARD. + :type _type_: str + :param _product_type: The product type of the card. + :type _product_type: str + :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type _pin_code_assignment: list[object_.CardPinAssignment] + :param _monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if not + supplied. + :type _monetary_account_id_fallback: int + :param _order_status: The order status of the card. Can be + NEW_CARD_REQUEST_RECEIVED, CARD_REQUEST_PENDING, SENT_FOR_PRODUCTION, + ACCEPTED_FOR_PRODUCTION, DELIVERED_TO_CUSTOMER, CARD_UPDATE_REQUESTED, + CARD_UPDATE_PENDING, CARD_UPDATE_SENT, CARD_UPDATE_ACCEPTED, + VIRTUAL_DELIVERY, NEW_CARD_REQUEST_PENDING_USER_APPROVAL, SENT_FOR_DELIVERY + or NEW_CARD_REQUEST_CANCELLED. + :type _order_status: str + :param _id_: The id of the card. + :type _id_: int + :param _created: The timestamp of the card's creation. + :type _created: str + :param _updated: The timestamp of the card's last update. + :type _updated: str + :param _public_uuid: The public UUID of the card. + :type _public_uuid: str + :param _user_id: DEPRECATED. ID of the user who is owner of the card. + :type _user_id: int + :param _user_owner_id: ID of the user who is owner of the card. + :type _user_owner_id: int + :param _user_holder_id: ID of the user who is holder of the card. + :type _user_holder_id: int + :param _sub_type: The sub-type of the card. + :type _sub_type: str + :param _product_sub_type: The product sub-type of the card. + :type _product_sub_type: str + :param _first_line: The first line of text on the card + :type _first_line: str + :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED. + :type _status: str + :param _sub_status: The sub-status of the card. Can be NONE or REPLACED. + :type _sub_status: str + :param _expiry_date: Expiry date of the card. + :type _expiry_date: str + :param _primary_account_numbers: Array of PANs and their attributes. + :type _primary_account_numbers: list[object_.CardPrimaryAccountNumber] + :param _payment_account_reference: The payment account reference number + associated with the card. + :type _payment_account_reference: str + :param _card_limit: The spending limit for the card. + :type _card_limit: object_.Amount + :param _card_limit_atm: The ATM spending limit for the card. + :type _card_limit_atm: object_.Amount + :param _country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type _country_permission: list[object_.CardCountryPermission] + :param _label_monetary_account_ordered: The monetary account this card was + ordered on and the label user that owns the card. + :type _label_monetary_account_ordered: object_.MonetaryAccountReference + :param _label_monetary_account_current: The monetary account that this card + is currently linked to and the label user viewing it. + :type _label_monetary_account_current: object_.MonetaryAccountReference + :param _monetary_account: Current monetary account (only for prepaid credit + cards). + :type _monetary_account: MonetaryAccount + :param _country: The country that is domestic to the card. Defaults to + country of residence of user. + :type _country: str + :param _card_shipment_tracking_url: A tracking link provided by our shipment + provider. + :type _card_shipment_tracking_url: str + :param _is_card_eligible_for_free_replacement: Whether this card is eligible + for a free replacement. + :type _is_card_eligible_for_free_replacement: bool + :param _card_replacement: The card replacement for this card. + :type _card_replacement: CardReplacement + :param _card_generated_cvc2: The generated CVC2 code for this card. + :type _card_generated_cvc2: CardGeneratedCvc2 + :param _is_limited_edition: Whether this card is a limited edition metal + card. + :type _is_limited_edition: bool + :param _card_metal_member_since_date: The date for the member since field on + the black metal card. + :type _card_metal_member_since_date: str + :param _company_employee_card: Details of this card belonging to a company, + if applicable. + :type _company_employee_card: CompanyEmployeeCard """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch" + _ENDPOINT_URL_CREATE = "user/{}/card-debit" # Field constants. - FIELD_PAYMENTS = "payments" + FIELD_SECOND_LINE = "second_line" + FIELD_NAME_ON_CARD = "name_on_card" + FIELD_PREFERRED_NAME_ON_CARD = "preferred_name_on_card" + FIELD_ALIAS = "alias" + FIELD_TYPE = "type" + FIELD_PRODUCT_TYPE = "product_type" + FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" + FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback" + FIELD_ORDER_STATUS = "order_status" # Object type. - _OBJECT_TYPE_GET = "PaymentBatch" + _OBJECT_TYPE_POST = "CardDebit" - _payments = None - _payments_field_for_request = None + _id_ = None + _created = None + _updated = None + _public_uuid = None + _user_id = None + _user_owner_id = None + _user_holder_id = None + _type_ = None + _sub_type = None + _product_type = None + _product_sub_type = None + _first_line = None + _second_line = None + _status = None + _sub_status = None + _order_status = None + _expiry_date = None + _name_on_card = None + _preferred_name_on_card = None + _primary_account_numbers = None + _payment_account_reference = None + _card_limit = None + _card_limit_atm = None + _country_permission = None + _label_monetary_account_ordered = None + _label_monetary_account_current = None + _monetary_account = None + _pin_code_assignment = None + _monetary_account_id_fallback = None + _country = None + _card_shipment_tracking_url = None + _is_card_eligible_for_free_replacement = None + _card_replacement = None + _card_generated_cvc2 = None + _is_limited_edition = None + _card_metal_member_since_date = None + _company_employee_card = None + _second_line_field_for_request = None + _name_on_card_field_for_request = None + _preferred_name_on_card_field_for_request = None + _alias_field_for_request = None + _type__field_for_request = None + _product_type_field_for_request = None + _pin_code_assignment_field_for_request = None + _monetary_account_id_fallback_field_for_request = None + _order_status_field_for_request = None - def __init__(self, payments): + def __init__(self, second_line, name_on_card, type_, product_type, preferred_name_on_card=None, alias=None, pin_code_assignment=None, monetary_account_id_fallback=None, order_status=None): """ - :param payments: The list of payments we want to send in a single batch. - :type payments: list[Payment] + :param second_line: The second line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can be + empty. + :type second_line: str + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param type_: The type of card to order. Can be MAESTRO or MASTERCARD. + :type type_: str + :param product_type: The product type of the card to order. + :type product_type: str + :param preferred_name_on_card: The user's preferred name that can be put on + the card. + :type preferred_name_on_card: str + :param alias: The pointer to the monetary account that will be connected at + first with the card. Its IBAN code is also the one that will be printed on + the card itself. The pointer must be of type IBAN. + :type alias: object_.Pointer + :param pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param monetary_account_id_fallback: ID of the MA to be used as fallback for + this card if insufficient balance. Fallback account is removed if not + supplied. + :type monetary_account_id_fallback: int + :param order_status: The order status of this card. Can be + CARD_REQUEST_PENDING or VIRTUAL_DELIVERY. + :type order_status: str """ - self._payments_field_for_request = payments + self._second_line_field_for_request = second_line + self._name_on_card_field_for_request = name_on_card + self._type__field_for_request = type_ + self._product_type_field_for_request = product_type + self._preferred_name_on_card_field_for_request = preferred_name_on_card + self._alias_field_for_request = alias + self._pin_code_assignment_field_for_request = pin_code_assignment + self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback + self._order_status_field_for_request = order_status @classmethod - def create(cls, payments, monetary_account_id=None, custom_headers=None): + def create(cls,second_line, name_on_card, type_, product_type, preferred_name_on_card=None, alias=None, pin_code_assignment=None, monetary_account_id_fallback=None, order_status=None, custom_headers=None): """ - Create a payment batch by sending an array of single payment objects, - that will become part of the batch. + Create a new debit card request. :type user_id: int - :type monetary_account_id: int - :param payments: The list of payments we want to send in a single batch. - :type payments: list[Payment] + :param second_line: The second line of text on the card, used as + name/description for it. It can contain at most 17 characters and it can + be empty. + :type second_line: str + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param type_: The type of card to order. Can be MAESTRO or MASTERCARD. + :type type_: str + :param product_type: The product type of the card to order. + :type product_type: str + :param preferred_name_on_card: The user's preferred name that can be put + on the card. + :type preferred_name_on_card: str + :param alias: The pointer to the monetary account that will be connected + at first with the card. Its IBAN code is also the one that will be + printed on the card itself. The pointer must be of type IBAN. + :type alias: object_.Pointer + :param pin_code_assignment: Array of Types, PINs, account IDs assigned + to the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if + not supplied. + :type monetary_account_id_fallback: int + :param order_status: The order status of this card. Can be + CARD_REQUEST_PENDING or VIRTUAL_DELIVERY. + :type order_status: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseCardDebit """ if custom_headers is None: custom_headers = {} request_map = { - cls.FIELD_PAYMENTS: payments - } +cls.FIELD_SECOND_LINE : second_line, +cls.FIELD_NAME_ON_CARD : name_on_card, +cls.FIELD_PREFERRED_NAME_ON_CARD : preferred_name_on_card, +cls.FIELD_ALIAS : alias, +cls.FIELD_TYPE : type_, +cls.FIELD_PRODUCT_TYPE : product_type, +cls.FIELD_PIN_CODE_ASSIGNMENT : pin_code_assignment, +cls.FIELD_MONETARY_ACCOUNT_ID_FALLBACK : monetary_account_id_fallback, +cls.FIELD_ORDER_STATUS : order_status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseCardDebit.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) ) - @classmethod - def update(cls, payment_batch_id, monetary_account_id=None, - custom_headers=None): + @property + def id_(self): """ - Revoke a bunq.to payment batch. The status of all the payments will be - set to REVOKED. - - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: int """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) + return self._id_ - request_map = { + @property + def created(self): + """ + :rtype: str + """ - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._created - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def updated(self): + """ + :rtype: str + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._updated - @classmethod - def get(cls, payment_batch_id, monetary_account_id=None, - custom_headers=None): + @property + def public_uuid(self): """ - Return the details of a specific payment batch. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponsePaymentBatch + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._public_uuid - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def user_id(self): + """ + :rtype: int + """ - return BunqResponsePaymentBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._user_id - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def user_owner_id(self): """ - Return all the payment batches for a monetary account. - - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponsePaymentBatchList + :rtype: int """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._user_owner_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def user_holder_id(self): + """ + :rtype: int + """ - return BunqResponsePaymentBatchList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._user_holder_id @property - def payments(self): + def type_(self): """ - :rtype: list[Payment] + :rtype: str """ - return self._payments + return self._type_ - def is_all_field_none(self): + @property + def sub_type(self): """ - :rtype: bool + :rtype: str """ - if self._payments is not None: - return False - - return True + return self._sub_type - @staticmethod - def from_json(json_str): + @property + def product_type(self): """ - :type json_str: str - - :rtype: PaymentBatch + :rtype: str """ - return converter.json_to_class(PaymentBatch, json_str) + return self._product_type + @property + def product_sub_type(self): + """ + :rtype: str + """ -class DraftShareInviteApiKeyQrCodeContent(core.BunqModel): - """ - This call returns the raw content of the QR code that links to this draft - share invite. When a bunq user scans this QR code with the bunq app the - draft share invite will be shown on his/her device. - """ + return self._product_sub_type - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/draft-share-invite-api-key/{}/qr-code-content" + @property + def first_line(self): + """ + :rtype: str + """ - # Object type. - _OBJECT_TYPE_GET = "DraftShareInviteApiKeyQrCodeContent" + return self._first_line - @classmethod - def list(cls, draft_share_invite_api_key_id, custom_headers=None): + @property + def second_line(self): """ - Returns the raw content of the QR code that links to this draft share - invite. The raw content is the binary representation of a file, without - any JSON wrapping. - - :type user_id: int - :type draft_share_invite_api_key_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._second_line - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), draft_share_invite_api_key_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def status(self): + """ + :rtype: str + """ - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) + return self._status - def is_all_field_none(self): + @property + def sub_status(self): """ - :rtype: bool + :rtype: str """ - return True + return self._sub_status - @staticmethod - def from_json(json_str): + @property + def order_status(self): """ - :type json_str: str - - :rtype: DraftShareInviteApiKeyQrCodeContent + :rtype: str """ - return converter.json_to_class(DraftShareInviteApiKeyQrCodeContent, - json_str) + return self._order_status + @property + def expiry_date(self): + """ + :rtype: str + """ -class DraftShareInviteApiKey(core.BunqModel): - """ - Used to create a draft share invite for a user with another bunq user. The - user that accepts the invite can share his MAs with the user that created - the invite. - - :param _status: The status of the draft share invite. Can be USED, CANCELLED - and PENDING. - :type _status: str - :param _sub_status: The sub-status of the draft share invite. Can be NONE, - ACCEPTED or REJECTED. - :type _sub_status: str - :param _expiration: The moment when this draft share invite expires. - :type _expiration: str - :param _user_alias_created: The user who created the draft share invite. - :type _user_alias_created: object_.LabelUser - :param _draft_share_url: The URL redirecting user to the draft share invite - in the app. Only works on mobile devices. - :type _draft_share_url: str - :param _api_key: The API key generated for this DraftShareInviteApiKey. - :type _api_key: str - :param _id_: The id of the newly created draft share invite. - :type _id_: int - """ + return self._expiry_date - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/draft-share-invite-api-key" - _ENDPOINT_URL_READ = "user/{}/draft-share-invite-api-key/{}" - _ENDPOINT_URL_UPDATE = "user/{}/draft-share-invite-api-key/{}" - _ENDPOINT_URL_LISTING = "user/{}/draft-share-invite-api-key" + @property + def name_on_card(self): + """ + :rtype: str + """ - # Field constants. - FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_EXPIRATION = "expiration" + return self._name_on_card - # Object type. - _OBJECT_TYPE_GET = "DraftShareInviteApiKey" - _OBJECT_TYPE_PUT = "DraftShareInviteApiKey" + @property + def preferred_name_on_card(self): + """ + :rtype: str + """ - _user_alias_created = None - _status = None - _sub_status = None - _expiration = None - _draft_share_url = None - _api_key = None - _id_ = None - _status_field_for_request = None - _sub_status_field_for_request = None - _expiration_field_for_request = None + return self._preferred_name_on_card - def __init__(self, expiration=None, status=None, sub_status=None): + @property + def primary_account_numbers(self): """ - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :param status: The status of the draft share invite. Can be CANCELLED (the - user cancels the draft share before it's used). - :type status: str - :param sub_status: The sub-status of the draft share invite. Can be NONE, - ACCEPTED or REJECTED. - :type sub_status: str + :rtype: list[object_.CardPrimaryAccountNumber] """ - self._expiration_field_for_request = expiration - self._status_field_for_request = status - self._sub_status_field_for_request = sub_status + return self._primary_account_numbers - @classmethod - def create(cls, expiration, status=None, sub_status=None, - custom_headers=None): + @property + def payment_account_reference(self): """ - :type user_id: int - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :param status: The status of the draft share invite. Can be CANCELLED - (the user cancels the draft share before it's used). - :type status: str - :param sub_status: The sub-status of the draft share invite. Can be - NONE, ACCEPTED or REJECTED. - :type sub_status: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_EXPIRATION: expiration - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._payment_account_reference - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def card_limit(self): + """ + :rtype: object_.Amount + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._card_limit - @classmethod - def get(cls, draft_share_invite_api_key_id, custom_headers=None): + @property + def card_limit_atm(self): """ - Get the details of a specific draft of a share invite. - - :type api_context: context.ApiContext - :type user_id: int - :type draft_share_invite_api_key_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDraftShareInviteApiKey + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} + return self._card_limit_atm - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - draft_share_invite_api_key_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def country_permission(self): + """ + :rtype: list[object_.CardCountryPermission] + """ - return BunqResponseDraftShareInviteApiKey.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._country_permission - @classmethod - def update(cls, draft_share_invite_api_key_id, status=None, sub_status=None, - expiration=None, custom_headers=None): + @property + def label_monetary_account_ordered(self): """ - Update a draft share invite. When sending status CANCELLED it is - possible to cancel the draft share invite. - - :type user_id: int - :type draft_share_invite_api_key_id: int - :param status: The status of the draft share invite. Can be CANCELLED - (the user cancels the draft share before it's used). - :type status: str - :param sub_status: The sub-status of the draft share invite. Can be - NONE, ACCEPTED or REJECTED. - :type sub_status: str - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDraftShareInviteApiKey + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} + return self._label_monetary_account_ordered - api_client = client.ApiClient(cls._get_api_context()) + @property + def label_monetary_account_current(self): + """ + :rtype: object_.MonetaryAccountReference + """ - request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_EXPIRATION: expiration - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._label_monetary_account_current - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - draft_share_invite_api_key_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def monetary_account(self): + """ + :rtype: MonetaryAccount + """ - return BunqResponseDraftShareInviteApiKey.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) - ) + return self._monetary_account - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def pin_code_assignment(self): """ - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseDraftShareInviteApiKeyList + :rtype: list[object_.CardPinAssignment] """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._pin_code_assignment - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def monetary_account_id_fallback(self): + """ + :rtype: int + """ - return BunqResponseDraftShareInviteApiKeyList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._monetary_account_id_fallback @property - def user_alias_created(self): + def country(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._user_alias_created + return self._country @property - def status(self): + def card_shipment_tracking_url(self): """ :rtype: str """ - return self._status + return self._card_shipment_tracking_url @property - def sub_status(self): + def is_card_eligible_for_free_replacement(self): """ - :rtype: str + :rtype: bool """ - return self._sub_status + return self._is_card_eligible_for_free_replacement @property - def expiration(self): + def card_replacement(self): """ - :rtype: str + :rtype: CardReplacement """ - return self._expiration + return self._card_replacement @property - def draft_share_url(self): + def card_generated_cvc2(self): """ - :rtype: str + :rtype: CardGeneratedCvc2 """ - return self._draft_share_url + return self._card_generated_cvc2 @property - def api_key(self): + def is_limited_edition(self): + """ + :rtype: bool + """ + + return self._is_limited_edition + + @property + def card_metal_member_since_date(self): """ :rtype: str """ - return self._api_key + return self._card_metal_member_since_date @property - def id_(self): + def company_employee_card(self): """ - :rtype: int + :rtype: CompanyEmployeeCard """ - return self._id_ + return self._company_employee_card def is_all_field_none(self): """ :rtype: bool """ - if self._user_alias_created is not None: + if self._id_ is not None: return False - if self._status is not None: + if self._created is not None: return False - if self._sub_status is not None: + if self._updated is not None: return False - if self._expiration is not None: + if self._public_uuid is not None: return False - if self._draft_share_url is not None: + if self._user_id is not None: return False - if self._api_key is not None: + if self._user_owner_id is not None: return False - if self._id_ is not None: + if self._user_holder_id is not None: return False - return True + if self._type_ is not None: + return False + + if self._sub_type is not None: + return False + + if self._product_type is not None: + return False + + if self._product_sub_type is not None: + return False + + if self._first_line is not None: + return False + + if self._second_line is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._order_status is not None: + return False + + if self._expiry_date is not None: + return False + + if self._name_on_card is not None: + return False + + if self._preferred_name_on_card is not None: + return False + + if self._primary_account_numbers is not None: + return False + + if self._payment_account_reference is not None: + return False + + if self._card_limit is not None: + return False + + if self._card_limit_atm is not None: + return False + + if self._country_permission is not None: + return False + + if self._label_monetary_account_ordered is not None: + return False + + if self._label_monetary_account_current is not None: + return False + + if self._monetary_account is not None: + return False + + if self._pin_code_assignment is not None: + return False + + if self._monetary_account_id_fallback is not None: + return False + + if self._country is not None: + return False + + if self._card_shipment_tracking_url is not None: + return False + + if self._is_card_eligible_for_free_replacement is not None: + return False + + if self._card_replacement is not None: + return False + + if self._card_generated_cvc2 is not None: + return False + + if self._is_limited_edition is not None: + return False + + if self._card_metal_member_since_date is not None: + return False + + if self._company_employee_card is not None: + return False + + return True @staticmethod def from_json(json_str): """ :type json_str: str - :rtype: DraftShareInviteApiKey + :rtype: CardDebitApiObject """ - return converter.json_to_class(DraftShareInviteApiKey, json_str) + return converter.json_to_class(CardDebitApiObject, json_str) -class DraftShareInviteBankQrCodeContent(core.BunqModel): +class CardNameApiObject(BunqModel): """ - This call returns the raw content of the QR code that links to this draft - share invite. When a bunq user scans this QR code with the bunq app the - draft share invite will be shown on his/her device. + Endpoint for getting all the accepted card names for a user. As bunq do not + allow total freedom in choosing the name that is going to be printed on the + card, the following formats are accepted: Name Surname, N. Surname, N + Surname or Surname. + + :param _name: The card name. + :type _name: str + :param _possible_card_name_array: All possible variations (of suitable + length) of user's legal name for the debit card. + :type _possible_card_name_array: list[str] """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/draft-share-invite-bank/{}/qr-code-content" + _ENDPOINT_URL_LISTING = "user/{}/card-name" + + # Field constants. + FIELD_NAME = "name" # Object type. - _OBJECT_TYPE_GET = "DraftShareInviteBankQrCodeContent" + _OBJECT_TYPE_GET = "CardUserNameArray" + + _possible_card_name_array = None + _name_field_for_request = None + + def __init__(self, name): + """ + :param name: The card name. + :type name: str + """ + + self._name_field_for_request = name @classmethod - def list(cls, draft_share_invite_bank_id, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Returns the raw content of the QR code that links to this draft share - invite. The raw content is the binary representation of a file, without - any JSON wrapping. + Return all the accepted card names for a specific user. :type user_id: int - :type draft_share_invite_bank_id: int + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBytes + :rtype: BunqResponseCardNameList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), draft_share_invite_bank_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) + return BunqResponseCardNameList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) + @property + def possible_card_name_array(self): + """ + :rtype: list[str] + """ + + return self._possible_card_name_array + def is_all_field_none(self): """ :rtype: bool """ + if self._possible_card_name_array is not None: + return False + return True @staticmethod @@ -8014,91 +7175,90 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftShareInviteBankQrCodeContent + :rtype: CardNameApiObject """ - return converter.json_to_class(DraftShareInviteBankQrCodeContent, - json_str) + return converter.json_to_class(CardNameApiObject, json_str) -class DraftShareInviteBank(core.BunqModel): +class CardReplaceApiObject(BunqModel): """ - Used to create a draft share invite for a monetary account with another bunq - user, as in the 'Connect' feature in the bunq app. The user that accepts the - invite can share one of their MonetaryAccounts with the user that created - the invite. + It is possible to order a card replacement with the bunq API.

You + can order up to one free card replacement per year. Additional replacement + requests will be billed.

The card replacement will have the same + expiry date and the same pricing as the old card, but it will have a new + card number. You can change the description and optional the PIN through the + card replacement endpoint. - :param _status: The status of the draft share invite. Can be USED, CANCELLED - and PENDING. - :type _status: str - :param _expiration: The moment when this draft share invite expires. - :type _expiration: str - :param _draft_share_settings: The draft share invite details. - :type _draft_share_settings: object_.DraftShareInviteEntry - :param _user_alias_created: The user who created the draft share invite. - :type _user_alias_created: object_.LabelUser - :param _share_invite_bank_response_id: The id of the share invite bank - response this draft share belongs to. - :type _share_invite_bank_response_id: int - :param _draft_share_url: The URL redirecting user to the draft share invite - in the app. Only works on mobile devices. - :type _draft_share_url: str - :param _id_: The id of the newly created draft share invite. + :param _name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type _name_on_card: str + :param _preferred_name_on_card: The user's preferred name that can be put on + the card. + :type _preferred_name_on_card: str + :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type _pin_code_assignment: list[object_.CardPinAssignment] + :param _second_line: The second line on the card. + :type _second_line: str + :param _id_: The id of the new card. :type _id_: int """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/draft-share-invite-bank" - _ENDPOINT_URL_READ = "user/{}/draft-share-invite-bank/{}" - _ENDPOINT_URL_UPDATE = "user/{}/draft-share-invite-bank/{}" - _ENDPOINT_URL_LISTING = "user/{}/draft-share-invite-bank" + _ENDPOINT_URL_CREATE = "user/{}/card/{}/replace" # Field constants. - FIELD_STATUS = "status" - FIELD_EXPIRATION = "expiration" - FIELD_DRAFT_SHARE_SETTINGS = "draft_share_settings" + FIELD_NAME_ON_CARD = "name_on_card" + FIELD_PREFERRED_NAME_ON_CARD = "preferred_name_on_card" + FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" + FIELD_SECOND_LINE = "second_line" - # Object type. - _OBJECT_TYPE_GET = "DraftShareInviteBank" - _user_alias_created = None - _status = None - _expiration = None - _share_invite_bank_response_id = None - _draft_share_url = None - _draft_share_settings = None _id_ = None - _status_field_for_request = None - _expiration_field_for_request = None - _draft_share_settings_field_for_request = None + _name_on_card_field_for_request = None + _preferred_name_on_card_field_for_request = None + _pin_code_assignment_field_for_request = None + _second_line_field_for_request = None - def __init__(self, expiration=None, draft_share_settings=None, status=None): + def __init__(self, name_on_card=None, preferred_name_on_card=None, pin_code_assignment=None, second_line=None): """ - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :param draft_share_settings: The draft share invite details. - :type draft_share_settings: object_.DraftShareInviteEntry - :param status: The status of the draft share invite. Can be CANCELLED (the - user cancels the draft share before it's used). - :type status: str + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param preferred_name_on_card: The user's preferred name that can be put on + the card. + :type preferred_name_on_card: str + :param pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param second_line: The second line on the card. + :type second_line: str """ - self._expiration_field_for_request = expiration - self._draft_share_settings_field_for_request = draft_share_settings - self._status_field_for_request = status + self._name_on_card_field_for_request = name_on_card + self._preferred_name_on_card_field_for_request = preferred_name_on_card + self._pin_code_assignment_field_for_request = pin_code_assignment + self._second_line_field_for_request = second_line @classmethod - def create(cls, expiration, draft_share_settings, status=None, - custom_headers=None): + def create(cls,card_id, name_on_card=None, preferred_name_on_card=None, pin_code_assignment=None, second_line=None, custom_headers=None): """ + Request a card replacement. + :type user_id: int - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :param draft_share_settings: The draft share invite details. - :type draft_share_settings: object_.DraftShareInviteEntry - :param status: The status of the draft share invite. Can be CANCELLED - (the user cancels the draft share before it's used). - :type status: str + :type card_id: int + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param preferred_name_on_card: The user's preferred name that can be put + on the card. + :type preferred_name_on_card: str + :param pin_code_assignment: Array of Types, PINs, account IDs assigned + to the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param second_line: The second line on the card. + :type second_line: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -8108,100 +7268,417 @@ def create(cls, expiration, draft_share_settings, status=None, custom_headers = {} request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_DRAFT_SHARE_SETTINGS: draft_share_settings - } +cls.FIELD_NAME_ON_CARD : name_on_card, +cls.FIELD_PREFERRED_NAME_ON_CARD : preferred_name_on_card, +cls.FIELD_PIN_CODE_ASSIGNMENT : pin_code_assignment, +cls.FIELD_SECOND_LINE : second_line +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), card_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) - @classmethod - def get(cls, draft_share_invite_bank_id, custom_headers=None): + @property + def id_(self): """ - Get the details of a specific draft of a share invite. - - :type api_context: context.ApiContext - :type user_id: int - :type draft_share_invite_bank_id: int - :type custom_headers: dict[str, str]|None + :rtype: int + """ + + return self._id_ + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str - :rtype: BunqResponseDraftShareInviteBank + :rtype: CardReplaceApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(CardReplaceApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - draft_share_invite_bank_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseDraftShareInviteBank.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) +class CardApiObject(BunqModel): + """ + Endpoint for retrieving details for the cards the user has access to. + + :param _pin_code: The plaintext pin code. Requests require encryption to be + enabled. + :type _pin_code: str + :param _activation_code: DEPRECATED: Activate a card by setting status to + ACTIVE when the order_status is ACCEPTED_FOR_PRODUCTION. + :type _activation_code: str + :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN, CANCELLED, EXPIRED or PIN_TRIES_EXCEEDED. + :type _status: str + :param _order_status: The order status of the card. Can be + NEW_CARD_REQUEST_RECEIVED, CARD_REQUEST_PENDING, SENT_FOR_PRODUCTION, + ACCEPTED_FOR_PRODUCTION, DELIVERED_TO_CUSTOMER, CARD_UPDATE_REQUESTED, + CARD_UPDATE_PENDING, CARD_UPDATE_SENT, CARD_UPDATE_ACCEPTED, + VIRTUAL_DELIVERY, NEW_CARD_REQUEST_PENDING_USER_APPROVAL, SENT_FOR_DELIVERY + or NEW_CARD_REQUEST_CANCELLED. + :type _order_status: str + :param _card_limit: The spending limit for the card. + :type _card_limit: object_.Amount + :param _card_limit_atm: The ATM spending limit for the card. + :type _card_limit_atm: object_.Amount + :param _country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type _country_permission: list[object_.CardCountryPermission] + :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type _pin_code_assignment: list[object_.CardPinAssignment] + :param _primary_account_numbers: Array of PANs and their attributes. + :type _primary_account_numbers: list[object_.CardPrimaryAccountNumber] + :param _monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if not + supplied. + :type _monetary_account_id_fallback: int + :param _preferred_name_on_card: The user's preferred name on the card. + :type _preferred_name_on_card: str + :param _second_line: The second line of text on the card + :type _second_line: str + :param _cancellation_reason: The reason for card cancellation. + :type _cancellation_reason: str + :param _id_: The id of the card. + :type _id_: int + :param _created: The timestamp of the card's creation. + :type _created: str + :param _updated: The timestamp of the card's last update. + :type _updated: str + :param _public_uuid: The public UUID of the card. + :type _public_uuid: str + :param _user_id: DEPRECATED. ID of the user who is owner of the card. + :type _user_id: int + :param _user_owner_id: ID of the user who is owner of the card. + :type _user_owner_id: int + :param _user_holder_id: ID of the user who is holder of the card. + :type _user_holder_id: int + :param _type_: The type of the card. Can be MAESTRO, MASTERCARD. + :type _type_: str + :param _sub_type: The sub-type of the card. + :type _sub_type: str + :param _product_type: The product type of the card. + :type _product_type: str + :param _product_sub_type: The product sub-type of the card. + :type _product_sub_type: str + :param _first_line: The first line of text on the card + :type _first_line: str + :param _sub_status: The sub-status of the card. Can be NONE or REPLACED. + :type _sub_status: str + :param _expiry_date: Expiry date of the card. + :type _expiry_date: str + :param _name_on_card: The user's name on the card. + :type _name_on_card: str + :param _payment_account_reference: The payment account reference number + associated with the card. + :type _payment_account_reference: str + :param _label_monetary_account_ordered: The monetary account this card was + ordered on and the label user that owns the card. + :type _label_monetary_account_ordered: object_.MonetaryAccountReference + :param _label_monetary_account_current: The monetary account that this card + is currently linked to and the label user viewing it. + :type _label_monetary_account_current: object_.MonetaryAccountReference + :param _monetary_account: Current monetary account (only for prepaid credit + cards). + :type _monetary_account: MonetaryAccount + :param _country: The country that is domestic to the card. Defaults to + country of residence of user. + :type _country: str + :param _card_shipment_tracking_url: A tracking link provided by our shipment + provider. + :type _card_shipment_tracking_url: str + :param _is_card_eligible_for_free_replacement: Whether this card is eligible + for a free replacement. + :type _is_card_eligible_for_free_replacement: bool + :param _card_replacement: The card replacement for this card. + :type _card_replacement: CardReplacement + :param _card_generated_cvc2: The generated CVC2 code for this card. + :type _card_generated_cvc2: CardGeneratedCvc2 + :param _is_limited_edition: Whether this card is a limited edition metal + card. + :type _is_limited_edition: bool + :param _card_metal_member_since_date: The date for the member since field on + the black metal card. + :type _card_metal_member_since_date: str + :param _company_employee_card: Details of this card belonging to a company, + if applicable. + :type _company_employee_card: CompanyEmployeeCard + """ + + # Endpoint constants. + _ENDPOINT_URL_UPDATE = "user/{}/card/{}" + _ENDPOINT_URL_READ = "user/{}/card/{}" + _ENDPOINT_URL_LISTING = "user/{}/card" + + # Field constants. + FIELD_PIN_CODE = "pin_code" + FIELD_ACTIVATION_CODE = "activation_code" + FIELD_STATUS = "status" + FIELD_ORDER_STATUS = "order_status" + FIELD_CARD_LIMIT = "card_limit" + FIELD_CARD_LIMIT_ATM = "card_limit_atm" + FIELD_COUNTRY_PERMISSION = "country_permission" + FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment" + FIELD_PRIMARY_ACCOUNT_NUMBERS = "primary_account_numbers" + FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback" + FIELD_PREFERRED_NAME_ON_CARD = "preferred_name_on_card" + FIELD_SECOND_LINE = "second_line" + FIELD_CANCELLATION_REASON = "cancellation_reason" + + # Object type. + _OBJECT_TYPE_PUT = "Card" + _OBJECT_TYPE_GET = "Card" + + _id_ = None + _created = None + _updated = None + _public_uuid = None + _user_id = None + _user_owner_id = None + _user_holder_id = None + _type_ = None + _sub_type = None + _product_type = None + _product_sub_type = None + _first_line = None + _second_line = None + _status = None + _sub_status = None + _order_status = None + _expiry_date = None + _name_on_card = None + _preferred_name_on_card = None + _primary_account_numbers = None + _payment_account_reference = None + _card_limit = None + _card_limit_atm = None + _country_permission = None + _label_monetary_account_ordered = None + _label_monetary_account_current = None + _monetary_account = None + _pin_code_assignment = None + _monetary_account_id_fallback = None + _country = None + _card_shipment_tracking_url = None + _is_card_eligible_for_free_replacement = None + _card_replacement = None + _card_generated_cvc2 = None + _is_limited_edition = None + _card_metal_member_since_date = None + _company_employee_card = None + _pin_code_field_for_request = None + _activation_code_field_for_request = None + _status_field_for_request = None + _order_status_field_for_request = None + _card_limit_field_for_request = None + _card_limit_atm_field_for_request = None + _country_permission_field_for_request = None + _pin_code_assignment_field_for_request = None + _primary_account_numbers_field_for_request = None + _monetary_account_id_fallback_field_for_request = None + _preferred_name_on_card_field_for_request = None + _second_line_field_for_request = None + _cancellation_reason_field_for_request = None + + def __init__(self, pin_code=None, activation_code=None, status=None, order_status=None, card_limit=None, card_limit_atm=None, country_permission=None, pin_code_assignment=None, primary_account_numbers=None, monetary_account_id_fallback=None, preferred_name_on_card=None, second_line=None, cancellation_reason=None): + """ + :param pin_code: The plaintext pin code. Requests require encryption to be + enabled. + :type pin_code: str + :param activation_code: DEPRECATED: Activate a card by setting status to + ACTIVE when the order_status is ACCEPTED_FOR_PRODUCTION. + :type activation_code: str + :param status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when + order status is + ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Can only be set to DEACTIVATED after initial activation, i.e. order_status + is + DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are + permanent and cannot be changed after. + :type status: str + :param order_status: The order status to set for the card. Set to + CARD_REQUEST_PENDING to get a virtual card produced. + :type order_status: str + :param card_limit: The spending limit for the card. + :type card_limit: object_.Amount + :param card_limit_atm: The ATM spending limit for the card. + :type card_limit_atm: object_.Amount + :param country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type country_permission: list[object_.CardCountryPermission] + :param pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param primary_account_numbers: Array of PANs and their attributes. + :type primary_account_numbers: list[object_.CardPrimaryAccountNumber] + :param monetary_account_id_fallback: ID of the MA to be used as fallback for + this card if insufficient balance. Fallback account is removed if not + supplied. + :type monetary_account_id_fallback: int + :param preferred_name_on_card: The user's preferred name as it will be on + the card. + :type preferred_name_on_card: str + :param second_line: The second line of text on the card + :type second_line: str + :param cancellation_reason: The reason for card cancellation. + :type cancellation_reason: str + """ + + self._pin_code_field_for_request = pin_code + self._activation_code_field_for_request = activation_code + self._status_field_for_request = status + self._order_status_field_for_request = order_status + self._card_limit_field_for_request = card_limit + self._card_limit_atm_field_for_request = card_limit_atm + self._country_permission_field_for_request = country_permission + self._pin_code_assignment_field_for_request = pin_code_assignment + self._primary_account_numbers_field_for_request = primary_account_numbers + self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback + self._preferred_name_on_card_field_for_request = preferred_name_on_card + self._second_line_field_for_request = second_line + self._cancellation_reason_field_for_request = cancellation_reason @classmethod - def update(cls, draft_share_invite_bank_id, status=None, expiration=None, - draft_share_settings=None, custom_headers=None): + def update(cls, card_id, pin_code=None, activation_code=None, status=None, order_status=None, card_limit=None, card_limit_atm=None, country_permission=None, pin_code_assignment=None, primary_account_numbers=None, monetary_account_id_fallback=None, preferred_name_on_card=None, second_line=None, cancellation_reason=None, custom_headers=None): """ - Update a draft share invite. When sending status CANCELLED it is - possible to cancel the draft share invite. + Update the card details. Allow to change pin code, status, limits, + country permissions and the monetary account connected to the card. When + the card has been received, it can be also activated through this + endpoint. :type user_id: int - :type draft_share_invite_bank_id: int - :param status: The status of the draft share invite. Can be CANCELLED - (the user cancels the draft share before it's used). + :type card_id: int + :param pin_code: The plaintext pin code. Requests require encryption to + be enabled. + :type pin_code: str + :param activation_code: DEPRECATED: Activate a card by setting status to + ACTIVE when the order_status is ACCEPTED_FOR_PRODUCTION. + :type activation_code: str + :param status: The status to set for the card. Can be ACTIVE, + DEACTIVATED, LOST, STOLEN or CANCELLED, and can only be set to + LOST/STOLEN/CANCELLED when order status is + ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Can only be set to DEACTIVATED after initial activation, i.e. + order_status is + DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) + are permanent and cannot be changed after. :type status: str - :param expiration: The moment when this draft share invite expires. - :type expiration: str - :param draft_share_settings: The draft share invite details. - :type draft_share_settings: object_.DraftShareInviteEntry + :param order_status: The order status to set for the card. Set to + CARD_REQUEST_PENDING to get a virtual card produced. + :type order_status: str + :param card_limit: The spending limit for the card. + :type card_limit: object_.Amount + :param card_limit_atm: The ATM spending limit for the card. + :type card_limit_atm: object_.Amount + :param country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type country_permission: list[object_.CardCountryPermission] + :param pin_code_assignment: Array of Types, PINs, account IDs assigned + to the card. + :type pin_code_assignment: list[object_.CardPinAssignment] + :param primary_account_numbers: Array of PANs and their attributes. + :type primary_account_numbers: list[object_.CardPrimaryAccountNumber] + :param monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if + not supplied. + :type monetary_account_id_fallback: int + :param preferred_name_on_card: The user's preferred name as it will be + on the card. + :type preferred_name_on_card: str + :param second_line: The second line of text on the card + :type second_line: str + :param cancellation_reason: The reason for card cancellation. + :type cancellation_reason: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseCard """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_STATUS: status, - cls.FIELD_EXPIRATION: expiration, - cls.FIELD_DRAFT_SHARE_SETTINGS: draft_share_settings - } +cls.FIELD_PIN_CODE : pin_code, +cls.FIELD_ACTIVATION_CODE : activation_code, +cls.FIELD_STATUS : status, +cls.FIELD_ORDER_STATUS : order_status, +cls.FIELD_CARD_LIMIT : card_limit, +cls.FIELD_CARD_LIMIT_ATM : card_limit_atm, +cls.FIELD_COUNTRY_PERMISSION : country_permission, +cls.FIELD_PIN_CODE_ASSIGNMENT : pin_code_assignment, +cls.FIELD_PRIMARY_ACCOUNT_NUMBERS : primary_account_numbers, +cls.FIELD_MONETARY_ACCOUNT_ID_FALLBACK : monetary_account_id_fallback, +cls.FIELD_PREFERRED_NAME_ON_CARD : preferred_name_on_card, +cls.FIELD_SECOND_LINE : second_line, +cls.FIELD_CANCELLATION_REASON : cancellation_reason +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - draft_share_invite_bank_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), card_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseCard.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) + ) + + @classmethod + def get(cls, card_id, custom_headers=None): + """ + Return the details of a specific card. + + :type api_context: ApiContext + :type user_id: int + :type card_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCard + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), card_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseCard.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod def list(cls, params=None, custom_headers=None): """ + Return all the cards available to the user. + :type user_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseDraftShareInviteBankList + :rtype: BunqResponseCardList """ if params is None: @@ -8210,356 +7687,309 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseDraftShareInviteBankList.cast_from_bunq_response( + return BunqResponseCardList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def user_alias_created(self): + def id_(self): """ - :rtype: object_.LabelUser + :rtype: int """ - return self._user_alias_created + return self._id_ @property - def status(self): + def created(self): """ :rtype: str """ - return self._status + return self._created @property - def expiration(self): + def updated(self): """ :rtype: str """ - return self._expiration + return self._updated @property - def share_invite_bank_response_id(self): + def public_uuid(self): """ - :rtype: int + :rtype: str """ - return self._share_invite_bank_response_id + return self._public_uuid @property - def draft_share_url(self): + def user_id(self): """ - :rtype: str + :rtype: int """ - return self._draft_share_url + return self._user_id @property - def draft_share_settings(self): + def user_owner_id(self): """ - :rtype: object_.DraftShareInviteEntry + :rtype: int """ - return self._draft_share_settings + return self._user_owner_id @property - def id_(self): + def user_holder_id(self): """ :rtype: int """ - return self._id_ + return self._user_holder_id - def is_all_field_none(self): + @property + def type_(self): """ - :rtype: bool + :rtype: str """ - if self._user_alias_created is not None: - return False - - if self._status is not None: - return False - - if self._expiration is not None: - return False - - if self._share_invite_bank_response_id is not None: - return False + return self._type_ - if self._draft_share_url is not None: - return False + @property + def sub_type(self): + """ + :rtype: str + """ - if self._draft_share_settings is not None: - return False + return self._sub_type - if self._id_ is not None: - return False + @property + def product_type(self): + """ + :rtype: str + """ - return True + return self._product_type - @staticmethod - def from_json(json_str): + @property + def product_sub_type(self): """ - :type json_str: str - - :rtype: DraftShareInviteBank + :rtype: str """ - return converter.json_to_class(DraftShareInviteBank, json_str) + return self._product_sub_type + @property + def first_line(self): + """ + :rtype: str + """ -class ExportAnnualOverviewContent(core.BunqModel): - """ - Fetch the raw content of an annual overview. The annual overview is always - in PDF format. Doc won't display the response of a request to get the - content of an annual overview. - """ + return self._first_line - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/export-annual-overview/{}/content" + @property + def second_line(self): + """ + :rtype: str + """ - # Object type. - _OBJECT_TYPE_GET = "ExportAnnualOverviewContent" + return self._second_line - @classmethod - def list(cls, export_annual_overview_id, custom_headers=None): + @property + def status(self): """ - Used to retrieve the raw content of an annual overview. - - :type user_id: int - :type export_annual_overview_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._status - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), export_annual_overview_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def sub_status(self): + """ + :rtype: str + """ - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) + return self._sub_status - def is_all_field_none(self): + @property + def order_status(self): """ - :rtype: bool + :rtype: str """ - return True + return self._order_status - @staticmethod - def from_json(json_str): + @property + def expiry_date(self): """ - :type json_str: str - - :rtype: ExportAnnualOverviewContent + :rtype: str """ - return converter.json_to_class(ExportAnnualOverviewContent, json_str) + return self._expiry_date + @property + def name_on_card(self): + """ + :rtype: str + """ -class ExportAnnualOverview(core.BunqModel): - """ - Used to create new and read existing annual overviews of all the user's - monetary accounts. Once created, annual overviews can be downloaded in PDF - format via the 'export-annual-overview/{id}/content' endpoint. - - :param _year: The year for which the overview is. - :type _year: int - :param _id_: The id of the annual overview as created on the server. - :type _id_: int - :param _created: The timestamp of the annual overview 's creation. - :type _created: str - :param _updated: The timestamp of the annual overview 's last update. - :type _updated: str - :param _alias_user: The user to which this annual overview belongs. - :type _alias_user: object_.LabelUser - """ + return self._name_on_card - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/export-annual-overview" - _ENDPOINT_URL_READ = "user/{}/export-annual-overview/{}" - _ENDPOINT_URL_DELETE = "user/{}/export-annual-overview/{}" - _ENDPOINT_URL_LISTING = "user/{}/export-annual-overview" + @property + def preferred_name_on_card(self): + """ + :rtype: str + """ - # Field constants. - FIELD_YEAR = "year" + return self._preferred_name_on_card - # Object type. - _OBJECT_TYPE_GET = "ExportAnnualOverview" + @property + def primary_account_numbers(self): + """ + :rtype: list[object_.CardPrimaryAccountNumber] + """ - _id_ = None - _created = None - _updated = None - _year = None - _alias_user = None - _year_field_for_request = None + return self._primary_account_numbers - def __init__(self, year): + @property + def payment_account_reference(self): """ - :param year: The year for which the overview is. - :type year: int + :rtype: str """ - self._year_field_for_request = year + return self._payment_account_reference - @classmethod - def create(cls, year, custom_headers=None): + @property + def card_limit(self): """ - Create a new annual overview for a specific year. An overview can be - generated only for a past year. - - :type user_id: int - :param year: The year for which the overview is. - :type year: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} + return self._card_limit - request_map = { - cls.FIELD_YEAR: year - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + @property + def card_limit_atm(self): + """ + :rtype: object_.Amount + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + return self._card_limit_atm - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + @property + def country_permission(self): + """ + :rtype: list[object_.CardCountryPermission] + """ - @classmethod - def get(cls, export_annual_overview_id, custom_headers=None): + return self._country_permission + + @property + def label_monetary_account_ordered(self): """ - Get an annual overview for a user by its id. - - :type api_context: context.ApiContext - :type user_id: int - :type export_annual_overview_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseExportAnnualOverview + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} + return self._label_monetary_account_ordered - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - export_annual_overview_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def label_monetary_account_current(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseExportAnnualOverview.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._label_monetary_account_current - @classmethod - def delete(cls, export_annual_overview_id, custom_headers=None): + @property + def monetary_account(self): """ - :type user_id: int - :type export_annual_overview_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: MonetaryAccount """ - if custom_headers is None: - custom_headers = {} + return self._monetary_account - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - export_annual_overview_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def pin_code_assignment(self): + """ + :rtype: list[object_.CardPinAssignment] + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._pin_code_assignment - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def monetary_account_id_fallback(self): """ - List all the annual overviews for a user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseExportAnnualOverviewList + :rtype: int """ - if params is None: - params = {} + return self._monetary_account_id_fallback - if custom_headers is None: - custom_headers = {} + @property + def country(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._country - return BunqResponseExportAnnualOverviewList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def card_shipment_tracking_url(self): + """ + :rtype: str + """ + + return self._card_shipment_tracking_url @property - def id_(self): + def is_card_eligible_for_free_replacement(self): """ - :rtype: int + :rtype: bool """ - return self._id_ + return self._is_card_eligible_for_free_replacement @property - def created(self): + def card_replacement(self): """ - :rtype: str + :rtype: CardReplacement """ - return self._created + return self._card_replacement @property - def updated(self): + def card_generated_cvc2(self): """ - :rtype: str + :rtype: CardGeneratedCvc2 """ - return self._updated + return self._card_generated_cvc2 @property - def year(self): + def is_limited_edition(self): """ - :rtype: int + :rtype: bool """ - return self._year + return self._is_limited_edition @property - def alias_user(self): + def card_metal_member_since_date(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._alias_user + return self._card_metal_member_since_date + + @property + def company_employee_card(self): + """ + :rtype: CompanyEmployeeCard + """ + + return self._company_employee_card def is_all_field_none(self): """ @@ -8575,69 +8005,107 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._year is not None: + if self._public_uuid is not None: return False - if self._alias_user is not None: + if self._user_id is not None: return False - return True + if self._user_owner_id is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: ExportAnnualOverview - """ + if self._user_holder_id is not None: + return False - return converter.json_to_class(ExportAnnualOverview, json_str) + if self._type_ is not None: + return False + if self._sub_type is not None: + return False -class CustomerStatementExportContent(core.BunqModel): - """ - Fetch the raw content of a statement export. The returned file format could - be MT940, CSV or PDF depending on the statement format specified during the - statement creation. The doc won't display the response of a request to get - the content of a statement export. - """ + if self._product_type is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/customer-statement/{}/content" + if self._product_sub_type is not None: + return False - # Object type. - _OBJECT_TYPE_GET = "CustomerStatementExportContent" + if self._first_line is not None: + return False - @classmethod - def list(cls, customer_statement_id, monetary_account_id=None, - custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type customer_statement_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes - """ + if self._second_line is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._status is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - customer_statement_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + if self._sub_status is not None: + return False - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) + if self._order_status is not None: + return False - def is_all_field_none(self): - """ - :rtype: bool - """ + if self._expiry_date is not None: + return False + + if self._name_on_card is not None: + return False + + if self._preferred_name_on_card is not None: + return False + + if self._primary_account_numbers is not None: + return False + + if self._payment_account_reference is not None: + return False + + if self._card_limit is not None: + return False + + if self._card_limit_atm is not None: + return False + + if self._country_permission is not None: + return False + + if self._label_monetary_account_ordered is not None: + return False + + if self._label_monetary_account_current is not None: + return False + + if self._monetary_account is not None: + return False + + if self._pin_code_assignment is not None: + return False + + if self._monetary_account_id_fallback is not None: + return False + + if self._country is not None: + return False + + if self._card_shipment_tracking_url is not None: + return False + + if self._is_card_eligible_for_free_replacement is not None: + return False + + if self._card_replacement is not None: + return False + + if self._card_generated_cvc2 is not None: + return False + + if self._is_limited_edition is not None: + return False + + if self._card_metal_member_since_date is not None: + return False + + if self._company_employee_card is not None: + return False return True @@ -8646,109 +8114,57 @@ def from_json(json_str): """ :type json_str: str - :rtype: CustomerStatementExportContent + :rtype: CardApiObject """ - return converter.json_to_class(CustomerStatementExportContent, json_str) + return converter.json_to_class(CardApiObject, json_str) -class CustomerStatementExport(core.BunqModel): +class CertificatePinnedApiObject(BunqModel): """ - Used to create new and read existing statement exports. Statement exports - can be created in either CSV, MT940 or PDF file format. + This endpoint allow you to pin the certificate chains to your account. These + certificate chains are used for SSL validation whenever a callback is + initiated to one of your https callback urls. - :param _statement_format: The format of statement. - :type _statement_format: str - :param _date_start: The date from when this statement shows transactions. - :type _date_start: str - :param _date_end: The date until which statement shows transactions. - :type _date_end: str - :param _regional_format: The regional format of a CSV statement. - :type _regional_format: str - :param _id_: The id of the customer statement model. + :param _certificate_chain: The certificate chain in .PEM format. + Certificates are glued with newline characters. + :type _certificate_chain: str + :param _id_: The id generated for the pinned certificate chain. :type _id_: int - :param _created: The timestamp of the statement model's creation. - :type _created: str - :param _updated: The timestamp of the statement model's last update. - :type _updated: str - :param _status: The status of the export. - :type _status: str - :param _statement_number: MT940 Statement number. Unique per monetary - account. - :type _statement_number: int - :param _alias_monetary_account: The monetary account for which this - statement was created. - :type _alias_monetary_account: object_.MonetaryAccountReference """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/customer-statement" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/customer-statement/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/customer-statement" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/customer-statement/{}" + _ENDPOINT_URL_CREATE = "user/{}/certificate-pinned" + _ENDPOINT_URL_DELETE = "user/{}/certificate-pinned/{}" + _ENDPOINT_URL_LISTING = "user/{}/certificate-pinned" + _ENDPOINT_URL_READ = "user/{}/certificate-pinned/{}" # Field constants. - FIELD_STATEMENT_FORMAT = "statement_format" - FIELD_DATE_START = "date_start" - FIELD_DATE_END = "date_end" - FIELD_REGIONAL_FORMAT = "regional_format" + FIELD_CERTIFICATE_CHAIN = "certificate_chain" # Object type. - _OBJECT_TYPE_GET = "CustomerStatement" + _OBJECT_TYPE_GET = "CertificatePinned" + _certificate_chain = None _id_ = None - _created = None - _updated = None - _date_start = None - _date_end = None - _status = None - _statement_number = None - _statement_format = None - _regional_format = None - _alias_monetary_account = None - _statement_format_field_for_request = None - _date_start_field_for_request = None - _date_end_field_for_request = None - _regional_format_field_for_request = None + _certificate_chain_field_for_request = None - def __init__(self, statement_format, date_start, date_end, - regional_format=None): + def __init__(self, certificate_chain): """ - :param statement_format: The format type of statement. Allowed values: - MT940, CSV, PDF. - :type statement_format: str - :param date_start: The start date for making statements. - :type date_start: str - :param date_end: The end date for making statements. - :type date_end: str - :param regional_format: Required for CSV exports. The regional format of the - statement, can be UK_US (comma-separated) or EUROPEAN (semicolon-separated). - :type regional_format: str + :param certificate_chain: The certificate chain in .PEM format. + :type certificate_chain: list[object_.Certificate] """ - self._statement_format_field_for_request = statement_format - self._date_start_field_for_request = date_start - self._date_end_field_for_request = date_end - self._regional_format_field_for_request = regional_format + self._certificate_chain_field_for_request = certificate_chain @classmethod - def create(cls, statement_format, date_start, date_end, - monetary_account_id=None, regional_format=None, - custom_headers=None): + def create(cls,certificate_chain, custom_headers=None): """ + Pin the certificate chain. + :type user_id: int - :type monetary_account_id: int - :param statement_format: The format type of statement. Allowed values: - MT940, CSV, PDF. - :type statement_format: str - :param date_start: The start date for making statements. - :type date_start: str - :param date_end: The end date for making statements. - :type date_end: str - :param regional_format: Required for CSV exports. The regional format of - the statement, can be UK_US (comma-separated) or EUROPEAN - (semicolon-separated). - :type regional_format: str + :param certificate_chain: The certificate chain in .PEM format. + :type certificate_chain: list[object_.Certificate] :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -8758,62 +8174,53 @@ def create(cls, statement_format, date_start, date_end, custom_headers = {} request_map = { - cls.FIELD_STATEMENT_FORMAT: statement_format, - cls.FIELD_DATE_START: date_start, - cls.FIELD_DATE_END: date_end, - cls.FIELD_REGIONAL_FORMAT: regional_format - } +cls.FIELD_CERTIFICATE_CHAIN : certificate_chain +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, customer_statement_export_id, monetary_account_id=None, - custom_headers=None): + def delete(cls, certificate_pinned_id, custom_headers=None): """ - :type api_context: context.ApiContext + Remove the pinned certificate chain with the specific ID. + :type user_id: int - :type monetary_account_id: int - :type customer_statement_export_id: int + :type certificate_pinned_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCustomerStatementExport + :rtype: BunqResponseNone """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - customer_statement_export_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), certificate_pinned_id) + response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseCustomerStatementExport.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ + List all the pinned certificate chain for the given user. + :type user_id: int - :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCustomerStatementExportList + :rtype: BunqResponseCertificatePinnedList """ if params is None: @@ -8822,42 +8229,46 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCustomerStatementExportList.cast_from_bunq_response( + return BunqResponseCertificatePinnedList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def delete(cls, customer_statement_export_id, monetary_account_id=None, - custom_headers=None): + def get(cls, certificate_pinned_id, custom_headers=None): """ + Get the pinned certificate chain with the specified ID. + + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type customer_statement_export_id: int + :type certificate_pinned_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseCertificatePinned """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - customer_statement_export_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), certificate_pinned_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseCertificatePinned.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) + @property + def certificate_chain(self): + """ + :rtype: str + """ + + return self._certificate_chain + @property def id_(self): """ @@ -8866,37 +8277,99 @@ def id_(self): return self._id_ - @property - def created(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._created + if self._certificate_chain is not None: + return False - @property - def updated(self): + if self._id_ is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: CertificatePinnedApiObject """ - return self._updated + return converter.json_to_class(CertificatePinnedApiObject, json_str) - @property - def date_start(self): + +class CompanyEmployeeSettingAdyenCardTransactionApiObject(BunqModel): + """ + Manage permissions for Adyen card transactions / Tap to Pay for a company + employee. + + :param _pointer_counter_user: The pointer to the employee for which you want + to create a card. + :type _pointer_counter_user: object_.Pointer + :param _status: Whether the user is allowed to use Tap to Pay. + :type _status: str + :param _monetary_account_payout_id: The ID of the monetary account where Tap + to Pay transactions should be paid out to. + :type _monetary_account_payout_id: int + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/company-employee-setting-adyen-card-transaction/{}" + + # Field constants. + FIELD_POINTER_COUNTER_USER = "pointer_counter_user" + FIELD_STATUS = "status" + FIELD_MONETARY_ACCOUNT_PAYOUT_ID = "monetary_account_payout_id" + + # Object type. + _OBJECT_TYPE_GET = "CompanyEmployeeSettingAdyenCardTransaction" + + _status = None + _monetary_account_payout_id = None + _pointer_counter_user_field_for_request = None + _status_field_for_request = None + _monetary_account_payout_id_field_for_request = None + + def __init__(self, pointer_counter_user, status=None, monetary_account_payout_id=None): """ - :rtype: str + :param pointer_counter_user: The pointer to the employee for which you want + to create a card. + :type pointer_counter_user: object_.Pointer + :param status: Whether the user is allowed to use Tap to Pay. + :type status: str + :param monetary_account_payout_id: The ID of the monetary account where Tap + to Pay transactions should be paid out to. + :type monetary_account_payout_id: int """ - return self._date_start + self._pointer_counter_user_field_for_request = pointer_counter_user + self._status_field_for_request = status + self._monetary_account_payout_id_field_for_request = monetary_account_payout_id - @property - def date_end(self): + @classmethod + def get(cls, company_employee_setting_adyen_card_transaction_id, custom_headers=None): """ - :rtype: str + :type api_context: ApiContext + :type user_id: int + :type company_employee_setting_adyen_card_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCompanyEmployeeSettingAdyenCardTransaction """ - return self._date_end + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), company_employee_setting_adyen_card_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseCompanyEmployeeSettingAdyenCardTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) @property def status(self): @@ -8907,70 +8380,22 @@ def status(self): return self._status @property - def statement_number(self): + def monetary_account_payout_id(self): """ :rtype: int """ - return self._statement_number + return self._monetary_account_payout_id - @property - def statement_format(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._statement_format + if self._status is not None: + return False - @property - def regional_format(self): - """ - :rtype: str - """ - - return self._regional_format - - @property - def alias_monetary_account(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._alias_monetary_account - - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._date_start is not None: - return False - - if self._date_end is not None: - return False - - if self._status is not None: - return False - - if self._statement_number is not None: - return False - - if self._statement_format is not None: - return False - - if self._regional_format is not None: - return False - - if self._alias_monetary_account is not None: + if self._monetary_account_payout_id is not None: return False return True @@ -8980,132 +8405,283 @@ def from_json(json_str): """ :type json_str: str - :rtype: CustomerStatementExport + :rtype: CompanyEmployeeSettingAdyenCardTransactionApiObject """ - return converter.json_to_class(CustomerStatementExport, json_str) + return converter.json_to_class(CompanyEmployeeSettingAdyenCardTransactionApiObject, json_str) -class InstallationServerPublicKey(core.BunqModel): +class CompanyApiObject(BunqModel): """ - Using /installation/_/server-public-key you can request the ServerPublicKey - again. This is done by referring to the id of the Installation. + Create and manage companies. - :param _server_public_key: The server's public key for this Installation. - :type _server_public_key: str + :param _name: The company name. + :type _name: str + :param _address_main: The company's main address. + :type _address_main: object_.Address + :param _address_postal: The company's postal address. + :type _address_postal: object_.Address + :param _country: The country where the company is registered. + :type _country: str + :param _ubo: The names and birth dates of the company's ultimate beneficiary + owners. Minimum zero, maximum four. + :type _ubo: list[object_.Ubo] + :param _chamber_of_commerce_number: The company's chamber of commerce + number. + :type _chamber_of_commerce_number: str + :param _legal_form: The company's legal form. + :type _legal_form: str + :param _subscription_type: The subscription type for the company. + :type _subscription_type: str + :param _avatar_uuid: The public UUID of the company's avatar. + :type _avatar_uuid: str + :param _vat_number: DEPRECATED All the vat numbers of the company + :type _vat_number: object_.CompanyVatNumber + :param _vat_numbers: All the vat numbers of the company + :type _vat_numbers: list[object_.CompanyVatNumber] + :param _signup_track_type: The type of signup track the user is following. + :type _signup_track_type: str + :param _UserCompany: + :type _UserCompany: UserCompany """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "installation/{}/server-public-key" + _ENDPOINT_URL_CREATE = "user/{}/company" + _ENDPOINT_URL_READ = "user/{}/company/{}" + _ENDPOINT_URL_LISTING = "user/{}/company" + _ENDPOINT_URL_UPDATE = "user/{}/company/{}" + + # Field constants. + FIELD_NAME = "name" + FIELD_ADDRESS_MAIN = "address_main" + FIELD_ADDRESS_POSTAL = "address_postal" + FIELD_COUNTRY = "country" + FIELD_UBO = "ubo" + FIELD_CHAMBER_OF_COMMERCE_NUMBER = "chamber_of_commerce_number" + FIELD_LEGAL_FORM = "legal_form" + FIELD_SUBSCRIPTION_TYPE = "subscription_type" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_VAT_NUMBER = "vat_number" + FIELD_VAT_NUMBERS = "vat_numbers" + FIELD_SIGNUP_TRACK_TYPE = "signup_track_type" # Object type. - _OBJECT_TYPE_GET = "ServerPublicKey" + _OBJECT_TYPE_GET = "UserCompany" - _server_public_key = None + _UserCompany = None + _name_field_for_request = None + _address_main_field_for_request = None + _address_postal_field_for_request = None + _country_field_for_request = None + _ubo_field_for_request = None + _chamber_of_commerce_number_field_for_request = None + _legal_form_field_for_request = None + _subscription_type_field_for_request = None + _avatar_uuid_field_for_request = None + _vat_number_field_for_request = None + _vat_numbers_field_for_request = None + _signup_track_type_field_for_request = None + + def __init__(self, name, address_main, address_postal, country, legal_form, subscription_type, ubo=None, chamber_of_commerce_number=None, avatar_uuid=None, vat_number=None, vat_numbers=None, signup_track_type=None): + """ + :param name: The company name. + :type name: str + :param address_main: The company's main address. + :type address_main: object_.Address + :param address_postal: The company's postal address. + :type address_postal: object_.Address + :param country: The country where the company is registered. + :type country: str + :param legal_form: The company's legal form. + :type legal_form: str + :param subscription_type: The subscription type for the company. + :type subscription_type: str + :param ubo: The names and birth dates of the company's ultimate beneficiary + owners. Minimum zero, maximum four. + :type ubo: list[object_.Ubo] + :param chamber_of_commerce_number: The company's chamber of commerce number. + :type chamber_of_commerce_number: str + :param avatar_uuid: The public UUID of the company's avatar. + :type avatar_uuid: str + :param vat_number: DEPRECATED All the vat numbers of the company + :type vat_number: object_.CompanyVatNumber + :param vat_numbers: All the vat numbers of the company + :type vat_numbers: list[object_.CompanyVatNumber] + :param signup_track_type: The type of signup track the user is following. + :type signup_track_type: str + """ + + self._name_field_for_request = name + self._address_main_field_for_request = address_main + self._address_postal_field_for_request = address_postal + self._country_field_for_request = country + self._legal_form_field_for_request = legal_form + self._subscription_type_field_for_request = subscription_type + self._ubo_field_for_request = ubo + self._chamber_of_commerce_number_field_for_request = chamber_of_commerce_number + self._avatar_uuid_field_for_request = avatar_uuid + self._vat_number_field_for_request = vat_number + self._vat_numbers_field_for_request = vat_numbers + self._signup_track_type_field_for_request = signup_track_type @classmethod - def list(cls, installation_id, params=None, custom_headers=None): + def create(cls,name, address_main, address_postal, country, legal_form, subscription_type, ubo=None, chamber_of_commerce_number=None, avatar_uuid=None, vat_number=None, vat_numbers=None, signup_track_type=None, custom_headers=None): """ - Show the ServerPublicKey for this Installation. - - :type installation_id: int - :type params: dict[str, str]|None + :type user_id: int + :param name: The company name. + :type name: str + :param address_main: The company's main address. + :type address_main: object_.Address + :param address_postal: The company's postal address. + :type address_postal: object_.Address + :param country: The country where the company is registered. + :type country: str + :param legal_form: The company's legal form. + :type legal_form: str + :param subscription_type: The subscription type for the company. + :type subscription_type: str + :param ubo: The names and birth dates of the company's ultimate + beneficiary owners. Minimum zero, maximum four. + :type ubo: list[object_.Ubo] + :param chamber_of_commerce_number: The company's chamber of commerce + number. + :type chamber_of_commerce_number: str + :param avatar_uuid: The public UUID of the company's avatar. + :type avatar_uuid: str + :param vat_number: DEPRECATED All the vat numbers of the company + :type vat_number: object_.CompanyVatNumber + :param vat_numbers: All the vat numbers of the company + :type vat_numbers: list[object_.CompanyVatNumber] + :param signup_track_type: The type of signup track the user is + following. + :type signup_track_type: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInstallationServerPublicKeyList + :rtype: BunqResponseInt """ - if params is None: - params = {} - if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format(installation_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + request_map = { +cls.FIELD_NAME : name, +cls.FIELD_ADDRESS_MAIN : address_main, +cls.FIELD_ADDRESS_POSTAL : address_postal, +cls.FIELD_COUNTRY : country, +cls.FIELD_UBO : ubo, +cls.FIELD_CHAMBER_OF_COMMERCE_NUMBER : chamber_of_commerce_number, +cls.FIELD_LEGAL_FORM : legal_form, +cls.FIELD_SUBSCRIPTION_TYPE : subscription_type, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_VAT_NUMBER : vat_number, +cls.FIELD_VAT_NUMBERS : vat_numbers, +cls.FIELD_SIGNUP_TRACK_TYPE : signup_track_type +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - return BunqResponseInstallationServerPublicKeyList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) - @property - def server_public_key(self): + @classmethod + def get(cls, company_id, custom_headers=None): """ - :rtype: str + :type api_context: ApiContext + :type user_id: int + :type company_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCompany """ - return self._server_public_key - - def is_all_field_none(self): - """ - :rtype: bool - """ + if custom_headers is None: + custom_headers = {} - if self._server_public_key is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), company_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return True + return BunqResponseCompany.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) - @staticmethod - def from_json(json_str): + @classmethod + def list(cls, params=None, custom_headers=None): """ - :type json_str: str + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None - :rtype: InstallationServerPublicKey + :rtype: BunqResponseCompanyList """ - return converter.json_to_class(InstallationServerPublicKey, json_str) + if params is None: + params = {} + if custom_headers is None: + custom_headers = {} -class ShareInviteBankAmountUsed(core.BunqModel): - """ - When you have connected your monetary account bank to a user, and given this - user a (for example) daily budget of 10 EUR. If this users has used his - entire budget or part of it, this call can be used to reset the amount he - used to 0. The user can then spend the daily budget of 10 EUR again. - """ + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) - # Endpoint constants. - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/share-invite-bank-inquiry/{}/amount-used/{}" + return BunqResponseCompanyList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @classmethod - def delete(cls, share_invite_bank_inquiry_id, - share_invite_bank_amount_used_id, monetary_account_id=None, - custom_headers=None): + def update(cls, company_id, avatar_uuid=None, custom_headers=None): """ - Reset the available budget for a bank account share. To be called - without any ID at the end of the path. - :type user_id: int - :type monetary_account_id: int - :type share_invite_bank_inquiry_id: int - :type share_invite_bank_amount_used_id: int + :type company_id: int + :param avatar_uuid: The public UUID of the company's avatar. + :type avatar_uuid: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - share_invite_bank_inquiry_id, - share_invite_bank_amount_used_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + request_map = { +cls.FIELD_AVATAR_UUID : avatar_uuid +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), company_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) + @property + def UserCompany(self): + """ + :rtype: UserCompany + """ + + return self._UserCompany + def is_all_field_none(self): """ :rtype: bool """ + if self._UserCompany is not None: + return False + return True @staticmethod @@ -9113,237 +8689,307 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareInviteBankAmountUsed + :rtype: CompanyApiObject """ - return converter.json_to_class(ShareInviteBankAmountUsed, json_str) + return converter.json_to_class(CompanyApiObject, json_str) -class ShareInviteBankInquiry(core.BunqModel): +class UserCompanyApiObject(BunqModel): """ - Used to share a monetary account with another bunq user, as in the 'Connect' - feature in the bunq app. Allow the creation of share inquiries that, in the - same way as request inquiries, can be revoked by the user creating them or - accepted/rejected by the other party. + With UserCompany you can retrieve information regarding the authenticated + UserCompany and update specific fields.

Notification filters can be + set on a UserCompany level to receive callbacks. For more information check + the dedicated callbacks page. - :param _counter_user_alias: The label of the user to share with. - :type _counter_user_alias: object_.LabelUser - :param _draft_share_invite_bank_id: The id of the draft share invite bank. - :type _draft_share_invite_bank_id: int - :param _share_detail: The share details. Only one of these objects is - returned. - :type _share_detail: object_.ShareDetail - :param _status: The status of the share. Can be PENDING, REVOKED (the user - deletes the share inquiry before it's accepted), ACCEPTED, CANCELLED (the - user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual connects) + :param _name: The company name. + :type _name: str + :param _public_nick_name: The company's public nick name. + :type _public_nick_name: str + :param _avatar_uuid: The public UUID of the company's avatar. + :type _avatar_uuid: str + :param _address_main: The company's main address. + :type _address_main: object_.Address + :param _address_postal: The company's postal address. + :type _address_postal: object_.Address + :param _language: The person's preferred language. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type _language: str + :param _region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type _region: str + :param _country: The country as an ISO 3166-1 alpha-2 country code. + :type _country: str + :param _ubo: The names of the company's ultimate beneficiary owners. Minimum + zero, maximum four. + :type _ubo: list[object_.Ubo] + :param _chamber_of_commerce_number: The company's chamber of commerce + number. + :type _chamber_of_commerce_number: str + :param _legal_form: The company's legal form. + :type _legal_form: str + :param _status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. :type _status: str - :param _share_type: The share type, either STANDARD or MUTUAL. - :type _share_type: str - :param _start_date: The start date of this share. - :type _start_date: str - :param _end_date: The expiration date of this share. - :type _end_date: str - :param _alias: The label of the monetary account that's being shared. - :type _alias: object_.MonetaryAccountReference - :param _user_alias_created: The user who created the share. - :type _user_alias_created: object_.LabelUser - :param _user_alias_revoked: The user who revoked the share. - :type _user_alias_revoked: object_.LabelUser - :param _monetary_account_id: The id of the monetary account the share - applies to. - :type _monetary_account_id: int - :param _id_: The id of the newly created share invite. + :param _sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, + APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or + SUBMIT. + :type _sub_status: str + :param _session_timeout: The setting for the session timeout of the company + in seconds. + :type _session_timeout: int + :param _daily_limit_without_confirmation_login: The amount the company can + pay in the session without asking for credentials. + :type _daily_limit_without_confirmation_login: object_.Amount + :param _id_: The id of the modified company. :type _id_: int + :param _created: The timestamp of the company object's creation. + :type _created: str + :param _updated: The timestamp of the company object's last update. + :type _updated: str + :param _public_uuid: The company's public UUID. + :type _public_uuid: str + :param _display_name: The company's display name. + :type _display_name: str + :param _alias: The aliases of the account. + :type _alias: list[object_.Pointer] + :param _type_of_business_entity: The type of business entity. + :type _type_of_business_entity: str + :param _sector_of_industry: The sector of industry. + :type _sector_of_industry: str + :param _counter_bank_iban: The company's other bank account IBAN, through + which we verify it. + :type _counter_bank_iban: str + :param _avatar: The company's avatar. + :type _avatar: object_.Avatar + :param _address_shipping: The company's shipping address. + :type _address_shipping: object_.Address + :param _version_terms_of_service: The version of the terms of service + accepted by the user. + :type _version_terms_of_service: str + :param _directors: The existing bunq aliases for the company's directors. + :type _directors: list[object_.LabelUser] + :param _notification_filters: The types of notifications that will result in + a push notification or URL callback for this UserCompany. + :type _notification_filters: list[object_.NotificationFilter] + :param _customer: The customer profile of the company. + :type _customer: Customer + :param _customer_limit: The customer limits of the company. + :type _customer_limit: CustomerLimit + :param _billing_contract: The subscription of the company. + :type _billing_contract: list[BillingContractSubscription] + :param _deny_reason: The user deny reason. + :type _deny_reason: str + :param _relations: The relations for this user. + :type _relations: list[RelationUser] + :param _tax_resident: The user's tax residence numbers for different + countries. + :type _tax_resident: list[object_.TaxResident] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/share-invite-bank-inquiry" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/share-invite-bank-inquiry/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/share-invite-bank-inquiry/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/share-invite-bank-inquiry" + _ENDPOINT_URL_READ = "user-company/{}" + _ENDPOINT_URL_UPDATE = "user-company/{}" # Field constants. - FIELD_COUNTER_USER_ALIAS = "counter_user_alias" - FIELD_DRAFT_SHARE_INVITE_BANK_ID = "draft_share_invite_bank_id" - FIELD_SHARE_DETAIL = "share_detail" + FIELD_NAME = "name" + FIELD_PUBLIC_NICK_NAME = "public_nick_name" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_ADDRESS_MAIN = "address_main" + FIELD_ADDRESS_POSTAL = "address_postal" + FIELD_LANGUAGE = "language" + FIELD_REGION = "region" + FIELD_COUNTRY = "country" + FIELD_UBO = "ubo" + FIELD_CHAMBER_OF_COMMERCE_NUMBER = "chamber_of_commerce_number" + FIELD_LEGAL_FORM = "legal_form" FIELD_STATUS = "status" - FIELD_SHARE_TYPE = "share_type" - FIELD_START_DATE = "start_date" - FIELD_END_DATE = "end_date" + FIELD_SUB_STATUS = "sub_status" + FIELD_SESSION_TIMEOUT = "session_timeout" + FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login" # Object type. - _OBJECT_TYPE_GET = "ShareInviteBankInquiry" + _OBJECT_TYPE_GET = "UserCompany" + _id_ = None + _created = None + _updated = None + _public_uuid = None + _name = None + _display_name = None + _public_nick_name = None _alias = None - _user_alias_created = None - _user_alias_revoked = None - _counter_user_alias = None - _monetary_account_id = None - _draft_share_invite_bank_id = None - _share_detail = None + _chamber_of_commerce_number = None + _legal_form = None + _type_of_business_entity = None + _sector_of_industry = None + _counter_bank_iban = None + _avatar = None + _address_main = None + _address_postal = None + _address_shipping = None + _version_terms_of_service = None + _directors = None + _language = None + _country = None + _region = None + _ubo = None _status = None - _share_type = None - _start_date = None - _end_date = None - _id_ = None - _counter_user_alias_field_for_request = None - _draft_share_invite_bank_id_field_for_request = None - _share_detail_field_for_request = None + _sub_status = None + _session_timeout = None + _daily_limit_without_confirmation_login = None + _notification_filters = None + _customer = None + _customer_limit = None + _billing_contract = None + _deny_reason = None + _relations = None + _tax_resident = None + _name_field_for_request = None + _public_nick_name_field_for_request = None + _avatar_uuid_field_for_request = None + _address_main_field_for_request = None + _address_postal_field_for_request = None + _language_field_for_request = None + _region_field_for_request = None + _country_field_for_request = None + _ubo_field_for_request = None + _chamber_of_commerce_number_field_for_request = None + _legal_form_field_for_request = None _status_field_for_request = None - _share_type_field_for_request = None - _start_date_field_for_request = None - _end_date_field_for_request = None + _sub_status_field_for_request = None + _session_timeout_field_for_request = None + _daily_limit_without_confirmation_login_field_for_request = None - def __init__(self, counter_user_alias, share_detail=None, status=None, - draft_share_invite_bank_id=None, share_type=None, - start_date=None, end_date=None): + def __init__(self, address_main=None, language=None, region=None, name=None, public_nick_name=None, avatar_uuid=None, address_postal=None, country=None, ubo=None, chamber_of_commerce_number=None, legal_form=None, status=None, sub_status=None, session_timeout=None, daily_limit_without_confirmation_login=None): """ - :param counter_user_alias: The pointer of the user to share with. - :type counter_user_alias: object_.Pointer - :param share_detail: The share details. Only one of these objects may be - passed. - :type share_detail: object_.ShareDetail - :param status: The status of the share. Can be PENDING, REVOKED (the user - deletes the share inquiry before it's accepted), ACCEPTED, CANCELLED (the - user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual - connects). + :param address_main: The user's main address. + :type address_main: object_.Address + :param language: The person's preferred language. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type language: str + :param region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type region: str + :param name: The company name. + :type name: str + :param public_nick_name: The company's nick name. + :type public_nick_name: str + :param avatar_uuid: The public UUID of the company's avatar. + :type avatar_uuid: str + :param address_postal: The company's postal address. + :type address_postal: object_.Address + :param country: The country where the company is registered. + :type country: str + :param ubo: The names and birth dates of the company's ultimate beneficiary + owners. Minimum zero, maximum four. + :type ubo: list[object_.Ubo] + :param chamber_of_commerce_number: The company's chamber of commerce number. + :type chamber_of_commerce_number: str + :param legal_form: The company's legal form. + :type legal_form: str + :param status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. :type status: str - :param draft_share_invite_bank_id: The id of the draft share invite bank. - :type draft_share_invite_bank_id: int - :param share_type: The share type, either STANDARD or MUTUAL. - :type share_type: str - :param start_date: The start date of this share. - :type start_date: str - :param end_date: The expiration date of this share. - :type end_date: str + :param sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, + APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or + SUBMIT. + :type sub_status: str + :param session_timeout: The setting for the session timeout of the company + in seconds. + :type session_timeout: int + :param daily_limit_without_confirmation_login: The amount the company can + pay in the session without asking for credentials. + :type daily_limit_without_confirmation_login: object_.Amount """ - self._counter_user_alias_field_for_request = counter_user_alias - self._share_detail_field_for_request = share_detail + self._address_main_field_for_request = address_main + self._language_field_for_request = language + self._region_field_for_request = region + self._name_field_for_request = name + self._public_nick_name_field_for_request = public_nick_name + self._avatar_uuid_field_for_request = avatar_uuid + self._address_postal_field_for_request = address_postal + self._country_field_for_request = country + self._ubo_field_for_request = ubo + self._chamber_of_commerce_number_field_for_request = chamber_of_commerce_number + self._legal_form_field_for_request = legal_form self._status_field_for_request = status - self._draft_share_invite_bank_id_field_for_request = draft_share_invite_bank_id - self._share_type_field_for_request = share_type - self._start_date_field_for_request = start_date - self._end_date_field_for_request = end_date - - @classmethod - def create(cls, counter_user_alias, share_detail, status, - monetary_account_id=None, draft_share_invite_bank_id=None, - share_type=None, start_date=None, end_date=None, - custom_headers=None): - """ - Create a new share inquiry for a monetary account, specifying the - permission the other bunq user will have on it. - - :type user_id: int - :type monetary_account_id: int - :param counter_user_alias: The pointer of the user to share with. - :type counter_user_alias: object_.Pointer - :param share_detail: The share details. Only one of these objects may be - passed. - :type share_detail: object_.ShareDetail - :param status: The status of the share. Can be PENDING, REVOKED (the - user deletes the share inquiry before it's accepted), ACCEPTED, - CANCELLED (the user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual - connects). - :type status: str - :param draft_share_invite_bank_id: The id of the draft share invite - bank. - :type draft_share_invite_bank_id: int - :param share_type: The share type, either STANDARD or MUTUAL. - :type share_type: str - :param start_date: The start date of this share. - :type start_date: str - :param end_date: The expiration date of this share. - :type end_date: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_COUNTER_USER_ALIAS: counter_user_alias, - cls.FIELD_DRAFT_SHARE_INVITE_BANK_ID: draft_share_invite_bank_id, - cls.FIELD_SHARE_DETAIL: share_detail, - cls.FIELD_STATUS: status, - cls.FIELD_SHARE_TYPE: share_type, - cls.FIELD_START_DATE: start_date, - cls.FIELD_END_DATE: end_date - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + self._sub_status_field_for_request = sub_status + self._session_timeout_field_for_request = session_timeout + self._daily_limit_without_confirmation_login_field_for_request = daily_limit_without_confirmation_login @classmethod - def get(cls, share_invite_bank_inquiry_id, monetary_account_id=None, - custom_headers=None): + def get(cls, custom_headers=None): """ - Get the details of a specific share inquiry. + Get a specific company. - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type share_invite_bank_inquiry_id: int + :type api_context: ApiContext + :type user_company_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseShareInviteBankInquiry + :rtype: BunqResponseUserCompany """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - share_invite_bank_inquiry_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseShareInviteBankInquiry.cast_from_bunq_response( + return BunqResponseUserCompany.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, share_invite_bank_inquiry_id, monetary_account_id=None, - share_detail=None, status=None, start_date=None, end_date=None, - custom_headers=None): + def update(cls, name=None, public_nick_name=None, avatar_uuid=None, address_main=None, address_postal=None, language=None, region=None, country=None, ubo=None, chamber_of_commerce_number=None, legal_form=None, status=None, sub_status=None, session_timeout=None, daily_limit_without_confirmation_login=None, custom_headers=None): """ - Update the details of a share. This includes updating status (revoking - or cancelling it), granted permission and validity period of this share. + Modify a specific company's data. - :type user_id: int - :type monetary_account_id: int - :type share_invite_bank_inquiry_id: int - :param share_detail: The share details. Only one of these objects may be - passed. - :type share_detail: object_.ShareDetail - :param status: The status of the share. Can be PENDING, REVOKED (the - user deletes the share inquiry before it's accepted), ACCEPTED, - CANCELLED (the user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual - connects). + :type user_company_id: int + :param name: The company name. + :type name: str + :param public_nick_name: The company's nick name. + :type public_nick_name: str + :param avatar_uuid: The public UUID of the company's avatar. + :type avatar_uuid: str + :param address_main: The user's main address. + :type address_main: object_.Address + :param address_postal: The company's postal address. + :type address_postal: object_.Address + :param language: The person's preferred language. Formatted as a ISO + 639-1 language code plus a ISO 3166-1 alpha-2 country code, seperated by + an underscore. + :type language: str + :param region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type region: str + :param country: The country where the company is registered. + :type country: str + :param ubo: The names and birth dates of the company's ultimate + beneficiary owners. Minimum zero, maximum four. + :type ubo: list[object_.Ubo] + :param chamber_of_commerce_number: The company's chamber of commerce + number. + :type chamber_of_commerce_number: str + :param legal_form: The company's legal form. + :type legal_form: str + :param status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. :type status: str - :param start_date: The start date of this share. - :type start_date: str - :param end_date: The expiration date of this share. - :type end_date: str + :param sub_status: The user sub-status. Can be: NONE, FACE_RESET, + APPROVAL, APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, + COUNTER_IBAN, IDEAL or SUBMIT. + :type sub_status: str + :param session_timeout: The setting for the session timeout of the + company in seconds. + :type session_timeout: int + :param daily_limit_without_confirmation_login: The amount the company + can pay in the session without asking for credentials. + :type daily_limit_without_confirmation_login: object_.Amount :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -9352,482 +8998,307 @@ def update(cls, share_invite_bank_inquiry_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_SHARE_DETAIL: share_detail, - cls.FIELD_STATUS: status, - cls.FIELD_START_DATE: start_date, - cls.FIELD_END_DATE: end_date - } +cls.FIELD_NAME : name, +cls.FIELD_PUBLIC_NICK_NAME : public_nick_name, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_ADDRESS_MAIN : address_main, +cls.FIELD_ADDRESS_POSTAL : address_postal, +cls.FIELD_LANGUAGE : language, +cls.FIELD_REGION : region, +cls.FIELD_COUNTRY : country, +cls.FIELD_UBO : ubo, +cls.FIELD_CHAMBER_OF_COMMERCE_NUMBER : chamber_of_commerce_number, +cls.FIELD_LEGAL_FORM : legal_form, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_SESSION_TIMEOUT : session_timeout, +cls.FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN : daily_limit_without_confirmation_login +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - share_invite_bank_inquiry_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id()) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def id_(self): """ - Get a list with all the share inquiries for a monetary account, only if - the requesting user has permission to change the details of the various - ones. - - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseShareInviteBankInquiryList + :rtype: int """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseShareInviteBankInquiryList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._id_ @property - def alias(self): + def created(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: str """ - return self._alias + return self._created @property - def user_alias_created(self): + def updated(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._user_alias_created + return self._updated @property - def user_alias_revoked(self): + def public_uuid(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._user_alias_revoked + return self._public_uuid @property - def counter_user_alias(self): + def name(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._counter_user_alias + return self._name @property - def monetary_account_id(self): + def display_name(self): """ - :rtype: int + :rtype: str """ - return self._monetary_account_id + return self._display_name @property - def draft_share_invite_bank_id(self): + def public_nick_name(self): """ - :rtype: int + :rtype: str """ - return self._draft_share_invite_bank_id + return self._public_nick_name @property - def share_detail(self): + def alias(self): """ - :rtype: object_.ShareDetail + :rtype: list[object_.Pointer] """ - return self._share_detail + return self._alias @property - def status(self): + def chamber_of_commerce_number(self): """ :rtype: str """ - return self._status + return self._chamber_of_commerce_number @property - def share_type(self): + def legal_form(self): """ :rtype: str """ - return self._share_type + return self._legal_form @property - def start_date(self): + def type_of_business_entity(self): """ :rtype: str """ - return self._start_date + return self._type_of_business_entity @property - def end_date(self): + def sector_of_industry(self): """ :rtype: str """ - return self._end_date + return self._sector_of_industry @property - def id_(self): + def counter_bank_iban(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._counter_bank_iban - def is_all_field_none(self): + @property + def avatar(self): """ - :rtype: bool + :rtype: object_.Avatar """ - if self._alias is not None: - return False - - if self._user_alias_created is not None: - return False - - if self._user_alias_revoked is not None: - return False - - if self._counter_user_alias is not None: - return False - - if self._monetary_account_id is not None: - return False - - if self._draft_share_invite_bank_id is not None: - return False - - if self._share_detail is not None: - return False - - if self._status is not None: - return False - - if self._share_type is not None: - return False - - if self._start_date is not None: - return False - - if self._end_date is not None: - return False - - if self._id_ is not None: - return False - - return True + return self._avatar - @staticmethod - def from_json(json_str): + @property + def address_main(self): """ - :type json_str: str - - :rtype: ShareInviteBankInquiry + :rtype: object_.Address """ - return converter.json_to_class(ShareInviteBankInquiry, json_str) - - -class ShareInviteBankResponse(core.BunqModel): - """ - Used to view or respond to shares a user was invited to. See - 'share-invite-bank-inquiry' for more information about the inquiring - endpoint. - - :param _status: The status of the share. Can be PENDING, REVOKED (the user - deletes the share inquiry before it's accepted), ACCEPTED, CANCELLED (the - user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual connects) - :type _status: str - :param _id_: The id of the ShareInviteBankResponse. - :type _id_: int - :param _created: The timestamp of the ShareInviteBankResponse creation. - :type _created: str - :param _updated: The timestamp of the ShareInviteBankResponse last update. - :type _updated: str - :param _counter_alias: The monetary account and user who created the share. - :type _counter_alias: object_.MonetaryAccountReference - :param _user_alias_cancelled: The user who cancelled the share if it has - been revoked or rejected. - :type _user_alias_cancelled: object_.LabelUser - :param _monetary_account_id: The id of the monetary account the ACCEPTED - share applies to. null otherwise. - :type _monetary_account_id: int - :param _draft_share_invite_bank_id: The id of the draft share invite bank. - :type _draft_share_invite_bank_id: int - :param _share_detail: The share details. - :type _share_detail: object_.ShareDetail - :param _share_type: The share type, either STANDARD or MUTUAL. - :type _share_type: str - :param _start_date: The start date of this share. - :type _start_date: str - :param _end_date: The expiration date of this share. - :type _end_date: str - :param _description: The description of this share. It is basically the - monetary account description. - :type _description: str - """ - - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/share-invite-bank-response/{}" - _ENDPOINT_URL_UPDATE = "user/{}/share-invite-bank-response/{}" - _ENDPOINT_URL_LISTING = "user/{}/share-invite-bank-response" - - # Field constants. - FIELD_STATUS = "status" - - # Object type. - _OBJECT_TYPE_GET = "ShareInviteBankResponse" - - _id_ = None - _created = None - _updated = None - _counter_alias = None - _user_alias_cancelled = None - _monetary_account_id = None - _draft_share_invite_bank_id = None - _share_detail = None - _status = None - _share_type = None - _start_date = None - _end_date = None - _description = None - _status_field_for_request = None + return self._address_main - def __init__(self, status=None): + @property + def address_postal(self): """ - :param status: The status of the share. Can be PENDING, REVOKED (the user - deletes the share inquiry before it's accepted), ACCEPTED, CANCELLED (the - user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual connects) - :type status: str + :rtype: object_.Address """ - self._status_field_for_request = status + return self._address_postal - @classmethod - def get(cls, share_invite_bank_response_id, custom_headers=None): + @property + def address_shipping(self): """ - Return the details of a specific share a user was invited to. - - :type api_context: context.ApiContext - :type user_id: int - :type share_invite_bank_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseShareInviteBankResponse + :rtype: object_.Address """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - share_invite_bank_response_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseShareInviteBankResponse.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._address_shipping - @classmethod - def update(cls, share_invite_bank_response_id, status=None, - custom_headers=None): + @property + def version_terms_of_service(self): """ - Accept or reject a share a user was invited to. - - :type user_id: int - :type share_invite_bank_response_id: int - :param status: The status of the share. Can be PENDING, REVOKED (the - user deletes the share inquiry before it's accepted), ACCEPTED, - CANCELLED (the user deletes an active share) or CANCELLATION_PENDING, - CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual - connects) - :type status: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._version_terms_of_service - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - share_invite_bank_response_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def directors(self): + """ + :rtype: list[object_.LabelUser] + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._directors - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def language(self): """ - Return all the shares a user was invited to. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseShareInviteBankResponseList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._language - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def country(self): + """ + :rtype: str + """ - return BunqResponseShareInviteBankResponseList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._country @property - def id_(self): + def region(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._region @property - def created(self): + def ubo(self): """ - :rtype: str + :rtype: list[object_.Ubo] """ - return self._created + return self._ubo @property - def updated(self): + def status(self): """ :rtype: str """ - return self._updated + return self._status @property - def counter_alias(self): + def sub_status(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: str """ - return self._counter_alias + return self._sub_status @property - def user_alias_cancelled(self): + def session_timeout(self): """ - :rtype: object_.LabelUser + :rtype: int """ - return self._user_alias_cancelled + return self._session_timeout @property - def monetary_account_id(self): + def daily_limit_without_confirmation_login(self): """ - :rtype: int + :rtype: object_.Amount """ - return self._monetary_account_id + return self._daily_limit_without_confirmation_login @property - def draft_share_invite_bank_id(self): + def notification_filters(self): """ - :rtype: int + :rtype: list[object_.NotificationFilter] """ - return self._draft_share_invite_bank_id + return self._notification_filters @property - def share_detail(self): + def customer(self): """ - :rtype: object_.ShareDetail + :rtype: Customer """ - return self._share_detail + return self._customer @property - def status(self): + def customer_limit(self): """ - :rtype: str + :rtype: CustomerLimit """ - return self._status + return self._customer_limit @property - def share_type(self): + def billing_contract(self): """ - :rtype: str + :rtype: list[BillingContractSubscription] """ - return self._share_type + return self._billing_contract @property - def start_date(self): + def deny_reason(self): """ :rtype: str """ - return self._start_date + return self._deny_reason @property - def end_date(self): + def relations(self): """ - :rtype: str + :rtype: list[RelationUser] """ - return self._end_date + return self._relations @property - def description(self): + def tax_resident(self): """ - :rtype: str + :rtype: list[object_.TaxResident] """ - return self._description + return self._tax_resident def is_all_field_none(self): """ @@ -9843,34 +9314,97 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._counter_alias is not None: + if self._public_uuid is not None: return False - if self._user_alias_cancelled is not None: + if self._name is not None: return False - if self._monetary_account_id is not None: + if self._display_name is not None: return False - if self._draft_share_invite_bank_id is not None: + if self._public_nick_name is not None: return False - if self._share_detail is not None: + if self._alias is not None: + return False + + if self._chamber_of_commerce_number is not None: + return False + + if self._legal_form is not None: + return False + + if self._type_of_business_entity is not None: + return False + + if self._sector_of_industry is not None: + return False + + if self._counter_bank_iban is not None: + return False + + if self._avatar is not None: + return False + + if self._address_main is not None: + return False + + if self._address_postal is not None: + return False + + if self._address_shipping is not None: + return False + + if self._version_terms_of_service is not None: + return False + + if self._directors is not None: + return False + + if self._language is not None: + return False + + if self._country is not None: + return False + + if self._region is not None: + return False + + if self._ubo is not None: return False if self._status is not None: return False - if self._share_type is not None: + if self._sub_status is not None: return False - if self._start_date is not None: + if self._session_timeout is not None: return False - if self._end_date is not None: + if self._daily_limit_without_confirmation_login is not None: return False - if self._description is not None: + if self._notification_filters is not None: + return False + + if self._customer is not None: + return False + + if self._customer_limit is not None: + return False + + if self._billing_contract is not None: + return False + + if self._deny_reason is not None: + return False + + if self._relations is not None: + return False + + if self._tax_resident is not None: return False return True @@ -9880,621 +9414,486 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareInviteBankResponse + :rtype: UserCompanyApiObject """ - return converter.json_to_class(ShareInviteBankResponse, json_str) + return converter.json_to_class(UserCompanyApiObject, json_str) -class MonetaryAccountBank(core.BunqModel): +class CustomerApiObject(BunqModel): """ - With MonetaryAccountBank you can create a new bank account, retrieve - information regarding your existing MonetaryAccountBanks and update specific - fields of an existing MonetaryAccountBank. Examples of fields that can be - updated are the description, the daily limit and the avatar of the - account.

Notification filters can be set on a monetary account - level to receive callbacks. For more information check the dedicated callbacks page. + Used to view a customer. - :param _currency: The currency of the MonetaryAccountBank as an ISO 4217 - formatted currency code. - :type _currency: str - :param _description: The description of the MonetaryAccountBank. Defaults to - 'bunq account'. - :type _description: str - :param _daily_limit: The daily spending limit Amount of the - MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the - MonetaryAccountBank's currency. Limited to 10000 EUR. - :type _daily_limit: object_.Amount - :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. - :type _avatar_uuid: str - :param _status: The status of the MonetaryAccountBank. Can be: ACTIVE, - BLOCKED, CANCELLED or PENDING_REOPEN - :type _status: str - :param _sub_status: The sub-status of the MonetaryAccountBank providing - extra information regarding the status. Will be NONE for ACTIVE or - PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and - REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. - :type _sub_status: str - :param _reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. - :type _reason: str - :param _reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. - :type _reason_description: str - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountBank. - :type _notification_filters: list[object_.NotificationFilter] - :param _setting: The settings of the MonetaryAccountBank. - :type _setting: object_.MonetaryAccountSetting - :param _id_: The id of the MonetaryAccountBank. + :param _billing_account_id: The primary billing account account's id. + :type _billing_account_id: str + :param _invoice_notification_preference: The preferred notification type for + invoices. + :type _invoice_notification_preference: str + :param _id_: The id of the customer. :type _id_: int - :param _created: The timestamp of the MonetaryAccountBank's creation. + :param _created: The timestamp of the customer object's creation. :type _created: str - :param _updated: The timestamp of the MonetaryAccountBank's last update. + :param _updated: The timestamp of the customer object's last update. :type _updated: str - :param _avatar: The Avatar of the MonetaryAccountBank. - :type _avatar: object_.Avatar - :param _daily_spent: Total Amount of money spent today. Timezone aware. - :type _daily_spent: object_.Amount - :param _overdraft_limit: The maximum Amount the MonetaryAccountBank can be - 'in the red'. - :type _overdraft_limit: object_.Amount - :param _balance: The current balance Amount of the MonetaryAccountBank. - :type _balance: object_.Amount - :param _alias: The Aliases for the MonetaryAccountBank. - :type _alias: list[object_.Pointer] - :param _public_uuid: The MonetaryAccountBank's public UUID. - :type _public_uuid: str - :param _user_id: The id of the User who owns the MonetaryAccountBank. - :type _user_id: int - :param _monetary_account_profile: The profile of the account. - :type _monetary_account_profile: MonetaryAccountProfile """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account-bank" - _ENDPOINT_URL_READ = "user/{}/monetary-account-bank/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-bank/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account-bank" - # Field constants. - FIELD_CURRENCY = "currency" - FIELD_DESCRIPTION = "description" - FIELD_DAILY_LIMIT = "daily_limit" - FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_REASON = "reason" - FIELD_REASON_DESCRIPTION = "reason_description" - FIELD_NOTIFICATION_FILTERS = "notification_filters" - FIELD_SETTING = "setting" + FIELD_BILLING_ACCOUNT_ID = "billing_account_id" + FIELD_INVOICE_NOTIFICATION_PREFERENCE = "invoice_notification_preference" - # Object type. - _OBJECT_TYPE_GET = "MonetaryAccountBank" _id_ = None _created = None _updated = None - _avatar = None - _currency = None - _description = None - _daily_limit = None - _daily_spent = None - _overdraft_limit = None - _balance = None - _alias = None - _public_uuid = None - _status = None - _sub_status = None - _reason = None - _reason_description = None - _user_id = None - _monetary_account_profile = None - _notification_filters = None - _setting = None - _currency_field_for_request = None - _description_field_for_request = None - _daily_limit_field_for_request = None - _avatar_uuid_field_for_request = None - _status_field_for_request = None - _sub_status_field_for_request = None - _reason_field_for_request = None - _reason_description_field_for_request = None - _notification_filters_field_for_request = None - _setting_field_for_request = None + _billing_account_id = None + _invoice_notification_preference = None + _billing_account_id_field_for_request = None + _invoice_notification_preference_field_for_request = None - def __init__(self, currency, description=None, daily_limit=None, - avatar_uuid=None, status=None, sub_status=None, reason=None, - reason_description=None, notification_filters=None, - setting=None): + def __init__(self, billing_account_id=None, invoice_notification_preference=None): """ - :param currency: The currency of the MonetaryAccountBank as an ISO 4217 - formatted currency code. - :type currency: str - :param description: The description of the MonetaryAccountBank. Defaults to - 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the - MonetaryAccountBank's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountBank. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT - requests to cancel (close) or reopen the MonetaryAccountBank. When updating - the status and/or sub_status no other fields can be updated in the same - request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountBank providing extra - information regarding the status. Should be ignored for POST requests. In - case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. - When updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if updating - the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountBank. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountBank. - :type setting: object_.MonetaryAccountSetting + :param billing_account_id: The primary billing account account's id. + :type billing_account_id: str + :param invoice_notification_preference: The preferred notification type for + invoices + :type invoice_notification_preference: str """ - self._currency_field_for_request = currency - self._description_field_for_request = description - self._daily_limit_field_for_request = daily_limit - self._avatar_uuid_field_for_request = avatar_uuid - self._status_field_for_request = status - self._sub_status_field_for_request = sub_status - self._reason_field_for_request = reason - self._reason_description_field_for_request = reason_description - self._notification_filters_field_for_request = notification_filters - self._setting_field_for_request = setting + self._billing_account_id_field_for_request = billing_account_id + self._invoice_notification_preference_field_for_request = invoice_notification_preference - @classmethod - def create(cls, currency, description=None, daily_limit=None, - avatar_uuid=None, status=None, sub_status=None, reason=None, - reason_description=None, notification_filters=None, setting=None, - custom_headers=None): + + + @property + def id_(self): """ - Create new MonetaryAccountBank. - - :type user_id: int - :param currency: The currency of the MonetaryAccountBank as an ISO 4217 - formatted currency code. - :type currency: str - :param description: The description of the MonetaryAccountBank. Defaults - to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the - MonetaryAccountBank's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountBank. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountBank. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountBank providing - extra information regarding the status. Should be ignored for POST - requests. In case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be - NONE. When updating the status and/or sub_status no other fields can be - updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountBank. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountBank. - :type setting: object_.MonetaryAccountSetting - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._id_ - request_map = { - cls.FIELD_CURRENCY: currency, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + @property + def created(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + return self._created - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + @property + def updated(self): + """ + :rtype: str + """ - @classmethod - def get(cls, monetary_account_bank_id, custom_headers=None): + return self._updated + + @property + def billing_account_id(self): """ - Get a specific MonetaryAccountBank. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_bank_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseMonetaryAccountBank + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._billing_account_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - monetary_account_bank_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def invoice_notification_preference(self): + """ + :rtype: str + """ - return BunqResponseMonetaryAccountBank.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._invoice_notification_preference - @classmethod - def update(cls, monetary_account_bank_id, description=None, - daily_limit=None, avatar_uuid=None, status=None, sub_status=None, - reason=None, reason_description=None, notification_filters=None, - setting=None, custom_headers=None): + def is_all_field_none(self): """ - Update a specific existing MonetaryAccountBank. - - :type user_id: int - :type monetary_account_bank_id: int - :param description: The description of the MonetaryAccountBank. Defaults - to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the - MonetaryAccountBank's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountBank. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountBank. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountBank providing - extra information regarding the status. Should be ignored for POST - requests. In case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be - NONE. When updating the status and/or sub_status no other fields can be - updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountBank. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountBank. - :type setting: object_.MonetaryAccountSetting - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: bool """ - if custom_headers is None: - custom_headers = {} + if self._id_ is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) + if self._created is not None: + return False - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._updated is not None: + return False - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - monetary_account_bank_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + if self._billing_account_id is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._invoice_notification_preference is not None: + return False - @classmethod - def list(cls, params=None, custom_headers=None): + return True + + @staticmethod + def from_json(json_str): """ - Gets a listing of all MonetaryAccountBanks of a given user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseMonetaryAccountBankList + :rtype: CustomerApiObject """ - if params is None: - params = {} + return converter.json_to_class(CustomerApiObject, json_str) - if custom_headers is None: - custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) +class RelationUserApiObject(BunqModel): + """ + Manage the relation user details. + + :param _user_id: The user's ID. + :type _user_id: str + :param _counter_user_id: The counter user's ID. + :type _counter_user_id: str + :param _label_user: The user's label. + :type _label_user: object_.LabelUser + :param _counter_label_user: The counter user's label. + :type _counter_label_user: object_.LabelUser + :param _relationship: The requested relation type. + :type _relationship: str + :param _status: The request's status, only for UPDATE. + :type _status: str + :param _user_status: The account status of a user + :type _user_status: str + :param _counter_user_status: The account status of a user + :type _counter_user_status: str + :param _company_employee_setting_adyen_card_transaction: Tap to Pay settings + for the company employee. + :type _company_employee_setting_adyen_card_transaction: + CompanyEmployeeSettingAdyenCardTransaction + :param _all_company_employee_card: Cards accessible by the company employee + :type _all_company_employee_card: list[CompanyEmployeeCard] + """ - return BunqResponseMonetaryAccountBankList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + _user_id = None + _counter_user_id = None + _label_user = None + _counter_label_user = None + _relationship = None + _status = None + _user_status = None + _counter_user_status = None + _company_employee_setting_adyen_card_transaction = None + _all_company_employee_card = None @property - def id_(self): + def user_id(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._user_id @property - def created(self): + def counter_user_id(self): """ :rtype: str """ - return self._created + return self._counter_user_id @property - def updated(self): + def label_user(self): """ - :rtype: str + :rtype: object_.LabelUser """ - return self._updated + return self._label_user @property - def avatar(self): + def counter_label_user(self): """ - :rtype: object_.Avatar + :rtype: object_.LabelUser """ - return self._avatar + return self._counter_label_user @property - def currency(self): + def relationship(self): """ :rtype: str """ - return self._currency + return self._relationship @property - def description(self): + def status(self): """ :rtype: str """ - return self._description + return self._status @property - def daily_limit(self): + def user_status(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_limit + return self._user_status @property - def daily_spent(self): + def counter_user_status(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_spent + return self._counter_user_status @property - def overdraft_limit(self): + def company_employee_setting_adyen_card_transaction(self): """ - :rtype: object_.Amount + :rtype: CompanyEmployeeSettingAdyenCardTransaction """ - return self._overdraft_limit + return self._company_employee_setting_adyen_card_transaction @property - def balance(self): + def all_company_employee_card(self): """ - :rtype: object_.Amount + :rtype: list[CompanyEmployeeCard] """ - return self._balance + return self._all_company_employee_card - @property - def alias(self): + def is_all_field_none(self): """ - :rtype: list[object_.Pointer] + :rtype: bool """ - return self._alias + if self._user_id is not None: + return False - @property - def public_uuid(self): + if self._counter_user_id is not None: + return False + + if self._label_user is not None: + return False + + if self._counter_label_user is not None: + return False + + if self._relationship is not None: + return False + + if self._status is not None: + return False + + if self._user_status is not None: + return False + + if self._counter_user_status is not None: + return False + + if self._company_employee_setting_adyen_card_transaction is not None: + return False + + if self._all_company_employee_card is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: RelationUserApiObject """ - return self._public_uuid + return converter.json_to_class(RelationUserApiObject, json_str) - @property - def status(self): + +class CompanyEmployeeCardApiObject(BunqModel): + """ + Manage cards for company employees. + + :param _pointer_counter_user: The pointer to the employee for which you want + to create a card. + :type _pointer_counter_user: object_.Pointer + :param _pointer_monetary_account: The pointer to the monetary account that + will be connected at first with the card. + :type _pointer_monetary_account: object_.Pointer + :param _type_: The type of card to order. + :type _type_: str + :param _product_type: The product type of the card to order. + :type _product_type: str + :param _company_name_on_card: The name of the company that should be + displayed on the card. + :type _company_name_on_card: str + :param _employee_name_on_card: The name of the employee that should be + displayed on the card. + :type _employee_name_on_card: str + :param _employee_preferred_name_on_card: The user's preferred name as it + will be on the card. + :type _employee_preferred_name_on_card: str + :param _amount_limit_monthly: The monthly spending limit for this employee + on the card. + :type _amount_limit_monthly: object_.Amount + :param _status: The status of the employee card. + :type _status: str + :param _card: The actual card. + :type _card: Card + :param _amount_spent_monthly: The monthly spend for this employee on the + card. + :type _amount_spent_monthly: object_.Amount + :param _number_of_company_employee_card_receipt_pending: The number of + transactions that still need a receipt. + :type _number_of_company_employee_card_receipt_pending: int + :param _company_employee_card_limit: The company employee's monthly + cumulative card limit. + :type _company_employee_card_limit: CompanyEmployeeCardLimit + """ + + # Field constants. + FIELD_POINTER_COUNTER_USER = "pointer_counter_user" + FIELD_POINTER_MONETARY_ACCOUNT = "pointer_monetary_account" + FIELD_TYPE = "type" + FIELD_PRODUCT_TYPE = "product_type" + FIELD_COMPANY_NAME_ON_CARD = "company_name_on_card" + FIELD_EMPLOYEE_NAME_ON_CARD = "employee_name_on_card" + FIELD_EMPLOYEE_PREFERRED_NAME_ON_CARD = "employee_preferred_name_on_card" + FIELD_AMOUNT_LIMIT_MONTHLY = "amount_limit_monthly" + FIELD_STATUS = "status" + + + _card = None + _status = None + _company_name_on_card = None + _amount_limit_monthly = None + _amount_spent_monthly = None + _number_of_company_employee_card_receipt_pending = None + _company_employee_card_limit = None + _pointer_counter_user_field_for_request = None + _pointer_monetary_account_field_for_request = None + _type__field_for_request = None + _product_type_field_for_request = None + _company_name_on_card_field_for_request = None + _employee_name_on_card_field_for_request = None + _employee_preferred_name_on_card_field_for_request = None + _amount_limit_monthly_field_for_request = None + _status_field_for_request = None + + def __init__(self, pointer_counter_user, pointer_monetary_account, type_, product_type, company_name_on_card, employee_name_on_card=None, employee_preferred_name_on_card=None, amount_limit_monthly=None, status=None): """ - :rtype: str + :param pointer_counter_user: The pointer to the employee for which you want + to create a card. + :type pointer_counter_user: object_.Pointer + :param pointer_monetary_account: The pointer to the monetary account that + will be connected at first with the card. + :type pointer_monetary_account: object_.Pointer + :param type_: The type of card to order. + :type type_: str + :param product_type: The product type of the card to order. + :type product_type: str + :param company_name_on_card: The name of the company that should be + displayed on the card. + :type company_name_on_card: str + :param employee_name_on_card: The name of the employee that should be + displayed on the card. + :type employee_name_on_card: str + :param employee_preferred_name_on_card: The user's preferred name as it will + be on the card. + :type employee_preferred_name_on_card: str + :param amount_limit_monthly: The monthly spending limit for this employee on + the card. + :type amount_limit_monthly: object_.Amount + :param status: The status of the employee card. + :type status: str """ - return self._status + self._pointer_counter_user_field_for_request = pointer_counter_user + self._pointer_monetary_account_field_for_request = pointer_monetary_account + self._type__field_for_request = type_ + self._product_type_field_for_request = product_type + self._company_name_on_card_field_for_request = company_name_on_card + self._employee_name_on_card_field_for_request = employee_name_on_card + self._employee_preferred_name_on_card_field_for_request = employee_preferred_name_on_card + self._amount_limit_monthly_field_for_request = amount_limit_monthly + self._status_field_for_request = status + + @property - def sub_status(self): + def card(self): """ - :rtype: str + :rtype: Card """ - return self._sub_status + return self._card @property - def reason(self): + def status(self): """ :rtype: str """ - return self._reason + return self._status @property - def reason_description(self): + def company_name_on_card(self): """ :rtype: str """ - return self._reason_description + return self._company_name_on_card @property - def user_id(self): + def amount_limit_monthly(self): """ - :rtype: int + :rtype: object_.Amount """ - return self._user_id + return self._amount_limit_monthly @property - def monetary_account_profile(self): + def amount_spent_monthly(self): """ - :rtype: MonetaryAccountProfile + :rtype: object_.Amount """ - return self._monetary_account_profile + return self._amount_spent_monthly @property - def notification_filters(self): + def number_of_company_employee_card_receipt_pending(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: int """ - return self._notification_filters + return self._number_of_company_employee_card_receipt_pending @property - def setting(self): + def company_employee_card_limit(self): """ - :rtype: object_.MonetaryAccountSetting + :rtype: CompanyEmployeeCardLimit """ - return self._setting + return self._company_employee_card_limit def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._avatar is not None: - return False - - if self._currency is not None: - return False - - if self._description is not None: - return False - - if self._daily_limit is not None: - return False - - if self._daily_spent is not None: - return False - - if self._overdraft_limit is not None: - return False - - if self._balance is not None: - return False - - if self._alias is not None: - return False - - if self._public_uuid is not None: + if self._card is not None: return False if self._status is not None: return False - if self._sub_status is not None: - return False - - if self._reason is not None: - return False - - if self._reason_description is not None: + if self._company_name_on_card is not None: return False - if self._user_id is not None: + if self._amount_limit_monthly is not None: return False - if self._monetary_account_profile is not None: + if self._amount_spent_monthly is not None: return False - if self._notification_filters is not None: + if self._number_of_company_employee_card_receipt_pending is not None: return False - if self._setting is not None: + if self._company_employee_card_limit is not None: return False return True @@ -10504,72 +9903,96 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountBank + :rtype: CompanyEmployeeCardApiObject """ - return converter.json_to_class(MonetaryAccountBank, json_str) + return converter.json_to_class(CompanyEmployeeCardApiObject, json_str) -class MonetaryAccountProfile(core.BunqModel): +class CompanyEmployeeCardLimitApiObject(BunqModel): """ - Used to update and read up monetary account profiles, to keep the balance - between specific thresholds. + Manage the card limit for company employees. - :param _profile_fill: The profile settings for triggering the fill of a - monetary account. - :type _profile_fill: object_.MonetaryAccountProfileFill - :param _profile_drain: The profile settings for moving excesses to a savings - account - :type _profile_drain: object_.MonetaryAccountProfileDrain + :param _amount_limit_monthly: The monthly spending limit for this employee + on the card. + :type _amount_limit_monthly: object_.Amount + :param _user_company_id: Company item id. + :type _user_company_id: int + :param _user_employee_id: Company employee item id. + :type _user_employee_id: int + :param _amount_spent_monthly: The monthly spend for this employee on the + card. + :type _amount_spent_monthly: object_.Amount """ # Field constants. - FIELD_PROFILE_FILL = "profile_fill" - FIELD_PROFILE_DRAIN = "profile_drain" + FIELD_AMOUNT_LIMIT_MONTHLY = "amount_limit_monthly" - _profile_fill = None - _profile_drain = None - _profile_fill_field_for_request = None - _profile_drain_field_for_request = None - def __init__(self, profile_fill=None, profile_drain=None): + _user_company_id = None + _user_employee_id = None + _amount_limit_monthly = None + _amount_spent_monthly = None + _amount_limit_monthly_field_for_request = None + + def __init__(self, amount_limit_monthly=None): """ - :param profile_fill: The profile settings for triggering the fill of a - monetary account. - :type profile_fill: object_.MonetaryAccountProfileFill - :param profile_drain: The profile settings for moving excesses to a savings - account - :type profile_drain: object_.MonetaryAccountProfileDrain + :param amount_limit_monthly: The monthly spending limit for this employee on + the card. + :type amount_limit_monthly: object_.Amount """ - self._profile_fill_field_for_request = profile_fill - self._profile_drain_field_for_request = profile_drain + self._amount_limit_monthly_field_for_request = amount_limit_monthly + + @property - def profile_fill(self): + def user_company_id(self): """ - :rtype: object_.MonetaryAccountProfileFill + :rtype: int """ - return self._profile_fill + return self._user_company_id @property - def profile_drain(self): + def user_employee_id(self): """ - :rtype: object_.MonetaryAccountProfileDrain + :rtype: int """ - return self._profile_drain + return self._user_employee_id - def is_all_field_none(self): + @property + def amount_limit_monthly(self): """ - :rtype: bool + :rtype: object_.Amount """ - if self._profile_fill is not None: - return False + return self._amount_limit_monthly - if self._profile_drain is not None: + @property + def amount_spent_monthly(self): + """ + :rtype: object_.Amount + """ + + return self._amount_spent_monthly + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._user_company_id is not None: + return False + + if self._user_employee_id is not None: + return False + + if self._amount_limit_monthly is not None: + return False + + if self._amount_spent_monthly is not None: return False return True @@ -10579,78 +10002,140 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountProfile + :rtype: CompanyEmployeeCardLimitApiObject """ - return converter.json_to_class(MonetaryAccountProfile, json_str) + return converter.json_to_class(CompanyEmployeeCardLimitApiObject, json_str) -class MonetaryAccount(core.BunqModel, core.AnchoredObjectInterface): +class ConfirmationOfFundsApiObject(BunqModel): """ - Used to show the MonetaryAccounts that you can access. Currently the only - MonetaryAccount type is MonetaryAccountBank. See also: - monetary-account-bank.

Notification filters can be set on a - monetary account level to receive callbacks. For more information check the - dedicated callbacks page. + Used to confirm availability of funds on an account. - :param _MonetaryAccountBank: - :type _MonetaryAccountBank: MonetaryAccountBank - :param _MonetaryAccountJoint: - :type _MonetaryAccountJoint: MonetaryAccountJoint - :param _MonetaryAccountLight: - :type _MonetaryAccountLight: MonetaryAccountLight + :param _pointer_iban: The pointer (IBAN) of the account we're querying. + :type _pointer_iban: object_.Pointer + :param _amount: The amount we want to check for. + :type _amount: object_.Amount + :param _has_sufficient_funds: Whether the account has sufficient funds. + :type _has_sufficient_funds: bool """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account" + _ENDPOINT_URL_CREATE = "user/{}/confirmation-of-funds" + + # Field constants. + FIELD_POINTER_IBAN = "pointer_iban" + FIELD_AMOUNT = "amount" # Object type. - _OBJECT_TYPE_GET = "MonetaryAccount" + _OBJECT_TYPE_POST = "ConfirmationOfFunds" - _MonetaryAccountBank = None - _MonetaryAccountJoint = None - _MonetaryAccountLight = None + _has_sufficient_funds = None + _pointer_iban_field_for_request = None + _amount_field_for_request = None + + def __init__(self, pointer_iban, amount): + """ + :param pointer_iban: The pointer (IBAN) of the account we're querying. + :type pointer_iban: object_.Pointer + :param amount: The amount we want to check for. + :type amount: object_.Amount + """ + + self._pointer_iban_field_for_request = pointer_iban + self._amount_field_for_request = amount @classmethod - def get(cls, monetary_account_id, custom_headers=None): + def create(cls,pointer_iban, amount, custom_headers=None): """ - Get a specific MonetaryAccount. - - :type api_context: context.ApiContext :type user_id: int - :type monetary_account_id: int + :param pointer_iban: The pointer (IBAN) of the account we're querying. + :type pointer_iban: object_.Pointer + :param amount: The amount we want to check for. + :type amount: object_.Amount :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMonetaryAccount + :rtype: BunqResponseConfirmationOfFunds """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + request_map = { +cls.FIELD_POINTER_IBAN : pointer_iban, +cls.FIELD_AMOUNT : amount +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - return BunqResponseMonetaryAccount.cast_from_bunq_response( - cls._from_json(response_raw) + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseConfirmationOfFunds.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) ) + @property + def has_sufficient_funds(self): + """ + :rtype: bool + """ + + return self._has_sufficient_funds + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._has_sufficient_funds is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ConfirmationOfFundsApiObject + """ + + return converter.json_to_class(ConfirmationOfFundsApiObject, json_str) + + +class CurrencyCloudBeneficiaryRequirementApiObject(BunqModel): + """ + Endpoint to list requirements for CurrencyCloud beneficiaries. + + :param _payment_type: The payment type this requirement is for. + :type _payment_type: str + :param _legal_entity_type: The entity type this requirement is for. + :type _legal_entity_type: str + :param _all_field: The fields that are required. + :type _all_field: list[object_.CurrencyCloudBeneficiaryRequirementField] + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/currency-cloud-beneficiary-requirement" + + # Object type. + _OBJECT_TYPE_GET = "CurrencyCloudBeneficiaryRequirement" + + _payment_type = None + _legal_entity_type = None + _all_field = None + @classmethod def list(cls, params=None, custom_headers=None): """ - Get a collection of all your MonetaryAccounts. - :type user_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMonetaryAccountList + :rtype: BunqResponseCurrencyCloudBeneficiaryRequirementList """ if params is None: @@ -10659,68 +10144,50 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseMonetaryAccountList.cast_from_bunq_response( - cls._from_json_list(response_raw) + return BunqResponseCurrencyCloudBeneficiaryRequirementList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def MonetaryAccountBank(self): + def payment_type(self): """ - :rtype: MonetaryAccountBank + :rtype: str """ - return self._MonetaryAccountBank + return self._payment_type @property - def MonetaryAccountJoint(self): + def legal_entity_type(self): """ - :rtype: MonetaryAccountJoint + :rtype: str """ - return self._MonetaryAccountJoint + return self._legal_entity_type @property - def MonetaryAccountLight(self): + def all_field(self): """ - :rtype: MonetaryAccountLight - """ - - return self._MonetaryAccountLight - - def get_referenced_object(self): - """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: list[object_.CurrencyCloudBeneficiaryRequirementField] """ - if self._MonetaryAccountBank is not None: - return self._MonetaryAccountBank - - if self._MonetaryAccountJoint is not None: - return self._MonetaryAccountJoint - - if self._MonetaryAccountLight is not None: - return self._MonetaryAccountLight - - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._all_field def is_all_field_none(self): """ :rtype: bool """ - if self._MonetaryAccountBank is not None: + if self._payment_type is not None: return False - if self._MonetaryAccountJoint is not None: + if self._legal_entity_type is not None: return False - if self._MonetaryAccountLight is not None: + if self._all_field is not None: return False return True @@ -10730,255 +10197,112 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccount + :rtype: CurrencyCloudBeneficiaryRequirementApiObject """ - return converter.json_to_class(MonetaryAccount, json_str) + return converter.json_to_class(CurrencyCloudBeneficiaryRequirementApiObject, json_str) -class MonetaryAccountJoint(core.BunqModel): +class CurrencyCloudBeneficiaryApiObject(BunqModel): """ - The endpoint for joint monetary accounts. + Endpoint to manage CurrencyCloud beneficiaries. - :param _currency: The currency of the MonetaryAccountJoint as an ISO 4217 - formatted currency code. + :param _name: The name of the beneficiary. + :type _name: str + :param _country: The country of the beneficiary. + :type _country: str + :param _currency: The currency of the beneficiary. :type _currency: str - :param _description: The description of the MonetaryAccountJoint. Defaults - to 'bunq account'. - :type _description: str - :param _daily_limit: The daily spending limit Amount of the - MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the - MonetaryAccountJoint's currency. Limited to 10000 EUR. - :type _daily_limit: object_.Amount - :param _overdraft_limit: The maximum Amount the MonetaryAccountJoint can be - 'in the red'. - :type _overdraft_limit: object_.Amount - :param _alias: The Aliases for the MonetaryAccountJoint. - :type _alias: list[object_.Pointer] - :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. - :type _avatar_uuid: str - :param _status: The status of the MonetaryAccountJoint. Can be: ACTIVE, - BLOCKED, CANCELLED or PENDING_REOPEN - :type _status: str - :param _sub_status: The sub-status of the MonetaryAccountJoint providing - extra information regarding the status. Will be NONE for ACTIVE or - PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and - REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. - :type _sub_status: str - :param _reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountJoint, can only be OTHER. - :type _reason: str - :param _reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountJoint. Can be any user provided - message. - :type _reason_description: str - :param _all_co_owner: The users the account will be joint with. - :type _all_co_owner: list[object_.CoOwner] - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountJoint. - :type _notification_filters: list[object_.NotificationFilter] - :param _setting: The settings of the MonetaryAccountJoint. - :type _setting: object_.MonetaryAccountSetting - :param _id_: The id of the MonetaryAccountJoint. + :param _payment_type: The payment type this requirement is for. + :type _payment_type: str + :param _legal_entity_type: The legal entity type of the beneficiary. + :type _legal_entity_type: str + :param _all_field: All fields that were required by CurrencyCloud. Obtained + through the CurrencyCloudBeneficiaryRequirement listing. + :type _all_field: list[str] + :param _id_: The id of the profile. :type _id_: int - :param _created: The timestamp of the MonetaryAccountJoint's creation. + :param _created: The timestamp of the beneficiaries creation. :type _created: str - :param _updated: The timestamp of the MonetaryAccountJoint's last update. + :param _updated: The timestamp of the beneficiaries last update. :type _updated: str - :param _avatar: The Avatar of the MonetaryAccountJoint. - :type _avatar: object_.Avatar - :param _daily_spent: Total Amount of money spent today. Timezone aware. - :type _daily_spent: object_.Amount - :param _balance: The current balance Amount of the MonetaryAccountJoint. - :type _balance: object_.Amount - :param _public_uuid: The MonetaryAccountJoint's public UUID. - :type _public_uuid: str - :param _user_id: The id of the User who owns the MonetaryAccountJoint. - :type _user_id: int - :param _monetary_account_profile: The profile of the account. - :type _monetary_account_profile: MonetaryAccountProfile + :param _account_number: The account number to display for the beneficiary. + :type _account_number: str + :param _external_identifier: The external identifier of the beneficiary. + :type _external_identifier: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account-joint" - _ENDPOINT_URL_READ = "user/{}/monetary-account-joint/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-joint/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account-joint" + _ENDPOINT_URL_CREATE = "user/{}/currency-cloud-beneficiary" + _ENDPOINT_URL_READ = "user/{}/currency-cloud-beneficiary/{}" + _ENDPOINT_URL_LISTING = "user/{}/currency-cloud-beneficiary" # Field constants. + FIELD_NAME = "name" + FIELD_COUNTRY = "country" FIELD_CURRENCY = "currency" - FIELD_DESCRIPTION = "description" - FIELD_DAILY_LIMIT = "daily_limit" - FIELD_OVERDRAFT_LIMIT = "overdraft_limit" - FIELD_ALIAS = "alias" - FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_REASON = "reason" - FIELD_REASON_DESCRIPTION = "reason_description" - FIELD_ALL_CO_OWNER = "all_co_owner" - FIELD_NOTIFICATION_FILTERS = "notification_filters" - FIELD_SETTING = "setting" + FIELD_PAYMENT_TYPE = "payment_type" + FIELD_LEGAL_ENTITY_TYPE = "legal_entity_type" + FIELD_ALL_FIELD = "all_field" # Object type. - _OBJECT_TYPE_GET = "MonetaryAccountJoint" + _OBJECT_TYPE_GET = "CurrencyCloudBeneficiary" _id_ = None _created = None _updated = None - _avatar = None + _name = None + _account_number = None _currency = None - _description = None - _daily_limit = None - _daily_spent = None - _overdraft_limit = None - _balance = None - _alias = None - _public_uuid = None - _status = None - _sub_status = None - _reason = None - _reason_description = None - _all_co_owner = None - _user_id = None - _monetary_account_profile = None - _notification_filters = None - _setting = None + _external_identifier = None + _name_field_for_request = None + _country_field_for_request = None _currency_field_for_request = None - _description_field_for_request = None - _daily_limit_field_for_request = None - _overdraft_limit_field_for_request = None - _alias_field_for_request = None - _avatar_uuid_field_for_request = None - _status_field_for_request = None - _sub_status_field_for_request = None - _reason_field_for_request = None - _reason_description_field_for_request = None - _all_co_owner_field_for_request = None - _notification_filters_field_for_request = None - _setting_field_for_request = None + _payment_type_field_for_request = None + _legal_entity_type_field_for_request = None + _all_field_field_for_request = None - def __init__(self, currency, all_co_owner, description=None, - daily_limit=None, overdraft_limit=None, alias=None, - avatar_uuid=None, status=None, sub_status=None, reason=None, - reason_description=None, notification_filters=None, - setting=None): + def __init__(self, name, country, currency, payment_type, legal_entity_type, all_field): """ - :param currency: The currency of the MonetaryAccountJoint as an ISO 4217 - formatted currency code. + :param name: The name of the beneficiary. + :type name: str + :param country: The country of the beneficiary. + :type country: str + :param currency: The currency of the beneficiary. :type currency: str - :param all_co_owner: The users the account will be joint with. - :type all_co_owner: list[object_.CoOwner] - :param description: The description of the MonetaryAccountJoint. Defaults to - 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the - MonetaryAccountJoint's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param overdraft_limit: The maximum Amount the MonetaryAccountJoint can be - 'in the red'. Must be 0 EUR or omitted. - :type overdraft_limit: object_.Amount - :param alias: The Aliases to add to MonetaryAccountJoint. Must all be - confirmed first. Can mostly be ignored. - :type alias: list[object_.Pointer] - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountJoint. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT - requests to cancel (close) or reopen the MonetaryAccountJoint. When updating - the status and/or sub_status no other fields can be updated in the same - request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountJoint providing - extra information regarding the status. Should be ignored for POST requests. - In case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. - When updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountJoint, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountJoint. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountJoint. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountJoint. - :type setting: object_.MonetaryAccountSetting + :param payment_type: The payment type this requirement is for. + :type payment_type: str + :param legal_entity_type: The legal entity type of the beneficiary. + :type legal_entity_type: str + :param all_field: All fields that were required by CurrencyCloud. Obtained + through the CurrencyCloudBeneficiaryRequirement listing. + :type all_field: list[str] """ + self._name_field_for_request = name + self._country_field_for_request = country self._currency_field_for_request = currency - self._all_co_owner_field_for_request = all_co_owner - self._description_field_for_request = description - self._daily_limit_field_for_request = daily_limit - self._overdraft_limit_field_for_request = overdraft_limit - self._alias_field_for_request = alias - self._avatar_uuid_field_for_request = avatar_uuid - self._status_field_for_request = status - self._sub_status_field_for_request = sub_status - self._reason_field_for_request = reason - self._reason_description_field_for_request = reason_description - self._notification_filters_field_for_request = notification_filters - self._setting_field_for_request = setting + self._payment_type_field_for_request = payment_type + self._legal_entity_type_field_for_request = legal_entity_type + self._all_field_field_for_request = all_field @classmethod - def create(cls, currency, all_co_owner, description=None, daily_limit=None, - overdraft_limit=None, alias=None, avatar_uuid=None, status=None, - sub_status=None, reason=None, reason_description=None, - notification_filters=None, setting=None, custom_headers=None): + def create(cls,name, country, currency, payment_type, legal_entity_type, all_field, custom_headers=None): """ :type user_id: int - :param currency: The currency of the MonetaryAccountJoint as an ISO 4217 - formatted currency code. + :param name: The name of the beneficiary. + :type name: str + :param country: The country of the beneficiary. + :type country: str + :param currency: The currency of the beneficiary. :type currency: str - :param all_co_owner: The users the account will be joint with. - :type all_co_owner: list[object_.CoOwner] - :param description: The description of the MonetaryAccountJoint. - Defaults to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the - MonetaryAccountJoint's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param overdraft_limit: The maximum Amount the MonetaryAccountJoint can - be 'in the red'. Must be 0 EUR or omitted. - :type overdraft_limit: object_.Amount - :param alias: The Aliases to add to MonetaryAccountJoint. Must all be - confirmed first. Can mostly be ignored. - :type alias: list[object_.Pointer] - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountJoint. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountJoint. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountJoint providing - extra information regarding the status. Should be ignored for POST - requests. In case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be - NONE. When updating the status and/or sub_status no other fields can be - updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountJoint, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountJoint. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountJoint. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountJoint. - :type setting: object_.MonetaryAccountSetting + :param payment_type: The payment type this requirement is for. + :type payment_type: str + :param legal_entity_type: The legal entity type of the beneficiary. + :type legal_entity_type: str + :param all_field: All fields that were required by CurrencyCloud. + Obtained through the CurrencyCloudBeneficiaryRequirement listing. + :type all_field: list[str] :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -10988,133 +10312,47 @@ def create(cls, currency, all_co_owner, description=None, daily_limit=None, custom_headers = {} request_map = { - cls.FIELD_CURRENCY: currency, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_OVERDRAFT_LIMIT: overdraft_limit, - cls.FIELD_ALIAS: alias, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_ALL_CO_OWNER: all_co_owner, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } +cls.FIELD_NAME : name, +cls.FIELD_COUNTRY : country, +cls.FIELD_CURRENCY : currency, +cls.FIELD_PAYMENT_TYPE : payment_type, +cls.FIELD_LEGAL_ENTITY_TYPE : legal_entity_type, +cls.FIELD_ALL_FIELD : all_field +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, monetary_account_joint_id, custom_headers=None): + def get(cls, currency_cloud_beneficiary_id, custom_headers=None): """ - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int - :type monetary_account_joint_id: int + :type currency_cloud_beneficiary_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMonetaryAccountJoint + :rtype: BunqResponseCurrencyCloudBeneficiary """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - monetary_account_joint_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), currency_cloud_beneficiary_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseMonetaryAccountJoint.cast_from_bunq_response( + return BunqResponseCurrencyCloudBeneficiary.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def update(cls, monetary_account_joint_id, description=None, - daily_limit=None, avatar_uuid=None, status=None, sub_status=None, - reason=None, reason_description=None, notification_filters=None, - setting=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_joint_id: int - :param description: The description of the MonetaryAccountJoint. - Defaults to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the - MonetaryAccountJoint's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountJoint. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountJoint. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type status: str - :param sub_status: The sub-status of the MonetaryAccountJoint providing - extra information regarding the status. Should be ignored for POST - requests. In case of PUT requests with status CANCELLED it can only be - REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be - NONE. When updating the status and/or sub_status no other fields can be - updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountJoint, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountJoint. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountJoint. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountJoint. - :type setting: object_.MonetaryAccountSetting - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - monetary_account_joint_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - @classmethod def list(cls, params=None, custom_headers=None): """ @@ -11122,7 +10360,7 @@ def list(cls, params=None, custom_headers=None): :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMonetaryAccountJointList + :rtype: BunqResponseCurrencyCloudBeneficiaryList """ if params is None: @@ -11131,12 +10369,11 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseMonetaryAccountJointList.cast_from_bunq_response( + return BunqResponseCurrencyCloudBeneficiaryList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @@ -11165,215 +10402,148 @@ def updated(self): return self._updated @property - def avatar(self): + def name(self): """ - :rtype: object_.Avatar + :rtype: str """ - return self._avatar + return self._name @property - def currency(self): + def account_number(self): """ :rtype: str """ - return self._currency + return self._account_number @property - def description(self): + def currency(self): """ :rtype: str """ - return self._description + return self._currency @property - def daily_limit(self): + def external_identifier(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_limit + return self._external_identifier - @property - def daily_spent(self): + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._daily_spent + if self._id_ is not None: + return False - @property - def overdraft_limit(self): - """ - :rtype: object_.Amount - """ + if self._created is not None: + return False - return self._overdraft_limit + if self._updated is not None: + return False - @property - def balance(self): - """ - :rtype: object_.Amount - """ + if self._name is not None: + return False - return self._balance + if self._account_number is not None: + return False - @property - def alias(self): - """ - :rtype: list[object_.Pointer] - """ + if self._currency is not None: + return False - return self._alias + if self._external_identifier is not None: + return False - @property - def public_uuid(self): + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: CurrencyCloudBeneficiaryApiObject """ - return self._public_uuid + return converter.json_to_class(CurrencyCloudBeneficiaryApiObject, json_str) - @property - def status(self): - """ - :rtype: str - """ - return self._status +class CurrencyCloudPaymentQuoteApiObject(BunqModel): + """ + Endpoint for managing currency conversions. + + :param _pointers: The points we want to know the fees for. + :type _pointers: list[object_.Pointer] + :param _amount_fee: The amount that we'll charge the user with. + :type _amount_fee: object_.Amount + """ - @property - def sub_status(self): - """ - :rtype: str - """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/currency-cloud-payment-quote" - return self._sub_status + # Field constants. + FIELD_POINTERS = "pointers" - @property - def reason(self): - """ - :rtype: str - """ - return self._reason + _amount_fee = None + _pointers_field_for_request = None - @property - def reason_description(self): + def __init__(self, pointers): """ - :rtype: str + :param pointers: The points we want to know the fees for. + :type pointers: list[object_.Pointer] """ - return self._reason_description + self._pointers_field_for_request = pointers - @property - def all_co_owner(self): + @classmethod + def create(cls,pointers, monetary_account_id=None, custom_headers=None): """ - :rtype: list[object_.CoOwner] + :type user_id: int + :type monetary_account_id: int + :param pointers: The points we want to know the fees for. + :type pointers: list[object_.Pointer] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._all_co_owner + if custom_headers is None: + custom_headers = {} - @property - def user_id(self): - """ - :rtype: int - """ + request_map = { +cls.FIELD_POINTERS : pointers +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - return self._user_id + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) @property - def monetary_account_profile(self): + def amount_fee(self): """ - :rtype: MonetaryAccountProfile + :rtype: object_.Amount """ - return self._monetary_account_profile - - @property - def notification_filters(self): - """ - :rtype: list[object_.NotificationFilter] - """ - - return self._notification_filters - - @property - def setting(self): - """ - :rtype: object_.MonetaryAccountSetting - """ - - return self._setting + return self._amount_fee def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._avatar is not None: - return False - - if self._currency is not None: - return False - - if self._description is not None: - return False - - if self._daily_limit is not None: - return False - - if self._daily_spent is not None: - return False - - if self._overdraft_limit is not None: - return False - - if self._balance is not None: - return False - - if self._alias is not None: - return False - - if self._public_uuid is not None: - return False - - if self._status is not None: - return False - - if self._sub_status is not None: - return False - - if self._reason is not None: - return False - - if self._reason_description is not None: - return False - - if self._all_co_owner is not None: - return False - - if self._user_id is not None: - return False - - if self._monetary_account_profile is not None: - return False - - if self._notification_filters is not None: - return False - - if self._setting is not None: + if self._amount_fee is not None: return False return True @@ -11383,247 +10553,120 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountJoint + :rtype: CurrencyCloudPaymentQuoteApiObject """ - return converter.json_to_class(MonetaryAccountJoint, json_str) + return converter.json_to_class(CurrencyCloudPaymentQuoteApiObject, json_str) -class MonetaryAccountLight(core.BunqModel): +class CurrencyConversionQuoteApiObject(BunqModel): """ - With MonetaryAccountLight is a monetary account for bunq light users. - Through this endpoint you can retrieve information regarding your existing - MonetaryAccountLights and update specific fields of an existing - MonetaryAccountLight. Examples of fields that can be updated are the - description, the daily limit and the avatar of the account. + Endpoint to create a quote for currency conversions. - :param _currency: The currency of the MonetaryAccountLight as an ISO 4217 - formatted currency code. - :type _currency: str - :param _description: The description of the MonetaryAccountLight. Defaults - to 'bunq account'. - :type _description: str - :param _daily_limit: The daily spending limit Amount of the - MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the - MonetaryAccountLight's currency. Limited to 10000 EUR. - :type _daily_limit: object_.Amount - :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. - :type _avatar_uuid: str - :param _status: The status of the MonetaryAccountLight. Can be: ACTIVE, - BLOCKED, CANCELLED or PENDING_REOPEN + :param _amount: The amount to convert. + :type _amount: object_.Amount + :param _currency_source: The currency we are converting. + :type _currency_source: str + :param _currency_target: The currency we are converting towards. + :type _currency_target: str + :param _order_type: The type of the quote, SELL or BUY. + :type _order_type: str + :param _counterparty_alias: The Alias of the party we are transferring the + money to. + :type _counterparty_alias: object_.Pointer + :param _status: The status of the quote. :type _status: str - :param _sub_status: The sub-status of the MonetaryAccountLight providing - extra information regarding the status. Will be NONE for ACTIVE or - PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and - REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. - :type _sub_status: str - :param _reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. - :type _reason: str - :param _reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. - :type _reason_description: str - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountLight. - :type _notification_filters: list[object_.NotificationFilter] - :param _setting: The settings of the MonetaryAccountLight. - :type _setting: object_.MonetaryAccountSetting - :param _id_: The id of the MonetaryAccountLight. + :param _id_: The id of the quote. :type _id_: int - :param _created: The timestamp of the MonetaryAccountLight's creation. + :param _created: The timestamp of the quote's creation. :type _created: str - :param _updated: The timestamp of the MonetaryAccountLight's last update. + :param _updated: The timestamp of the quote's last update. :type _updated: str - :param _avatar: The Avatar of the MonetaryAccountLight. - :type _avatar: object_.Avatar - :param _daily_spent: Total Amount of money spent today. Timezone aware. - :type _daily_spent: object_.Amount - :param _balance: The current balance Amount of the MonetaryAccountLight. - :type _balance: object_.Amount - :param _alias: The Aliases for the MonetaryAccountLight. - :type _alias: list[object_.Pointer] - :param _public_uuid: The MonetaryAccountLight's public UUID. - :type _public_uuid: str - :param _user_id: The id of the User who owns the MonetaryAccountLight. - :type _user_id: int - :param _balance_maximum: The maximum balance Amount of the - MonetaryAccountLight. - :type _balance_maximum: object_.Amount - :param _budget_month_used: The amount of the monthly budget used. - :type _budget_month_used: object_.Amount - :param _budget_month_maximum: The total amount of the monthly budget. - :type _budget_month_maximum: object_.Amount - :param _budget_year_used: The amount of the yearly budget used. - :type _budget_year_used: object_.Amount - :param _budget_year_maximum: The total amount of the yearly budget. - :type _budget_year_maximum: object_.Amount - :param _budget_withdrawal_year_used: The amount of the yearly withdrawal - budget used. - :type _budget_withdrawal_year_used: object_.Amount - :param _budget_withdrawal_year_maximum: The total amount of the yearly - withdrawal budget. - :type _budget_withdrawal_year_maximum: object_.Amount + :param _amount_source: The amount to convert. + :type _amount_source: object_.Amount + :param _amount_target: The amount to convert to. + :type _amount_target: object_.Amount + :param _rate: The conversion rate. + :type _rate: str + :param _time_expiry: Timestamp for when this quote expires and the user + should request a new one. + :type _time_expiry: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account-light" - _ENDPOINT_URL_READ = "user/{}/monetary-account-light/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-light/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account-light" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/currency-conversion-quote" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/currency-conversion-quote/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/currency-conversion-quote/{}" # Field constants. - FIELD_CURRENCY = "currency" - FIELD_DESCRIPTION = "description" - FIELD_DAILY_LIMIT = "daily_limit" - FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_AMOUNT = "amount" + FIELD_CURRENCY_SOURCE = "currency_source" + FIELD_CURRENCY_TARGET = "currency_target" + FIELD_ORDER_TYPE = "order_type" + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_REASON = "reason" - FIELD_REASON_DESCRIPTION = "reason_description" - FIELD_NOTIFICATION_FILTERS = "notification_filters" - FIELD_SETTING = "setting" # Object type. - _OBJECT_TYPE_GET = "MonetaryAccountLight" + _OBJECT_TYPE_GET = "CurrencyConversionQuote" + _OBJECT_TYPE_PUT = "" _id_ = None _created = None _updated = None - _avatar = None - _currency = None - _description = None - _daily_limit = None - _daily_spent = None - _balance = None - _alias = None - _public_uuid = None _status = None - _sub_status = None - _reason = None - _reason_description = None - _user_id = None - _balance_maximum = None - _budget_month_used = None - _budget_month_maximum = None - _budget_year_used = None - _budget_year_maximum = None - _budget_withdrawal_year_used = None - _budget_withdrawal_year_maximum = None - _notification_filters = None - _setting = None - _currency_field_for_request = None - _description_field_for_request = None - _daily_limit_field_for_request = None - _avatar_uuid_field_for_request = None + _amount_source = None + _amount_target = None + _rate = None + _time_expiry = None + _amount_field_for_request = None + _currency_source_field_for_request = None + _currency_target_field_for_request = None + _order_type_field_for_request = None + _counterparty_alias_field_for_request = None _status_field_for_request = None - _sub_status_field_for_request = None - _reason_field_for_request = None - _reason_description_field_for_request = None - _notification_filters_field_for_request = None - _setting_field_for_request = None - def __init__(self, currency, description=None, daily_limit=None, - avatar_uuid=None, status=None, sub_status=None, reason=None, - reason_description=None, notification_filters=None, - setting=None): + def __init__(self, amount, currency_source, currency_target, order_type, counterparty_alias, status=None): """ - :param currency: The currency of the MonetaryAccountLight as an ISO 4217 - formatted currency code. - :type currency: str - :param description: The description of the MonetaryAccountLight. Defaults to - 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the - MonetaryAccountLight's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountLight. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT - requests to cancel (close) or reopen the MonetaryAccountLight. When updating - the status and/or sub_status no other fields can be updated in the same - request (and vice versa). + :param amount: The amount to convert. + :type amount: object_.Amount + :param currency_source: The currency we are converting. + :type currency_source: str + :param currency_target: The currency we are converting towards. + :type currency_target: str + :param order_type: The type of the quote, SELL or BUY. + :type order_type: str + :param counterparty_alias: The Alias of the party we are transferring the + money to. + :type counterparty_alias: object_.Pointer + :param status: The status of the quote. :type status: str - :param sub_status: The sub-status of the MonetaryAccountLight providing - extra information regarding the status. Should be ignored for POST requests - and can only be REDEMPTION_VOLUNTARY for PUT requests with status CANCELLED. - When updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if updating - the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this MonetaryAccountLight. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountLight. - :type setting: object_.MonetaryAccountSetting """ - self._currency_field_for_request = currency - self._description_field_for_request = description - self._daily_limit_field_for_request = daily_limit - self._avatar_uuid_field_for_request = avatar_uuid + self._amount_field_for_request = amount + self._currency_source_field_for_request = currency_source + self._currency_target_field_for_request = currency_target + self._order_type_field_for_request = order_type + self._counterparty_alias_field_for_request = counterparty_alias self._status_field_for_request = status - self._sub_status_field_for_request = sub_status - self._reason_field_for_request = reason - self._reason_description_field_for_request = reason_description - self._notification_filters_field_for_request = notification_filters - self._setting_field_for_request = setting @classmethod - def create(cls, currency, description=None, daily_limit=None, - avatar_uuid=None, status=None, sub_status=None, reason=None, - reason_description=None, notification_filters=None, setting=None, - custom_headers=None): + def create(cls,amount, currency_source, currency_target, order_type, counterparty_alias, monetary_account_id=None, status=None, custom_headers=None): """ - Create new MonetaryAccountLight. - :type user_id: int - :param currency: The currency of the MonetaryAccountLight as an ISO 4217 - formatted currency code. - :type currency: str - :param description: The description of the MonetaryAccountLight. - Defaults to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the - MonetaryAccountLight's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountLight. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountLight. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). + :type monetary_account_id: int + :param amount: The amount to convert. + :type amount: object_.Amount + :param currency_source: The currency we are converting. + :type currency_source: str + :param currency_target: The currency we are converting towards. + :type currency_target: str + :param order_type: The type of the quote, SELL or BUY. + :type order_type: str + :param counterparty_alias: The Alias of the party we are transferring + the money to. + :type counterparty_alias: object_.Pointer + :param status: The status of the quote. :type status: str - :param sub_status: The sub-status of the MonetaryAccountLight providing - extra information regarding the status. Should be ignored for POST - requests and can only be REDEMPTION_VOLUNTARY for PUT requests with - status CANCELLED. When updating the status and/or sub_status no other - fields can be updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountLight. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountLight. - :type setting: object_.MonetaryAccountSetting :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -11633,158 +10676,78 @@ def create(cls, currency, description=None, daily_limit=None, custom_headers = {} request_map = { - cls.FIELD_CURRENCY: currency, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } +cls.FIELD_AMOUNT : amount, +cls.FIELD_CURRENCY_SOURCE : currency_source, +cls.FIELD_CURRENCY_TARGET : currency_target, +cls.FIELD_ORDER_TYPE : order_type, +cls.FIELD_COUNTERPARTY_ALIAS : counterparty_alias, +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, monetary_account_light_id, custom_headers=None): + def get(cls, currency_conversion_quote_id, monetary_account_id=None, custom_headers=None): """ - Get a specific MonetaryAccountLight. - - :type api_context: context.ApiContext + :type api_context: ApiContext :type user_id: int - :type monetary_account_light_id: int + :type monetary_account_id: int + :type currency_conversion_quote_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMonetaryAccountLight + :rtype: BunqResponseCurrencyConversionQuote """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - monetary_account_light_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), currency_conversion_quote_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseMonetaryAccountLight.cast_from_bunq_response( + return BunqResponseCurrencyConversionQuote.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, monetary_account_light_id, description=None, - daily_limit=None, avatar_uuid=None, status=None, sub_status=None, - reason=None, reason_description=None, notification_filters=None, - setting=None, custom_headers=None): + def update(cls, currency_conversion_quote_id, monetary_account_id=None, status=None, custom_headers=None): """ - Update a specific existing MonetaryAccountLight. - :type user_id: int - :type monetary_account_light_id: int - :param description: The description of the MonetaryAccountLight. - Defaults to 'bunq account'. - :type description: str - :param daily_limit: The daily spending limit Amount of the - MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the - MonetaryAccountLight's currency. Limited to 10000 EUR. - :type daily_limit: object_.Amount - :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. - :type avatar_uuid: str - :param status: The status of the MonetaryAccountLight. Ignored in POST - requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in - PUT requests to cancel (close) or reopen the MonetaryAccountLight. When - updating the status and/or sub_status no other fields can be updated in - the same request (and vice versa). + :type monetary_account_id: int + :type currency_conversion_quote_id: int + :param status: The status of the quote. :type status: str - :param sub_status: The sub-status of the MonetaryAccountLight providing - extra information regarding the status. Should be ignored for POST - requests and can only be REDEMPTION_VOLUNTARY for PUT requests with - status CANCELLED. When updating the status and/or sub_status no other - fields can be updated in the same request (and vice versa). - :type sub_status: str - :param reason: The reason for voluntarily cancelling (closing) the - MonetaryAccountBank, can only be OTHER. Should only be specified if - updating the status to CANCELLED. - :type reason: str - :param reason_description: The optional free-form reason for voluntarily - cancelling (closing) the MonetaryAccountBank. Can be any user provided - message. Should only be specified if updating the status to CANCELLED. - :type reason_description: str - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this MonetaryAccountLight. - :type notification_filters: list[object_.NotificationFilter] - :param setting: The settings of the MonetaryAccountLight. - :type setting: object_.MonetaryAccountSetting :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseCurrencyConversionQuote """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_DAILY_LIMIT: daily_limit, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_REASON: reason, - cls.FIELD_REASON_DESCRIPTION: reason_description, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters, - cls.FIELD_SETTING: setting - } +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - monetary_account_light_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def list(cls, params=None, custom_headers=None): - """ - Gets a listing of all MonetaryAccountLights of a given user. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseMonetaryAccountLightList - """ - - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), currency_conversion_quote_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseMonetaryAccountLightList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseCurrencyConversionQuote.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) ) @property @@ -11812,180 +10775,304 @@ def updated(self): return self._updated @property - def avatar(self): + def status(self): """ - :rtype: object_.Avatar + :rtype: str """ - return self._avatar + return self._status @property - def currency(self): + def amount_source(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._currency + return self._amount_source @property - def description(self): + def amount_target(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._description + return self._amount_target @property - def daily_limit(self): + def rate(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_limit + return self._rate @property - def daily_spent(self): + def time_expiry(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_spent + return self._time_expiry - @property - def balance(self): + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._balance + if self._id_ is not None: + return False - @property - def alias(self): + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._status is not None: + return False + + if self._amount_source is not None: + return False + + if self._amount_target is not None: + return False + + if self._rate is not None: + return False + + if self._time_expiry is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: list[object_.Pointer] + :type json_str: str + + :rtype: CurrencyConversionQuoteApiObject """ - return self._alias + return converter.json_to_class(CurrencyConversionQuoteApiObject, json_str) - @property - def public_uuid(self): + +class CurrencyConversionApiObject(BunqModel): + """ + Endpoint for managing currency conversions. + + :param _id_: The id of the conversion. + :type _id_: int + :param _created: The timestamp of the conversion's creation. + :type _created: str + :param _updated: The timestamp of the conversion's last update. + :type _updated: str + :param _status: The status of the conversion. + :type _status: str + :param _date_delivery_expected: The expected delivery date of the + conversion. + :type _date_delivery_expected: str + :param _rate: The rate of the conversion. + :type _rate: str + :param _amount: The amount of the conversion. + :type _amount: object_.Amount + :param _counter_amount: The amount of the counter conversion. + :type _counter_amount: object_.Amount + :param _group_uuid: The group uuid of the conversion. + :type _group_uuid: str + :param _type_: The type of this conversion. + :type _type_: str + :param _order_type: The order type, buying or selling. + :type _order_type: str + :param _label_monetary_account: The label of the monetary account. + :type _label_monetary_account: object_.MonetaryAccountReference + :param _counter_label_monetary_account: The label of the counter monetary + account. + :type _counter_label_monetary_account: object_.MonetaryAccountReference + :param _payment: The payment associated with this conversion. + :type _payment: Payment + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/currency-conversion" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/currency-conversion/{}" + + # Object type. + _OBJECT_TYPE_GET = "CurrencyConversion" + + _id_ = None + _created = None + _updated = None + _status = None + _date_delivery_expected = None + _rate = None + _amount = None + _counter_amount = None + _group_uuid = None + _type_ = None + _order_type = None + _label_monetary_account = None + _counter_label_monetary_account = None + _payment = None + + @classmethod + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :type monetary_account_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCurrencyConversionList """ - return self._public_uuid + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseCurrencyConversionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, currency_conversion_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type currency_conversion_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseCurrencyConversion + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), currency_conversion_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseCurrencyConversion.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def status(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._status + return self._id_ @property - def sub_status(self): + def created(self): """ :rtype: str """ - return self._sub_status + return self._created @property - def reason(self): + def updated(self): """ :rtype: str """ - return self._reason + return self._updated @property - def reason_description(self): + def status(self): """ :rtype: str """ - return self._reason_description + return self._status @property - def user_id(self): + def date_delivery_expected(self): """ - :rtype: int + :rtype: str """ - return self._user_id + return self._date_delivery_expected @property - def balance_maximum(self): + def rate(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._balance_maximum + return self._rate @property - def budget_month_used(self): + def amount(self): """ :rtype: object_.Amount """ - return self._budget_month_used + return self._amount @property - def budget_month_maximum(self): + def counter_amount(self): """ :rtype: object_.Amount """ - return self._budget_month_maximum + return self._counter_amount @property - def budget_year_used(self): + def group_uuid(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._budget_year_used + return self._group_uuid @property - def budget_year_maximum(self): + def type_(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._budget_year_maximum + return self._type_ @property - def budget_withdrawal_year_used(self): + def order_type(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._budget_withdrawal_year_used + return self._order_type @property - def budget_withdrawal_year_maximum(self): + def label_monetary_account(self): """ - :rtype: object_.Amount + :rtype: object_.MonetaryAccountReference """ - return self._budget_withdrawal_year_maximum + return self._label_monetary_account @property - def notification_filters(self): + def counter_label_monetary_account(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: object_.MonetaryAccountReference """ - return self._notification_filters + return self._counter_label_monetary_account @property - def setting(self): + def payment(self): """ - :rtype: object_.MonetaryAccountSetting + :rtype: Payment """ - return self._setting + return self._payment def is_all_field_none(self): """ @@ -12001,70 +11088,37 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._avatar is not None: + if self._status is not None: return False - if self._currency is not None: + if self._date_delivery_expected is not None: return False - if self._description is not None: + if self._rate is not None: return False - if self._daily_limit is not None: + if self._amount is not None: return False - if self._daily_spent is not None: + if self._counter_amount is not None: return False - if self._balance is not None: + if self._group_uuid is not None: return False - if self._alias is not None: + if self._type_ is not None: return False - if self._public_uuid is not None: + if self._order_type is not None: return False - if self._status is not None: + if self._label_monetary_account is not None: return False - if self._sub_status is not None: + if self._counter_label_monetary_account is not None: return False - if self._reason is not None: - return False - - if self._reason_description is not None: - return False - - if self._user_id is not None: - return False - - if self._balance_maximum is not None: - return False - - if self._budget_month_used is not None: - return False - - if self._budget_month_maximum is not None: - return False - - if self._budget_year_used is not None: - return False - - if self._budget_year_maximum is not None: - return False - - if self._budget_withdrawal_year_used is not None: - return False - - if self._budget_withdrawal_year_maximum is not None: - return False - - if self._notification_filters is not None: - return False - - if self._setting is not None: + if self._payment is not None: return False return True @@ -12074,120 +11128,97 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountLight + :rtype: CurrencyConversionApiObject """ - return converter.json_to_class(MonetaryAccountLight, json_str) + return converter.json_to_class(CurrencyConversionApiObject, json_str) -class NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment(core.BunqModel): +class DeviceServerApiObject(BunqModel): """ - Used to manage attachment notes. + After having created an Installation you can now create a DeviceServer. A + DeviceServer is needed to do a login call with session-server. - :param _description: Optional description of the attachment. + :param _description: The description of the DeviceServer. :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + :param _secret: The API key. You can request an API key in the bunq app. + :type _secret: str + :param _permitted_ips: An array of IPs (v4 or v6) this DeviceServer will be + able to do calls from. These will be linked to the API key. + :type _permitted_ips: list[str] + :param _id_: The id of the DeviceServer as created on the server. :type _id_: int - :param _created: The timestamp of the note's creation. + :param _created: The timestamp of the DeviceServer's creation. :type _created: str - :param _updated: The timestamp of the note's last update. + :param _updated: The timestamp of the DeviceServer's last update. :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _ip: The ip address which was used to create the DeviceServer. + :type _ip: str + :param _status: The status of the DeviceServer. Can be ACTIVE, BLOCKED, + NEEDS_CONFIRMATION or OBSOLETE. + :type _status: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" + _ENDPOINT_URL_CREATE = "device-server" + _ENDPOINT_URL_READ = "device-server/{}" + _ENDPOINT_URL_LISTING = "device-server" # Field constants. FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_SECRET = "secret" + FIELD_PERMITTED_IPS = "permitted_ips" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + _OBJECT_TYPE_GET = "DeviceServer" _id_ = None _created = None _updated = None - _label_user_creator = None _description = None - _attachment = None + _ip = None + _status = None _description_field_for_request = None - _attachment_id_field_for_request = None + _secret_field_for_request = None + _permitted_ips_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, description, secret, permitted_ips=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. + :param description: The description of the DeviceServer. This is only for + your own reference when reading the DeviceServer again. :type description: str + :param secret: The API key. You can request an API key in the bunq app. + :type secret: str + :param permitted_ips: An array of IPs (v4 or v6) this DeviceServer will be + able to do calls from. These will be linked to the API key. + :type permitted_ips: list[str] """ - self._attachment_id_field_for_request = attachment_id self._description_field_for_request = description + self._secret_field_for_request = secret + self._permitted_ips_field_for_request = permitted_ips @classmethod - def create(cls, switch_service_payment_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def create(cls,description, secret, permitted_ips=None, custom_headers=None): """ - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None + Create a new DeviceServer providing the installation token in the header + and signing the request with the private part of the key you used to + create the installation. The API Key that you are using will be bound to + the IP address of the DeviceServer which you have + created.

Using a Wildcard API Key gives you the freedom to make + API calls even if the IP address has changed after the POST + device-server.

Find out more at this link https://bunq.com/en/apikey-dynamic-ip. - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def update(cls, switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int - :type - note_attachment_bank_switch_service_netherlands_incoming_payment_id: int - :param description: Optional description of the attachment. + :param description: The description of the DeviceServer. This is only + for your own reference when reading the DeviceServer again. :type description: str + :param secret: The API key. You can request an API key in the bunq app. + :type secret: str + :param permitted_ips: An array of IPs (v4 or v6) this DeviceServer will + be able to do calls from. These will be linked to the API key. + :type permitted_ips: list[str] :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -12196,71 +11227,55 @@ def update(cls, switch_service_payment_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_DESCRIPTION : description, +cls.FIELD_SECRET : secret, +cls.FIELD_PERMITTED_IPS : permitted_ips +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, custom_headers=None): + def get(cls, device_server_id, custom_headers=None): """ - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int - :type - note_attachment_bank_switch_service_netherlands_incoming_payment_id: int + Get one of your DeviceServers. + + :type api_context: ApiContext + :type device_server_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseDeviceServer """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(device_server_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseDeviceServer.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, switch_service_payment_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get a collection of all the DeviceServers you have created. - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: - BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList + :rtype: BunqResponseDeviceServerList """ if params is None: @@ -12269,49 +11284,14 @@ def list(cls, switch_service_payment_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - switch_service_payment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList.cast_from_bunq_response( + return BunqResponseDeviceServerList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int - :type - note_attachment_bank_switch_service_netherlands_incoming_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: - BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_attachment_bank_switch_service_netherlands_incoming_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -12337,28 +11317,28 @@ def updated(self): return self._updated @property - def label_user_creator(self): + def description(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._description @property - def description(self): + def ip(self): """ :rtype: str """ - return self._description + return self._ip @property - def attachment(self): + def status(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._status def is_all_field_none(self): """ @@ -12374,13 +11354,13 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._description is not None: return False - if self._description is not None: + if self._ip is not None: return False - if self._attachment is not None: + if self._status is not None: return False return True @@ -12390,66 +11370,240 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment + :rtype: DeviceServerApiObject """ - return converter.json_to_class( - NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment, json_str) + return converter.json_to_class(DeviceServerApiObject, json_str) -class NoteTextBankSwitchServiceNetherlandsIncomingPayment(core.BunqModel): +class DeviceApiObject(BunqModel, AnchorObjectInterface): """ - Used to manage text notes. + Used to get a Device or a listing of Devices. Creating a DeviceServer should + happen via /device-server - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. + :param _DeviceServer: + :type _DeviceServer: DeviceServer + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + # Endpoint constants. + _ENDPOINT_URL_READ = "device/{}" + _ENDPOINT_URL_LISTING = "device" + + # Object type. + _OBJECT_TYPE_GET = "Device" + + _DeviceServer = None + + @classmethod + def get(cls, device_id, custom_headers=None): + """ + Get a single Device. A Device is either a DevicePhone or a DeviceServer. + + :type api_context: ApiContext + :type device_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseDevice + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(device_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseDevice.cast_from_bunq_response( + cls._from_json(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Get a collection of Devices. A Device is either a DevicePhone or a + DeviceServer. + + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseDeviceList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseDeviceList.cast_from_bunq_response( + cls._from_json_list(response_raw) + ) + + @property + def DeviceServer(self): + """ + :rtype: DeviceServer + """ + + return self._DeviceServer + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._DeviceServer is not None: + return self._DeviceServer + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._DeviceServer is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: DeviceApiObject + """ + + return converter.json_to_class(DeviceApiObject, json_str) + + +class DraftPaymentApiObject(BunqModel): + """ + A DraftPayment is like a regular Payment, but it needs to be accepted by the + sending party before the actual Payment is done. + + :param _status: The status of the DraftPayment. + :type _status: str + :param _entries: The entries in the DraftPayment. + :type _entries: list[object_.DraftPaymentEntry] + :param _previous_updated_timestamp: The last updated_timestamp that you + received for this DraftPayment. This needs to be provided to prevent race + conditions. + :type _previous_updated_timestamp: str + :param _number_of_required_accepts: The number of accepts that are required + for the draft payment to receive status ACCEPTED. Currently only 1 is valid. + :type _number_of_required_accepts: int + :param _schedule: The schedule details. + :type _schedule: Schedule + :param _id_: The id of the created DrafPayment. :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _monetary_account_id: The id of the MonetaryAccount the DraftPayment + applies to. + :type _monetary_account_id: int + :param _user_alias_created: The label of the User who created the + DraftPayment. + :type _user_alias_created: object_.LabelUser + :param _responses: All responses to this draft payment. + :type _responses: list[object_.DraftPaymentResponse] + :param _type_: The type of the DraftPayment. + :type _type_: str + :param _object_: The Payment or PaymentBatch. This will only be present + after the DraftPayment has been accepted. + :type _object_: object_.DraftPaymentAnchorObject + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}" # Field constants. - FIELD_CONTENT = "content" + FIELD_STATUS = "status" + FIELD_ENTRIES = "entries" + FIELD_PREVIOUS_UPDATED_TIMESTAMP = "previous_updated_timestamp" + FIELD_NUMBER_OF_REQUIRED_ACCEPTS = "number_of_required_accepts" + FIELD_SCHEDULE = "schedule" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "DraftPayment" _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _monetary_account_id = None + _user_alias_created = None + _responses = None + _status = None + _type_ = None + _entries = None + _object_ = None + _request_reference_split_the_bill = None + _schedule = None + _status_field_for_request = None + _entries_field_for_request = None + _previous_updated_timestamp_field_for_request = None + _number_of_required_accepts_field_for_request = None + _schedule_field_for_request = None - def __init__(self, content=None): + def __init__(self, entries, number_of_required_accepts, status=None, previous_updated_timestamp=None, schedule=None): """ - :param content: The content of the note. - :type content: str + :param entries: The list of entries in the DraftPayment. Each entry will + result in a payment when the DraftPayment is accepted. + :type entries: list[object_.DraftPaymentEntry] + :param number_of_required_accepts: The number of accepts that are required + for the draft payment to receive status ACCEPTED. Currently only 1 is valid. + :type number_of_required_accepts: int + :param status: The status of the DraftPayment. + :type status: str + :param previous_updated_timestamp: The last updated_timestamp that you + received for this DraftPayment. This needs to be provided to prevent race + conditions. + :type previous_updated_timestamp: str + :param schedule: The schedule details when creating or updating a scheduled + payment. + :type schedule: Schedule """ - self._content_field_for_request = content + self._entries_field_for_request = entries + self._number_of_required_accepts_field_for_request = number_of_required_accepts + self._status_field_for_request = status + self._previous_updated_timestamp_field_for_request = previous_updated_timestamp + self._schedule_field_for_request = schedule @classmethod - def create(cls, switch_service_payment_id, monetary_account_id=None, - content=None, custom_headers=None): + def create(cls,entries, number_of_required_accepts, monetary_account_id=None, status=None, previous_updated_timestamp=None, schedule=None, custom_headers=None): """ + Create a new DraftPayment. + :type user_id: int :type monetary_account_id: int - :type switch_service_payment_id: int - :param content: The content of the note. - :type content: str + :param entries: The list of entries in the DraftPayment. Each entry will + result in a payment when the DraftPayment is accepted. + :type entries: list[object_.DraftPaymentEntry] + :param number_of_required_accepts: The number of accepts that are + required for the draft payment to receive status ACCEPTED. Currently + only 1 is valid. + :type number_of_required_accepts: int + :param status: The status of the DraftPayment. + :type status: str + :param previous_updated_timestamp: The last updated_timestamp that you + received for this DraftPayment. This needs to be provided to prevent + race conditions. + :type previous_updated_timestamp: str + :param schedule: The schedule details when creating or updating a + scheduled payment. + :type schedule: Schedule :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -12459,35 +11613,41 @@ def create(cls, switch_service_payment_id, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_STATUS : status, +cls.FIELD_ENTRIES : entries, +cls.FIELD_PREVIOUS_UPDATED_TIMESTAMP : previous_updated_timestamp, +cls.FIELD_NUMBER_OF_REQUIRED_ACCEPTS : number_of_required_accepts, +cls.FIELD_SCHEDULE : schedule +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, content=None, custom_headers=None): + def update(cls, draft_payment_id, monetary_account_id=None, status=None, previous_updated_timestamp=None, schedule=None, custom_headers=None): """ + Update a DraftPayment. + :type user_id: int :type monetary_account_id: int - :type switch_service_payment_id: int - :type note_text_bank_switch_service_netherlands_incoming_payment_id: int - :param content: The content of the note. - :type content: str + :type draft_payment_id: int + :param status: The status of the DraftPayment. + :type status: str + :param previous_updated_timestamp: The last updated_timestamp that you + received for this DraftPayment. This needs to be provided to prevent + race conditions. + :type previous_updated_timestamp: str + :param schedule: The schedule details when creating or updating a + scheduled payment. + :type schedule: Schedule :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -12496,70 +11656,35 @@ def update(cls, switch_service_payment_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_STATUS : status, +cls.FIELD_PREVIOUS_UPDATED_TIMESTAMP : previous_updated_timestamp, +cls.FIELD_SCHEDULE : schedule +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type switch_service_payment_id: int - :type note_text_bank_switch_service_netherlands_incoming_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - - @classmethod - def list(cls, switch_service_payment_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get a listing of all DraftPayments from a given MonetaryAccount. :type user_id: int :type monetary_account_id: int - :type switch_service_payment_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: - BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList + :rtype: BunqResponseDraftPaymentList """ if params is None: @@ -12568,44 +11693,36 @@ def list(cls, switch_service_payment_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - switch_service_payment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList.cast_from_bunq_response( + return BunqResponseDraftPaymentList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id, - monetary_account_id=None, custom_headers=None): + def get(cls, draft_payment_id, monetary_account_id=None, custom_headers=None): """ - :type api_context: context.ApiContext + Get a specific DraftPayment. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type switch_service_payment_id: int - :type note_text_bank_switch_service_netherlands_incoming_payment_id: int + :type draft_payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment + :rtype: BunqResponseDraftPayment """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - switch_service_payment_id, - note_text_bank_switch_service_netherlands_incoming_payment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment.cast_from_bunq_response( + return BunqResponseDraftPayment.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @@ -12618,36 +11735,76 @@ def id_(self): return self._id_ @property - def created(self): + def monetary_account_id(self): """ - :rtype: str + :rtype: int """ - return self._created + return self._monetary_account_id @property - def updated(self): + def user_alias_created(self): """ - :rtype: str + :rtype: object_.LabelUser """ - return self._updated + return self._user_alias_created @property - def label_user_creator(self): + def responses(self): """ - :rtype: object_.LabelUser + :rtype: list[object_.DraftPaymentResponse] """ - return self._label_user_creator + return self._responses @property - def content(self): + def status(self): """ :rtype: str """ - return self._content + return self._status + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def entries(self): + """ + :rtype: list[object_.DraftPaymentEntry] + """ + + return self._entries + + @property + def object_(self): + """ + :rtype: object_.DraftPaymentAnchorObject + """ + + return self._object_ + + @property + def request_reference_split_the_bill(self): + """ + :rtype: list[object_.RequestInquiryReference] + """ + + return self._request_reference_split_the_bill + + @property + def schedule(self): + """ + :rtype: Schedule + """ + + return self._schedule def is_all_field_none(self): """ @@ -12657,16 +11814,31 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: + if self._monetary_account_id is not None: return False - if self._updated is not None: + if self._user_alias_created is not None: return False - if self._label_user_creator is not None: + if self._responses is not None: return False - if self._content is not None: + if self._status is not None: + return False + + if self._type_ is not None: + return False + + if self._entries is not None: + return False + + if self._object_ is not None: + return False + + if self._request_reference_split_the_bill is not None: + return False + + if self._schedule is not None: return False return True @@ -12676,191 +11848,115 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextBankSwitchServiceNetherlandsIncomingPayment + :rtype: DraftPaymentApiObject """ - return converter.json_to_class( - NoteTextBankSwitchServiceNetherlandsIncomingPayment, json_str) + return converter.json_to_class(DraftPaymentApiObject, json_str) -class NoteAttachmentBunqMeFundraiserResult(core.BunqModel): +class ScheduleApiObject(BunqModel): """ - Used to manage attachment notes. + view for reading the scheduled definitions. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _time_start: The schedule start time (UTC). + :type _time_start: str + :param _time_end: The schedule end time (UTC). + :type _time_end: str + :param _recurrence_unit: The schedule recurrence unit, options: ONCE, + HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY + :type _recurrence_unit: str + :param _recurrence_size: The schedule recurrence size. For example size 4 + and unit WEEKLY means the recurrence is every 4 weeks. + :type _recurrence_size: int + :param _status: The schedule status, options: ACTIVE, FINISHED, CANCELLED. + :type _status: str + :param _object_: The scheduled object. (Payment, PaymentBatch) + :type _object_: object_.ScheduleAnchorObject """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule" # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_TIME_START = "time_start" + FIELD_TIME_END = "time_end" + FIELD_RECURRENCE_UNIT = "recurrence_unit" + FIELD_RECURRENCE_SIZE = "recurrence_size" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None - - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - """ + _OBJECT_TYPE_GET = "Schedule" - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + _time_start = None + _time_end = None + _recurrence_unit = None + _recurrence_size = None + _status = None + _object_ = None + _time_start_field_for_request = None + _time_end_field_for_request = None + _recurrence_unit_field_for_request = None + _recurrence_size_field_for_request = None - @classmethod - def create(cls, bunqme_fundraiser_result_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def __init__(self, time_start=None, recurrence_unit=None, recurrence_size=None, time_end=None): """ - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :param time_start: The schedule start time (UTC). + :type time_start: str + :param recurrence_unit: The schedule recurrence unit, options: ONCE, HOURLY, + DAILY, WEEKLY, MONTHLY, YEARLY + :type recurrence_unit: str + :param recurrence_size: The schedule recurrence size. For example size 4 and + unit WEEKLY means the recurrence is every 4 weeks. + :type recurrence_size: int + :param time_end: The schedule end time (UTC). + :type time_end: str """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + self._time_start_field_for_request = time_start + self._recurrence_unit_field_for_request = recurrence_unit + self._recurrence_size_field_for_request = recurrence_size + self._time_end_field_for_request = time_end @classmethod - def update(cls, bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id, - monetary_account_id=None, description=None, custom_headers=None): + def get(cls, schedule_id, monetary_account_id=None, custom_headers=None): """ - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_attachment_bunq_me_fundraiser_result_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None + Get a specific schedule definition for a given monetary account. - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def delete(cls, bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id, - monetary_account_id=None, custom_headers=None): - """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_attachment_bunq_me_fundraiser_result_id: int + :type schedule_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseSchedule """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseSchedule.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, bunqme_fundraiser_result_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get a collection of scheduled definition for a given monetary account. + You can add the parameter type to filter the response. When + type={SCHEDULE_DEFINITION_PAYMENT,SCHEDULE_DEFINITION_PAYMENT_BATCH} is + provided only schedule definition object that relate to these + definitions are returned. :type user_id: int :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentBunqMeFundraiserResultList + :rtype: BunqResponseScheduleList """ if params is None: @@ -12869,116 +11965,83 @@ def list(cls, bunqme_fundraiser_result_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - bunqme_fundraiser_result_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentBunqMeFundraiserResultList.cast_from_bunq_response( + return BunqResponseScheduleList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id, - monetary_account_id=None, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_attachment_bunq_me_fundraiser_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentBunqMeFundraiserResult - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_attachment_bunq_me_fundraiser_result_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteAttachmentBunqMeFundraiserResult.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property - def id_(self): + def time_start(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._time_start @property - def created(self): + def time_end(self): """ :rtype: str """ - return self._created + return self._time_end @property - def updated(self): + def recurrence_unit(self): """ :rtype: str """ - return self._updated + return self._recurrence_unit @property - def label_user_creator(self): + def recurrence_size(self): """ - :rtype: object_.LabelUser + :rtype: int """ - return self._label_user_creator + return self._recurrence_size @property - def description(self): + def status(self): """ :rtype: str """ - return self._description + return self._status @property - def attachment(self): + def object_(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: object_.ScheduleAnchorObject """ - return self._attachment + return self._object_ def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._time_start is not None: return False - if self._created is not None: + if self._time_end is not None: return False - if self._updated is not None: + if self._recurrence_unit is not None: return False - if self._label_user_creator is not None: + if self._recurrence_size is not None: return False - if self._description is not None: + if self._status is not None: return False - if self._attachment is not None: + if self._object_ is not None: return False return True @@ -12988,66 +12051,24 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentBunqMeFundraiserResult + :rtype: ScheduleApiObject """ - return converter.json_to_class(NoteAttachmentBunqMeFundraiserResult, - json_str) + return converter.json_to_class(ScheduleApiObject, json_str) -class NoteTextBunqMeFundraiserResult(core.BunqModel): +class ServerErrorApiObject(BunqModel): """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + An endpoint that will always throw an error. """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" - - # Field constants. - FIELD_CONTENT = "content" - - # Object type. - _OBJECT_TYPE_GET = "NoteText" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _ENDPOINT_URL_CREATE = "server-error" - def __init__(self, content=None): - """ - :param content: The content of the note. - :type content: str - """ - - self._content_field_for_request = content @classmethod - def create(cls, bunqme_fundraiser_result_id, monetary_account_id=None, - content=None, custom_headers=None): + def create(cls, custom_headers=None): """ - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :param content: The content of the note. - :type content: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -13057,106 +12078,141 @@ def create(cls, bunqme_fundraiser_result_id, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_CONTENT: content - } + +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) - @classmethod - def update(cls, bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, - content=None, custom_headers=None): + + def is_all_field_none(self): """ - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_text_bunq_me_fundraiser_result_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None + :rtype: bool + """ + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str - :rtype: BunqResponseInt + :rtype: ServerErrorApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(ServerErrorApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) +class EventApiObject(BunqModel): + """ + Used to view events. Events are automatically created and contain + information about everything that happens to your bunq account. In the bunq + app events are shown in your 'overview'. Examples of when events are created + or modified: payment sent, payment received, request for payment received or + connect invite received. + + :param _id_: The id of the event. + :type _id_: int + :param _created: The timestamp of the event's creation. + :type _created: str + :param _updated: The timestamp of the event's last update. + :type _updated: str + :param _action: The performed action. Can be: CREATE or UPDATE. + :type _action: str + :param _user_id: The id of the user the event applied to (if it was a user + event). + :type _user_id: str + :param _monetary_account_id: The id of the monetary account the event + applied to (if it was a monetary account event). + :type _monetary_account_id: str + :param _object_: The details of the external object the event was created + for. + :type _object_: object_.EventObject + :param _status: The event status. Can be: FINALIZED or AWAITING_REPLY. An + example of FINALIZED event is a payment received event, while an + AWAITING_REPLY event is a request received event. + :type _status: str + :param _object_data_at_event: Fields of the external model which we have + stored so we know what they were at the time of the event. + :type _object_data_at_event: object_.EventObject + :param _is_event_latest_for_object: Indicator whether this is the latest + event for the object. + :type _is_event_latest_for_object: bool + :param _is_event_reassignable: Indicator whether this is event can be + reassigned to another Monetary Account. + :type _is_event_reassignable: bool + """ - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/event/{}" + _ENDPOINT_URL_LISTING = "user/{}/event" - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + # Object type. + _OBJECT_TYPE_GET = "Event" + + _id_ = None + _created = None + _updated = None + _action = None + _user_id = None + _monetary_account_id = None + _object_ = None + _status = None + _object_data_at_event = None + _is_event_latest_for_object = None + _is_event_reassignable = None @classmethod - def delete(cls, bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, - custom_headers=None): + def get(cls, event_id, custom_headers=None): """ + Get a specific event for a given user. + + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_text_bunq_me_fundraiser_result_id: int + :type event_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseEvent """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), event_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseEvent.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, bunqme_fundraiser_result_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get a collection of events for a given user. You can add query the + parameters monetary_account_id, status and/or display_user_event to + filter the response. When monetary_account_id={id,id} is provided only + events that relate to these monetary account ids are returned. When + status={AWAITING_REPLY/FINALIZED} is provided the response only contains + events with the status AWAITING_REPLY or FINALIZED. When + display_user_event={true/false} is set to false user events are excluded + from the response, when not provided user events are displayed. User + events are events that are not related to a monetary account (for + example: connect invites). :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextBunqMeFundraiserResultList + :rtype: BunqResponseEventList """ if params is None: @@ -13165,47 +12221,14 @@ def list(cls, bunqme_fundraiser_result_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - bunqme_fundraiser_result_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextBunqMeFundraiserResultList.cast_from_bunq_response( + return BunqResponseEventList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, - custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type bunqme_fundraiser_result_id: int - :type note_text_bunq_me_fundraiser_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextBunqMeFundraiserResult - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - bunqme_fundraiser_result_id, - note_text_bunq_me_fundraiser_result_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteTextBunqMeFundraiserResult.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -13231,20 +12254,68 @@ def updated(self): return self._updated @property - def label_user_creator(self): + def action(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._action @property - def content(self): + def user_id(self): """ :rtype: str """ - return self._content + return self._user_id + + @property + def monetary_account_id(self): + """ + :rtype: str + """ + + return self._monetary_account_id + + @property + def object_(self): + """ + :rtype: object_.EventObject + """ + + return self._object_ + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def object_data_at_event(self): + """ + :rtype: object_.EventObject + """ + + return self._object_data_at_event + + @property + def is_event_latest_for_object(self): + """ + :rtype: bool + """ + + return self._is_event_latest_for_object + + @property + def is_event_reassignable(self): + """ + :rtype: bool + """ + + return self._is_event_reassignable def is_all_field_none(self): """ @@ -13260,10 +12331,28 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._action is not None: return False - if self._content is not None: + if self._user_id is not None: + return False + + if self._monetary_account_id is not None: + return False + + if self._object_ is not None: + return False + + if self._status is not None: + return False + + if self._object_data_at_event is not None: + return False + + if self._is_event_latest_for_object is not None: + return False + + if self._is_event_reassignable is not None: return False return True @@ -13273,118 +12362,206 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextBunqMeFundraiserResult + :rtype: EventApiObject """ - return converter.json_to_class(NoteTextBunqMeFundraiserResult, json_str) + return converter.json_to_class(EventApiObject, json_str) -class NoteAttachmentDraftPayment(core.BunqModel): +class FeatureAnnouncementApiObject(BunqModel): """ - Used to manage attachment notes. + view for updating the feature display. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _avatar: The Avatar of the event overview. + :type _avatar: object_.Avatar + :param _title: The event overview title of the feature display + :type _title: str + :param _sub_title: The event overview subtitle of the feature display + :type _sub_title: str + :param _type_: The type of the feature announcement so apps can override + with their own stuff if desired + :type _type_: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + _ENDPOINT_URL_READ = "user/{}/feature-announcement/{}" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None - - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - """ + _OBJECT_TYPE_GET = "FeatureAnnouncement" - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + _avatar = None + _title = None + _sub_title = None + _type_ = None @classmethod - def create(cls, draft_payment_id, attachment_id, monetary_account_id=None, - description=None, custom_headers=None): + def get(cls, feature_announcement_id, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type draft_payment_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :type feature_announcement_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseFeatureAnnouncement """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), feature_announcement_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseFeatureAnnouncement.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def title(self): + """ + :rtype: str + """ + + return self._title + + @property + def sub_title(self): + """ + :rtype: str + """ + + return self._sub_title + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._avatar is not None: + return False + + if self._title is not None: + return False + + if self._sub_title is not None: + return False + + if self._type_ is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: FeatureAnnouncementApiObject + """ + + return converter.json_to_class(FeatureAnnouncementApiObject, json_str) + + +class IdealMerchantTransactionApiObject(BunqModel): + """ + View for requesting iDEAL transactions and polling their status. + + :param _amount_requested: The requested amount of money to add. + :type _amount_requested: object_.Amount + :param _issuer: The BIC of the issuer. + :type _issuer: str + :param _monetary_account_id: The id of the monetary account this ideal + merchant transaction links to. + :type _monetary_account_id: int + :param _alias: The alias of the monetary account to add money to. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The alias of the monetary account the money + comes from. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _amount_guaranteed: In case of a successful transaction, the amount + of money that will be transferred. + :type _amount_guaranteed: object_.Amount + :param _expiration: When the transaction will expire. + :type _expiration: str + :param _issuer_name: The Name of the issuer. + :type _issuer_name: str + :param _issuer_authentication_url: The URL to visit to + :type _issuer_authentication_url: str + :param _purchase_identifier: The 'purchase ID' of the iDEAL transaction. + :type _purchase_identifier: str + :param _status: The status of the transaction. + :type _status: str + :param _status_timestamp: When the status was last updated. + :type _status_timestamp: str + :param _transaction_identifier: The 'transaction ID' of the iDEAL + transaction. + :type _transaction_identifier: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction" + + # Field constants. + FIELD_AMOUNT_REQUESTED = "amount_requested" + FIELD_ISSUER = "issuer" + + # Object type. + _OBJECT_TYPE_GET = "IdealMerchantTransaction" + + _monetary_account_id = None + _alias = None + _counterparty_alias = None + _amount_guaranteed = None + _amount_requested = None + _expiration = None + _issuer = None + _issuer_name = None + _issuer_authentication_url = None + _purchase_identifier = None + _status = None + _status_timestamp = None + _transaction_identifier = None + _amount_requested_field_for_request = None + _issuer_field_for_request = None + + def __init__(self, amount_requested, issuer): + """ + :param amount_requested: The requested amount of money to add. + :type amount_requested: object_.Amount + :param issuer: The BIC of the issuing bank to ask for money. + :type issuer: str + """ + + self._amount_requested_field_for_request = amount_requested + self._issuer_field_for_request = issuer + @classmethod - def update(cls, draft_payment_id, note_attachment_draft_payment_id, - monetary_account_id=None, description=None, custom_headers=None): + def create(cls,amount_requested, issuer, monetary_account_id=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :type note_attachment_draft_payment_id: int - :param description: Optional description of the attachment. - :type description: str + :param amount_requested: The requested amount of money to add. + :type amount_requested: object_.Amount + :param issuer: The BIC of the issuing bank to ask for money. + :type issuer: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -13393,68 +12570,54 @@ def update(cls, draft_payment_id, note_attachment_draft_payment_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_AMOUNT_REQUESTED : amount_requested, +cls.FIELD_ISSUER : issuer +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_attachment_draft_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, draft_payment_id, note_attachment_draft_payment_id, - monetary_account_id=None, custom_headers=None): + def get(cls, ideal_merchant_transaction_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :type note_attachment_draft_payment_id: int + :type ideal_merchant_transaction_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseIdealMerchantTransaction """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_attachment_draft_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseIdealMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, draft_payment_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. - :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentDraftPaymentList + :rtype: BunqResponseIdealMerchantTransactionList """ if params is None: @@ -13463,115 +12626,160 @@ def list(cls, draft_payment_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - draft_payment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentDraftPaymentList.cast_from_bunq_response( + return BunqResponseIdealMerchantTransactionList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, draft_payment_id, note_attachment_draft_payment_id, - monetary_account_id=None, custom_headers=None): + @property + def monetary_account_id(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type draft_payment_id: int - :type note_attachment_draft_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentDraftPayment + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._monetary_account_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_attachment_draft_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseNoteAttachmentDraftPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._alias @property - def id_(self): + def counterparty_alias(self): """ - :rtype: int + :rtype: object_.MonetaryAccountReference """ - return self._id_ + return self._counterparty_alias @property - def created(self): + def amount_guaranteed(self): + """ + :rtype: object_.Amount + """ + + return self._amount_guaranteed + + @property + def amount_requested(self): + """ + :rtype: object_.Amount + """ + + return self._amount_requested + + @property + def expiration(self): """ :rtype: str """ - return self._created + return self._expiration @property - def updated(self): + def issuer(self): """ :rtype: str """ - return self._updated + return self._issuer @property - def label_user_creator(self): + def issuer_name(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._issuer_name @property - def description(self): + def issuer_authentication_url(self): """ :rtype: str """ - return self._description + return self._issuer_authentication_url @property - def attachment(self): + def purchase_identifier(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._purchase_identifier + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def status_timestamp(self): + """ + :rtype: str + """ + + return self._status_timestamp + + @property + def transaction_identifier(self): + """ + :rtype: str + """ + + return self._transaction_identifier def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._monetary_account_id is not None: return False - if self._created is not None: + if self._alias is not None: return False - if self._updated is not None: + if self._counterparty_alias is not None: return False - if self._label_user_creator is not None: + if self._amount_guaranteed is not None: return False - if self._description is not None: + if self._amount_requested is not None: return False - if self._attachment is not None: + if self._expiration is not None: + return False + + if self._issuer is not None: + return False + + if self._issuer_name is not None: + return False + + if self._issuer_authentication_url is not None: + return False + + if self._purchase_identifier is not None: + return False + + if self._status is not None: + return False + + if self._status_timestamp is not None: + return False + + if self._transaction_identifier is not None: return False return True @@ -13581,65 +12789,77 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentDraftPayment + :rtype: IdealMerchantTransactionApiObject """ - return converter.json_to_class(NoteAttachmentDraftPayment, json_str) + return converter.json_to_class(IdealMerchantTransactionApiObject, json_str) -class NoteTextDraftPayment(core.BunqModel): +class SchedulePaymentApiObject(BunqModel): """ - Used to manage text notes. + Endpoint for schedule payments. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _payment: The payment details. + :type _payment: object_.SchedulePaymentEntry + :param _schedule: The schedule details. + :type _schedule: Schedule + :param _purpose: The schedule purpose. + :type _purpose: str + :param _status: The schedule status, options: ACTIVE, FINISHED, CANCELLED. + :type _status: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment/{}" # Field constants. - FIELD_CONTENT = "content" + FIELD_PAYMENT = "payment" + FIELD_SCHEDULE = "schedule" + FIELD_PURPOSE = "purpose" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "ScheduledPayment" + _OBJECT_TYPE_PUT = "ScheduledPayment" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _payment = None + _schedule = None + _status = None + _purpose = None + _payment_field_for_request = None + _schedule_field_for_request = None + _purpose_field_for_request = None - def __init__(self, content=None): + def __init__(self, payment=None, schedule=None, purpose=None): """ - :param content: The content of the note. - :type content: str + :param payment: The payment details. + :type payment: object_.SchedulePaymentEntry + :param schedule: The schedule details when creating or updating a scheduled + payment. + :type schedule: Schedule + :param purpose: The purpose of this scheduled payment. + :type purpose: str """ - self._content_field_for_request = content + self._payment_field_for_request = payment + self._schedule_field_for_request = schedule + self._purpose_field_for_request = purpose @classmethod - def create(cls, draft_payment_id, monetary_account_id=None, content=None, - custom_headers=None): + def create(cls,payment, schedule, monetary_account_id=None, purpose=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :param content: The content of the note. - :type content: str + :param payment: The payment details. + :type payment: object_.SchedulePaymentEntry + :param schedule: The schedule details when creating or updating a + scheduled payment. + :type schedule: Schedule + :param purpose: The purpose of this scheduled payment. + :type purpose: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -13649,104 +12869,76 @@ def create(cls, draft_payment_id, monetary_account_id=None, content=None, custom_headers = {} request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_PAYMENT : payment, +cls.FIELD_SCHEDULE : schedule, +cls.FIELD_PURPOSE : purpose +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, draft_payment_id, note_text_draft_payment_id, - monetary_account_id=None, content=None, custom_headers=None): + def delete(cls, schedule_payment_id, monetary_account_id=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :type note_text_draft_payment_id: int - :param content: The content of the note. - :type content: str + :type schedule_payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseNone """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_text_draft_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) ) @classmethod - def delete(cls, draft_payment_id, note_text_draft_payment_id, - monetary_account_id=None, custom_headers=None): + def get(cls, schedule_payment_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :type note_text_draft_payment_id: int + :type schedule_payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseSchedulePayment """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_text_draft_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseSchedulePayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, draft_payment_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. - :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextDraftPaymentList + :rtype: BunqResponseSchedulePaymentList """ if params is None: @@ -13755,104 +12947,97 @@ def list(cls, draft_payment_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - draft_payment_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextDraftPaymentList.cast_from_bunq_response( + return BunqResponseSchedulePaymentList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, draft_payment_id, note_text_draft_payment_id, - monetary_account_id=None, custom_headers=None): + def update(cls, schedule_payment_id, monetary_account_id=None, payment=None, schedule=None, custom_headers=None): """ - :type api_context: context.ApiContext :type user_id: int :type monetary_account_id: int - :type draft_payment_id: int - :type note_text_draft_payment_id: int + :type schedule_payment_id: int + :param payment: The payment details. + :type payment: object_.SchedulePaymentEntry + :param schedule: The schedule details when creating or updating a + scheduled payment. + :type schedule: Schedule :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextDraftPayment + :rtype: BunqResponseSchedulePayment """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - draft_payment_id, - note_text_draft_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) - return BunqResponseNoteTextDraftPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + request_map = { +cls.FIELD_PAYMENT : payment, +cls.FIELD_SCHEDULE : schedule +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - @property - def id_(self): - """ - :rtype: int - """ + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return self._id_ + return BunqResponseSchedulePayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) + ) @property - def created(self): + def payment(self): """ - :rtype: str + :rtype: object_.SchedulePaymentEntry """ - return self._created + return self._payment @property - def updated(self): + def schedule(self): """ - :rtype: str + :rtype: Schedule """ - return self._updated + return self._schedule @property - def label_user_creator(self): + def status(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._status @property - def content(self): + def purpose(self): """ :rtype: str """ - return self._content + return self._purpose def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: + if self._payment is not None: return False - if self._updated is not None: + if self._schedule is not None: return False - if self._label_user_creator is not None: + if self._status is not None: return False - if self._content is not None: + if self._purpose is not None: return False return True @@ -13862,119 +13047,83 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextDraftPayment + :rtype: SchedulePaymentApiObject """ - return converter.json_to_class(NoteTextDraftPayment, json_str) + return converter.json_to_class(SchedulePaymentApiObject, json_str) -class NoteAttachmentIdealMerchantTransaction(core.BunqModel): +class SchedulePaymentBatchApiObject(BunqModel): """ - Used to manage attachment notes. + Endpoint for schedule payment batches. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _payments: The payment details. + :type _payments: list[object_.SchedulePaymentEntry] + :param _schedule: The schedule details. + :type _schedule: Schedule """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment-batch/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment-batch" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment-batch/{}" # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_PAYMENTS = "payments" + FIELD_SCHEDULE = "schedule" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + _OBJECT_TYPE_GET = "ScheduledPaymentBatch" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + _payments = None + _schedule = None + _payments_field_for_request = None + _schedule_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, payments=None, schedule=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :param payments: The payment details. + :type payments: list[object_.SchedulePaymentEntry] + :param schedule: The schedule details when creating a scheduled payment. + :type schedule: Schedule """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + self._payments_field_for_request = payments + self._schedule_field_for_request = schedule @classmethod - def create(cls, ideal_merchant_transaction_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def get(cls, schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :type schedule_payment_batch_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseSchedulePaymentBatch """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseSchedulePaymentBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id, - monetary_account_id=None, description=None, custom_headers=None): + def create(cls,payments, schedule, monetary_account_id=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_attachment_ideal_merchant_transaction_id: int - :param description: Optional description of the attachment. - :type description: str + :param payments: The payment details. + :type payments: list[object_.SchedulePaymentEntry] + :param schedule: The schedule details when creating a scheduled payment. + :type schedule: Schedule :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -13983,187 +13132,104 @@ def update(cls, ideal_merchant_transaction_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_PAYMENTS : payments, +cls.FIELD_SCHEDULE : schedule +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): + def update(cls, schedule_payment_batch_id, monetary_account_id=None, payments=None, schedule=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_attachment_ideal_merchant_transaction_id: int + :type schedule_payment_batch_id: int + :param payments: The payment details. + :type payments: list[object_.SchedulePaymentEntry] + :param schedule: The schedule details when creating a scheduled payment. + :type schedule: Schedule :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - - @classmethod - def list(cls, ideal_merchant_transaction_id, monetary_account_id=None, - params=None, custom_headers=None): - """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentIdealMerchantTransactionList - """ - - if params is None: - params = {} + api_client = ApiClient(cls._get_api_context()) - if custom_headers is None: - custom_headers = {} + request_map = { +cls.FIELD_PAYMENTS : payments, +cls.FIELD_SCHEDULE : schedule +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - ideal_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return BunqResponseNoteAttachmentIdealMerchantTransactionList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) @classmethod - def get(cls, ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): + def delete(cls, schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): """ - :type api_context: context.ApiContext :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_attachment_ideal_merchant_transaction_id: int + :type schedule_payment_batch_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentIdealMerchantTransaction + :rtype: BunqResponseNone """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_attachment_ideal_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseNoteAttachmentIdealMerchantTransaction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) ) @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created - - @property - def updated(self): - """ - :rtype: str - """ - - return self._updated - - @property - def label_user_creator(self): - """ - :rtype: object_.LabelUser - """ - - return self._label_user_creator - - @property - def description(self): + def payments(self): """ - :rtype: str + :rtype: list[object_.SchedulePaymentEntry] """ - return self._description + return self._payments @property - def attachment(self): + def schedule(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: Schedule """ - return self._attachment + return self._schedule def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._label_user_creator is not None: - return False - - if self._description is not None: + if self._payments is not None: return False - if self._attachment is not None: + if self._schedule is not None: return False return True @@ -14173,104 +13239,100 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentIdealMerchantTransaction + :rtype: SchedulePaymentBatchApiObject """ - return converter.json_to_class(NoteAttachmentIdealMerchantTransaction, - json_str) + return converter.json_to_class(SchedulePaymentBatchApiObject, json_str) -class NoteTextIdealMerchantTransaction(core.BunqModel): +class ScheduleInstanceApiObject(BunqModel): """ - Used to manage text notes. + view for reading, updating and listing the scheduled instance. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _state: The state of the scheduleInstance. (FINISHED_SUCCESSFULLY, + RETRY, FAILED_USER_ERROR) + :type _state: str + :param _time_start: The schedule start time (UTC). + :type _time_start: str + :param _time_end: The schedule end time (UTC). + :type _time_end: str + :param _error_message: The message when the scheduled instance has run and + failed due to user error. + :type _error_message: list[object_.Error] + :param _scheduled_object: The scheduled object. (Payment, PaymentBatch) + :type _scheduled_object: object_.ScheduleAnchorObject + :param _result_object: The result object of this schedule instance. + (Payment, PaymentBatch) + :type _result_object: object_.ScheduleInstanceAnchorObject + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance" # Field constants. - FIELD_CONTENT = "content" + FIELD_STATE = "state" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "ScheduledInstance" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _state = None + _time_start = None + _time_end = None + _error_message = None + _scheduled_object = None + _result_object = None + _request_reference_split_the_bill = None + _state_field_for_request = None - def __init__(self, content=None): + def __init__(self, state=None): """ - :param content: The content of the note. - :type content: str + :param state: Change the state of the scheduleInstance from + FAILED_USER_ERROR to RETRY. + :type state: str """ - self._content_field_for_request = content + self._state_field_for_request = state @classmethod - def create(cls, ideal_merchant_transaction_id, monetary_account_id=None, - content=None, custom_headers=None): + def get(cls, schedule_id, schedule_instance_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :param content: The content of the note. - :type content: str + :type schedule_id: int + :type schedule_instance_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseScheduleInstance """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseScheduleInstance.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id, - monetary_account_id=None, content=None, custom_headers=None): + def update(cls, schedule_id, schedule_instance_id, monetary_account_id=None, state=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_text_ideal_merchant_transaction_id: int - :param content: The content of the note. - :type content: str + :type schedule_id: int + :type schedule_instance_id: int + :param state: Change the state of the scheduleInstance from + FAILED_USER_ERROR to RETRY. + :type state: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -14279,69 +13341,32 @@ def update(cls, ideal_merchant_transaction_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_STATE : state +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_text_ideal_merchant_transaction_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - - @classmethod - def list(cls, ideal_merchant_transaction_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,schedule_id, monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. - :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int + :type schedule_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextIdealMerchantTransactionList + :rtype: BunqResponseScheduleInstanceList """ if params is None: @@ -14350,105 +13375,94 @@ def list(cls, ideal_merchant_transaction_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - ideal_merchant_transaction_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextIdealMerchantTransactionList.cast_from_bunq_response( + return BunqResponseScheduleInstanceList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id, monetary_account_id=None, - custom_headers=None): + @property + def state(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type ideal_merchant_transaction_id: int - :type note_text_ideal_merchant_transaction_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextIdealMerchantTransaction + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._state - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id, - note_text_ideal_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def time_start(self): + """ + :rtype: str + """ - return BunqResponseNoteTextIdealMerchantTransaction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._time_start @property - def id_(self): + def time_end(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._time_end @property - def created(self): + def error_message(self): """ - :rtype: str + :rtype: list[object_.Error] """ - return self._created + return self._error_message @property - def updated(self): + def scheduled_object(self): """ - :rtype: str + :rtype: object_.ScheduleAnchorObject """ - return self._updated + return self._scheduled_object @property - def label_user_creator(self): + def result_object(self): """ - :rtype: object_.LabelUser + :rtype: object_.ScheduleInstanceAnchorObject """ - return self._label_user_creator + return self._result_object @property - def content(self): + def request_reference_split_the_bill(self): """ - :rtype: str + :rtype: list[object_.RequestInquiryReference] """ - return self._content + return self._request_reference_split_the_bill def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._state is not None: return False - if self._created is not None: + if self._time_start is not None: return False - if self._updated is not None: + if self._time_end is not None: return False - if self._label_user_creator is not None: + if self._error_message is not None: return False - if self._content is not None: + if self._scheduled_object is not None: + return False + + if self._result_object is not None: + return False + + if self._request_reference_split_the_bill is not None: return False return True @@ -14458,268 +13472,370 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextIdealMerchantTransaction + :rtype: ScheduleInstanceApiObject """ - return converter.json_to_class(NoteTextIdealMerchantTransaction, - json_str) + return converter.json_to_class(ScheduleInstanceApiObject, json_str) -class NoteAttachmentMasterCardAction(core.BunqModel): +class MasterCardActionApiObject(BunqModel): """ - Used to manage attachment notes. + MasterCard transaction view. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + :param _id_: The id of the MastercardAction. :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _monetary_account_id: The id of the monetary account this action + links to. + :type _monetary_account_id: int + :param _card_id: The id of the card this action links to. + :type _card_id: int + :param _amount_local: The amount of the transaction in local currency. + :type _amount_local: object_.Amount + :param _amount_converted: The amount of the transaction in local currency. + :type _amount_converted: object_.Amount + :param _amount_billing: The amount of the transaction in the monetary + account's currency. + :type _amount_billing: object_.Amount + :param _amount_original_local: The original amount in local currency. + :type _amount_original_local: object_.Amount + :param _amount_original_billing: The original amount in the monetary + account's currency. + :type _amount_original_billing: object_.Amount + :param _amount_fee: The fee amount as charged by the merchant, if + applicable. + :type _amount_fee: object_.Amount + :param _card_authorisation_id_response: The response code by which + authorised transaction can be identified as authorised by bunq. + :type _card_authorisation_id_response: str + :param _decision: Why the transaction was denied, if it was denied, or just + ALLOWED. + :type _decision: str + :param _payment_status: The payment status of the transaction. For example + PAYMENT_SUCCESSFUL, for a successful payment. + :type _payment_status: str + :param _decision_description: Empty if allowed, otherwise a textual + explanation of why it was denied. + :type _decision_description: str + :param _decision_description_translated: Empty if allowed, otherwise a + textual explanation of why it was denied in user's language. + :type _decision_description_translated: str + :param _decision_together_url: Empty if allowed or if no relevant Together + topic exists, otherwise contains the URL for a Together topic with more + information about the decision. + :type _decision_together_url: str + :param _description: The description for this transaction to display. + :type _description: str + :param _authorisation_status: The status in the authorisation process. + :type _authorisation_status: str + :param _authorisation_type: The type of transaction that was delivered using + the card. + :type _authorisation_type: str + :param _pan_entry_mode_user: The type of entry mode the user used. Can be + 'ATM', 'ICC', 'MAGNETIC_STRIPE' or 'E_COMMERCE'. + :type _pan_entry_mode_user: str + :param _settlement_status: The setlement status in the authorisation + process. + :type _settlement_status: str + :param _clearing_status: The clearing status of the authorisation. Can be + 'PENDING', 'FIRST_PRESENTMENT_COMPLETE' or 'REFUND_LENIENCY'. + :type _clearing_status: str + :param _maturity_date: The maturity date. + :type _maturity_date: str + :param _city: The city where the message originates from as announced by the + terminal. + :type _city: str + :param _alias: The monetary account label of the account that this action is + created for. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The monetary account label of the counterparty. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _label_card: The label of the card. + :type _label_card: object_.LabelCard + :param _merchant_id: The identification string of the merchant. + :type _merchant_id: str + :param _token_status: If this is a tokenisation action, this shows the + status of the token. + :type _token_status: str + :param _reservation_expiry_time: If this is a reservation, the moment the + reservation will expire. + :type _reservation_expiry_time: str + :param _clearing_expiry_time: The time when the processing of the clearing + is expired, refunding the authorisation. + :type _clearing_expiry_time: str + :param _applied_limit: The type of the limit applied to validate if this + MasterCardAction was within the spending limits. The returned string matches + the limit types as defined in the card endpoint. + :type _applied_limit: str + :param _secure_code_id: The secure code id for this mastercard action or + null. + :type _secure_code_id: int + :param _wallet_provider_id: The ID of the wallet provider as defined by + MasterCard. 420 = bunq Android app with Tap&Pay; 103 = Apple Pay. + :type _wallet_provider_id: str + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] + :param _card_tokenization_event: The cardTokenization event awaiting + acceptance by the user + :type _card_tokenization_event: Event + :param _all_mastercard_action_refund: A reference to the Refunds if they + exist. + :type _all_mastercard_action_refund: list[MasterCardActionRefund] + :param _pos_card_presence: The Card Presence type of the POS. + :type _pos_card_presence: str + :param _pos_card_holder_presence: The Card Holder Presence type of the POS. + :type _pos_card_holder_presence: str + :param _eligible_whitelist_id: The whitelist id for this action or null. + :type _eligible_whitelist_id: int + :param _cashback_payout_item: The cashback payout item for this action or + null + :type _cashback_payout_item: CashbackPayoutItem + :param _point_mutation: The point mutation for this action or null + :type _point_mutation: PointMutation + :param _blacklist: DEPRECATED. The blacklist enabled for the merchant of + this transaction + :type _blacklist: UserBlocklistMasterCardMerchant + :param _blocklist: The blocklist enabled for the merchant of this + transaction + :type _blocklist: UserBlocklistMasterCardMerchant + :param _additional_authentication_status: The status of the additional + authentication performed (3ds) by the user for this transaction. + :type _additional_authentication_status: str + :param _pin_status: Status checking the provided PIN. + :type _pin_status: str + :param _mastercard_action_report: The report for this transaction + :type _mastercard_action_report: MasterCardActionReport + :param _merchant_category_code: The MCC provided. + :type _merchant_category_code: str + :param _company_employee_card_receipt: The receipt the company employee has + to provide for this transaction. + :type _company_employee_card_receipt: CompanyEmployeeCardReceipt """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + _OBJECT_TYPE_GET = "MasterCardAction" _id_ = None - _created = None - _updated = None - _label_user_creator = None + _monetary_account_id = None + _card_id = None + _amount_local = None + _amount_converted = None + _amount_billing = None + _amount_original_local = None + _amount_original_billing = None + _amount_fee = None + _card_authorisation_id_response = None + _decision = None + _payment_status = None + _decision_description = None + _decision_description_translated = None + _decision_together_url = None _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None - - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - """ - - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + _authorisation_status = None + _authorisation_type = None + _pan_entry_mode_user = None + _settlement_status = None + _clearing_status = None + _maturity_date = None + _city = None + _alias = None + _counterparty_alias = None + _label_card = None + _merchant_id = None + _token_status = None + _reservation_expiry_time = None + _clearing_expiry_time = None + _applied_limit = None + _secure_code_id = None + _wallet_provider_id = None + _request_reference_split_the_bill = None + _card_tokenization_event = None + _all_mastercard_action_refund = None + _pos_card_presence = None + _pos_card_holder_presence = None + _eligible_whitelist_id = None + _cashback_payout_item = None + _point_mutation = None + _blacklist = None + _blocklist = None + _additional_authentication_status = None + _pin_status = None + _mastercard_action_report = None + _merchant_category_code = None + _company_employee_card_receipt = None @classmethod - def create(cls, mastercard_action_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def get(cls, master_card_action_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type mastercard_action_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :type master_card_action_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseMasterCardAction """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), master_card_action_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseMasterCardAction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, mastercard_action_id, note_attachment_master_card_action_id, - monetary_account_id=None, description=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type mastercard_action_id: int - :type note_attachment_master_card_action_id: int - :param description: Optional description of the attachment. - :type description: str + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseMasterCardActionList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return BunqResponseMasterCardActionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_attachment_master_card_action_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def id_(self): + """ + :rtype: int + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._id_ - @classmethod - def delete(cls, mastercard_action_id, note_attachment_master_card_action_id, - monetary_account_id=None, custom_headers=None): + @property + def monetary_account_id(self): """ - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type note_attachment_master_card_action_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._monetary_account_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_attachment_master_card_action_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def card_id(self): + """ + :rtype: int + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._card_id - @classmethod - def list(cls, mastercard_action_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def amount_local(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentMasterCardActionList + :rtype: object_.Amount """ - if params is None: - params = {} + return self._amount_local - if custom_headers is None: - custom_headers = {} + @property + def amount_converted(self): + """ + :rtype: object_.Amount + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - mastercard_action_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._amount_converted - return BunqResponseNoteAttachmentMasterCardActionList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def amount_billing(self): + """ + :rtype: object_.Amount + """ - @classmethod - def get(cls, mastercard_action_id, note_attachment_master_card_action_id, - monetary_account_id=None, custom_headers=None): + return self._amount_billing + + @property + def amount_original_local(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type note_attachment_master_card_action_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentMasterCardAction + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} + return self._amount_original_local - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_attachment_master_card_action_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def amount_original_billing(self): + """ + :rtype: object_.Amount + """ - return BunqResponseNoteAttachmentMasterCardAction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._amount_original_billing @property - def id_(self): + def amount_fee(self): """ - :rtype: int + :rtype: object_.Amount """ - return self._id_ + return self._amount_fee @property - def created(self): + def card_authorisation_id_response(self): """ :rtype: str """ - return self._created + return self._card_authorisation_id_response @property - def updated(self): + def decision(self): """ :rtype: str """ - return self._updated + return self._decision @property - def label_user_creator(self): + def payment_status(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._payment_status + + @property + def decision_description(self): + """ + :rtype: str + """ + + return self._decision_description + + @property + def decision_description_translated(self): + """ + :rtype: str + """ + + return self._decision_description_translated + + @property + def decision_together_url(self): + """ + :rtype: str + """ + + return self._decision_together_url @property def description(self): @@ -14730,296 +13846,260 @@ def description(self): return self._description @property - def attachment(self): + def authorisation_status(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._authorisation_status - def is_all_field_none(self): + @property + def authorisation_type(self): """ - :rtype: bool + :rtype: str """ - if self._id_ is not None: - return False + return self._authorisation_type - if self._created is not None: - return False + @property + def pan_entry_mode_user(self): + """ + :rtype: str + """ - if self._updated is not None: - return False + return self._pan_entry_mode_user - if self._label_user_creator is not None: - return False + @property + def settlement_status(self): + """ + :rtype: str + """ - if self._description is not None: - return False + return self._settlement_status - if self._attachment is not None: - return False + @property + def clearing_status(self): + """ + :rtype: str + """ - return True + return self._clearing_status - @staticmethod - def from_json(json_str): + @property + def maturity_date(self): """ - :type json_str: str - - :rtype: NoteAttachmentMasterCardAction + :rtype: str """ - return converter.json_to_class(NoteAttachmentMasterCardAction, json_str) + return self._maturity_date + @property + def city(self): + """ + :rtype: str + """ -class NoteTextMasterCardAction(core.BunqModel): - """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - """ + return self._city - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - # Field constants. - FIELD_CONTENT = "content" + return self._alias - # Object type. - _OBJECT_TYPE_GET = "NoteText" + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + return self._counterparty_alias - def __init__(self, content=None): + @property + def label_card(self): """ - :param content: The content of the note. - :type content: str + :rtype: object_.LabelCard """ - self._content_field_for_request = content + return self._label_card - @classmethod - def create(cls, mastercard_action_id, monetary_account_id=None, - content=None, custom_headers=None): + @property + def merchant_id(self): """ - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._merchant_id - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def token_status(self): + """ + :rtype: str + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._token_status - @classmethod - def update(cls, mastercard_action_id, note_text_master_card_action_id, - monetary_account_id=None, content=None, custom_headers=None): + @property + def reservation_expiry_time(self): """ - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type note_text_master_card_action_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._reservation_expiry_time - api_client = client.ApiClient(cls._get_api_context()) + @property + def clearing_expiry_time(self): + """ + :rtype: str + """ - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._clearing_expiry_time - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_text_master_card_action_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def applied_limit(self): + """ + :rtype: str + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._applied_limit - @classmethod - def delete(cls, mastercard_action_id, note_text_master_card_action_id, - monetary_account_id=None, custom_headers=None): + @property + def secure_code_id(self): """ - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type note_text_master_card_action_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._secure_code_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_text_master_card_action_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def wallet_provider_id(self): + """ + :rtype: str + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._wallet_provider_id - @classmethod - def list(cls, mastercard_action_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def request_reference_split_the_bill(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextMasterCardActionList + :rtype: list[object_.RequestInquiryReference] """ - if params is None: - params = {} + return self._request_reference_split_the_bill - if custom_headers is None: - custom_headers = {} + @property + def card_tokenization_event(self): + """ + :rtype: Event + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - mastercard_action_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._card_tokenization_event - return BunqResponseNoteTextMasterCardActionList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def all_mastercard_action_refund(self): + """ + :rtype: list[MasterCardActionRefund] + """ - @classmethod - def get(cls, mastercard_action_id, note_text_master_card_action_id, - monetary_account_id=None, custom_headers=None): + return self._all_mastercard_action_refund + + @property + def pos_card_presence(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type mastercard_action_id: int - :type note_text_master_card_action_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextMasterCardAction + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._pos_card_presence - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - mastercard_action_id, - note_text_master_card_action_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def pos_card_holder_presence(self): + """ + :rtype: str + """ - return BunqResponseNoteTextMasterCardAction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._pos_card_holder_presence @property - def id_(self): + def eligible_whitelist_id(self): """ :rtype: int """ - return self._id_ + return self._eligible_whitelist_id @property - def created(self): + def cashback_payout_item(self): + """ + :rtype: CashbackPayoutItem + """ + + return self._cashback_payout_item + + @property + def point_mutation(self): + """ + :rtype: PointMutation + """ + + return self._point_mutation + + @property + def blacklist(self): + """ + :rtype: UserBlocklistMasterCardMerchant + """ + + return self._blacklist + + @property + def blocklist(self): + """ + :rtype: UserBlocklistMasterCardMerchant + """ + + return self._blocklist + + @property + def additional_authentication_status(self): """ :rtype: str """ - return self._created + return self._additional_authentication_status @property - def updated(self): + def pin_status(self): """ :rtype: str """ - return self._updated + return self._pin_status @property - def label_user_creator(self): + def mastercard_action_report(self): """ - :rtype: object_.LabelUser + :rtype: MasterCardActionReport """ - return self._label_user_creator + return self._mastercard_action_report @property - def content(self): + def merchant_category_code(self): """ :rtype: str """ - return self._content + return self._merchant_category_code + + @property + def company_employee_card_receipt(self): + """ + :rtype: CompanyEmployeeCardReceipt + """ + + return self._company_employee_card_receipt def is_all_field_none(self): """ @@ -15029,254 +14109,298 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: + if self._monetary_account_id is not None: return False - if self._updated is not None: + if self._card_id is not None: return False - if self._label_user_creator is not None: + if self._amount_local is not None: return False - if self._content is not None: + if self._amount_converted is not None: return False - return True + if self._amount_billing is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: NoteTextMasterCardAction - """ + if self._amount_original_local is not None: + return False - return converter.json_to_class(NoteTextMasterCardAction, json_str) + if self._amount_original_billing is not None: + return False + if self._amount_fee is not None: + return False -class NoteAttachmentPaymentBatch(core.BunqModel): - """ - Used to manage attachment notes. - - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] - """ + if self._card_authorisation_id_response is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" + if self._decision is not None: + return False - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + if self._payment_status is not None: + return False - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + if self._decision_description is not None: + return False - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + if self._decision_description_translated is not None: + return False - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - """ + if self._decision_together_url is not None: + return False - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + if self._description is not None: + return False - @classmethod - def create(cls, payment_batch_id, attachment_id, monetary_account_id=None, - description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + if self._authorisation_status is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._authorisation_type is not None: + return False - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._pan_entry_mode_user is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._settlement_status is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._clearing_status is not None: + return False - @classmethod - def update(cls, payment_batch_id, note_attachment_payment_batch_id, - monetary_account_id=None, description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_attachment_payment_batch_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + if self._maturity_date is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._city is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) + if self._alias is not None: + return False - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._counterparty_alias is not None: + return False - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_attachment_payment_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + if self._label_card is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._merchant_id is not None: + return False - @classmethod - def delete(cls, payment_batch_id, note_attachment_payment_batch_id, - monetary_account_id=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_attachment_payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ + if self._token_status is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._reservation_expiry_time is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_attachment_payment_batch_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + if self._clearing_expiry_time is not None: + return False - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + if self._applied_limit is not None: + return False - @classmethod - def list(cls, payment_batch_id, monetary_account_id=None, params=None, - custom_headers=None): + if self._secure_code_id is not None: + return False + + if self._wallet_provider_id is not None: + return False + + if self._request_reference_split_the_bill is not None: + return False + + if self._card_tokenization_event is not None: + return False + + if self._all_mastercard_action_refund is not None: + return False + + if self._pos_card_presence is not None: + return False + + if self._pos_card_holder_presence is not None: + return False + + if self._eligible_whitelist_id is not None: + return False + + if self._cashback_payout_item is not None: + return False + + if self._point_mutation is not None: + return False + + if self._blacklist is not None: + return False + + if self._blocklist is not None: + return False + + if self._additional_authentication_status is not None: + return False + + if self._pin_status is not None: + return False + + if self._mastercard_action_report is not None: + return False + + if self._merchant_category_code is not None: + return False + + if self._company_employee_card_receipt is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseNoteAttachmentPaymentBatchList + :rtype: MasterCardActionApiObject """ - if params is None: - params = {} + return converter.json_to_class(MasterCardActionApiObject, json_str) - if custom_headers is None: - custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - payment_batch_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) +class MasterCardActionRefundApiObject(BunqModel): + """ + Endpoint for creating a refund request for a masterCard transaction. + + :param _type_: Type of this refund. Can de REFUND or CHARGEBACK + :type _type_: str + :param _sub_type: The sub type of this refund indicating whether the + chargeback will be FULL or PARTIAL. + :type _sub_type: str + :param _amount: The amount to refund. + :type _amount: object_.Amount + :param _category: The category of the refund, required for chargeback. + :type _category: str + :param _reason: The reason of the refund. Can be REFUND_EXPIRED_TRANSACTION, + REFUND_REQUESTED, REFUND_MERCHANT, REFUND_CHARGEBACK. + :type _reason: str + :param _comment: Comment about the refund. + :type _comment: str + :param _attachment: The Attachments to attach to the refund request. + :type _attachment: list[object_.AttachmentMasterCardActionRefund] + :param _terms_and_conditions: Proof that the user acknowledged the terms and + conditions for chargebacks. + :type _terms_and_conditions: str + :param _id_: The id of the refund. + :type _id_: int + :param _created: The timestamp of the refund's creation. + :type _created: str + :param _updated: The timestamp of the refund's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _status: The status of the refunded mastercard action. Can be + AUTO_APPROVED, AUTO_APPROVED_WAITING_FOR_EXPIRY, PENDING_APPROVAL, APPROVED, + REFUNDED, DENIED or FAILED + :type _status: str + :param _reference_mastercard_action_event: The reference to the object this + refund applies to. + :type _reference_mastercard_action_event: + list[object_.MasterCardActionReference] + :param _mastercard_action_id: The id of mastercard action being refunded. + :type _mastercard_action_id: int + :param _alias: The monetary account label of the account that this action is + created for. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The monetary account label of the counterparty. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description for this transaction to display. + :type _description: str + :param _label_card: The label of the card. + :type _label_card: object_.LabelCard + :param _time_refund: The time the refund will take place. + :type _time_refund: str + :param _additional_information: All additional information provided by the + user. + :type _additional_information: object_.AdditionalInformation + :param _status_description: Description of the refund's current status. + :type _status_description: str + :param _status_description_translated: Description of the refund's current + status, translated in user's language. + :type _status_description_translated: str + :param _status_together_url: Together topic concerning the refund's current + status. + :type _status_together_url: str + """ - return BunqResponseNoteAttachmentPaymentBatchList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + # Field constants. + FIELD_TYPE = "type" + FIELD_SUB_TYPE = "sub_type" + FIELD_AMOUNT = "amount" + FIELD_CATEGORY = "category" + FIELD_REASON = "reason" + FIELD_COMMENT = "comment" + FIELD_ATTACHMENT = "attachment" + FIELD_TERMS_AND_CONDITIONS = "terms_and_conditions" - @classmethod - def get(cls, payment_batch_id, note_attachment_payment_batch_id, - monetary_account_id=None, custom_headers=None): + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _status = None + _reference_mastercard_action_event = None + _mastercard_action_id = None + _type_ = None + _sub_type = None + _reason = None + _amount = None + _alias = None + _counterparty_alias = None + _description = None + _label_card = None + _time_refund = None + _additional_information = None + _status_description = None + _status_description_translated = None + _status_together_url = None + _type__field_for_request = None + _sub_type_field_for_request = None + _amount_field_for_request = None + _category_field_for_request = None + _reason_field_for_request = None + _comment_field_for_request = None + _attachment_field_for_request = None + _terms_and_conditions_field_for_request = None + + def __init__(self, sub_type, amount, type_=None, category=None, reason=None, comment=None, attachment=None, terms_and_conditions=None): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_attachment_payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentPaymentBatch + :param sub_type: The sub type of this refund indicating whether the + chargeback will be FULL or PARTIAL. + :type sub_type: str + :param amount: The amount to refund. + :type amount: object_.Amount + :param type_: Type of this refund. Can de REFUND or CHARGEBACK. DEPRECATED: + This is now determined by backend. + :type type_: str + :param category: The category of the refund, required for chargeback. + :type category: str + :param reason: The reason to refund, required for chargeback. + :type reason: str + :param comment: Comment about the refund. + :type comment: str + :param attachment: The Attachments to attach to the refund request. + :type attachment: list[object_.AttachmentMasterCardActionRefund] + :param terms_and_conditions: Proof that the user acknowledged the terms and + conditions for chargebacks. + :type terms_and_conditions: str """ - if custom_headers is None: - custom_headers = {} + self._sub_type_field_for_request = sub_type + self._amount_field_for_request = amount + self._type__field_for_request = type_ + self._category_field_for_request = category + self._reason_field_for_request = reason + self._comment_field_for_request = comment + self._attachment_field_for_request = attachment + self._terms_and_conditions_field_for_request = terms_and_conditions - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_attachment_payment_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNoteAttachmentPaymentBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) @property def id_(self): @@ -15311,304 +14435,132 @@ def label_user_creator(self): return self._label_user_creator @property - def description(self): + def status(self): """ :rtype: str """ - return self._description + return self._status @property - def attachment(self): + def reference_mastercard_action_event(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: list[object_.MasterCardActionReference] """ - return self._attachment + return self._reference_mastercard_action_event - def is_all_field_none(self): + @property + def mastercard_action_id(self): """ - :rtype: bool + :rtype: int """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._label_user_creator is not None: - return False - - if self._description is not None: - return False - - if self._attachment is not None: - return False - - return True + return self._mastercard_action_id - @staticmethod - def from_json(json_str): + @property + def type_(self): """ - :type json_str: str - - :rtype: NoteAttachmentPaymentBatch + :rtype: str """ - return converter.json_to_class(NoteAttachmentPaymentBatch, json_str) - - -class NoteTextPaymentBatch(core.BunqModel): - """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" - - # Field constants. - FIELD_CONTENT = "content" - - # Object type. - _OBJECT_TYPE_GET = "NoteText" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + return self._type_ - def __init__(self, content=None): + @property + def sub_type(self): """ - :param content: The content of the note. - :type content: str + :rtype: str """ - self._content_field_for_request = content + return self._sub_type - @classmethod - def create(cls, payment_batch_id, monetary_account_id=None, content=None, - custom_headers=None): + @property + def reason(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._reason - @classmethod - def update(cls, payment_batch_id, note_text_payment_batch_id, - monetary_account_id=None, content=None, custom_headers=None): + @property + def amount(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_text_payment_batch_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_text_payment_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._amount - @classmethod - def delete(cls, payment_batch_id, note_text_payment_batch_id, - monetary_account_id=None, custom_headers=None): + @property + def alias(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_text_payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_text_payment_batch_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._alias - @classmethod - def list(cls, payment_batch_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def counterparty_alias(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextPaymentBatchList + :rtype: object_.MonetaryAccountReference """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - payment_batch_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseNoteTextPaymentBatchList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._counterparty_alias - @classmethod - def get(cls, payment_batch_id, note_text_payment_batch_id, - monetary_account_id=None, custom_headers=None): + @property + def description(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_batch_id: int - :type note_text_payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextPaymentBatch + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._description - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_batch_id, - note_text_payment_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def label_card(self): + """ + :rtype: object_.LabelCard + """ - return BunqResponseNoteTextPaymentBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._label_card @property - def id_(self): + def time_refund(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._time_refund @property - def created(self): + def additional_information(self): """ - :rtype: str + :rtype: object_.AdditionalInformation """ - return self._created + return self._additional_information @property - def updated(self): + def status_description(self): """ :rtype: str """ - return self._updated + return self._status_description @property - def label_user_creator(self): + def status_description_translated(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._status_description_translated @property - def content(self): + def status_together_url(self): """ :rtype: str """ - return self._content + return self._status_together_url def is_all_field_none(self): """ @@ -15627,7 +14579,52 @@ def is_all_field_none(self): if self._label_user_creator is not None: return False - if self._content is not None: + if self._status is not None: + return False + + if self._reference_mastercard_action_event is not None: + return False + + if self._mastercard_action_id is not None: + return False + + if self._type_ is not None: + return False + + if self._sub_type is not None: + return False + + if self._reason is not None: + return False + + if self._amount is not None: + return False + + if self._alias is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._label_card is not None: + return False + + if self._time_refund is not None: + return False + + if self._additional_information is not None: + return False + + if self._status_description is not None: + return False + + if self._status_description_translated is not None: + return False + + if self._status_together_url is not None: return False return True @@ -15637,304 +14634,392 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextPaymentBatch + :rtype: MasterCardActionRefundApiObject """ - return converter.json_to_class(NoteTextPaymentBatch, json_str) + return converter.json_to_class(MasterCardActionRefundApiObject, json_str) -class NoteAttachmentPayment(core.BunqModel): +class CashbackPayoutItemApiObject(BunqModel): """ - Used to manage attachment notes. + Cashback payout item details. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _status: The status of the cashback payout item. + :type _status: str + :param _amount: The amount of cashback earned. + :type _amount: object_.Amount + :param _rate_applied: The cashback rate. + :type _rate_applied: str + :param _transaction_category: The transaction category that this cashback is + for. + :type _transaction_category: AdditionalTransactionInformationCategory + :param _user_partner_promotion: The partner promotion that this cashback is + for. + :type _user_partner_promotion: UserPartnerPromotionCashback """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" + _status = None + _amount = None + _rate_applied = None + _transaction_category = None + _user_partner_promotion = None - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + @property + def status(self): + """ + :rtype: str + """ - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + return self._status - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + @property + def amount(self): + """ + :rtype: object_.Amount + """ - def __init__(self, attachment_id, description=None): + return self._amount + + @property + def rate_applied(self): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :rtype: str """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + return self._rate_applied - @classmethod - def create(cls, payment_id, attachment_id, monetary_account_id=None, - description=None, custom_headers=None): + @property + def transaction_category(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: AdditionalTransactionInformationCategory """ - if custom_headers is None: - custom_headers = {} + return self._transaction_category - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + @property + def user_partner_promotion(self): + """ + :rtype: UserPartnerPromotionCashback + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + return self._user_partner_promotion - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + def is_all_field_none(self): + """ + :rtype: bool + """ - @classmethod - def update(cls, payment_id, note_attachment_payment_id, - monetary_account_id=None, description=None, custom_headers=None): + if self._status is not None: + return False + + if self._amount is not None: + return False + + if self._rate_applied is not None: + return False + + if self._transaction_category is not None: + return False + + if self._user_partner_promotion is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_attachment_payment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: CashbackPayoutItemApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(CashbackPayoutItemApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) +class UserPartnerPromotionCashbackApiObject(BunqModel): + """ + Endpoint to specify that a user signed up using a promotion code. + + :param _promotion_code: The promotion code used in signup to indicate the + partner that referred the user. + :type _promotion_code: str + :param _status: The status of the user partner promotion. + :type _status: str + :param _number_of_transaction_remaining: The number of transactions that are + still eligible for this promotion. + :type _number_of_transaction_remaining: int + :param _partner_promotion: The promotion that the user signed up with. + :type _partner_promotion: PartnerPromotionCashback + """ - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_attachment_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + # Field constants. + FIELD_PROMOTION_CODE = "promotion_code" - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - @classmethod - def delete(cls, payment_id, note_attachment_payment_id, - monetary_account_id=None, custom_headers=None): + _status = None + _number_of_transaction_remaining = None + _partner_promotion = None + _promotion_code_field_for_request = None + + def __init__(self, promotion_code): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_attachment_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :param promotion_code: The promotion code used in signup to indicate the + partner that referred the user. + :type promotion_code: str """ - if custom_headers is None: - custom_headers = {} + self._promotion_code_field_for_request = promotion_code - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_attachment_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - @classmethod - def list(cls, payment_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def status(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentPaymentList + :rtype: str """ - if params is None: - params = {} + return self._status - if custom_headers is None: - custom_headers = {} + @property + def number_of_transaction_remaining(self): + """ + :rtype: int + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), payment_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._number_of_transaction_remaining - return BunqResponseNoteAttachmentPaymentList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def partner_promotion(self): + """ + :rtype: PartnerPromotionCashback + """ - @classmethod - def get(cls, payment_id, note_attachment_payment_id, - monetary_account_id=None, custom_headers=None): + return self._partner_promotion + + def is_all_field_none(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_attachment_payment_id: int - :type custom_headers: dict[str, str]|None + :rtype: bool + """ + + if self._status is not None: + return False + + if self._number_of_transaction_remaining is not None: + return False + + if self._partner_promotion is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str - :rtype: BunqResponseNoteAttachmentPayment + :rtype: UserPartnerPromotionCashbackApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(UserPartnerPromotionCashbackApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_attachment_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNoteAttachmentPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) +class PartnerPromotionCashbackApiObject(BunqModel): + """ + Read the publicly available information of a partner’s promotion. + + :param _public_uuid: The public UUID of the cashback promotion. + :type _public_uuid: str + :param _status: The status of the cashback promotion. + :type _status: str + :param _promotion_code: The promotion code used in signup to indicate the + partner that referred the user. + :type _promotion_code: str + :param _amount_cashback_per_transaction_maximum: The amount of cashback per + transaction, will not be higher than the amount of the transaction. + :type _amount_cashback_per_transaction_maximum: object_.Amount + :param _number_of_transaction_maximum: The maximum number of transactions + that can be made. + :type _number_of_transaction_maximum: int + :param _amount_transaction_minimum: The minimum amount of a transaction. + :type _amount_transaction_minimum: object_.Amount + :param _url_together: The URL to the Together page with FAQs about this + promotion. + :type _url_together: str + :param _deeplink: The deeplink to the cashback promotion. + :type _deeplink: str + :param _partner_name: The name of the partner. + :type _partner_name: str + :param _partner_avatar: The avatar of the partner. + :type _partner_avatar: object_.Avatar + :param _promotion_title_short: The short title of the promotion. + :type _promotion_title_short: list[str] + :param _promotion_title_long: The long title of the promotion. + :type _promotion_title_long: list[str] + :param _promotion_description: The description of the promotion. + :type _promotion_description: list[str] + """ + + _public_uuid = None + _status = None + _promotion_code = None + _amount_cashback_per_transaction_maximum = None + _number_of_transaction_maximum = None + _amount_transaction_minimum = None + _url_together = None + _deeplink = None + _partner_name = None + _partner_avatar = None + _promotion_title_short = None + _promotion_title_long = None + _promotion_description = None @property - def id_(self): + def public_uuid(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._public_uuid @property - def created(self): + def status(self): """ :rtype: str """ - return self._created + return self._status @property - def updated(self): + def promotion_code(self): """ :rtype: str """ - return self._updated + return self._promotion_code @property - def label_user_creator(self): + def amount_cashback_per_transaction_maximum(self): """ - :rtype: object_.LabelUser + :rtype: object_.Amount """ - return self._label_user_creator + return self._amount_cashback_per_transaction_maximum @property - def description(self): + def number_of_transaction_maximum(self): + """ + :rtype: int + """ + + return self._number_of_transaction_maximum + + @property + def amount_transaction_minimum(self): + """ + :rtype: object_.Amount + """ + + return self._amount_transaction_minimum + + @property + def url_together(self): """ :rtype: str """ - return self._description + return self._url_together @property - def attachment(self): + def deeplink(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._deeplink + + @property + def partner_name(self): + """ + :rtype: str + """ + + return self._partner_name + + @property + def partner_avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._partner_avatar + + @property + def promotion_title_short(self): + """ + :rtype: list[str] + """ + + return self._promotion_title_short + + @property + def promotion_title_long(self): + """ + :rtype: list[str] + """ + + return self._promotion_title_long + + @property + def promotion_description(self): + """ + :rtype: list[str] + """ + + return self._promotion_description def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._public_uuid is not None: return False - if self._created is not None: + if self._status is not None: return False - if self._updated is not None: + if self._promotion_code is not None: return False - if self._label_user_creator is not None: + if self._amount_cashback_per_transaction_maximum is not None: return False - if self._description is not None: + if self._number_of_transaction_maximum is not None: return False - if self._attachment is not None: + if self._amount_transaction_minimum is not None: + return False + + if self._url_together is not None: + return False + + if self._deeplink is not None: + return False + + if self._partner_name is not None: + return False + + if self._partner_avatar is not None: + return False + + if self._promotion_title_short is not None: + return False + + if self._promotion_title_long is not None: + return False + + if self._promotion_description is not None: return False return True @@ -15944,258 +15029,214 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentPayment + :rtype: PartnerPromotionCashbackApiObject """ - return converter.json_to_class(NoteAttachmentPayment, json_str) + return converter.json_to_class(PartnerPromotionCashbackApiObject, json_str) -class NoteTextPayment(core.BunqModel): +class PointMutationApiObject(BunqModel): """ - Used to manage text notes. + Endpoint to retrieve point mutation. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _number_of_point: The number of points earned. + :type _number_of_point: int """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}/note-text/{}" - - # Field constants. - FIELD_CONTENT = "content" - - # Object type. - _OBJECT_TYPE_GET = "NoteText" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _number_of_point = None - def __init__(self, content=None): + @property + def number_of_point(self): """ - :param content: The content of the note. - :type content: str + :rtype: int """ - self._content_field_for_request = content + return self._number_of_point - @classmethod - def create(cls, payment_id, monetary_account_id=None, content=None, - custom_headers=None): + def is_all_field_none(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: bool """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._number_of_point is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return True - @classmethod - def update(cls, payment_id, note_text_payment_id, monetary_account_id=None, - content=None, custom_headers=None): + @staticmethod + def from_json(json_str): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_text_payment_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: PointMutationApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(PointMutationApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) +class UserBlocklistMasterCardMerchantApiObject(BunqModel): + """ + Fetch blocklists of merchants created by user + + :param _merchant_name: The name of the merchant. + :type _merchant_name: str + :param _merchant_id: The blocklisted merchant. + :type _merchant_id: str + :param _merchant_identifier: Identifier of the merchant we are blocklisting. + :type _merchant_identifier: str + :param _mastercard_merchant_id: The blocklisted merchant. + :type _mastercard_merchant_id: str + :param _external_merchant_id: Externally provided merchant identification. + :type _external_merchant_id: str + :param _id_: The id of the blocklist. + :type _id_: int + :param _created: The timestamp of the object's creation. + :type _created: str + :param _updated: The timestamp of the object's last update. + :type _updated: str + :param _status: The status of the the blocklist. + :type _status: str + :param _merchant_hash: Hash of the merchant we are blocklisting. + :type _merchant_hash: str + :param _merchant_avatar: + :type _merchant_avatar: Avatar + """ - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_text_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + # Field constants. + FIELD_MERCHANT_NAME = "merchant_name" + FIELD_MERCHANT_ID = "merchant_id" + FIELD_MERCHANT_IDENTIFIER = "merchant_identifier" + FIELD_MASTERCARD_MERCHANT_ID = "mastercard_merchant_id" + FIELD_EXTERNAL_MERCHANT_ID = "external_merchant_id" - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - @classmethod - def delete(cls, payment_id, note_text_payment_id, monetary_account_id=None, - custom_headers=None): + _id_ = None + _created = None + _updated = None + _status = None + _merchant_name = None + _merchant_id = None + _merchant_identifier = None + _mastercard_merchant_id = None + _external_merchant_id = None + _merchant_hash = None + _merchant_avatar = None + _merchant_name_field_for_request = None + _merchant_id_field_for_request = None + _merchant_identifier_field_for_request = None + _mastercard_merchant_id_field_for_request = None + _external_merchant_id_field_for_request = None + + def __init__(self, merchant_name, merchant_id=None, merchant_identifier=None, mastercard_merchant_id=None, external_merchant_id=None): + """ + :param merchant_name: The name of the merchant. + :type merchant_name: str + :param merchant_id: The merchant id. + :type merchant_id: str + :param merchant_identifier: Optional identifier of the merchant to + blocklist. + :type merchant_identifier: str + :param mastercard_merchant_id: Master card merchant id. + :type mastercard_merchant_id: str + :param external_merchant_id: Externally provided merchant id. + :type external_merchant_id: str + """ + + self._merchant_name_field_for_request = merchant_name + self._merchant_id_field_for_request = merchant_id + self._merchant_identifier_field_for_request = merchant_identifier + self._mastercard_merchant_id_field_for_request = mastercard_merchant_id + self._external_merchant_id_field_for_request = external_merchant_id + + + + @property + def id_(self): """ - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_text_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._id_ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_text_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def created(self): + """ + :rtype: str + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._created - @classmethod - def list(cls, payment_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def updated(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextPaymentList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._updated - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), payment_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def status(self): + """ + :rtype: str + """ - return BunqResponseNoteTextPaymentList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._status - @classmethod - def get(cls, payment_id, note_text_payment_id, monetary_account_id=None, - custom_headers=None): + @property + def merchant_name(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type payment_id: int - :type note_text_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextPayment + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._merchant_name - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - payment_id, - note_text_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def merchant_id(self): + """ + :rtype: str + """ - return BunqResponseNoteTextPayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._merchant_id @property - def id_(self): + def merchant_identifier(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._merchant_identifier @property - def created(self): + def mastercard_merchant_id(self): """ :rtype: str """ - return self._created + return self._mastercard_merchant_id @property - def updated(self): + def external_merchant_id(self): """ :rtype: str """ - return self._updated + return self._external_merchant_id @property - def label_user_creator(self): + def merchant_hash(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._merchant_hash @property - def content(self): + def merchant_avatar(self): """ - :rtype: str + :rtype: Avatar """ - return self._content + return self._merchant_avatar def is_all_field_none(self): """ @@ -16211,10 +15252,28 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._status is not None: return False - if self._content is not None: + if self._merchant_name is not None: + return False + + if self._merchant_id is not None: + return False + + if self._merchant_identifier is not None: + return False + + if self._mastercard_merchant_id is not None: + return False + + if self._external_merchant_id is not None: + return False + + if self._merchant_hash is not None: + return False + + if self._merchant_avatar is not None: return False return True @@ -16224,308 +15283,185 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextPayment + :rtype: UserBlocklistMasterCardMerchantApiObject """ - return converter.json_to_class(NoteTextPayment, json_str) + return converter.json_to_class(UserBlocklistMasterCardMerchantApiObject, json_str) -class NoteAttachmentRequestInquiryBatch(core.BunqModel): +class MasterCardActionReportApiObject(BunqModel): """ - Used to manage attachment notes. + MasterCard report view. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _mastercard_action_id: The id of mastercard action being reported. + :type _mastercard_action_id: int + :param _type_: The id of mastercard action being reported. + :type _type_: str + :param _status: The id of mastercard action being reported. + :type _status: str + :param _merchant_id: The reported merchant. + :type _merchant_id: str + :param _merchant_name: The name of the merchant. + :type _merchant_name: str + :param _counterparty_alias: The monetary account label of the merchant. + :type _counterparty_alias: object_.MonetaryAccountReference """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_MASTERCARD_ACTION_ID = "mastercard_action_id" + FIELD_TYPE = "type" + FIELD_STATUS = "status" - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + _mastercard_action_id = None + _type_ = None + _status = None + _merchant_id = None + _merchant_name = None + _counterparty_alias = None + _mastercard_action_id_field_for_request = None + _type__field_for_request = None + _status_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, mastercard_action_id, type_, status=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :param mastercard_action_id: The id of mastercard action being reported. + :type mastercard_action_id: int + :param type_: The type of report. Can be 'FRAUD' or 'MERCHANT_BLOCKED'. + :type type_: str + :param status: The id of mastercard action being reported. + :type status: str """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description - - @classmethod - def create(cls, request_inquiry_batch_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + self._mastercard_action_id_field_for_request = mastercard_action_id + self._type__field_for_request = type_ + self._status_field_for_request = status - if custom_headers is None: - custom_headers = {} - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def mastercard_action_id(self): + """ + :rtype: int + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._mastercard_action_id - @classmethod - def update(cls, request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id, - monetary_account_id=None, description=None, custom_headers=None): + @property + def type_(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type note_attachment_request_inquiry_batch_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._type_ - api_client = client.ApiClient(cls._get_api_context()) + @property + def status(self): + """ + :rtype: str + """ - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._status - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def merchant_id(self): + """ + :rtype: str + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._merchant_id - @classmethod - def delete(cls, request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id, - monetary_account_id=None, custom_headers=None): + @property + def merchant_name(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type note_attachment_request_inquiry_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._merchant_name - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._counterparty_alias - @classmethod - def list(cls, request_inquiry_batch_id, monetary_account_id=None, - params=None, custom_headers=None): + def is_all_field_none(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentRequestInquiryBatchList + :rtype: bool """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + if self._mastercard_action_id is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_inquiry_batch_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + if self._type_ is not None: + return False - return BunqResponseNoteAttachmentRequestInquiryBatchList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + if self._status is not None: + return False - @classmethod - def get(cls, request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id, monetary_account_id=None, - custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type note_attachment_request_inquiry_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentRequestInquiryBatch - """ + if self._merchant_id is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._merchant_name is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_attachment_request_inquiry_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + if self._counterparty_alias is not None: + return False - return BunqResponseNoteAttachmentRequestInquiryBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return True - @property - def id_(self): + @staticmethod + def from_json(json_str): """ - :rtype: int + :type json_str: str + + :rtype: MasterCardActionReportApiObject """ - return self._id_ + return converter.json_to_class(MasterCardActionReportApiObject, json_str) - @property - def created(self): - """ - :rtype: str - """ - return self._created +class CompanyEmployeeCardReceiptApiObject(BunqModel): + """ + The receipt the company employee has provided for a transaction. + + :param _status: The status of the receipt. + :type _status: str + """ - @property - def updated(self): - """ - :rtype: str - """ + # Field constants. + FIELD_STATUS = "status" - return self._updated - @property - def label_user_creator(self): + _status = None + _status_field_for_request = None + + def __init__(self, status=None): """ - :rtype: object_.LabelUser + :param status: Update the status of this receipt. + :type status: str """ - return self._label_user_creator + self._status_field_for_request = status - @property - def description(self): - """ - :rtype: str - """ - return self._description @property - def attachment(self): + def status(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._status def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._label_user_creator is not None: - return False - - if self._description is not None: - return False - - if self._attachment is not None: + if self._status is not None: return False return True @@ -16535,66 +15471,96 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentRequestInquiryBatch + :rtype: CompanyEmployeeCardReceiptApiObject """ - return converter.json_to_class(NoteAttachmentRequestInquiryBatch, - json_str) + return converter.json_to_class(CompanyEmployeeCardReceiptApiObject, json_str) -class NoteTextRequestInquiryBatch(core.BunqModel): +class RequestInquiryBatchApiObject(BunqModel): """ - Used to manage text notes. + Create a batch of requests for payment, or show the request batches of a + monetary account. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _request_inquiries: The list of requests that were made. + :type _request_inquiries: list[RequestInquiry] + :param _status: The status of the request. + :type _status: str + :param _total_amount_inquired: The total amount originally inquired for this + batch. + :type _total_amount_inquired: object_.Amount + :param _event_id: The ID of the associated event if the request batch was + made using 'split the bill'. + :type _event_id: int + :param _reference_split_the_bill: The reference to the object used for split + the bill. Can be Payment, PaymentBatch, ScheduleInstance, RequestResponse + and MasterCardAction + :type _reference_split_the_bill: + object_.RequestReferenceSplitTheBillAnchorObject """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch" # Field constants. - FIELD_CONTENT = "content" + FIELD_REQUEST_INQUIRIES = "request_inquiries" + FIELD_STATUS = "status" + FIELD_TOTAL_AMOUNT_INQUIRED = "total_amount_inquired" + FIELD_EVENT_ID = "event_id" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "RequestInquiryBatch" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _request_inquiries = None + _total_amount_inquired = None + _reference_split_the_bill = None + _request_inquiries_field_for_request = None + _status_field_for_request = None + _total_amount_inquired_field_for_request = None + _event_id_field_for_request = None - def __init__(self, content=None): + def __init__(self, request_inquiries, total_amount_inquired, status=None, event_id=None): """ - :param content: The content of the note. - :type content: str + :param request_inquiries: The list of request inquiries we want to send in 1 + batch. + :type request_inquiries: list[RequestInquiry] + :param total_amount_inquired: The total amount originally inquired for this + batch. + :type total_amount_inquired: object_.Amount + :param status: The status of the request. + :type status: str + :param event_id: The ID of the associated event if the request batch was + made using 'split the bill'. + :type event_id: int """ - self._content_field_for_request = content + self._request_inquiries_field_for_request = request_inquiries + self._total_amount_inquired_field_for_request = total_amount_inquired + self._status_field_for_request = status + self._event_id_field_for_request = event_id @classmethod - def create(cls, request_inquiry_batch_id, monetary_account_id=None, - content=None, custom_headers=None): + def create(cls,request_inquiries, total_amount_inquired, monetary_account_id=None, status=None, event_id=None, custom_headers=None): """ + Create a request batch by sending an array of single request objects, + that will become part of the batch. + :type user_id: int :type monetary_account_id: int - :type request_inquiry_batch_id: int - :param content: The content of the note. - :type content: str + :param request_inquiries: The list of request inquiries we want to send + in 1 batch. + :type request_inquiries: list[RequestInquiry] + :param total_amount_inquired: The total amount originally inquired for + this batch. + :type total_amount_inquired: object_.Amount + :param status: The status of the request. + :type status: str + :param event_id: The ID of the associated event if the request batch was + made using 'split the bill'. + :type event_id: int :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -16604,35 +15570,34 @@ def create(cls, request_inquiry_batch_id, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_REQUEST_INQUIRIES : request_inquiries, +cls.FIELD_STATUS : status, +cls.FIELD_TOTAL_AMOUNT_INQUIRED : total_amount_inquired, +cls.FIELD_EVENT_ID : event_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, request_inquiry_batch_id, - note_text_request_inquiry_batch_id, monetary_account_id=None, - content=None, custom_headers=None): + def update(cls, request_inquiry_batch_id, monetary_account_id=None, status=None, custom_headers=None): """ + Revoke a request batch. The status of all the requests will be set to + REVOKED. + :type user_id: int :type monetary_account_id: int :type request_inquiry_batch_id: int - :type note_text_request_inquiry_batch_id: int - :param content: The content of the note. - :type content: str + :param status: The status of the request. + :type status: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -16641,69 +15606,58 @@ def update(cls, request_inquiry_batch_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_text_request_inquiry_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, request_inquiry_batch_id, - note_text_request_inquiry_batch_id, monetary_account_id=None, - custom_headers=None): + def get(cls, request_inquiry_batch_id, monetary_account_id=None, custom_headers=None): """ + Return the details of a specific request batch. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int :type request_inquiry_batch_id: int - :type note_text_request_inquiry_batch_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseRequestInquiryBatch """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_text_request_inquiry_batch_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseRequestInquiryBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, request_inquiry_batch_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + Return all the request batches for a monetary account. :type user_id: int :type monetary_account_id: int - :type request_inquiry_batch_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextRequestInquiryBatchList + :rtype: BunqResponseRequestInquiryBatchList """ if params is None: @@ -16712,104 +15666,50 @@ def list(cls, request_inquiry_batch_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_inquiry_batch_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextRequestInquiryBatchList.cast_from_bunq_response( + return BunqResponseRequestInquiryBatchList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, request_inquiry_batch_id, note_text_request_inquiry_batch_id, - monetary_account_id=None, custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type note_text_request_inquiry_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextRequestInquiryBatch - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id, - note_text_request_inquiry_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteTextRequestInquiryBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created - @property - def updated(self): + def request_inquiries(self): """ - :rtype: str + :rtype: list[RequestInquiry] """ - return self._updated + return self._request_inquiries @property - def label_user_creator(self): + def total_amount_inquired(self): """ - :rtype: object_.LabelUser + :rtype: object_.Amount """ - return self._label_user_creator + return self._total_amount_inquired @property - def content(self): + def reference_split_the_bill(self): """ - :rtype: str + :rtype: object_.RequestReferenceSplitTheBillAnchorObject """ - return self._content + return self._reference_split_the_bill def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: + if self._request_inquiries is not None: return False - if self._label_user_creator is not None: + if self._total_amount_inquired is not None: return False - if self._content is not None: + if self._reference_split_the_bill is not None: return False return True @@ -16819,80 +15719,292 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextRequestInquiryBatch + :rtype: RequestInquiryBatchApiObject """ - return converter.json_to_class(NoteTextRequestInquiryBatch, json_str) + return converter.json_to_class(RequestInquiryBatchApiObject, json_str) -class NoteAttachmentRequestInquiry(core.BunqModel): +class RequestInquiryApiObject(BunqModel): """ - Used to manage attachment notes. + RequestInquiry, aka 'RFP' (Request for Payment), is one of the innovative + features that bunq offers. To request payment from another bunq account a + new Request Inquiry is created. As with payments you can add attachments to + a RFP. Requests for Payment are the foundation for a number of consumer + features like 'Split the bill' and 'Request forwarding'. We invite you to + invent your own based on the bunq api! - :param _description: Optional description of the attachment. + :param _amount_inquired: The requested amount. + :type _amount_inquired: object_.Amount + :param _counterparty_alias: The LabelMonetaryAccount with the public + information of the MonetaryAccount the money was requested from. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description of the inquiry. :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + :param _attachment: The attachments attached to the payment. + :type _attachment: list[object_.BunqId] + :param _merchant_reference: The client's custom reference that was attached + to the request and the mutation. + :type _merchant_reference: str + :param _status: The status of the request. + :type _status: str + :param _minimum_age: The minimum age the user accepting the RequestInquiry + must have. + :type _minimum_age: int + :param _require_address: Whether or not an address must be provided on + accept. + :type _require_address: str + :param _want_tip: [DEPRECATED] Whether or not the accepting user can give an + extra tip on top of the requested Amount. Defaults to false. + :type _want_tip: bool + :param _allow_amount_lower: [DEPRECATED] Whether or not the accepting user + can choose to accept with a lower amount than requested. Defaults to false. + :type _allow_amount_lower: bool + :param _allow_amount_higher: [DEPRECATED] Whether or not the accepting user + can choose to accept with a higher amount than requested. Defaults to false. + :type _allow_amount_higher: bool + :param _allow_bunqme: Whether or not sending a bunq.me request is allowed. + :type _allow_bunqme: bool + :param _redirect_url: The URL which the user is sent to after accepting or + rejecting the Request. + :type _redirect_url: str + :param _event_id: The ID of the associated event if the request was made + using 'split the bill'. + :type _event_id: int + :param _id_: The id of the created RequestInquiry. :type _id_: int - :param _created: The timestamp of the note's creation. + :param _created: The timestamp of the payment request's creation. :type _created: str - :param _updated: The timestamp of the note's last update. + :param _updated: The timestamp of the payment request's last update. :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _time_responded: The timestamp of when the payment request was + responded to. + :type _time_responded: str + :param _time_expiry: The timestamp of when the payment request expired. + :type _time_expiry: str + :param _monetary_account_id: The id of the monetary account the request + response applies to. + :type _monetary_account_id: int + :param _amount_responded: The responded amount. + :type _amount_responded: object_.Amount + :param _user_alias_created: The label that's displayed to the counterparty + with the mutation. Includes user. + :type _user_alias_created: object_.LabelUser + :param _user_alias_revoked: The label that's displayed to the counterparty + with the mutation. Includes user. + :type _user_alias_revoked: object_.LabelUser + :param _batch_id: The id of the batch if the request was part of a batch. + :type _batch_id: int + :param _scheduled_id: The id of the scheduled job if the request was + scheduled. + :type _scheduled_id: int + :param _bunqme_share_url: The url that points to the bunq.me request. + :type _bunqme_share_url: str + :param _address_shipping: The shipping address provided by the accepting + user if an address was requested. + :type _address_shipping: object_.Address + :param _address_billing: The billing address provided by the accepting user + if an address was requested. + :type _address_billing: object_.Address + :param _geolocation: The geolocation where the payment was done. + :type _geolocation: object_.Geolocation + :param _reference_split_the_bill: The reference to the object used for split + the bill. Can be Payment, PaymentBatch, ScheduleInstance, RequestResponse + and MasterCardAction + :type _reference_split_the_bill: + object_.RequestReferenceSplitTheBillAnchorObject """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}" # Field constants. + FIELD_AMOUNT_INQUIRED = "amount_inquired" + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" - - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None + FIELD_ATTACHMENT = "attachment" + FIELD_MERCHANT_REFERENCE = "merchant_reference" + FIELD_STATUS = "status" + FIELD_MINIMUM_AGE = "minimum_age" + FIELD_REQUIRE_ADDRESS = "require_address" + FIELD_WANT_TIP = "want_tip" + FIELD_ALLOW_AMOUNT_LOWER = "allow_amount_lower" + FIELD_ALLOW_AMOUNT_HIGHER = "allow_amount_higher" + FIELD_ALLOW_BUNQME = "allow_bunqme" + FIELD_REDIRECT_URL = "redirect_url" + FIELD_EVENT_ID = "event_id" + + # Object type. + _OBJECT_TYPE_PUT = "RequestInquiry" + _OBJECT_TYPE_GET = "RequestInquiry" + + _id_ = None + _created = None + _updated = None + _time_responded = None + _time_expiry = None + _monetary_account_id = None + _amount_inquired = None + _amount_responded = None + _user_alias_created = None + _user_alias_revoked = None + _counterparty_alias = None + _description = None + _merchant_reference = None _attachment = None + _status = None + _batch_id = None + _scheduled_id = None + _minimum_age = None + _require_address = None + _bunqme_share_url = None + _redirect_url = None + _address_shipping = None + _address_billing = None + _geolocation = None + _reference_split_the_bill = None + _amount_inquired_field_for_request = None + _counterparty_alias_field_for_request = None _description_field_for_request = None - _attachment_id_field_for_request = None + _attachment_field_for_request = None + _merchant_reference_field_for_request = None + _status_field_for_request = None + _minimum_age_field_for_request = None + _require_address_field_for_request = None + _want_tip_field_for_request = None + _allow_amount_lower_field_for_request = None + _allow_amount_higher_field_for_request = None + _allow_bunqme_field_for_request = None + _redirect_url_field_for_request = None + _event_id_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, amount_inquired, counterparty_alias, description, allow_bunqme, attachment=None, merchant_reference=None, status=None, minimum_age=None, require_address=None, want_tip=None, allow_amount_lower=None, allow_amount_higher=None, redirect_url=None, event_id=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. + :param amount_inquired: The Amount requested to be paid by the person the + RequestInquiry is sent to. Must be bigger than 0. + :type amount_inquired: object_.Amount + :param counterparty_alias: The Alias of the party we are requesting the + money from. Can be an Alias of type EMAIL, PHONE_NUMBER or IBAN. In case the + EMAIL or PHONE_NUMBER Alias does not refer to a bunq monetary account, + 'allow_bunqme' needs to be 'true' in order to trigger the creation of a + bunq.me request. Otherwise no request inquiry will be sent. + :type counterparty_alias: object_.Pointer + :param description: The description for the RequestInquiry. Maximum 9000 + characters. Field is required but can be an empty string. :type description: str + :param allow_bunqme: Whether or not sending a bunq.me request is allowed. + :type allow_bunqme: bool + :param attachment: The Attachments to attach to the RequestInquiry. + :type attachment: list[object_.BunqId] + :param merchant_reference: Optional data to be included with the + RequestInquiry specific to the merchant. Has to be unique for the same + source MonetaryAccount. + :type merchant_reference: str + :param status: The status of the RequestInquiry. Ignored in POST requests + but can be used for revoking (cancelling) the RequestInquiry by setting + REVOKED with a PUT request. + :type status: str + :param minimum_age: The minimum age the user accepting the RequestInquiry + must have. Defaults to not checking. If set, must be between 12 and 100 + inclusive. + :type minimum_age: int + :param require_address: Whether a billing and shipping address must be + provided when paying the request. Possible values are: BILLING, SHIPPING, + BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. + :type require_address: str + :param want_tip: [DEPRECATED] Whether or not the accepting user can give an + extra tip on top of the requested Amount. Defaults to false. + :type want_tip: bool + :param allow_amount_lower: [DEPRECATED] Whether or not the accepting user + can choose to accept with a lower amount than requested. Defaults to false. + :type allow_amount_lower: bool + :param allow_amount_higher: [DEPRECATED] Whether or not the accepting user + can choose to accept with a higher amount than requested. Defaults to false. + :type allow_amount_higher: bool + :param redirect_url: The URL which the user is sent to after accepting or + rejecting the Request. + :type redirect_url: str + :param event_id: The ID of the associated event if the request was made + using 'split the bill'. + :type event_id: int """ - self._attachment_id_field_for_request = attachment_id + self._amount_inquired_field_for_request = amount_inquired + self._counterparty_alias_field_for_request = counterparty_alias self._description_field_for_request = description + self._allow_bunqme_field_for_request = allow_bunqme + self._attachment_field_for_request = attachment + self._merchant_reference_field_for_request = merchant_reference + self._status_field_for_request = status + self._minimum_age_field_for_request = minimum_age + self._require_address_field_for_request = require_address + self._want_tip_field_for_request = want_tip + self._allow_amount_lower_field_for_request = allow_amount_lower + self._allow_amount_higher_field_for_request = allow_amount_higher + self._redirect_url_field_for_request = redirect_url + self._event_id_field_for_request = event_id @classmethod - def create(cls, request_inquiry_id, attachment_id, monetary_account_id=None, - description=None, custom_headers=None): + def create(cls,amount_inquired, counterparty_alias, description, allow_bunqme, monetary_account_id=None, attachment=None, merchant_reference=None, status=None, minimum_age=None, require_address=None, want_tip=None, allow_amount_lower=None, allow_amount_higher=None, redirect_url=None, event_id=None, custom_headers=None): """ + Create a new payment request. + :type user_id: int :type monetary_account_id: int - :type request_inquiry_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. + :param amount_inquired: The Amount requested to be paid by the person + the RequestInquiry is sent to. Must be bigger than 0. + :type amount_inquired: object_.Amount + :param counterparty_alias: The Alias of the party we are requesting the + money from. Can be an Alias of type EMAIL, PHONE_NUMBER or IBAN. In case + the EMAIL or PHONE_NUMBER Alias does not refer to a bunq monetary + account, 'allow_bunqme' needs to be 'true' in order to trigger the + creation of a bunq.me request. Otherwise no request inquiry will be + sent. + :type counterparty_alias: object_.Pointer + :param description: The description for the RequestInquiry. Maximum 9000 + characters. Field is required but can be an empty string. :type description: str + :param allow_bunqme: Whether or not sending a bunq.me request is + allowed. + :type allow_bunqme: bool + :param attachment: The Attachments to attach to the RequestInquiry. + :type attachment: list[object_.BunqId] + :param merchant_reference: Optional data to be included with the + RequestInquiry specific to the merchant. Has to be unique for the same + source MonetaryAccount. + :type merchant_reference: str + :param status: The status of the RequestInquiry. Ignored in POST + requests but can be used for revoking (cancelling) the RequestInquiry by + setting REVOKED with a PUT request. + :type status: str + :param minimum_age: The minimum age the user accepting the + RequestInquiry must have. Defaults to not checking. If set, must be + between 12 and 100 inclusive. + :type minimum_age: int + :param require_address: Whether a billing and shipping address must be + provided when paying the request. Possible values are: BILLING, + SHIPPING, BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. + :type require_address: str + :param want_tip: [DEPRECATED] Whether or not the accepting user can give + an extra tip on top of the requested Amount. Defaults to false. + :type want_tip: bool + :param allow_amount_lower: [DEPRECATED] Whether or not the accepting + user can choose to accept with a lower amount than requested. Defaults + to false. + :type allow_amount_lower: bool + :param allow_amount_higher: [DEPRECATED] Whether or not the accepting + user can choose to accept with a higher amount than requested. Defaults + to false. + :type allow_amount_higher: bool + :param redirect_url: The URL which the user is sent to after accepting + or rejecting the Request. + :type redirect_url: str + :param event_id: The ID of the associated event if the request was made + using 'split the bill'. + :type event_id: int :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -16902,105 +16014,81 @@ def create(cls, request_inquiry_id, attachment_id, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } +cls.FIELD_AMOUNT_INQUIRED : amount_inquired, +cls.FIELD_COUNTERPARTY_ALIAS : counterparty_alias, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT : attachment, +cls.FIELD_MERCHANT_REFERENCE : merchant_reference, +cls.FIELD_STATUS : status, +cls.FIELD_MINIMUM_AGE : minimum_age, +cls.FIELD_REQUIRE_ADDRESS : require_address, +cls.FIELD_WANT_TIP : want_tip, +cls.FIELD_ALLOW_AMOUNT_LOWER : allow_amount_lower, +cls.FIELD_ALLOW_AMOUNT_HIGHER : allow_amount_higher, +cls.FIELD_ALLOW_BUNQME : allow_bunqme, +cls.FIELD_REDIRECT_URL : redirect_url, +cls.FIELD_EVENT_ID : event_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, request_inquiry_id, note_attachment_request_inquiry_id, - monetary_account_id=None, description=None, custom_headers=None): + def update(cls, request_inquiry_id, monetary_account_id=None, status=None, custom_headers=None): """ + Revoke a request for payment, by updating the status to REVOKED. + :type user_id: int :type monetary_account_id: int :type request_inquiry_id: int - :type note_attachment_request_inquiry_id: int - :param description: Optional description of the attachment. - :type description: str + :param status: The status of the RequestInquiry. Ignored in POST + requests but can be used for revoking (cancelling) the RequestInquiry by + setting REVOKED with a PUT request. + :type status: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseRequestInquiry """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_attachment_request_inquiry_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def delete(cls, request_inquiry_id, note_attachment_request_inquiry_id, - monetary_account_id=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :type note_attachment_request_inquiry_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_attachment_request_inquiry_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseRequestInquiry.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) ) @classmethod - def list(cls, request_inquiry_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get all payment requests for a user's monetary account. bunqme_share_url + is always null if the counterparty is a bunq user. :type user_id: int :type monetary_account_id: int - :type request_inquiry_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentRequestInquiryList + :rtype: BunqResponseRequestInquiryList """ if params is None: @@ -17009,43 +16097,37 @@ def list(cls, request_inquiry_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_inquiry_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentRequestInquiryList.cast_from_bunq_response( + return BunqResponseRequestInquiryList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, request_inquiry_id, note_attachment_request_inquiry_id, - monetary_account_id=None, custom_headers=None): + def get(cls, request_inquiry_id, monetary_account_id=None, custom_headers=None): """ - :type api_context: context.ApiContext + Get the details of a specific payment request, including its status. + bunqme_share_url is always null if the counterparty is a bunq user. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int :type request_inquiry_id: int - :type note_attachment_request_inquiry_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentRequestInquiry + :rtype: BunqResponseRequestInquiry """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_attachment_request_inquiry_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNoteAttachmentRequestInquiry.cast_from_bunq_response( + return BunqResponseRequestInquiry.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @@ -17074,312 +16156,180 @@ def updated(self): return self._updated @property - def label_user_creator(self): + def time_responded(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._time_responded @property - def description(self): + def time_expiry(self): """ :rtype: str """ - return self._description + return self._time_expiry @property - def attachment(self): + def monetary_account_id(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: int """ - return self._attachment + return self._monetary_account_id - def is_all_field_none(self): + @property + def amount_inquired(self): """ - :rtype: bool + :rtype: object_.Amount """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._label_user_creator is not None: - return False - - if self._description is not None: - return False - - if self._attachment is not None: - return False - - return True + return self._amount_inquired - @staticmethod - def from_json(json_str): + @property + def amount_responded(self): """ - :type json_str: str - - :rtype: NoteAttachmentRequestInquiry + :rtype: object_.Amount """ - return converter.json_to_class(NoteAttachmentRequestInquiry, json_str) - - -class NoteTextRequestInquiry(core.BunqModel): - """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" - - # Field constants. - FIELD_CONTENT = "content" - - # Object type. - _OBJECT_TYPE_GET = "NoteText" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + return self._amount_responded - def __init__(self, content=None): + @property + def user_alias_created(self): """ - :param content: The content of the note. - :type content: str + :rtype: object_.LabelUser """ - self._content_field_for_request = content + return self._user_alias_created - @classmethod - def create(cls, request_inquiry_id, monetary_account_id=None, content=None, - custom_headers=None): + @property + def user_alias_revoked(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.LabelUser """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._user_alias_revoked - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._counterparty_alias - @classmethod - def update(cls, request_inquiry_id, note_text_request_inquiry_id, - monetary_account_id=None, content=None, custom_headers=None): + @property + def description(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :type note_text_request_inquiry_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._description - api_client = client.ApiClient(cls._get_api_context()) + @property + def merchant_reference(self): + """ + :rtype: str + """ - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._merchant_reference - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_text_request_inquiry_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def attachment(self): + """ + :rtype: list[object_.BunqId] + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._attachment - @classmethod - def delete(cls, request_inquiry_id, note_text_request_inquiry_id, - monetary_account_id=None, custom_headers=None): + @property + def status(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :type note_text_request_inquiry_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._status - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_text_request_inquiry_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def batch_id(self): + """ + :rtype: int + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._batch_id - @classmethod - def list(cls, request_inquiry_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def scheduled_id(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextRequestInquiryList + :rtype: int """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._scheduled_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_inquiry_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def minimum_age(self): + """ + :rtype: int + """ - return BunqResponseNoteTextRequestInquiryList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._minimum_age - @classmethod - def get(cls, request_inquiry_id, note_text_request_inquiry_id, - monetary_account_id=None, custom_headers=None): + @property + def require_address(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_id: int - :type note_text_request_inquiry_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextRequestInquiry + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._require_address - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id, - note_text_request_inquiry_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def bunqme_share_url(self): + """ + :rtype: str + """ - return BunqResponseNoteTextRequestInquiry.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._bunqme_share_url @property - def id_(self): + def redirect_url(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._redirect_url @property - def created(self): + def address_shipping(self): """ - :rtype: str + :rtype: object_.Address """ - return self._created + return self._address_shipping @property - def updated(self): + def address_billing(self): """ - :rtype: str + :rtype: object_.Address """ - return self._updated + return self._address_billing @property - def label_user_creator(self): + def geolocation(self): """ - :rtype: object_.LabelUser + :rtype: object_.Geolocation """ - return self._label_user_creator + return self._geolocation @property - def content(self): + def reference_split_the_bill(self): """ - :rtype: str + :rtype: object_.RequestReferenceSplitTheBillAnchorObject """ - return self._content + return self._reference_split_the_bill def is_all_field_none(self): """ @@ -17395,201 +16345,328 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._time_responded is not None: return False - if self._content is not None: + if self._time_expiry is not None: return False - return True + if self._monetary_account_id is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: NoteTextRequestInquiry - """ + if self._amount_inquired is not None: + return False - return converter.json_to_class(NoteTextRequestInquiry, json_str) + if self._amount_responded is not None: + return False + if self._user_alias_created is not None: + return False -class NoteAttachmentRequestResponse(core.BunqModel): - """ - Used to manage attachment notes. - - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + if self._user_alias_revoked is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._merchant_reference is not None: + return False + + if self._attachment is not None: + return False + + if self._status is not None: + return False + + if self._batch_id is not None: + return False + + if self._scheduled_id is not None: + return False + + if self._minimum_age is not None: + return False + + if self._require_address is not None: + return False + + if self._bunqme_share_url is not None: + return False + + if self._redirect_url is not None: + return False + + if self._address_shipping is not None: + return False + + if self._address_billing is not None: + return False + + if self._geolocation is not None: + return False + + if self._reference_split_the_bill is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: RequestInquiryApiObject + """ + + return converter.json_to_class(RequestInquiryApiObject, json_str) + + +class RequestResponseApiObject(BunqModel): + """ + A RequestResponse is what a user on the other side of a RequestInquiry gets + when he is sent one. So a RequestInquiry is the initiator and visible for + the user that sent it and that wants to receive the money. A RequestResponse + is what the other side sees, i.e. the user that pays the money to accept the + request. The content is almost identical. + + :param _amount_responded: The Amount the RequestResponse was accepted with. + :type _amount_responded: object_.Amount + :param _status: The status of the RequestResponse. Can be ACCEPTED, PENDING, + REJECTED, REFUND_REQUESTED, REFUNDED or REVOKED. + :type _status: str + :param _address_shipping: The shipping address provided by the accepting + user if an address was requested. + :type _address_shipping: object_.Address + :param _address_billing: The billing address provided by the accepting user + if an address was requested. + :type _address_billing: object_.Address + :param _currency_conversion_quote_id: When the request is accepted on a + monetary account with a different currency, a quote is expected to convert. + :type _currency_conversion_quote_id: int + :param _id_: The id of the Request Response. :type _id_: int - :param _created: The timestamp of the note's creation. + :param _created: The timestamp when the Request Response was created. :type _created: str - :param _updated: The timestamp of the note's last update. + :param _updated: The timestamp when the Request Response was last updated + (will be updated when chat messages are received). :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _time_responded: The timestamp of when the RequestResponse was + responded to. + :type _time_responded: str + :param _time_expiry: The timestamp of when the RequestResponse expired or + will expire. + :type _time_expiry: str + :param _time_refund_requested: The timestamp of when a refund request for + the RequestResponse was claimed. + :type _time_refund_requested: str + :param _time_refunded: The timestamp of when the RequestResponse was + refunded. + :type _time_refunded: str + :param _user_refund_requested: The label of the user that requested the + refund. + :type _user_refund_requested: object_.LabelUser + :param _monetary_account_id: The id of the MonetaryAccount the + RequestResponse was received on. + :type _monetary_account_id: int + :param _amount_inquired: The requested Amount. + :type _amount_inquired: object_.Amount + :param _description: The description for the RequestResponse provided by the + requesting party. Maximum 9000 characters. + :type _description: str + :param _alias: The LabelMonetaryAccount with the public information of the + MonetaryAccount this RequestResponse was received on. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The LabelMonetaryAccount with the public + information of the MonetaryAccount that is requesting money with this + RequestResponse. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _attachment: The Attachments attached to the RequestResponse. + :type _attachment: list[object_.Attachment] + :param _minimum_age: The minimum age the user accepting the RequestResponse + must have. + :type _minimum_age: int + :param _require_address: Whether or not an address must be provided on + accept. + :type _require_address: str + :param _geolocation: The Geolocation where the RequestResponse was created. + :type _geolocation: object_.Geolocation + :param _type_: The type of the RequestInquiry. Can be DIRECT_DEBIT, + DIRECT_DEBIT_B2B, IDEAL, SOFORT or INTERNAL. + :type _type_: str + :param _sub_type: The subtype of the RequestInquiry. Can be ONCE or + RECURRING for DIRECT_DEBIT RequestInquiries and NONE for all other. + :type _sub_type: str + :param _redirect_url: The URL which the user is sent to after accepting or + rejecting the Request. + :type _redirect_url: str + :param _credit_scheme_identifier: The credit scheme id provided by the + counterparty for DIRECT_DEBIT inquiries. + :type _credit_scheme_identifier: str + :param _mandate_identifier: The mandate id provided by the counterparty for + DIRECT_DEBIT inquiries. + :type _mandate_identifier: str + :param _registration_action: Recommended registration action after + IdealIssuerTransaction from iDEAL issuer transaction. + :type _registration_action: str + :param _eligible_whitelist_id: The whitelist id for this action or null. + :type _eligible_whitelist_id: int + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] + :param _event_id: The ID of the latest event for the request. + :type _event_id: int + :param _monetary_account_preferred_id: The ID of the monetary account this + user prefers to pay the request from. + :type _monetary_account_preferred_id: int """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-response/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}" # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_AMOUNT_RESPONDED = "amount_responded" + FIELD_STATUS = "status" + FIELD_ADDRESS_SHIPPING = "address_shipping" + FIELD_ADDRESS_BILLING = "address_billing" + FIELD_CURRENCY_CONVERSION_QUOTE_ID = "currency_conversion_quote_id" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + _OBJECT_TYPE_PUT = "RequestResponse" + _OBJECT_TYPE_GET = "RequestResponse" _id_ = None _created = None _updated = None - _label_user_creator = None + _time_responded = None + _time_expiry = None + _time_refund_requested = None + _time_refunded = None + _user_refund_requested = None + _monetary_account_id = None + _amount_inquired = None + _amount_responded = None + _status = None _description = None + _alias = None + _counterparty_alias = None _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + _minimum_age = None + _require_address = None + _geolocation = None + _type_ = None + _sub_type = None + _redirect_url = None + _address_billing = None + _address_shipping = None + _credit_scheme_identifier = None + _mandate_identifier = None + _registration_action = None + _eligible_whitelist_id = None + _request_reference_split_the_bill = None + _event_id = None + _monetary_account_preferred_id = None + _amount_responded_field_for_request = None + _status_field_for_request = None + _address_shipping_field_for_request = None + _address_billing_field_for_request = None + _currency_conversion_quote_id_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, status=None, amount_responded=None, address_shipping=None, address_billing=None, currency_conversion_quote_id=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :param status: The responding status of the RequestResponse. Can be ACCEPTED + or REJECTED. + :type status: str + :param amount_responded: The Amount the user decides to pay. + :type amount_responded: object_.Amount + :param address_shipping: The shipping Address to return to the user who + created the RequestInquiry. Should only be provided if 'require_address' is + set to SHIPPING, BILLING_SHIPPING or OPTIONAL. + :type address_shipping: object_.Address + :param address_billing: The billing Address to return to the user who + created the RequestInquiry. Should only be provided if 'require_address' is + set to BILLING, BILLING_SHIPPING or OPTIONAL. + :type address_billing: object_.Address + :param currency_conversion_quote_id: When the request is accepted on a + monetary account with a different currency, a quote is expected to convert. + :type currency_conversion_quote_id: int """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + self._status_field_for_request = status + self._amount_responded_field_for_request = amount_responded + self._address_shipping_field_for_request = address_shipping + self._address_billing_field_for_request = address_billing + self._currency_conversion_quote_id_field_for_request = currency_conversion_quote_id @classmethod - def create(cls, request_response_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def update(cls, request_response_id, monetary_account_id=None, amount_responded=None, status=None, address_shipping=None, address_billing=None, currency_conversion_quote_id=None, custom_headers=None): """ - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None + Update the status to accept or reject the RequestResponse. - :rtype: BunqResponseInt - """ - - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def update(cls, request_response_id, note_attachment_request_response_id, - monetary_account_id=None, description=None, custom_headers=None): - """ :type user_id: int :type monetary_account_id: int :type request_response_id: int - :type note_attachment_request_response_id: int - :param description: Optional description of the attachment. - :type description: str + :param amount_responded: The Amount the user decides to pay. + :type amount_responded: object_.Amount + :param status: The responding status of the RequestResponse. Can be + ACCEPTED or REJECTED. + :type status: str + :param address_shipping: The shipping Address to return to the user who + created the RequestInquiry. Should only be provided if 'require_address' + is set to SHIPPING, BILLING_SHIPPING or OPTIONAL. + :type address_shipping: object_.Address + :param address_billing: The billing Address to return to the user who + created the RequestInquiry. Should only be provided if 'require_address' + is set to BILLING, BILLING_SHIPPING or OPTIONAL. + :type address_billing: object_.Address + :param currency_conversion_quote_id: When the request is accepted on a + monetary account with a different currency, a quote is expected to + convert. + :type currency_conversion_quote_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseRequestResponse """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_AMOUNT_RESPONDED : amount_responded, +cls.FIELD_STATUS : status, +cls.FIELD_ADDRESS_SHIPPING : address_shipping, +cls.FIELD_ADDRESS_BILLING : address_billing, +cls.FIELD_CURRENCY_CONVERSION_QUOTE_ID : currency_conversion_quote_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_attachment_request_response_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def delete(cls, request_response_id, note_attachment_request_response_id, - monetary_account_id=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type note_attachment_request_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_attachment_request_response_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseRequestResponse.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) ) @classmethod - def list(cls, request_response_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + Get all RequestResponses for a MonetaryAccount. :type user_id: int :type monetary_account_id: int - :type request_response_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentRequestResponseList + :rtype: BunqResponseRequestResponseList """ if params is None: @@ -17598,43 +16675,36 @@ def list(cls, request_response_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_response_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentRequestResponseList.cast_from_bunq_response( + return BunqResponseRequestResponseList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, request_response_id, note_attachment_request_response_id, - monetary_account_id=None, custom_headers=None): + def get(cls, request_response_id, monetary_account_id=None, custom_headers=None): """ - :type api_context: context.ApiContext + Get the details for a specific existing RequestResponse. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int :type request_response_id: int - :type note_attachment_request_response_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentRequestResponse + :rtype: BunqResponseRequestResponse """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_attachment_request_response_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNoteAttachmentRequestResponse.cast_from_bunq_response( + return BunqResponseRequestResponse.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @@ -17663,312 +16733,228 @@ def updated(self): return self._updated @property - def label_user_creator(self): + def time_responded(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._time_responded @property - def description(self): + def time_expiry(self): """ :rtype: str """ - return self._description + return self._time_expiry @property - def attachment(self): + def time_refund_requested(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._time_refund_requested - def is_all_field_none(self): + @property + def time_refunded(self): """ - :rtype: bool + :rtype: str """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False + return self._time_refunded - if self._label_user_creator is not None: - return False + @property + def user_refund_requested(self): + """ + :rtype: object_.LabelUser + """ - if self._description is not None: - return False + return self._user_refund_requested - if self._attachment is not None: - return False + @property + def monetary_account_id(self): + """ + :rtype: int + """ - return True + return self._monetary_account_id - @staticmethod - def from_json(json_str): + @property + def amount_inquired(self): """ - :type json_str: str - - :rtype: NoteAttachmentRequestResponse + :rtype: object_.Amount """ - return converter.json_to_class(NoteAttachmentRequestResponse, json_str) + return self._amount_inquired + @property + def amount_responded(self): + """ + :rtype: object_.Amount + """ -class NoteTextRequestResponse(core.BunqModel): - """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - """ + return self._amount_responded - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-response/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" + @property + def status(self): + """ + :rtype: str + """ - # Field constants. - FIELD_CONTENT = "content" + return self._status - # Object type. - _OBJECT_TYPE_GET = "NoteText" + @property + def description(self): + """ + :rtype: str + """ - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + return self._description - def __init__(self, content=None): + @property + def alias(self): """ - :param content: The content of the note. - :type content: str + :rtype: object_.MonetaryAccountReference """ - self._content_field_for_request = content + return self._alias - @classmethod - def create(cls, request_response_id, monetary_account_id=None, content=None, - custom_headers=None): + @property + def counterparty_alias(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._counterparty_alias - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + @property + def attachment(self): + """ + :rtype: list[object_.Attachment] + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._attachment - @classmethod - def update(cls, request_response_id, note_text_request_response_id, - monetary_account_id=None, content=None, custom_headers=None): + @property + def minimum_age(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type note_text_request_response_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: int """ - if custom_headers is None: - custom_headers = {} + return self._minimum_age - api_client = client.ApiClient(cls._get_api_context()) + @property + def require_address(self): + """ + :rtype: str + """ - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._require_address - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_text_request_response_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def geolocation(self): + """ + :rtype: object_.Geolocation + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._geolocation - @classmethod - def delete(cls, request_response_id, note_text_request_response_id, - monetary_account_id=None, custom_headers=None): + @property + def type_(self): """ - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type note_text_request_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._type_ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_text_request_response_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + @property + def sub_type(self): + """ + :rtype: str + """ - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._sub_type - @classmethod - def list(cls, request_response_id, monetary_account_id=None, params=None, - custom_headers=None): + @property + def redirect_url(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextRequestResponseList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._redirect_url - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - request_response_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def address_billing(self): + """ + :rtype: object_.Address + """ - return BunqResponseNoteTextRequestResponseList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._address_billing - @classmethod - def get(cls, request_response_id, note_text_request_response_id, - monetary_account_id=None, custom_headers=None): + @property + def address_shipping(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type note_text_request_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextRequestResponse + :rtype: object_.Address """ - if custom_headers is None: - custom_headers = {} + return self._address_shipping - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id, - note_text_request_response_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def credit_scheme_identifier(self): + """ + :rtype: str + """ - return BunqResponseNoteTextRequestResponse.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._credit_scheme_identifier @property - def id_(self): + def mandate_identifier(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._mandate_identifier @property - def created(self): + def registration_action(self): """ :rtype: str """ - return self._created + return self._registration_action @property - def updated(self): + def eligible_whitelist_id(self): """ - :rtype: str + :rtype: int """ - return self._updated + return self._eligible_whitelist_id @property - def label_user_creator(self): + def request_reference_split_the_bill(self): """ - :rtype: object_.LabelUser + :rtype: list[object_.RequestInquiryReference] """ - return self._label_user_creator + return self._request_reference_split_the_bill @property - def content(self): + def event_id(self): """ - :rtype: str + :rtype: int """ - return self._content + return self._event_id + + @property + def monetary_account_preferred_id(self): + """ + :rtype: int + """ + + return self._monetary_account_preferred_id def is_all_field_none(self): """ @@ -17984,308 +16970,202 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._time_responded is not None: return False - if self._content is not None: + if self._time_expiry is not None: return False - return True + if self._time_refund_requested is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: NoteTextRequestResponse - """ + if self._time_refunded is not None: + return False - return converter.json_to_class(NoteTextRequestResponse, json_str) + if self._user_refund_requested is not None: + return False + if self._monetary_account_id is not None: + return False -class NoteAttachmentScheduleInstance(core.BunqModel): - """ - Used to manage attachment notes. - - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] - """ + if self._amount_inquired is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" + if self._amount_responded is not None: + return False - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + if self._status is not None: + return False - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + if self._description is not None: + return False - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + if self._alias is not None: + return False - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - """ + if self._counterparty_alias is not None: + return False - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + if self._attachment is not None: + return False - @classmethod - def create(cls, schedule_id, schedule_instance_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + if self._minimum_age is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._require_address is not None: + return False - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._geolocation is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._type_ is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._sub_type is not None: + return False - @classmethod - def update(cls, schedule_id, schedule_instance_id, - note_attachment_schedule_instance_id, monetary_account_id=None, - description=None, custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_attachment_schedule_instance_id: int - :param description: Optional description of the attachment. - :type description: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt - """ + if self._redirect_url is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._address_billing is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) + if self._address_shipping is not None: + return False - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._credit_scheme_identifier is not None: + return False - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_attachment_schedule_instance_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + if self._mandate_identifier is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._registration_action is not None: + return False - @classmethod - def delete(cls, schedule_id, schedule_instance_id, - note_attachment_schedule_instance_id, monetary_account_id=None, - custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_attachment_schedule_instance_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ + if self._eligible_whitelist_id is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._request_reference_split_the_bill is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_attachment_schedule_instance_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + if self._event_id is not None: + return False - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + if self._monetary_account_preferred_id is not None: + return False - @classmethod - def list(cls, schedule_id, schedule_instance_id, monetary_account_id=None, - params=None, custom_headers=None): + return True + + @staticmethod + def from_json(json_str): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseNoteAttachmentScheduleInstanceList + :rtype: RequestResponseApiObject """ - if params is None: - params = {} + return converter.json_to_class(RequestResponseApiObject, json_str) - if custom_headers is None: - custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - schedule_id, schedule_instance_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) +class WhitelistResultApiObject(BunqModel): + """ + Whitelist an SDD so that when one comes in, it is automatically accepted. + + :param _id_: The ID of the whitelist entry. + :type _id_: int + :param _monetary_account_paying_id: The account from which payments will be + deducted when a transaction is matched with this whitelist. + :type _monetary_account_paying_id: int + :param _status: The status of the WhitelistResult. + :type _status: str + :param _sub_status: The subStatus of the WhitelistResult. + :type _sub_status: str + :param _error_message: The message when the whitelist result has failed due + to user error. + :type _error_message: list[object_.Error] + :param _whitelist: The corresponding whitelist. + :type _whitelist: Whitelist + :param _object_: The details of the external object the event was created + for. + :type _object_: object_.WhitelistResultViewAnchoredObject + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] + """ - return BunqResponseNoteAttachmentScheduleInstanceList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + _id_ = None + _monetary_account_paying_id = None + _status = None + _sub_status = None + _error_message = None + _whitelist = None + _object_ = None + _request_reference_split_the_bill = None - @classmethod - def get(cls, schedule_id, schedule_instance_id, - note_attachment_schedule_instance_id, monetary_account_id=None, - custom_headers=None): + @property + def id_(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_attachment_schedule_instance_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentScheduleInstance + :rtype: int """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_attachment_schedule_instance_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteAttachmentScheduleInstance.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._id_ @property - def id_(self): + def monetary_account_paying_id(self): """ :rtype: int """ - return self._id_ + return self._monetary_account_paying_id @property - def created(self): + def status(self): """ :rtype: str """ - return self._created + return self._status @property - def updated(self): + def sub_status(self): """ :rtype: str """ - return self._updated + return self._sub_status @property - def label_user_creator(self): + def error_message(self): """ - :rtype: object_.LabelUser + :rtype: list[object_.Error] """ - return self._label_user_creator + return self._error_message @property - def description(self): + def whitelist(self): """ - :rtype: str + :rtype: Whitelist """ - return self._description + return self._whitelist @property - def attachment(self): + def object_(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: object_.WhitelistResultViewAnchoredObject """ - return self._attachment + return self._object_ + + @property + def request_reference_split_the_bill(self): + """ + :rtype: list[object_.RequestInquiryReference] + """ + + return self._request_reference_split_the_bill def is_all_field_none(self): """ @@ -18295,19 +17175,25 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: + if self._monetary_account_paying_id is not None: return False - if self._updated is not None: + if self._status is not None: return False - if self._label_user_creator is not None: + if self._sub_status is not None: return False - if self._description is not None: + if self._error_message is not None: return False - if self._attachment is not None: + if self._whitelist is not None: + return False + + if self._object_ is not None: + return False + + if self._request_reference_split_the_bill is not None: return False return True @@ -18317,106 +17203,126 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentScheduleInstance + :rtype: WhitelistResultApiObject """ - return converter.json_to_class(NoteAttachmentScheduleInstance, json_str) + return converter.json_to_class(WhitelistResultApiObject, json_str) -class NoteTextScheduleInstance(core.BunqModel): +class WhitelistApiObject(BunqModel): """ - Used to manage text notes. - - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + Whitelist a Request so that when one comes in, it is automatically accepted. """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" - - # Field constants. - FIELD_CONTENT = "content" - - # Object type. - _OBJECT_TYPE_GET = "NoteText" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None - def __init__(self, content=None): + def is_all_field_none(self): """ - :param content: The content of the note. - :type content: str + :rtype: bool """ - self._content_field_for_request = content + return True - @classmethod - def create(cls, schedule_id, schedule_instance_id, monetary_account_id=None, - content=None, custom_headers=None): + @staticmethod + def from_json(json_str): """ - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :param content: The content of the note. - :type content: str - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: WhitelistApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(WhitelistApiObject, json_str) - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) +class TransferwiseTransferApiObject(BunqModel): + """ + Used to create Transferwise payments. + + :param _monetary_account_id: The id of the monetary account the payment + should be made from. + :type _monetary_account_id: str + :param _recipient_id: The id of the target account. + :type _recipient_id: str + :param _alias: The LabelMonetaryAccount containing the public information of + 'this' (party) side of the Payment. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The LabelMonetaryAccount containing the public + information of the other (counterparty) side of the Payment. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _status: The status. + :type _status: str + :param _sub_status: The subStatus. + :type _sub_status: str + :param _status_transferwise: The status as Transferwise reports it. + :type _status_transferwise: str + :param _status_transferwise_issue: A status to indicatie if Transferwise has + an issue with this payment and requires more information. + :type _status_transferwise_issue: str + :param _amount_source: The source amount. + :type _amount_source: object_.Amount + :param _amount_target: The target amount. + :type _amount_target: object_.Amount + :param _rate: The rate of the payment. + :type _rate: str + :param _reference: The reference of the payment. + :type _reference: str + :param _pay_in_reference: The Pay-In reference of the payment. + :type _pay_in_reference: str + :param _time_delivery_estimate: The estimated delivery time. + :type _time_delivery_estimate: str + :param _quote: The quote details used to created the payment. + :type _quote: TransferwiseQuote + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote/{}/transferwise-transfer" + _ENDPOINT_URL_READ = "user/{}/transferwise-quote/{}/transferwise-transfer/{}" + _ENDPOINT_URL_LISTING = "user/{}/transferwise-quote/{}/transferwise-transfer" + + # Field constants. + FIELD_MONETARY_ACCOUNT_ID = "monetary_account_id" + FIELD_RECIPIENT_ID = "recipient_id" + + # Object type. + _OBJECT_TYPE_GET = "TransferwisePayment" + + _alias = None + _counterparty_alias = None + _status = None + _sub_status = None + _status_transferwise = None + _status_transferwise_issue = None + _amount_source = None + _amount_target = None + _rate = None + _reference = None + _pay_in_reference = None + _time_delivery_estimate = None + _quote = None + _monetary_account_id_field_for_request = None + _recipient_id_field_for_request = None + + def __init__(self, monetary_account_id, recipient_id): + """ + :param monetary_account_id: The id of the monetary account the payment + should be made from. + :type monetary_account_id: str + :param recipient_id: The id of the target account. + :type recipient_id: str + """ + + self._monetary_account_id_field_for_request = monetary_account_id + self._recipient_id_field_for_request = recipient_id @classmethod - def update(cls, schedule_id, schedule_instance_id, - note_text_schedule_instance_id, monetary_account_id=None, - content=None, custom_headers=None): + def create(cls,transferwise_quote_id, monetary_account_id, recipient_id, custom_headers=None): """ :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_text_schedule_instance_id: int - :param content: The content of the note. - :type content: str + :type transferwise_quote_id: int + :param monetary_account_id: The id of the monetary account the payment + should be made from. + :type monetary_account_id: str + :param recipient_id: The id of the target account. + :type recipient_id: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -18425,73 +17331,54 @@ def update(cls, schedule_id, schedule_instance_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_MONETARY_ACCOUNT_ID : monetary_account_id, +cls.FIELD_RECIPIENT_ID : recipient_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_text_schedule_instance_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, schedule_id, schedule_instance_id, - note_text_schedule_instance_id, monetary_account_id=None, - custom_headers=None): + def get(cls, transferwise_quote_id, transferwise_transfer_id, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_text_schedule_instance_id: int + :type transferwise_quote_id: int + :type transferwise_transfer_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseTransferwiseTransfer """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_text_schedule_instance_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), transferwise_quote_id, transferwise_transfer_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + return BunqResponseTransferwiseTransfer.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, schedule_id, schedule_instance_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,transferwise_quote_id, params=None, custom_headers=None): """ - Manage the notes for a given user. - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int + :type transferwise_quote_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextScheduleInstanceList + :rtype: BunqResponseTransferwiseTransferList """ if params is None: @@ -18500,107 +17387,160 @@ def list(cls, schedule_id, schedule_instance_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - schedule_id, schedule_instance_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), transferwise_quote_id) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextScheduleInstanceList.cast_from_bunq_response( + return BunqResponseTransferwiseTransferList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, schedule_id, schedule_instance_id, - note_text_schedule_instance_id, monetary_account_id=None, - custom_headers=None): + @property + def alias(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :type note_text_schedule_instance_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextScheduleInstance + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id, - note_text_schedule_instance_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteTextScheduleInstance.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._alias @property - def id_(self): + def counterparty_alias(self): """ - :rtype: int + :rtype: object_.MonetaryAccountReference """ - return self._id_ + return self._counterparty_alias @property - def created(self): + def status(self): """ :rtype: str """ - return self._created + return self._status @property - def updated(self): + def sub_status(self): """ :rtype: str """ - return self._updated + return self._sub_status @property - def label_user_creator(self): + def status_transferwise(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._status_transferwise @property - def content(self): + def status_transferwise_issue(self): """ :rtype: str """ - return self._content + return self._status_transferwise_issue + + @property + def amount_source(self): + """ + :rtype: object_.Amount + """ + + return self._amount_source + + @property + def amount_target(self): + """ + :rtype: object_.Amount + """ + + return self._amount_target + + @property + def rate(self): + """ + :rtype: str + """ + + return self._rate + + @property + def reference(self): + """ + :rtype: str + """ + + return self._reference + + @property + def pay_in_reference(self): + """ + :rtype: str + """ + + return self._pay_in_reference + + @property + def time_delivery_estimate(self): + """ + :rtype: str + """ + + return self._time_delivery_estimate + + @property + def quote(self): + """ + :rtype: TransferwiseQuote + """ + + return self._quote def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._alias is not None: return False - if self._created is not None: + if self._counterparty_alias is not None: return False - if self._updated is not None: + if self._status is not None: return False - if self._label_user_creator is not None: + if self._sub_status is not None: return False - if self._content is not None: + if self._status_transferwise is not None: + return False + + if self._status_transferwise_issue is not None: + return False + + if self._amount_source is not None: + return False + + if self._amount_target is not None: + return False + + if self._rate is not None: + return False + + if self._reference is not None: + return False + + if self._pay_in_reference is not None: + return False + + if self._time_delivery_estimate is not None: + return False + + if self._quote is not None: return False return True @@ -18610,80 +17550,104 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextScheduleInstance + :rtype: TransferwiseTransferApiObject """ - return converter.json_to_class(NoteTextScheduleInstance, json_str) + return converter.json_to_class(TransferwiseTransferApiObject, json_str) -class NoteAttachmentSofortMerchantTransaction(core.BunqModel): +class TransferwiseQuoteApiObject(BunqModel): """ - Used to manage attachment notes. + Used to get quotes from Transferwise. These can be used to initiate + payments. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + :param _currency_source: The source currency. + :type _currency_source: str + :param _currency_target: The target currency. + :type _currency_target: str + :param _amount_source: The source amount. + :type _amount_source: object_.Amount + :param _amount_target: The target amount. + :type _amount_target: object_.Amount + :param _id_: The id of the quote. :type _id_: int - :param _created: The timestamp of the note's creation. + :param _created: The timestamp of the quote's creation. :type _created: str - :param _updated: The timestamp of the note's last update. + :param _updated: The timestamp of the quote's last update. :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _time_expiry: The expiration timestamp of the quote. + :type _time_expiry: str + :param _quote_id: The quote id Transferwise needs. + :type _quote_id: str + :param _amount_fee: The fee amount. + :type _amount_fee: object_.Amount + :param _rate: The rate. + :type _rate: str + :param _time_delivery_estimate: The estimated delivery time. + :type _time_delivery_estimate: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote" + _ENDPOINT_URL_READ = "user/{}/transferwise-quote/{}" # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" + FIELD_CURRENCY_SOURCE = "currency_source" + FIELD_CURRENCY_TARGET = "currency_target" + FIELD_AMOUNT_SOURCE = "amount_source" + FIELD_AMOUNT_TARGET = "amount_target" # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" + _OBJECT_TYPE_GET = "TransferwiseQuote" _id_ = None _created = None _updated = None - _label_user_creator = None - _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None - - def __init__(self, attachment_id, description=None): - """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + _time_expiry = None + _quote_id = None + _amount_source = None + _amount_target = None + _amount_fee = None + _rate = None + _time_delivery_estimate = None + _currency_source_field_for_request = None + _currency_target_field_for_request = None + _amount_source_field_for_request = None + _amount_target_field_for_request = None + + def __init__(self, currency_source, currency_target, amount_source=None, amount_target=None): + """ + :param currency_source: The source currency. + :type currency_source: str + :param currency_target: The target currency. + :type currency_target: str + :param amount_source: The source amount. Required if target amount is left + empty. + :type amount_source: object_.Amount + :param amount_target: The target amount. Required if source amount is left + empty. + :type amount_target: object_.Amount """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + self._currency_source_field_for_request = currency_source + self._currency_target_field_for_request = currency_target + self._amount_source_field_for_request = amount_source + self._amount_target_field_for_request = amount_target @classmethod - def create(cls, sofort_merchant_transaction_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def create(cls,currency_source, currency_target, amount_source=None, amount_target=None, custom_headers=None): """ :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :param currency_source: The source currency. + :type currency_source: str + :param currency_target: The target currency. + :type currency_target: str + :param amount_source: The source amount. Required if target amount is + left empty. + :type amount_source: object_.Amount + :param amount_target: The target amount. Required if source amount is + left empty. + :type amount_target: object_.Amount :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -18693,203 +17657,124 @@ def create(cls, sofort_merchant_transaction_id, attachment_id, custom_headers = {} request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } +cls.FIELD_CURRENCY_SOURCE : currency_source, +cls.FIELD_CURRENCY_TARGET : currency_target, +cls.FIELD_AMOUNT_SOURCE : amount_source, +cls.FIELD_AMOUNT_TARGET : amount_target +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id, - monetary_account_id=None, description=None, custom_headers=None): + def get(cls, transferwise_quote_id, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_attachment_sofort_merchant_transaction_id: int - :param description: Optional description of the attachment. - :type description: str + :type transferwise_quote_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseTransferwiseQuote """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_DESCRIPTION: description - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseTransferwiseQuote.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def delete(cls, sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): + @property + def id_(self): """ - :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_attachment_sofort_merchant_transaction_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._id_ - @classmethod - def list(cls, sofort_merchant_transaction_id, monetary_account_id=None, - params=None, custom_headers=None): + @property + def created(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentSofortMerchantTransactionList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - sofort_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseNoteAttachmentSofortMerchantTransactionList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._created - @classmethod - def get(cls, sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): + @property + def updated(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_attachment_sofort_merchant_transaction_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentSofortMerchantTransaction + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._updated - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_attachment_sofort_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def time_expiry(self): + """ + :rtype: str + """ - return BunqResponseNoteAttachmentSofortMerchantTransaction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._time_expiry @property - def id_(self): + def quote_id(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._quote_id @property - def created(self): + def amount_source(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._created + return self._amount_source @property - def updated(self): + def amount_target(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._updated + return self._amount_target @property - def label_user_creator(self): + def amount_fee(self): """ - :rtype: object_.LabelUser + :rtype: object_.Amount """ - return self._label_user_creator + return self._amount_fee @property - def description(self): + def rate(self): """ :rtype: str """ - return self._description + return self._rate @property - def attachment(self): + def time_delivery_estimate(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._time_delivery_estimate def is_all_field_none(self): """ @@ -18905,13 +17790,25 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._time_expiry is not None: return False - if self._description is not None: + if self._quote_id is not None: return False - if self._attachment is not None: + if self._amount_source is not None: + return False + + if self._amount_target is not None: + return False + + if self._amount_fee is not None: + return False + + if self._rate is not None: + return False + + if self._time_delivery_estimate is not None: return False return True @@ -18921,66 +17818,170 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentSofortMerchantTransaction + :rtype: TransferwiseQuoteApiObject """ - return converter.json_to_class(NoteAttachmentSofortMerchantTransaction, - json_str) + return converter.json_to_class(TransferwiseQuoteApiObject, json_str) -class NoteTextSofortMerchantTransaction(core.BunqModel): +class ShareInviteMonetaryAccountInquiryApiObject(BunqModel): """ - Used to manage text notes. + [DEPRECATED - use /share-invite-monetary-account-response] Used to share a + monetary account with another bunq user, as in the 'Connect' feature in the + bunq app. Allow the creation of share inquiries that, in the same way as + request inquiries, can be revoked by the user creating them or + accepted/rejected by the other party. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. + :param _counter_user_alias: The label of the user to share with. + :type _counter_user_alias: object_.LabelUser + :param _access_type: Type of access that is in place. + :type _access_type: str + :param _draft_share_invite_bank_id: DEPRECATED: USE `access_type` INSTEAD | + The id of the draft share invite bank. + :type _draft_share_invite_bank_id: int + :param _share_detail: DEPRECATED: USE `access_type` INSTEAD | The share + details. Only one of these objects may be passed. + :type _share_detail: object_.ShareDetail + :param _status: The status of the share. Can be ACTIVE, REVOKED, REJECTED. + :type _status: str + :param _relationship: The relationship: COMPANY_DIRECTOR, COMPANY_EMPLOYEE, + etc + :type _relationship: str + :param _share_type: DEPRECATED: USE `access_type` INSTEAD | The share type, + either STANDARD or MUTUAL. + :type _share_type: str + :param _start_date: DEPRECATED: USE `access_type` INSTEAD | The start date + of this share. + :type _start_date: str + :param _end_date: DEPRECATED: USE `access_type` INSTEAD | The expiration + date of this share. + :type _end_date: str + :param _alias: The label of the monetary account that's being shared. + :type _alias: object_.MonetaryAccountReference + :param _user_alias_created: The user who created the share. + :type _user_alias_created: object_.LabelUser + :param _user_alias_revoked: The user who revoked the share. + :type _user_alias_revoked: object_.LabelUser + :param _monetary_account_id: The id of the monetary account the share + applies to. + :type _monetary_account_id: int + :param _id_: The id of the newly created share invite. :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/share-invite-monetary-account-inquiry" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/share-invite-monetary-account-inquiry/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/share-invite-monetary-account-inquiry/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/share-invite-monetary-account-inquiry" # Field constants. - FIELD_CONTENT = "content" + FIELD_COUNTER_USER_ALIAS = "counter_user_alias" + FIELD_ACCESS_TYPE = "access_type" + FIELD_DRAFT_SHARE_INVITE_BANK_ID = "draft_share_invite_bank_id" + FIELD_SHARE_DETAIL = "share_detail" + FIELD_STATUS = "status" + FIELD_RELATIONSHIP = "relationship" + FIELD_SHARE_TYPE = "share_type" + FIELD_START_DATE = "start_date" + FIELD_END_DATE = "end_date" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "ShareInviteMonetaryAccountInquiry" + _alias = None + _user_alias_created = None + _user_alias_revoked = None + _counter_user_alias = None + _monetary_account_id = None + _status = None + _access_type = None + _relationship = None _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _counter_user_alias_field_for_request = None + _access_type_field_for_request = None + _draft_share_invite_bank_id_field_for_request = None + _share_detail_field_for_request = None + _status_field_for_request = None + _relationship_field_for_request = None + _share_type_field_for_request = None + _start_date_field_for_request = None + _end_date_field_for_request = None - def __init__(self, content=None): + def __init__(self, counter_user_alias, access_type=None, draft_share_invite_bank_id=None, share_detail=None, status=None, relationship=None, share_type=None, start_date=None, end_date=None): """ - :param content: The content of the note. - :type content: str + :param counter_user_alias: The pointer of the user to share with. + :type counter_user_alias: object_.Pointer + :param access_type: Type of access that is wanted, one of VIEW_BALANCE, + VIEW_TRANSACTION, DRAFT_PAYMENT or FULL_TRANSIENT + :type access_type: str + :param draft_share_invite_bank_id: DEPRECATED: USE `access_type` INSTEAD | + The id of the draft share invite bank. + :type draft_share_invite_bank_id: int + :param share_detail: DEPRECATED: USE `access_type` INSTEAD | The share + details. Only one of these objects may be passed. + :type share_detail: object_.ShareDetail + :param status: The status of the share. Can be ACTIVE, REVOKED, REJECTED. + :type status: str + :param relationship: The relationship: COMPANY_DIRECTOR, COMPANY_EMPLOYEE, + etc + :type relationship: str + :param share_type: DEPRECATED: USE `access_type` INSTEAD | The share type, + either STANDARD or MUTUAL. + :type share_type: str + :param start_date: DEPRECATED: USE `access_type` INSTEAD | The start date of + this share. + :type start_date: str + :param end_date: DEPRECATED: USE `access_type` INSTEAD | The expiration date + of this share. + :type end_date: str """ - self._content_field_for_request = content + self._counter_user_alias_field_for_request = counter_user_alias + self._access_type_field_for_request = access_type + self._draft_share_invite_bank_id_field_for_request = draft_share_invite_bank_id + self._share_detail_field_for_request = share_detail + self._status_field_for_request = status + self._relationship_field_for_request = relationship + self._share_type_field_for_request = share_type + self._start_date_field_for_request = start_date + self._end_date_field_for_request = end_date @classmethod - def create(cls, sofort_merchant_transaction_id, monetary_account_id=None, - content=None, custom_headers=None): + def create(cls,counter_user_alias, monetary_account_id=None, access_type=None, draft_share_invite_bank_id=None, share_detail=None, status=None, relationship=None, share_type=None, start_date=None, end_date=None, custom_headers=None): """ + [DEPRECATED - use /share-invite-monetary-account-response] Create a new + share inquiry for a monetary account, specifying the permission the + other bunq user will have on it. + :type user_id: int :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :param content: The content of the note. - :type content: str + :param counter_user_alias: The pointer of the user to share with. + :type counter_user_alias: object_.Pointer + :param access_type: Type of access that is wanted, one of VIEW_BALANCE, + VIEW_TRANSACTION, DRAFT_PAYMENT or FULL_TRANSIENT + :type access_type: str + :param draft_share_invite_bank_id: DEPRECATED: USE `access_type` INSTEAD + | The id of the draft share invite bank. + :type draft_share_invite_bank_id: int + :param share_detail: DEPRECATED: USE `access_type` INSTEAD | The share + details. Only one of these objects may be passed. + :type share_detail: object_.ShareDetail + :param status: The status of the share. Can be ACTIVE, REVOKED, + REJECTED. + :type status: str + :param relationship: The relationship: COMPANY_DIRECTOR, + COMPANY_EMPLOYEE, etc + :type relationship: str + :param share_type: DEPRECATED: USE `access_type` INSTEAD | The share + type, either STANDARD or MUTUAL. + :type share_type: str + :param start_date: DEPRECATED: USE `access_type` INSTEAD | The start + date of this share. + :type start_date: str + :param end_date: DEPRECATED: USE `access_type` INSTEAD | The expiration + date of this share. + :type end_date: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -18990,106 +17991,121 @@ def create(cls, sofort_merchant_transaction_id, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_CONTENT: content - } +cls.FIELD_COUNTER_USER_ALIAS : counter_user_alias, +cls.FIELD_ACCESS_TYPE : access_type, +cls.FIELD_DRAFT_SHARE_INVITE_BANK_ID : draft_share_invite_bank_id, +cls.FIELD_SHARE_DETAIL : share_detail, +cls.FIELD_STATUS : status, +cls.FIELD_RELATIONSHIP : relationship, +cls.FIELD_SHARE_TYPE : share_type, +cls.FIELD_START_DATE : start_date, +cls.FIELD_END_DATE : end_date +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id, - monetary_account_id=None, content=None, custom_headers=None): + def get(cls, share_invite_monetary_account_inquiry_id, monetary_account_id=None, custom_headers=None): """ + [DEPRECATED - use /share-invite-monetary-account-response] Get the + details of a specific share inquiry. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_text_sofort_merchant_transaction_id: int - :param content: The content of the note. - :type content: str + :type share_invite_monetary_account_inquiry_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseShareInviteMonetaryAccountInquiry """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), share_invite_monetary_account_inquiry_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseShareInviteMonetaryAccountInquiry.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def delete(cls, sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id, - monetary_account_id=None, custom_headers=None): + def update(cls, share_invite_monetary_account_inquiry_id, monetary_account_id=None, access_type=None, share_detail=None, status=None, start_date=None, end_date=None, custom_headers=None): """ + [DEPRECATED - use /share-invite-monetary-account-response] Update the + details of a share. This includes updating status (revoking or + cancelling it), granted permission and validity period of this share. + :type user_id: int :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_text_sofort_merchant_transaction_id: int + :type share_invite_monetary_account_inquiry_id: int + :param access_type: Type of access that is wanted, one of VIEW_BALANCE, + VIEW_TRANSACTION, DRAFT_PAYMENT or FULL_TRANSIENT + :type access_type: str + :param share_detail: DEPRECATED: USE `access_type` INSTEAD | The share + details. Only one of these objects may be passed. + :type share_detail: object_.ShareDetail + :param status: The status of the share. Can be ACTIVE, REVOKED, + REJECTED. + :type status: str + :param start_date: DEPRECATED: USE `access_type` INSTEAD | The start + date of this share. + :type start_date: str + :param end_date: DEPRECATED: USE `access_type` INSTEAD | The expiration + date of this share. + :type end_date: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNone + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + api_client = ApiClient(cls._get_api_context()) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) + request_map = { +cls.FIELD_ACCESS_TYPE : access_type, +cls.FIELD_SHARE_DETAIL : share_detail, +cls.FIELD_STATUS : status, +cls.FIELD_START_DATE : start_date, +cls.FIELD_END_DATE : end_date +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), share_invite_monetary_account_inquiry_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) @classmethod - def list(cls, sofort_merchant_transaction_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Manage the notes for a given user. + [DEPRECATED - use /share-invite-monetary-account-response] Get a list + with all the share inquiries for a monetary account, only if the + requesting user has permission to change the details of the various + ones. :type user_id: int :type monetary_account_id: int - :type sofort_merchant_transaction_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteTextSofortMerchantTransactionList + :rtype: BunqResponseShareInviteMonetaryAccountInquiryList """ if params is None: @@ -19098,105 +18114,116 @@ def list(cls, sofort_merchant_transaction_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - sofort_merchant_transaction_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteTextSofortMerchantTransactionList.cast_from_bunq_response( + return BunqResponseShareInviteMonetaryAccountInquiryList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id, monetary_account_id=None, - custom_headers=None): + @property + def alias(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type sofort_merchant_transaction_id: int - :type note_text_sofort_merchant_transaction_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextSofortMerchantTransaction + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} + return self._alias - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - sofort_merchant_transaction_id, - note_text_sofort_merchant_transaction_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def user_alias_created(self): + """ + :rtype: object_.LabelUser + """ - return BunqResponseNoteTextSofortMerchantTransaction.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._user_alias_created @property - def id_(self): + def user_alias_revoked(self): + """ + :rtype: object_.LabelUser + """ + + return self._user_alias_revoked + + @property + def counter_user_alias(self): + """ + :rtype: object_.LabelUser + """ + + return self._counter_user_alias + + @property + def monetary_account_id(self): """ :rtype: int """ - return self._id_ + return self._monetary_account_id @property - def created(self): + def status(self): """ :rtype: str """ - return self._created + return self._status @property - def updated(self): + def access_type(self): """ :rtype: str """ - return self._updated + return self._access_type @property - def label_user_creator(self): + def relationship(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._label_user_creator + return self._relationship @property - def content(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._content + return self._id_ def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._alias is not None: return False - if self._created is not None: + if self._user_alias_created is not None: return False - if self._updated is not None: + if self._user_alias_revoked is not None: return False - if self._label_user_creator is not None: + if self._counter_user_alias is not None: return False - if self._content is not None: + if self._monetary_account_id is not None: + return False + + if self._status is not None: + return False + + if self._access_type is not None: + return False + + if self._relationship is not None: + return False + + if self._id_ is not None: return False return True @@ -19206,123 +18233,142 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextSofortMerchantTransaction + :rtype: ShareInviteMonetaryAccountInquiryApiObject """ - return converter.json_to_class(NoteTextSofortMerchantTransaction, - json_str) + return converter.json_to_class(ShareInviteMonetaryAccountInquiryApiObject, json_str) -class NoteAttachmentWhitelistResult(core.BunqModel): +class ShareInviteMonetaryAccountResponseApiObject(BunqModel): """ - Used to manage attachment notes. + Used to view or respond to shares a user was invited to. See + 'share-invite-bank-inquiry' for more information about the inquiring + endpoint. - :param _description: Optional description of the attachment. - :type _description: str - :param _attachment_id: The reference to the uploaded file to attach to this - note. - :type _attachment_id: int - :param _id_: The id of the note. + :param _status: The status of the share. Can be ACTIVE, REVOKED, REJECTED. + :type _status: str + :param _card_id: The card to link to the shared monetary account. Used only + if share_detail is ShareDetailCardPayment. + :type _card_id: int + :param _id_: The id of the ShareInviteBankResponse. :type _id_: int - :param _created: The timestamp of the note's creation. + :param _created: The timestamp of the ShareInviteBankResponse creation. :type _created: str - :param _updated: The timestamp of the note's last update. + :param _updated: The timestamp of the ShareInviteBankResponse last update. :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser - :param _attachment: The attachment attached to the note. - :type _attachment: list[object_.AttachmentMonetaryAccountPayment] - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT_ID = "attachment_id" - - # Object type. - _OBJECT_TYPE_GET = "NoteAttachment" - - _id_ = None - _created = None - _updated = None - _label_user_creator = None + :param _counter_alias: The monetary account and user who created the share. + :type _counter_alias: object_.MonetaryAccountReference + :param _user_alias_cancelled: The user who cancelled the share if it has + been revoked or rejected. + :type _user_alias_cancelled: object_.LabelUser + :param _monetary_account_id: The id of the monetary account the ACCEPTED + share applies to. null otherwise. + :type _monetary_account_id: int + :param _draft_share_invite_bank_id: The id of the draft share invite bank. + :type _draft_share_invite_bank_id: int + :param _share_detail: The share details. + :type _share_detail: object_.ShareDetail + :param _access_type: Type of access that is wanted, one of VIEW_BALANCE, + VIEW_TRANSACTION, DRAFT_PAYMENT or FULL_TRANSIENT + :type _access_type: str + :param _relation_user: All of the relation users towards this MA. + :type _relation_user: RelationUser + :param _share_type: The share type, either STANDARD or MUTUAL. + :type _share_type: str + :param _start_date: The start date of this share. + :type _start_date: str + :param _end_date: The expiration date of this share. + :type _end_date: str + :param _description: The description of this share. It is basically the + monetary account description. + :type _description: str + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/share-invite-monetary-account-response/{}" + _ENDPOINT_URL_UPDATE = "user/{}/share-invite-monetary-account-response/{}" + _ENDPOINT_URL_LISTING = "user/{}/share-invite-monetary-account-response" + + # Field constants. + FIELD_STATUS = "status" + FIELD_CARD_ID = "card_id" + + # Object type. + _OBJECT_TYPE_GET = "ShareInviteMonetaryAccountResponse" + + _id_ = None + _created = None + _updated = None + _counter_alias = None + _user_alias_cancelled = None + _monetary_account_id = None + _draft_share_invite_bank_id = None + _share_detail = None + _access_type = None + _status = None + _relation_user = None + _share_type = None + _start_date = None + _end_date = None _description = None - _attachment = None - _description_field_for_request = None - _attachment_id_field_for_request = None + _status_field_for_request = None + _card_id_field_for_request = None - def __init__(self, attachment_id, description=None): + def __init__(self, status=None, card_id=None): """ - :param attachment_id: The reference to the uploaded file to attach to this - note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :param status: The status of the share. Can be PENDING, REVOKED (the user + deletes the share inquiry before it's accepted), ACCEPTED, CANCELLED (the + user deletes an active share) or CANCELLATION_PENDING, + CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual connects) + :type status: str + :param card_id: The card to link to the shared monetary account. Used only + if share_detail is ShareDetailCardPayment. + :type card_id: int """ - self._attachment_id_field_for_request = attachment_id - self._description_field_for_request = description + self._status_field_for_request = status + self._card_id_field_for_request = card_id @classmethod - def create(cls, whitelist_id, whitelist_result_id, attachment_id, - monetary_account_id=None, description=None, custom_headers=None): + def get(cls, share_invite_monetary_account_response_id, custom_headers=None): """ + Return the details of a specific share a user was invited to. + + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :param attachment_id: The reference to the uploaded file to attach to - this note. - :type attachment_id: int - :param description: Optional description of the attachment. - :type description: str + :type share_invite_monetary_account_response_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseShareInviteMonetaryAccountResponse """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT_ID: attachment_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), share_invite_monetary_account_response_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseShareInviteMonetaryAccountResponse.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, whitelist_id, whitelist_result_id, - note_attachment_whitelist_result_id, monetary_account_id=None, - description=None, custom_headers=None): + def update(cls, share_invite_monetary_account_response_id, status=None, card_id=None, custom_headers=None): """ + Accept or reject a share a user was invited to. + :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_attachment_whitelist_result_id: int - :param description: Optional description of the attachment. - :type description: str + :type share_invite_monetary_account_response_id: int + :param status: The status of the share. Can be PENDING, REVOKED (the + user deletes the share inquiry before it's accepted), ACCEPTED, + CANCELLED (the user deletes an active share) or CANCELLATION_PENDING, + CANCELLATION_ACCEPTED, CANCELLATION_REJECTED (for canceling mutual + connects) + :type status: str + :param card_id: The card to link to the shared monetary account. Used + only if share_detail is ShareDetailCardPayment. + :type card_id: int :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -19331,73 +18377,33 @@ def update(cls, whitelist_id, whitelist_result_id, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_DESCRIPTION: description - } +cls.FIELD_STATUS : status, +cls.FIELD_CARD_ID : card_id +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_attachment_whitelist_result_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), share_invite_monetary_account_response_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def delete(cls, whitelist_id, whitelist_result_id, - note_attachment_whitelist_result_id, monetary_account_id=None, - custom_headers=None): - """ - :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_attachment_whitelist_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_attachment_whitelist_result_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - - @classmethod - def list(cls, whitelist_id, whitelist_result_id, monetary_account_id=None, - params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Manage the notes for a given user. + Return all the shares a user was invited to. :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseNoteAttachmentWhitelistResultList + :rtype: BunqResponseShareInviteMonetaryAccountResponseList """ if params is None: @@ -19406,49 +18412,14 @@ def list(cls, whitelist_id, whitelist_result_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - whitelist_id, whitelist_result_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseNoteAttachmentWhitelistResultList.cast_from_bunq_response( + return BunqResponseShareInviteMonetaryAccountResponseList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, whitelist_id, whitelist_result_id, - note_attachment_whitelist_result_id, monetary_account_id=None, - custom_headers=None): - """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_attachment_whitelist_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteAttachmentWhitelistResult - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_attachment_whitelist_result_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseNoteAttachmentWhitelistResult.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @property def id_(self): """ @@ -19474,28 +18445,100 @@ def updated(self): return self._updated @property - def label_user_creator(self): + def counter_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counter_alias + + @property + def user_alias_cancelled(self): """ :rtype: object_.LabelUser """ - return self._label_user_creator + return self._user_alias_cancelled @property - def description(self): + def monetary_account_id(self): + """ + :rtype: int + """ + + return self._monetary_account_id + + @property + def draft_share_invite_bank_id(self): + """ + :rtype: int + """ + + return self._draft_share_invite_bank_id + + @property + def share_detail(self): + """ + :rtype: object_.ShareDetail + """ + + return self._share_detail + + @property + def access_type(self): """ :rtype: str """ - return self._description + return self._access_type @property - def attachment(self): + def status(self): """ - :rtype: list[object_.AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._status + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def share_type(self): + """ + :rtype: str + """ + + return self._share_type + + @property + def start_date(self): + """ + :rtype: str + """ + + return self._start_date + + @property + def end_date(self): + """ + :rtype: str + """ + + return self._end_date + + @property + def description(self): + """ + :rtype: str + """ + + return self._description def is_all_field_none(self): """ @@ -19511,13 +18554,40 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._label_user_creator is not None: + if self._counter_alias is not None: return False - if self._description is not None: + if self._user_alias_cancelled is not None: return False - if self._attachment is not None: + if self._monetary_account_id is not None: + return False + + if self._draft_share_invite_bank_id is not None: + return False + + if self._share_detail is not None: + return False + + if self._access_type is not None: + return False + + if self._status is not None: + return False + + if self._relation_user is not None: + return False + + if self._share_type is not None: + return False + + if self._start_date is not None: + return False + + if self._end_date is not None: + return False + + if self._description is not None: return False return True @@ -19527,290 +18597,238 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteAttachmentWhitelistResult + :rtype: ShareInviteMonetaryAccountResponseApiObject """ - return converter.json_to_class(NoteAttachmentWhitelistResult, json_str) + return converter.json_to_class(ShareInviteMonetaryAccountResponseApiObject, json_str) -class NoteTextWhitelistResult(core.BunqModel): +class SofortMerchantTransactionApiObject(BunqModel): """ - Used to manage text notes. + View for requesting Sofort transactions and polling their status. - :param _content: The content of the note. - :type _content: str - :param _id_: The id of the note. - :type _id_: int - :param _created: The timestamp of the note's creation. - :type _created: str - :param _updated: The timestamp of the note's last update. - :type _updated: str - :param _label_user_creator: The label of the user who created this note. - :type _label_user_creator: object_.LabelUser + :param _amount_requested: The requested amount of money to add. + :type _amount_requested: object_.Amount + :param _issuer: The BIC of the issuer. + :type _issuer: str + :param _monetary_account_id: The id of the monetary account this sofort + merchant transaction links to. + :type _monetary_account_id: int + :param _alias: The alias of the monetary account to add money to. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The alias of the monetary account the money + comes from. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _amount_guaranteed: In case of a successful transaction, the amount + of money that will be transferred. + :type _amount_guaranteed: object_.Amount + :param _issuer_authentication_url: The URL to visit to + :type _issuer_authentication_url: str + :param _status: The status of the transaction. + :type _status: str + :param _error_message: The error message of the transaction. + :type _error_message: list[object_.Error] + :param _transaction_identifier: The 'transaction ID' of the Sofort + transaction. + :type _transaction_identifier: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/sofort-merchant-transaction" # Field constants. - FIELD_CONTENT = "content" + FIELD_AMOUNT_REQUESTED = "amount_requested" + FIELD_ISSUER = "issuer" # Object type. - _OBJECT_TYPE_GET = "NoteText" + _OBJECT_TYPE_GET = "SofortMerchantTransaction" - _id_ = None - _created = None - _updated = None - _label_user_creator = None - _content = None - _content_field_for_request = None + _monetary_account_id = None + _alias = None + _counterparty_alias = None + _amount_guaranteed = None + _amount_requested = None + _issuer = None + _issuer_authentication_url = None + _status = None + _error_message = None + _transaction_identifier = None + _amount_requested_field_for_request = None + _issuer_field_for_request = None - def __init__(self, content=None): + def __init__(self, amount_requested, issuer=None): """ - :param content: The content of the note. - :type content: str + :param amount_requested: The requested amount of money to add. + :type amount_requested: object_.Amount + :param issuer: The BIC of the issuing bank to ask for money. + :type issuer: str """ - self._content_field_for_request = content + self._amount_requested_field_for_request = amount_requested + self._issuer_field_for_request = issuer @classmethod - def create(cls, whitelist_id, whitelist_result_id, monetary_account_id=None, - content=None, custom_headers=None): + def get(cls, sofort_merchant_transaction_id, monetary_account_id=None, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :param content: The content of the note. - :type content: str + :type sofort_merchant_transaction_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseSofortMerchantTransaction """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseSofortMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, whitelist_id, whitelist_result_id, - note_text_whitelist_result_id, monetary_account_id=None, - content=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ :type user_id: int :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_text_whitelist_result_id: int - :param content: The content of the note. - :type content: str + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseSofortMerchantTransactionList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_CONTENT: content - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_text_whitelist_result_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseSofortMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def delete(cls, whitelist_id, whitelist_result_id, - note_text_whitelist_result_id, monetary_account_id=None, - custom_headers=None): + @property + def monetary_account_id(self): """ - :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_text_whitelist_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: int """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_text_whitelist_result_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._monetary_account_id - @classmethod - def list(cls, whitelist_id, whitelist_result_id, monetary_account_id=None, - params=None, custom_headers=None): + @property + def alias(self): """ - Manage the notes for a given user. - - :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextWhitelistResultList + :rtype: object_.MonetaryAccountReference """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._alias - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - whitelist_id, whitelist_result_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - return BunqResponseNoteTextWhitelistResultList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._counterparty_alias - @classmethod - def get(cls, whitelist_id, whitelist_result_id, - note_text_whitelist_result_id, monetary_account_id=None, - custom_headers=None): + @property + def amount_guaranteed(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type whitelist_id: int - :type whitelist_result_id: int - :type note_text_whitelist_result_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNoteTextWhitelistResult + :rtype: object_.Amount """ - if custom_headers is None: - custom_headers = {} + return self._amount_guaranteed - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - whitelist_id, - whitelist_result_id, - note_text_whitelist_result_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def amount_requested(self): + """ + :rtype: object_.Amount + """ - return BunqResponseNoteTextWhitelistResult.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._amount_requested @property - def id_(self): + def issuer(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._issuer @property - def created(self): + def issuer_authentication_url(self): """ :rtype: str """ - return self._created + return self._issuer_authentication_url @property - def updated(self): + def status(self): """ :rtype: str """ - return self._updated + return self._status @property - def label_user_creator(self): + def error_message(self): """ - :rtype: object_.LabelUser + :rtype: list[object_.Error] """ - return self._label_user_creator + return self._error_message @property - def content(self): + def transaction_identifier(self): """ :rtype: str """ - return self._content + return self._transaction_identifier def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._monetary_account_id is not None: return False - if self._created is not None: + if self._alias is not None: return False - if self._updated is not None: + if self._counterparty_alias is not None: return False - if self._label_user_creator is not None: + if self._amount_guaranteed is not None: return False - if self._content is not None: + if self._amount_requested is not None: + return False + + if self._issuer is not None: + return False + + if self._issuer_authentication_url is not None: + return False + + if self._status is not None: + return False + + if self._error_message is not None: + return False + + if self._transaction_identifier is not None: return False return True @@ -19820,95 +18838,54 @@ def from_json(json_str): """ :type json_str: str - :rtype: NoteTextWhitelistResult + :rtype: SofortMerchantTransactionApiObject """ - return converter.json_to_class(NoteTextWhitelistResult, json_str) + return converter.json_to_class(SofortMerchantTransactionApiObject, json_str) -class BunqMeFundraiserResult(core.BunqModel): +class ExportAnnualOverviewContentApiObject(BunqModel): """ - bunq.me fundraiser result containing all payments. - - :param _id_: The id of the bunq.me. - :type _id_: int - :param _created: The timestamp when the bunq.me was created. - :type _created: str - :param _updated: The timestamp when the bunq.me was last updated. - :type _updated: str - :param _bunqme_fundraiser_profile: The bunq.me fundraiser profile. - :type _bunqme_fundraiser_profile: BunqMeFundraiserProfile - :param _payments: The list of payments, paid to the bunq.me fundraiser - profile. - :type _payments: list[Payment] + Fetch the raw content of an annual overview. The annual overview is always + in PDF format. Doc won't display the response of a request to get the + content of an annual overview. """ - _id_ = None - _created = None - _updated = None - _bunqme_fundraiser_profile = None - _payments = None + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/export-annual-overview/{}/content" - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created + # Object type. + _OBJECT_TYPE_GET = "ExportAnnualOverviewContent" - @property - def updated(self): + @classmethod + def list(cls, export_annual_overview_id, custom_headers=None): """ - :rtype: str + Used to retrieve the raw content of an annual overview. + + :type user_id: int + :type export_annual_overview_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return self._updated - - @property - def bunqme_fundraiser_profile(self): - """ - :rtype: BunqMeFundraiserProfile - """ + if custom_headers is None: + custom_headers = {} - return self._bunqme_fundraiser_profile + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), export_annual_overview_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - @property - def payments(self): - """ - :rtype: list[Payment] - """ + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) - return self._payments def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._bunqme_fundraiser_profile is not None: - return False - - if self._payments is not None: - return False - return True @staticmethod @@ -19916,97 +18893,194 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeFundraiserResult + :rtype: ExportAnnualOverviewContentApiObject """ - return converter.json_to_class(BunqMeFundraiserResult, json_str) + return converter.json_to_class(ExportAnnualOverviewContentApiObject, json_str) -class BunqMeFundraiserProfile(core.BunqModel): +class ExportAnnualOverviewApiObject(BunqModel): """ - bunq.me public profile of the user. + Used to create new and read existing annual overviews of all the user's + monetary accounts. Once created, annual overviews can be downloaded in PDF + format via the 'export-annual-overview/{id}/content' endpoint. - :param _pointer: The pointer (url) which will be used to access the bunq.me - fundraiser profile. - :type _pointer: object_.MonetaryAccountReference - :param _color: The color chosen for the bunq.me fundraiser profile in - hexadecimal format. - :type _color: str - :param _alias: The LabelMonetaryAccount with the public information of the - User and the MonetaryAccount that created the bunq.me fundraiser profile. - :type _alias: object_.MonetaryAccountReference - :param _description: The description of the bunq.me fundraiser profile. - :type _description: str - :param _attachment: The attachments attached to the fundraiser profile. - :type _attachment: list[object_.AttachmentPublic] - :param _status: The status of the bunq.me fundraiser profile, can be ACTIVE - or DEACTIVATED. + :param _year: The year for which the overview is. + :type _year: int + :param _id_: The id of the annual overview as created on the server. + :type _id_: int + :param _created: The timestamp of the annual overview 's creation. + :type _created: str + :param _updated: The timestamp of the annual overview 's last update. + :type _updated: str + :param _status: The status of the annual overview export. :type _status: str - :param _redirect_url: The URL which the user is sent to when a payment is - completed. - :type _redirect_url: str + :param _alias_user: The user to which this annual overview belongs. + :type _alias_user: object_.LabelUser """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/export-annual-overview" + _ENDPOINT_URL_READ = "user/{}/export-annual-overview/{}" + _ENDPOINT_URL_DELETE = "user/{}/export-annual-overview/{}" + _ENDPOINT_URL_LISTING = "user/{}/export-annual-overview" + # Field constants. - FIELD_POINTER = "pointer" + FIELD_YEAR = "year" - _color = None - _alias = None - _description = None - _attachment = None - _pointer = None + # Object type. + _OBJECT_TYPE_GET = "ExportAnnualOverview" + + _id_ = None + _created = None + _updated = None + _year = None _status = None - _redirect_url = None - _pointer_field_for_request = None + _alias_user = None + _year_field_for_request = None - def __init__(self, pointer): + def __init__(self, year): """ - :param pointer: The pointer (url) which will be used to access the bunq.me - fundraiser profile. - :type pointer: object_.Pointer + :param year: The year for which the overview is. + :type year: int """ - self._pointer_field_for_request = pointer + self._year_field_for_request = year - @property - def color(self): + @classmethod + def create(cls,year, custom_headers=None): """ - :rtype: str + Create a new annual overview for a specific year. An overview can be + generated only for a past year. + + :type user_id: int + :param year: The year for which the overview is. + :type year: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._color + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_YEAR : year +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, export_annual_overview_id, custom_headers=None): + """ + Get an annual overview for a user by its id. + + :type api_context: ApiContext + :type user_id: int + :type export_annual_overview_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportAnnualOverview + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), export_annual_overview_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseExportAnnualOverview.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def delete(cls, export_annual_overview_id, custom_headers=None): + """ + :type user_id: int + :type export_annual_overview_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), export_annual_overview_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + List all the annual overviews for a user. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportAnnualOverviewList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseExportAnnualOverviewList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def alias(self): + def id_(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: int """ - return self._alias + return self._id_ @property - def description(self): + def created(self): """ :rtype: str """ - return self._description + return self._created @property - def attachment(self): + def updated(self): """ - :rtype: list[object_.AttachmentPublic] + :rtype: str """ - return self._attachment + return self._updated @property - def pointer(self): + def year(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: int """ - return self._pointer + return self._year @property def status(self): @@ -20017,37 +19091,34 @@ def status(self): return self._status @property - def redirect_url(self): + def alias_user(self): """ - :rtype: str + :rtype: object_.LabelUser """ - return self._redirect_url + return self._alias_user def is_all_field_none(self): """ :rtype: bool """ - if self._color is not None: - return False - - if self._alias is not None: + if self._id_ is not None: return False - if self._description is not None: + if self._created is not None: return False - if self._attachment is not None: + if self._updated is not None: return False - if self._pointer is not None: + if self._year is not None: return False if self._status is not None: return False - if self._redirect_url is not None: + if self._alias_user is not None: return False return True @@ -20057,57 +19128,47 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeFundraiserProfile + :rtype: ExportAnnualOverviewApiObject """ - return converter.json_to_class(BunqMeFundraiserProfile, json_str) + return converter.json_to_class(ExportAnnualOverviewApiObject, json_str) -class BunqMeTabResultResponse(core.BunqModel): +class ExportRibContentApiObject(BunqModel): """ - Used to view bunq.me TabResultResponse objects belonging to a tab. A - TabResultResponse is an object that holds details on a tab which has been - paid from the provided monetary account. - - :param _payment: The payment made for the bunq.me tab. - :type _payment: Payment + Fetch the raw content of an RIB. The RIB is always in PDF format. """ - _payment = None - - @property - def payment(self): - """ - :rtype: Payment - """ - - return self._payment - - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._payment is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/export-rib/{}/content" - return True + # Object type. + _OBJECT_TYPE_GET = "ExportRibContent" - @staticmethod - def from_json(json_str): + @classmethod + def list(cls, export_rib_id, monetary_account_id=None, custom_headers=None): """ - :type json_str: str + Used to retrieve the raw content of an RIB. - :rtype: BunqMeTabResultResponse + :type user_id: int + :type monetary_account_id: int + :type export_rib_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return converter.json_to_class(BunqMeTabResultResponse, json_str) + if custom_headers is None: + custom_headers = {} + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), export_rib_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) -class ChatMessage(core.BunqModel): - """ - Endpoint for retrieving the messages that are part of a conversation. - """ def is_all_field_none(self): """ @@ -20121,100 +19182,44 @@ def from_json(json_str): """ :type json_str: str - :rtype: ChatMessage + :rtype: ExportRibContentApiObject """ - return converter.json_to_class(ChatMessage, json_str) + return converter.json_to_class(ExportRibContentApiObject, json_str) -class IdealMerchantTransaction(core.BunqModel): +class ExportRibApiObject(BunqModel): """ - View for requesting iDEAL transactions and polling their status. + Used to create new and read existing RIBs of a monetary account - :param _amount_requested: The requested amount of money to add. - :type _amount_requested: object_.Amount - :param _issuer: The BIC of the issuer. - :type _issuer: str - :param _monetary_account_id: The id of the monetary account this ideal - merchant transaction links to. - :type _monetary_account_id: int - :param _alias: The alias of the monetary account to add money to. - :type _alias: object_.MonetaryAccountReference - :param _counterparty_alias: The alias of the monetary account the money - comes from. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _amount_guaranteed: In case of a successful transaction, the amount - of money that will be transferred. - :type _amount_guaranteed: object_.Amount - :param _expiration: When the transaction will expire. - :type _expiration: str - :param _issuer_name: The Name of the issuer. - :type _issuer_name: str - :param _issuer_authentication_url: The URL to visit to - :type _issuer_authentication_url: str - :param _purchase_identifier: The 'purchase ID' of the iDEAL transaction. - :type _purchase_identifier: str - :param _status: The status of the transaction. - :type _status: str - :param _status_timestamp: When the status was last updated. - :type _status_timestamp: str - :param _transaction_identifier: The 'transaction ID' of the iDEAL - transaction. - :type _transaction_identifier: str - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool + :param _id_: The id of the rib as created on the server. + :type _id_: int + :param _created: The timestamp of the RIB's creation. + :type _created: str + :param _updated: The timestamp of the RIB's last update. + :type _updated: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction" - - # Field constants. - FIELD_AMOUNT_REQUESTED = "amount_requested" - FIELD_ISSUER = "issuer" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/export-rib" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/export-rib/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/export-rib/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/export-rib" # Object type. - _OBJECT_TYPE_GET = "IdealMerchantTransaction" - - _monetary_account_id = None - _alias = None - _counterparty_alias = None - _amount_guaranteed = None - _amount_requested = None - _expiration = None - _issuer = None - _issuer_name = None - _issuer_authentication_url = None - _purchase_identifier = None - _status = None - _status_timestamp = None - _transaction_identifier = None - _allow_chat = None - _amount_requested_field_for_request = None - _issuer_field_for_request = None - - def __init__(self, amount_requested, issuer): - """ - :param amount_requested: The requested amount of money to add. - :type amount_requested: object_.Amount - :param issuer: The BIC of the issuing bank to ask for money. - :type issuer: str - """ + _OBJECT_TYPE_GET = "ExportRib" - self._amount_requested_field_for_request = amount_requested - self._issuer_field_for_request = issuer + _id_ = None + _created = None + _updated = None @classmethod - def create(cls, amount_requested, issuer, monetary_account_id=None, - custom_headers=None): + def create(cls,monetary_account_id=None, custom_headers=None): """ + Create a new RIB. + :type user_id: int :type monetary_account_id: int - :param amount_requested: The requested amount of money to add. - :type amount_requested: object_.Amount - :param issuer: The BIC of the issuing bank to ask for money. - :type issuer: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -20224,60 +19229,78 @@ def create(cls, amount_requested, issuer, monetary_account_id=None, custom_headers = {} request_map = { - cls.FIELD_AMOUNT_REQUESTED: amount_requested, - cls.FIELD_ISSUER: issuer - } + +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def get(cls, ideal_merchant_transaction_id, monetary_account_id=None, - custom_headers=None): + def get(cls, export_rib_id, monetary_account_id=None, custom_headers=None): """ - :type api_context: context.ApiContext + Get a RIB for a monetary account by its id. + + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type ideal_merchant_transaction_id: int + :type export_rib_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseIdealMerchantTransaction + :rtype: BunqResponseExportRib """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - ideal_merchant_transaction_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), export_rib_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseIdealMerchantTransaction.cast_from_bunq_response( + return BunqResponseExportRib.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def delete(cls, export_rib_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type export_rib_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), export_rib_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ + List all the RIBs for a monetary account. + :type user_id: int :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseIdealMerchantTransactionList + :rtype: BunqResponseExportRibList """ if params is None: @@ -20286,173 +19309,327 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseIdealMerchantTransactionList.cast_from_bunq_response( + return BunqResponseExportRibList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def monetary_account_id(self): + def id_(self): """ :rtype: int """ - return self._monetary_account_id + return self._id_ @property - def alias(self): + def created(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: str """ - return self._alias + return self._created @property - def counterparty_alias(self): + def updated(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: str """ - return self._counterparty_alias + return self._updated - @property - def amount_guaranteed(self): + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._amount_guaranteed + if self._id_ is not None: + return False - @property - def amount_requested(self): - """ - :rtype: object_.Amount - """ + if self._created is not None: + return False - return self._amount_requested + if self._updated is not None: + return False - @property - def expiration(self): + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: ExportRibApiObject """ - return self._expiration + return converter.json_to_class(ExportRibApiObject, json_str) - @property - def issuer(self): - """ - :rtype: str - """ - return self._issuer +class ExportStatementCardCsvApiObject(BunqModel): + """ + Used to serialize ExportStatementCardCsv + + :param _date_start: The date from when this statement shows transactions. + :type _date_start: str + :param _date_end: The date until which statement shows transactions. + :type _date_end: str + :param _regional_format: The regional format of a CSV statement. + :type _regional_format: str + :param _id_: The id of the customer statement model. + :type _id_: int + :param _created: The timestamp of the statement model's creation. + :type _created: str + :param _updated: The timestamp of the statement model's last update. + :type _updated: str + :param _status: The status of the export. + :type _status: str + :param _card_id: The card for which this statement was created. + :type _card_id: int + """ - @property - def issuer_name(self): - """ - :rtype: str - """ + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/card/{}/export-statement-card-csv" + _ENDPOINT_URL_READ = "user/{}/card/{}/export-statement-card-csv/{}" + _ENDPOINT_URL_LISTING = "user/{}/card/{}/export-statement-card-csv" + _ENDPOINT_URL_DELETE = "user/{}/card/{}/export-statement-card-csv/{}" - return self._issuer_name + # Field constants. + FIELD_DATE_START = "date_start" + FIELD_DATE_END = "date_end" + FIELD_REGIONAL_FORMAT = "regional_format" - @property - def issuer_authentication_url(self): - """ - :rtype: str - """ + # Object type. + _OBJECT_TYPE_GET = "ExportStatementCardCsv" - return self._issuer_authentication_url + _id_ = None + _created = None + _updated = None + _date_start = None + _date_end = None + _status = None + _regional_format = None + _card_id = None + _date_start_field_for_request = None + _date_end_field_for_request = None + _regional_format_field_for_request = None - @property - def purchase_identifier(self): + def __init__(self, date_start, date_end, regional_format): """ - :rtype: str + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str + :param regional_format: Required for CSV exports. The regional format of the + statement, can be UK_US (comma-separated) or EUROPEAN (semicolon-separated). + :type regional_format: str """ - return self._purchase_identifier + self._date_start_field_for_request = date_start + self._date_end_field_for_request = date_end + self._regional_format_field_for_request = regional_format - @property - def status(self): + @classmethod + def create(cls,card_id, date_start, date_end, regional_format, custom_headers=None): + """ + :type user_id: int + :type card_id: int + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str + :param regional_format: Required for CSV exports. The regional format of + the statement, can be UK_US (comma-separated) or EUROPEAN + (semicolon-separated). + :type regional_format: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DATE_START : date_start, +cls.FIELD_DATE_END : date_end, +cls.FIELD_REGIONAL_FORMAT : regional_format +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), card_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, card_id, export_statement_card_csv_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type card_id: int + :type export_statement_card_csv_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatementCardCsv + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), card_id, export_statement_card_csv_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseExportStatementCardCsv.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def list(cls,card_id, params=None, custom_headers=None): + """ + :type user_id: int + :type card_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatementCardCsvList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), card_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseExportStatementCardCsvList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def delete(cls, card_id, export_statement_card_csv_id, custom_headers=None): + """ + :type user_id: int + :type card_id: int + :type export_statement_card_csv_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), card_id, export_statement_card_csv_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): """ :rtype: str """ - return self._status + return self._created @property - def status_timestamp(self): + def updated(self): """ :rtype: str """ - return self._status_timestamp + return self._updated @property - def transaction_identifier(self): + def date_start(self): """ :rtype: str """ - return self._transaction_identifier + return self._date_start @property - def allow_chat(self): + def date_end(self): """ - :rtype: bool + :rtype: str """ - return self._allow_chat + return self._date_end - def is_all_field_none(self): + @property + def status(self): """ - :rtype: bool + :rtype: str """ - if self._monetary_account_id is not None: - return False + return self._status - if self._alias is not None: - return False + @property + def regional_format(self): + """ + :rtype: str + """ - if self._counterparty_alias is not None: - return False + return self._regional_format - if self._amount_guaranteed is not None: - return False + @property + def card_id(self): + """ + :rtype: int + """ - if self._amount_requested is not None: - return False + return self._card_id - if self._expiration is not None: - return False + def is_all_field_none(self): + """ + :rtype: bool + """ - if self._issuer is not None: + if self._id_ is not None: return False - if self._issuer_name is not None: + if self._created is not None: return False - if self._issuer_authentication_url is not None: + if self._updated is not None: return False - if self._purchase_identifier is not None: + if self._date_start is not None: return False - if self._status is not None: + if self._date_end is not None: return False - if self._status_timestamp is not None: + if self._status is not None: return False - if self._transaction_identifier is not None: + if self._regional_format is not None: return False - if self._allow_chat is not None: + if self._card_id is not None: return False return True @@ -20462,171 +19639,131 @@ def from_json(json_str): """ :type json_str: str - :rtype: IdealMerchantTransaction + :rtype: ExportStatementCardCsvApiObject """ - return converter.json_to_class(IdealMerchantTransaction, json_str) + return converter.json_to_class(ExportStatementCardCsvApiObject, json_str) -class MasterCardAction(core.BunqModel): +class ExportStatementCardPdfApiObject(BunqModel): """ - MasterCard transaction view. + Used to serialize ExportStatementCardPdf - :param _id_: The id of the MastercardAction. + :param _date_start: The date from when this statement shows transactions. + :type _date_start: str + :param _date_end: The date until which statement shows transactions. + :type _date_end: str + :param _id_: The id of the customer statement model. :type _id_: int - :param _monetary_account_id: The id of the monetary account this action - links to. - :type _monetary_account_id: int - :param _card_id: The id of the card this action links to. + :param _created: The timestamp of the statement model's creation. + :type _created: str + :param _updated: The timestamp of the statement model's last update. + :type _updated: str + :param _status: The status of the export. + :type _status: str + :param _card_id: The card for which this statement was created. :type _card_id: int - :param _amount_local: The amount of the transaction in local currency. - :type _amount_local: object_.Amount - :param _amount_billing: The amount of the transaction in the monetary - account's currency. - :type _amount_billing: object_.Amount - :param _amount_original_local: The original amount in local currency. - :type _amount_original_local: object_.Amount - :param _amount_original_billing: The original amount in the monetary - account's currency. - :type _amount_original_billing: object_.Amount - :param _amount_fee: The fee amount as charged by the merchant, if - applicable. - :type _amount_fee: object_.Amount - :param _card_authorisation_id_response: The response code by which - authorised transaction can be identified as authorised by bunq. - :type _card_authorisation_id_response: str - :param _decision: Why the transaction was denied, if it was denied, or just - ALLOWED. - :type _decision: str - :param _decision_description: Empty if allowed, otherwise a textual - explanation of why it was denied. - :type _decision_description: str - :param _decision_description_translated: Empty if allowed, otherwise a - textual explanation of why it was denied in user's language. - :type _decision_description_translated: str - :param _description: The description for this transaction to display. - :type _description: str - :param _authorisation_status: The status in the authorisation process. - :type _authorisation_status: str - :param _authorisation_type: The type of transaction that was delivered using - the card. - :type _authorisation_type: str - :param _pan_entry_mode_user: The type of entry mode the user used. Can be - 'ATM', 'ICC', 'MAGNETIC_STRIPE' or 'E_COMMERCE'. - :type _pan_entry_mode_user: str - :param _settlement_status: The setlement status in the authorisation - process. - :type _settlement_status: str - :param _city: The city where the message originates from as announced by the - terminal. - :type _city: str - :param _alias: The monetary account label of the account that this action is - created for. - :type _alias: object_.MonetaryAccountReference - :param _counterparty_alias: The monetary account label of the counterparty. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _label_card: The label of the card. - :type _label_card: object_.LabelCard - :param _token_status: If this is a tokenisation action, this shows the - status of the token. - :type _token_status: str - :param _reservation_expiry_time: If this is a reservation, the moment the - reservation will expire. - :type _reservation_expiry_time: str - :param _applied_limit: The type of the limit applied to validate if this - MasterCardAction was within the spending limits. The returned string matches - the limit types as defined in the card endpoint. - :type _applied_limit: str - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool - :param _eligible_whitelist_id: The whitelist id for this mastercard action - or null. - :type _eligible_whitelist_id: int - :param _secure_code_id: The secure code id for this mastercard action or - null. - :type _secure_code_id: int - :param _wallet_provider_id: The ID of the wallet provider as defined by - MasterCard. 420 = bunq Android app with Tap&Pay; 103 = Apple Pay. - :type _wallet_provider_id: str - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] """ # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action" + _ENDPOINT_URL_CREATE = "user/{}/card/{}/export-statement-card-pdf" + _ENDPOINT_URL_READ = "user/{}/card/{}/export-statement-card-pdf/{}" + _ENDPOINT_URL_LISTING = "user/{}/card/{}/export-statement-card-pdf" + _ENDPOINT_URL_DELETE = "user/{}/card/{}/export-statement-card-pdf/{}" + + # Field constants. + FIELD_DATE_START = "date_start" + FIELD_DATE_END = "date_end" # Object type. - _OBJECT_TYPE_GET = "MasterCardAction" + _OBJECT_TYPE_GET = "ExportStatementCardPdf" _id_ = None - _monetary_account_id = None + _created = None + _updated = None + _date_start = None + _date_end = None + _status = None _card_id = None - _amount_local = None - _amount_billing = None - _amount_original_local = None - _amount_original_billing = None - _amount_fee = None - _card_authorisation_id_response = None - _decision = None - _decision_description = None - _decision_description_translated = None - _description = None - _authorisation_status = None - _authorisation_type = None - _pan_entry_mode_user = None - _settlement_status = None - _city = None - _alias = None - _counterparty_alias = None - _label_card = None - _token_status = None - _reservation_expiry_time = None - _applied_limit = None - _allow_chat = None - _eligible_whitelist_id = None - _secure_code_id = None - _wallet_provider_id = None - _request_reference_split_the_bill = None + _date_start_field_for_request = None + _date_end_field_for_request = None + + def __init__(self, date_start, date_end): + """ + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str + """ + + self._date_start_field_for_request = date_start + self._date_end_field_for_request = date_end @classmethod - def get(cls, master_card_action_id, monetary_account_id=None, - custom_headers=None): + def create(cls,card_id, date_start, date_end, custom_headers=None): """ - :type api_context: context.ApiContext :type user_id: int - :type monetary_account_id: int - :type master_card_action_id: int + :type card_id: int + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMasterCardAction + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DATE_START : date_start, +cls.FIELD_DATE_END : date_end +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), card_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, card_id, export_statement_card_pdf_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type card_id: int + :type export_statement_card_pdf_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatementCardPdf """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - master_card_action_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), card_id, export_statement_card_pdf_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseMasterCardAction.cast_from_bunq_response( + return BunqResponseExportStatementCardPdf.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls,card_id, params=None, custom_headers=None): """ :type user_id: int - :type monetary_account_id: int + :type card_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseMasterCardActionList + :rtype: BunqResponseExportStatementCardPdfList """ if params is None: @@ -20635,16 +19772,36 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), card_id) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseMasterCardActionList.cast_from_bunq_response( + return BunqResponseExportStatementCardPdfList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) + @classmethod + def delete(cls, card_id, export_statement_card_pdf_id, custom_headers=None): + """ + :type user_id: int + :type card_id: int + :type export_statement_card_pdf_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), card_id, export_statement_card_pdf_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + @property def id_(self): """ @@ -20654,320 +19811,434 @@ def id_(self): return self._id_ @property - def monetary_account_id(self): + def created(self): """ - :rtype: int + :rtype: str """ - return self._monetary_account_id + return self._created @property - def card_id(self): + def updated(self): """ - :rtype: int + :rtype: str """ - return self._card_id + return self._updated @property - def amount_local(self): + def date_start(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount_local + return self._date_start @property - def amount_billing(self): + def date_end(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount_billing + return self._date_end @property - def amount_original_local(self): + def status(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount_original_local + return self._status @property - def amount_original_billing(self): + def card_id(self): """ - :rtype: object_.Amount + :rtype: int """ - return self._amount_original_billing + return self._card_id - @property - def amount_fee(self): + def is_all_field_none(self): """ - :rtype: object_.Amount + :rtype: bool """ - return self._amount_fee + if self._id_ is not None: + return False - @property - def card_authorisation_id_response(self): + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._date_start is not None: + return False + + if self._date_end is not None: + return False + + if self._status is not None: + return False + + if self._card_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: ExportStatementCardPdfApiObject """ - return self._card_authorisation_id_response + return converter.json_to_class(ExportStatementCardPdfApiObject, json_str) - @property - def decision(self): + +class ExportStatementCardApiObject(BunqModel): + """ + Used to create new and read existing card statement exports. Statement + exports can be created in either CSV or PDF file format. + + :param _id_: The id of the customer statement model. + :type _id_: int + :param _created: The timestamp of the statement model's creation. + :type _created: str + :param _updated: The timestamp of the statement model's last update. + :type _updated: str + :param _date_start: The date from when this statement shows transactions. + :type _date_start: str + :param _date_end: The date until which statement shows transactions. + :type _date_end: str + :param _status: The status of the export. + :type _status: str + :param _regional_format: The regional format of a CSV statement. + :type _regional_format: str + :param _card_id: The card for which this statement was created. + :type _card_id: int + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/card/{}/export-statement-card/{}" + _ENDPOINT_URL_LISTING = "user/{}/card/{}/export-statement-card" + + # Object type. + _OBJECT_TYPE_GET = "ExportStatementCard" + + _id_ = None + _created = None + _updated = None + _date_start = None + _date_end = None + _status = None + _regional_format = None + _card_id = None + + @classmethod + def get(cls, card_id, export_statement_card_id, custom_headers=None): """ - :rtype: str + :type api_context: ApiContext + :type user_id: int + :type card_id: int + :type export_statement_card_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatementCard """ - return self._decision + if custom_headers is None: + custom_headers = {} - @property - def decision_description(self): + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), card_id, export_statement_card_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseExportStatementCard.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def list(cls,card_id, params=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :type card_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatementCardList """ - return self._decision_description + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), card_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseExportStatementCardList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def decision_description_translated(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._decision_description_translated + return self._id_ @property - def description(self): + def created(self): """ :rtype: str """ - return self._description + return self._created @property - def authorisation_status(self): + def updated(self): """ :rtype: str """ - return self._authorisation_status + return self._updated @property - def authorisation_type(self): + def date_start(self): """ :rtype: str """ - return self._authorisation_type + return self._date_start @property - def pan_entry_mode_user(self): + def date_end(self): """ :rtype: str """ - return self._pan_entry_mode_user + return self._date_end @property - def settlement_status(self): + def status(self): """ :rtype: str """ - return self._settlement_status + return self._status @property - def city(self): + def regional_format(self): """ :rtype: str """ - return self._city + return self._regional_format @property - def alias(self): + def card_id(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: int """ - return self._alias + return self._card_id - @property - def counterparty_alias(self): + def is_all_field_none(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: bool """ - return self._counterparty_alias + if self._id_ is not None: + return False - @property - def label_card(self): - """ - :rtype: object_.LabelCard - """ + if self._created is not None: + return False - return self._label_card + if self._updated is not None: + return False - @property - def token_status(self): - """ - :rtype: str - """ + if self._date_start is not None: + return False - return self._token_status + if self._date_end is not None: + return False - @property - def reservation_expiry_time(self): - """ - :rtype: str - """ + if self._status is not None: + return False - return self._reservation_expiry_time + if self._regional_format is not None: + return False - @property - def applied_limit(self): - """ - :rtype: str - """ + if self._card_id is not None: + return False - return self._applied_limit + return True - @property - def allow_chat(self): + @staticmethod + def from_json(json_str): """ - :rtype: bool + :type json_str: str + + :rtype: ExportStatementCardApiObject """ - return self._allow_chat + return converter.json_to_class(ExportStatementCardApiObject, json_str) - @property - def eligible_whitelist_id(self): - """ - :rtype: int - """ - return self._eligible_whitelist_id +class ExportStatementCardContentApiObject(BunqModel): + """ + Fetch the raw content of a card statement export. The returned file format + could be CSV or PDF depending on the statement format specified during the + statement creation. The doc won't display the response of a request to get + the content of a statement export. + """ - @property - def secure_code_id(self): - """ - :rtype: int - """ + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/card/{}/export-statement-card/{}/content" - return self._secure_code_id + # Object type. + _OBJECT_TYPE_GET = "ExportStatementCardContent" - @property - def wallet_provider_id(self): + @classmethod + def list(cls, card_id, export_statement_card_id, custom_headers=None): """ - :rtype: str + :type user_id: int + :type card_id: int + :type export_statement_card_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes """ - return self._wallet_provider_id + if custom_headers is None: + custom_headers = {} - @property - def request_reference_split_the_bill(self): - """ - :rtype: list[object_.RequestInquiryReference] - """ + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), card_id, export_statement_card_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) - return self._request_reference_split_the_bill def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._monetary_account_id is not None: - return False - - if self._card_id is not None: - return False - - if self._amount_local is not None: - return False + return True - if self._amount_billing is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ExportStatementCardContentApiObject + """ - if self._amount_original_local is not None: - return False + return converter.json_to_class(ExportStatementCardContentApiObject, json_str) - if self._amount_original_billing is not None: - return False - if self._amount_fee is not None: - return False +class ExportStatementContentApiObject(BunqModel): + """ + Fetch the raw content of a statement export. The returned file format could + be MT940, CSV or PDF depending on the statement format specified during the + statement creation. The doc won't display the response of a request to get + the content of a statement export. + """ - if self._card_authorisation_id_response is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/customer-statement/{}/content" - if self._decision is not None: - return False + # Object type. + _OBJECT_TYPE_GET = "ExportStatementContent" - if self._decision_description is not None: - return False + @classmethod + def list(cls, customer_statement_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type customer_statement_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes + """ - if self._decision_description_translated is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._description is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), customer_statement_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - if self._authorisation_status is not None: - return False + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) - if self._authorisation_type is not None: - return False - if self._pan_entry_mode_user is not None: - return False + def is_all_field_none(self): + """ + :rtype: bool + """ - if self._settlement_status is not None: - return False + return True - if self._city is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ExportStatementContentApiObject + """ - if self._alias is not None: - return False + return converter.json_to_class(ExportStatementContentApiObject, json_str) - if self._counterparty_alias is not None: - return False - if self._label_card is not None: - return False +class ExportStatementPaymentContentApiObject(BunqModel): + """ + Fetch the raw content of a payment statement export. + """ - if self._token_status is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/event/{}/statement/{}/content" - if self._reservation_expiry_time is not None: - return False + # Object type. + _OBJECT_TYPE_GET = "ExportStatementPayment" - if self._applied_limit is not None: - return False + @classmethod + def list(cls, event_id, statement_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type event_id: int + :type statement_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseBytes + """ - if self._allow_chat is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._eligible_whitelist_id is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), event_id, statement_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - if self._secure_code_id is not None: - return False + return BunqResponseBytes.cast_from_bunq_response( + BunqResponse(response_raw.body_bytes, response_raw.headers) + ) - if self._wallet_provider_id is not None: - return False - if self._request_reference_split_the_bill is not None: - return False + def is_all_field_none(self): + """ + :rtype: bool + """ return True @@ -20976,303 +20247,43 @@ def from_json(json_str): """ :type json_str: str - :rtype: MasterCardAction + :rtype: ExportStatementPaymentContentApiObject """ - return converter.json_to_class(MasterCardAction, json_str) + return converter.json_to_class(ExportStatementPaymentContentApiObject, json_str) -class RequestInquiry(core.BunqModel): +class ExportStatementPaymentApiObject(BunqModel): """ - RequestInquiry, aka 'RFP' (Request for Payment), is one of the innovative - features that bunq offers. To request payment from another bunq account a - new Request Inquiry is created. As with payments you can add attachments to - a RFP. Requests for Payment are the foundation for a number of consumer - features like 'Split the bill' and 'Request forwarding'. We invite you to - invent your own based on the bunq api! + Used to create a statement export of a single payment. - :param _amount_inquired: The requested amount. - :type _amount_inquired: object_.Amount - :param _counterparty_alias: The LabelMonetaryAccount with the public - information of the MonetaryAccount the money was requested from. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _description: The description of the inquiry. - :type _description: str - :param _attachment: The attachments attached to the payment. - :type _attachment: list[object_.BunqId] - :param _merchant_reference: The client's custom reference that was attached - to the request and the mutation. - :type _merchant_reference: str - :param _status: The status of the request. - :type _status: str - :param _minimum_age: The minimum age the user accepting the RequestInquiry - must have. - :type _minimum_age: int - :param _require_address: Whether or not an address must be provided on - accept. - :type _require_address: str - :param _want_tip: [DEPRECATED] Whether or not the accepting user can give an - extra tip on top of the requested Amount. Defaults to false. - :type _want_tip: bool - :param _allow_amount_lower: [DEPRECATED] Whether or not the accepting user - can choose to accept with a lower amount than requested. Defaults to false. - :type _allow_amount_lower: bool - :param _allow_amount_higher: [DEPRECATED] Whether or not the accepting user - can choose to accept with a higher amount than requested. Defaults to false. - :type _allow_amount_higher: bool - :param _allow_bunqme: Whether or not sending a bunq.me request is allowed. - :type _allow_bunqme: bool - :param _redirect_url: The URL which the user is sent to after accepting or - rejecting the Request. - :type _redirect_url: str - :param _event_id: The ID of the associated event if the request was made - using 'split the bill'. - :type _event_id: int - :param _id_: The id of the created RequestInquiry. + :param _id_: The id of the single payment statement model. :type _id_: int - :param _created: The timestamp of the payment request's creation. + :param _created: The timestamp of the statement model's creation. :type _created: str - :param _updated: The timestamp of the payment request's last update. + :param _updated: The timestamp of the statement model's last update. :type _updated: str - :param _time_responded: The timestamp of when the payment request was - responded to. - :type _time_responded: str - :param _time_expiry: The timestamp of when the payment request expired. - :type _time_expiry: str - :param _monetary_account_id: The id of the monetary account the request - response applies to. - :type _monetary_account_id: int - :param _amount_responded: The responded amount. - :type _amount_responded: object_.Amount - :param _user_alias_created: The label that's displayed to the counterparty - with the mutation. Includes user. - :type _user_alias_created: object_.LabelUser - :param _user_alias_revoked: The label that's displayed to the counterparty - with the mutation. Includes user. - :type _user_alias_revoked: object_.LabelUser - :param _batch_id: The id of the batch if the request was part of a batch. - :type _batch_id: int - :param _scheduled_id: The id of the scheduled job if the request was - scheduled. - :type _scheduled_id: int - :param _bunqme_share_url: The url that points to the bunq.me request. - :type _bunqme_share_url: str - :param _address_shipping: The shipping address provided by the accepting - user if an address was requested. - :type _address_shipping: object_.Address - :param _address_billing: The billing address provided by the accepting user - if an address was requested. - :type _address_billing: object_.Address - :param _geolocation: The geolocation where the payment was done. - :type _geolocation: object_.Geolocation - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool - :param _reference_split_the_bill: The reference to the object used for split - the bill. Can be Payment, PaymentBatch, ScheduleInstance, RequestResponse - and MasterCardAction - :type _reference_split_the_bill: - object_.RequestReferenceSplitTheBillAnchorObject + :param _status: The status of the export. + :type _status: str """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}" - - # Field constants. - FIELD_AMOUNT_INQUIRED = "amount_inquired" - FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" - FIELD_DESCRIPTION = "description" - FIELD_ATTACHMENT = "attachment" - FIELD_MERCHANT_REFERENCE = "merchant_reference" - FIELD_STATUS = "status" - FIELD_MINIMUM_AGE = "minimum_age" - FIELD_REQUIRE_ADDRESS = "require_address" - FIELD_WANT_TIP = "want_tip" - FIELD_ALLOW_AMOUNT_LOWER = "allow_amount_lower" - FIELD_ALLOW_AMOUNT_HIGHER = "allow_amount_higher" - FIELD_ALLOW_BUNQME = "allow_bunqme" - FIELD_REDIRECT_URL = "redirect_url" - FIELD_EVENT_ID = "event_id" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/event/{}/statement" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/event/{}/statement/{}" # Object type. - _OBJECT_TYPE_PUT = "RequestInquiry" - _OBJECT_TYPE_GET = "RequestInquiry" + _OBJECT_TYPE_GET = "ExportStatementPayment" _id_ = None _created = None _updated = None - _time_responded = None - _time_expiry = None - _monetary_account_id = None - _amount_inquired = None - _amount_responded = None - _user_alias_created = None - _user_alias_revoked = None - _counterparty_alias = None - _description = None - _merchant_reference = None - _attachment = None _status = None - _batch_id = None - _scheduled_id = None - _minimum_age = None - _require_address = None - _bunqme_share_url = None - _redirect_url = None - _address_shipping = None - _address_billing = None - _geolocation = None - _allow_chat = None - _reference_split_the_bill = None - _amount_inquired_field_for_request = None - _counterparty_alias_field_for_request = None - _description_field_for_request = None - _attachment_field_for_request = None - _merchant_reference_field_for_request = None - _status_field_for_request = None - _minimum_age_field_for_request = None - _require_address_field_for_request = None - _want_tip_field_for_request = None - _allow_amount_lower_field_for_request = None - _allow_amount_higher_field_for_request = None - _allow_bunqme_field_for_request = None - _redirect_url_field_for_request = None - _event_id_field_for_request = None - - def __init__(self, amount_inquired, counterparty_alias, description, - allow_bunqme, attachment=None, merchant_reference=None, - status=None, minimum_age=None, require_address=None, - want_tip=None, allow_amount_lower=None, - allow_amount_higher=None, redirect_url=None, event_id=None): - """ - :param amount_inquired: The Amount requested to be paid by the person the - RequestInquiry is sent to. Must be bigger than 0. - :type amount_inquired: object_.Amount - :param counterparty_alias: The Alias of the party we are requesting the - money from. Can be an Alias of type EMAIL, PHONE_NUMBER or IBAN. In case the - EMAIL or PHONE_NUMBER Alias does not refer to a bunq monetary account, - 'allow_bunqme' needs to be 'true' in order to trigger the creation of a - bunq.me request. Otherwise no request inquiry will be sent. - :type counterparty_alias: object_.Pointer - :param description: The description for the RequestInquiry. Maximum 9000 - characters. Field is required but can be an empty string. - :type description: str - :param allow_bunqme: Whether or not sending a bunq.me request is allowed. - :type allow_bunqme: bool - :param attachment: The Attachments to attach to the RequestInquiry. - :type attachment: list[object_.BunqId] - :param merchant_reference: Optional data to be included with the - RequestInquiry specific to the merchant. Has to be unique for the same - source MonetaryAccount. - :type merchant_reference: str - :param status: The status of the RequestInquiry. Ignored in POST requests - but can be used for revoking (cancelling) the RequestInquiry by setting - REVOKED with a PUT request. - :type status: str - :param minimum_age: The minimum age the user accepting the RequestInquiry - must have. Defaults to not checking. If set, must be between 12 and 100 - inclusive. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the request. Possible values are: BILLING, SHIPPING, - BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param want_tip: [DEPRECATED] Whether or not the accepting user can give an - extra tip on top of the requested Amount. Defaults to false. - :type want_tip: bool - :param allow_amount_lower: [DEPRECATED] Whether or not the accepting user - can choose to accept with a lower amount than requested. Defaults to false. - :type allow_amount_lower: bool - :param allow_amount_higher: [DEPRECATED] Whether or not the accepting user - can choose to accept with a higher amount than requested. Defaults to false. - :type allow_amount_higher: bool - :param redirect_url: The URL which the user is sent to after accepting or - rejecting the Request. - :type redirect_url: str - :param event_id: The ID of the associated event if the request was made - using 'split the bill'. - :type event_id: int - """ - - self._amount_inquired_field_for_request = amount_inquired - self._counterparty_alias_field_for_request = counterparty_alias - self._description_field_for_request = description - self._allow_bunqme_field_for_request = allow_bunqme - self._attachment_field_for_request = attachment - self._merchant_reference_field_for_request = merchant_reference - self._status_field_for_request = status - self._minimum_age_field_for_request = minimum_age - self._require_address_field_for_request = require_address - self._want_tip_field_for_request = want_tip - self._allow_amount_lower_field_for_request = allow_amount_lower - self._allow_amount_higher_field_for_request = allow_amount_higher - self._redirect_url_field_for_request = redirect_url - self._event_id_field_for_request = event_id @classmethod - def create(cls, amount_inquired, counterparty_alias, description, - allow_bunqme, monetary_account_id=None, attachment=None, - merchant_reference=None, status=None, minimum_age=None, - require_address=None, want_tip=None, allow_amount_lower=None, - allow_amount_higher=None, redirect_url=None, event_id=None, - custom_headers=None): + def create(cls,event_id, monetary_account_id=None, custom_headers=None): """ - Create a new payment request. - :type user_id: int :type monetary_account_id: int - :param amount_inquired: The Amount requested to be paid by the person - the RequestInquiry is sent to. Must be bigger than 0. - :type amount_inquired: object_.Amount - :param counterparty_alias: The Alias of the party we are requesting the - money from. Can be an Alias of type EMAIL, PHONE_NUMBER or IBAN. In case - the EMAIL or PHONE_NUMBER Alias does not refer to a bunq monetary - account, 'allow_bunqme' needs to be 'true' in order to trigger the - creation of a bunq.me request. Otherwise no request inquiry will be - sent. - :type counterparty_alias: object_.Pointer - :param description: The description for the RequestInquiry. Maximum 9000 - characters. Field is required but can be an empty string. - :type description: str - :param allow_bunqme: Whether or not sending a bunq.me request is - allowed. - :type allow_bunqme: bool - :param attachment: The Attachments to attach to the RequestInquiry. - :type attachment: list[object_.BunqId] - :param merchant_reference: Optional data to be included with the - RequestInquiry specific to the merchant. Has to be unique for the same - source MonetaryAccount. - :type merchant_reference: str - :param status: The status of the RequestInquiry. Ignored in POST - requests but can be used for revoking (cancelling) the RequestInquiry by - setting REVOKED with a PUT request. - :type status: str - :param minimum_age: The minimum age the user accepting the - RequestInquiry must have. Defaults to not checking. If set, must be - between 12 and 100 inclusive. - :type minimum_age: int - :param require_address: Whether a billing and shipping address must be - provided when paying the request. Possible values are: BILLING, - SHIPPING, BILLING_SHIPPING, NONE, OPTIONAL. Default is NONE. - :type require_address: str - :param want_tip: [DEPRECATED] Whether or not the accepting user can give - an extra tip on top of the requested Amount. Defaults to false. - :type want_tip: bool - :param allow_amount_lower: [DEPRECATED] Whether or not the accepting - user can choose to accept with a lower amount than requested. Defaults - to false. - :type allow_amount_lower: bool - :param allow_amount_higher: [DEPRECATED] Whether or not the accepting - user can choose to accept with a higher amount than requested. Defaults - to false. - :type allow_amount_higher: bool - :param redirect_url: The URL which the user is sent to after accepting - or rejecting the Request. - :type redirect_url: str - :param event_id: The ID of the associated event if the request was made - using 'split the bill'. :type event_id: int :type custom_headers: dict[str, str]|None @@ -21283,88 +20294,271 @@ def create(cls, amount_inquired, counterparty_alias, description, custom_headers = {} request_map = { - cls.FIELD_AMOUNT_INQUIRED: amount_inquired, - cls.FIELD_COUNTERPARTY_ALIAS: counterparty_alias, - cls.FIELD_DESCRIPTION: description, - cls.FIELD_ATTACHMENT: attachment, - cls.FIELD_MERCHANT_REFERENCE: merchant_reference, - cls.FIELD_STATUS: status, - cls.FIELD_MINIMUM_AGE: minimum_age, - cls.FIELD_REQUIRE_ADDRESS: require_address, - cls.FIELD_WANT_TIP: want_tip, - cls.FIELD_ALLOW_AMOUNT_LOWER: allow_amount_lower, - cls.FIELD_ALLOW_AMOUNT_HIGHER: allow_amount_higher, - cls.FIELD_ALLOW_BUNQME: allow_bunqme, - cls.FIELD_REDIRECT_URL: redirect_url, - cls.FIELD_EVENT_ID: event_id - } + +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), event_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def update(cls, request_inquiry_id, monetary_account_id=None, status=None, - custom_headers=None): + def get(cls, event_id, export_statement_payment_id, monetary_account_id=None, custom_headers=None): """ - Revoke a request for payment, by updating the status to REVOKED. - + :type api_context: ApiContext :type user_id: int :type monetary_account_id: int - :type request_inquiry_id: int - :param status: The status of the RequestInquiry. Ignored in POST - requests but can be used for revoking (cancelling) the RequestInquiry by - setting REVOKED with a PUT request. - :type status: str + :type event_id: int + :type export_statement_payment_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseRequestInquiry + :rtype: BunqResponseExportStatementPayment """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), event_id, export_statement_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseRequestInquiry.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) + return BunqResponseExportStatementPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._status is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ExportStatementPaymentApiObject + """ + + return converter.json_to_class(ExportStatementPaymentApiObject, json_str) + + +class ExportStatementApiObject(BunqModel): + """ + Used to create new and read existing statement exports. Statement exports + can be created in either CSV, MT940 or PDF file format. + + :param _statement_format: The format of statement. + :type _statement_format: str + :param _date_start: The date from when this statement shows transactions. + :type _date_start: str + :param _date_end: The date until which statement shows transactions. + :type _date_end: str + :param _regional_format: The regional format of a CSV statement. + :type _regional_format: str + :param _include_attachment: Only for PDF exports. Includes attachments to + mutations in the export, such as scanned receipts. + :type _include_attachment: bool + :param _id_: The id of the customer statement model. + :type _id_: int + :param _created: The timestamp of the statement model's creation. + :type _created: str + :param _updated: The timestamp of the statement model's last update. + :type _updated: str + :param _status: The status of the export. + :type _status: str + :param _statement_number: MT940 Statement number. Unique per monetary + account. + :type _statement_number: int + :param _alias_monetary_account: The monetary account for which this + statement was created. + :type _alias_monetary_account: object_.MonetaryAccountReference + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/customer-statement" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/customer-statement/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/customer-statement" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/customer-statement/{}" + + # Field constants. + FIELD_STATEMENT_FORMAT = "statement_format" + FIELD_DATE_START = "date_start" + FIELD_DATE_END = "date_end" + FIELD_REGIONAL_FORMAT = "regional_format" + FIELD_INCLUDE_ATTACHMENT = "include_attachment" + + # Object type. + _OBJECT_TYPE_GET = "CustomerStatement" + + _id_ = None + _created = None + _updated = None + _date_start = None + _date_end = None + _status = None + _statement_number = None + _statement_format = None + _regional_format = None + _alias_monetary_account = None + _statement_format_field_for_request = None + _date_start_field_for_request = None + _date_end_field_for_request = None + _regional_format_field_for_request = None + _include_attachment_field_for_request = None + + def __init__(self, statement_format, date_start, date_end, regional_format=None, include_attachment=None): + """ + :param statement_format: The format type of statement. Allowed values: + MT940, CSV, PDF. + :type statement_format: str + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str + :param regional_format: Required for CSV exports. The regional format of the + statement, can be UK_US (comma-separated) or EUROPEAN (semicolon-separated). + :type regional_format: str + :param include_attachment: Only for PDF exports. Includes attachments to + mutations in the export, such as scanned receipts. + :type include_attachment: bool + """ + + self._statement_format_field_for_request = statement_format + self._date_start_field_for_request = date_start + self._date_end_field_for_request = date_end + self._regional_format_field_for_request = regional_format + self._include_attachment_field_for_request = include_attachment + + @classmethod + def create(cls,statement_format, date_start, date_end, monetary_account_id=None, regional_format=None, include_attachment=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :param statement_format: The format type of statement. Allowed values: + MT940, CSV, PDF. + :type statement_format: str + :param date_start: The start date for making statements. + :type date_start: str + :param date_end: The end date for making statements. + :type date_end: str + :param regional_format: Required for CSV exports. The regional format of + the statement, can be UK_US (comma-separated) or EUROPEAN + (semicolon-separated). + :type regional_format: str + :param include_attachment: Only for PDF exports. Includes attachments to + mutations in the export, such as scanned receipts. + :type include_attachment: bool + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_STATEMENT_FORMAT : statement_format, +cls.FIELD_DATE_START : date_start, +cls.FIELD_DATE_END : date_end, +cls.FIELD_REGIONAL_FORMAT : regional_format, +cls.FIELD_INCLUDE_ATTACHMENT : include_attachment +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, export_statement_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type export_statement_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseExportStatement + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), export_statement_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseExportStatement.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Get all payment requests for a user's monetary account. - :type user_id: int :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseRequestInquiryList + :rtype: BunqResponseExportStatementList """ if params is None: @@ -21373,43 +20567,34 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseRequestInquiryList.cast_from_bunq_response( + return BunqResponseExportStatementList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, request_inquiry_id, monetary_account_id=None, - custom_headers=None): + def delete(cls, export_statement_id, monetary_account_id=None, custom_headers=None): """ - Get the details of a specific payment request, including its status. - - :type api_context: context.ApiContext :type user_id: int :type monetary_account_id: int - :type request_inquiry_id: int + :type export_statement_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseRequestInquiry + :rtype: BunqResponseNone """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), export_statement_id) + response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseRequestInquiry.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) ) @property @@ -21437,188 +20622,238 @@ def updated(self): return self._updated @property - def time_responded(self): + def date_start(self): """ :rtype: str """ - return self._time_responded + return self._date_start @property - def time_expiry(self): + def date_end(self): """ :rtype: str """ - return self._time_expiry + return self._date_end @property - def monetary_account_id(self): + def status(self): """ - :rtype: int + :rtype: str """ - return self._monetary_account_id + return self._status @property - def amount_inquired(self): + def statement_number(self): """ - :rtype: object_.Amount + :rtype: int """ - return self._amount_inquired + return self._statement_number @property - def amount_responded(self): + def statement_format(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._amount_responded + return self._statement_format @property - def user_alias_created(self): + def regional_format(self): """ - :rtype: object_.LabelUser + :rtype: str """ - return self._user_alias_created + return self._regional_format @property - def user_alias_revoked(self): + def alias_monetary_account(self): """ - :rtype: object_.LabelUser + :rtype: object_.MonetaryAccountReference """ - return self._user_alias_revoked + return self._alias_monetary_account - @property - def counterparty_alias(self): + def is_all_field_none(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: bool """ - return self._counterparty_alias + if self._id_ is not None: + return False - @property - def description(self): - """ - :rtype: str - """ + if self._created is not None: + return False - return self._description + if self._updated is not None: + return False - @property - def merchant_reference(self): - """ - :rtype: str - """ + if self._date_start is not None: + return False - return self._merchant_reference + if self._date_end is not None: + return False - @property - def attachment(self): - """ - :rtype: list[object_.BunqId] - """ + if self._status is not None: + return False - return self._attachment + if self._statement_number is not None: + return False - @property - def status(self): - """ - :rtype: str - """ + if self._statement_format is not None: + return False - return self._status + if self._regional_format is not None: + return False - @property - def batch_id(self): - """ - :rtype: int - """ + if self._alias_monetary_account is not None: + return False - return self._batch_id + return True - @property - def scheduled_id(self): + @staticmethod + def from_json(json_str): """ - :rtype: int + :type json_str: str + + :rtype: ExportStatementApiObject """ - return self._scheduled_id + return converter.json_to_class(ExportStatementApiObject, json_str) - @property - def minimum_age(self): + +class InsightEventApiObject(BunqModel): + """ + Used to get events based on time and insight category. + + :param _id_: The id of the event. + :type _id_: int + :param _created: The timestamp of the event's creation. + :type _created: str + :param _updated: The timestamp of the event's last update. + :type _updated: str + :param _action: The performed action. Can be: CREATE or UPDATE. + :type _action: str + :param _user_id: The id of the user the event applied to (if it was a user + event). + :type _user_id: str + :param _monetary_account_id: The id of the monetary account the event + applied to (if it was a monetary account event). + :type _monetary_account_id: str + :param _object_: The details of the external object the event was created + for. + :type _object_: object_.EventObject + :param _status: The event status. Can be: FINALIZED or AWAITING_REPLY. An + example of FINALIZED event is a payment received event, while an + AWAITING_REPLY event is a request received event. + :type _status: str + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/insights-search" + + # Object type. + _OBJECT_TYPE_GET = "Event" + + _id_ = None + _created = None + _updated = None + _action = None + _user_id = None + _monetary_account_id = None + _object_ = None + _status = None + + @classmethod + def list(cls, params=None, custom_headers=None): """ - :rtype: int + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInsightEventList """ - return self._minimum_age + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseInsightEventList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def require_address(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._require_address + return self._id_ @property - def bunqme_share_url(self): + def created(self): """ :rtype: str """ - return self._bunqme_share_url + return self._created @property - def redirect_url(self): + def updated(self): """ :rtype: str """ - return self._redirect_url + return self._updated @property - def address_shipping(self): + def action(self): """ - :rtype: object_.Address + :rtype: str """ - return self._address_shipping + return self._action @property - def address_billing(self): + def user_id(self): """ - :rtype: object_.Address + :rtype: str """ - return self._address_billing + return self._user_id @property - def geolocation(self): + def monetary_account_id(self): """ - :rtype: object_.Geolocation + :rtype: str """ - return self._geolocation + return self._monetary_account_id @property - def allow_chat(self): + def object_(self): """ - :rtype: bool + :rtype: object_.EventObject """ - return self._allow_chat + return self._object_ @property - def reference_split_the_bill(self): + def status(self): """ - :rtype: object_.RequestReferenceSplitTheBillAnchorObject + :rtype: str """ - return self._reference_split_the_bill + return self._status def is_all_field_none(self): """ @@ -21634,73 +20869,102 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._time_responded is not None: + if self._action is not None: return False - if self._time_expiry is not None: + if self._user_id is not None: return False if self._monetary_account_id is not None: return False - if self._amount_inquired is not None: + if self._object_ is not None: return False - if self._amount_responded is not None: + if self._status is not None: return False - if self._user_alias_created is not None: - return False + return True - if self._user_alias_revoked is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: InsightEventApiObject + """ - if self._counterparty_alias is not None: - return False + return converter.json_to_class(InsightEventApiObject, json_str) - if self._description is not None: - return False - if self._merchant_reference is not None: - return False +class InsightPreferenceDateApiObject(BunqModel): + """ + Used to allow users to set insight/budget preferences. + + :param _day_of_month: The day of month at which budgeting/insights should + start. + :type _day_of_month: int + """ - if self._attachment is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/insight-preference-date" - if self._status is not None: - return False + # Field constants. + FIELD_DAY_OF_MONTH = "day_of_month" - if self._batch_id is not None: - return False + # Object type. + _OBJECT_TYPE_GET = "InsightPreferenceDate" - if self._scheduled_id is not None: - return False + _day_of_month = None + _day_of_month_field_for_request = None - if self._minimum_age is not None: - return False + def __init__(self, day_of_month): + """ + :param day_of_month: The day of month at which budgeting/insights should + start. + :type day_of_month: int + """ - if self._require_address is not None: - return False + self._day_of_month_field_for_request = day_of_month - if self._bunqme_share_url is not None: - return False + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInsightPreferenceDateList + """ - if self._redirect_url is not None: - return False + if params is None: + params = {} - if self._address_shipping is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._address_billing is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) - if self._geolocation is not None: - return False + return BunqResponseInsightPreferenceDateList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) - if self._allow_chat is not None: - return False + @property + def day_of_month(self): + """ + :rtype: int + """ - if self._reference_split_the_bill is not None: + return self._day_of_month + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._day_of_month is not None: return False return True @@ -21710,240 +20974,52 @@ def from_json(json_str): """ :type json_str: str - :rtype: RequestInquiry + :rtype: InsightPreferenceDateApiObject """ - return converter.json_to_class(RequestInquiry, json_str) + return converter.json_to_class(InsightPreferenceDateApiObject, json_str) -class RequestResponse(core.BunqModel): +class InsightApiObject(BunqModel): """ - A RequestResponse is what a user on the other side of a RequestInquiry gets - when he is sent one. So a RequestInquiry is the initiator and visible for - the user that sent it and that wants to receive the money. A RequestResponse - is what the other side sees, i.e. the user that pays the money to accept the - request. The content is almost identical. + Used to get insights about transactions between given time range. - :param _amount_responded: The Amount the RequestResponse was accepted with. - :type _amount_responded: object_.Amount - :param _status: The status of the RequestResponse. Can be ACCEPTED, PENDING, - REJECTED, REFUND_REQUESTED, REFUNDED or REVOKED. - :type _status: str - :param _address_shipping: The shipping address provided by the accepting - user if an address was requested. - :type _address_shipping: object_.Address - :param _address_billing: The billing address provided by the accepting user - if an address was requested. - :type _address_billing: object_.Address - :param _id_: The id of the Request Response. - :type _id_: int - :param _created: The timestamp when the Request Response was created. - :type _created: str - :param _updated: The timestamp when the Request Response was last updated - (will be updated when chat messages are received). - :type _updated: str - :param _time_responded: The timestamp of when the RequestResponse was - responded to. - :type _time_responded: str - :param _time_expiry: The timestamp of when the RequestResponse expired or - will expire. - :type _time_expiry: str - :param _time_refund_requested: The timestamp of when a refund request for - the RequestResponse was claimed. - :type _time_refund_requested: str - :param _time_refunded: The timestamp of when the RequestResponse was - refunded. - :type _time_refunded: str - :param _user_refund_requested: The label of the user that requested the - refund. - :type _user_refund_requested: object_.LabelUser - :param _monetary_account_id: The id of the MonetaryAccount the - RequestResponse was received on. - :type _monetary_account_id: int - :param _amount_inquired: The requested Amount. - :type _amount_inquired: object_.Amount - :param _description: The description for the RequestResponse provided by the - requesting party. Maximum 9000 characters. - :type _description: str - :param _alias: The LabelMonetaryAccount with the public information of the - MonetaryAccount this RequestResponse was received on. - :type _alias: object_.MonetaryAccountReference - :param _counterparty_alias: The LabelMonetaryAccount with the public - information of the MonetaryAccount that is requesting money with this - RequestResponse. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _attachment: The Attachments attached to the RequestResponse. - :type _attachment: list[object_.Attachment] - :param _minimum_age: The minimum age the user accepting the RequestResponse - must have. - :type _minimum_age: int - :param _require_address: Whether or not an address must be provided on - accept. - :type _require_address: str - :param _geolocation: The Geolocation where the RequestResponse was created. - :type _geolocation: object_.Geolocation - :param _type_: The type of the RequestInquiry. Can be DIRECT_DEBIT, - DIRECT_DEBIT_B2B, IDEAL, SOFORT or INTERNAL. - :type _type_: str - :param _sub_type: The subtype of the RequestInquiry. Can be ONCE or - RECURRING for DIRECT_DEBIT RequestInquiries and NONE for all other. - :type _sub_type: str - :param _redirect_url: The URL which the user is sent to after accepting or - rejecting the Request. - :type _redirect_url: str - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool - :param _credit_scheme_identifier: The credit scheme id provided by the - counterparty for DIRECT_DEBIT inquiries. - :type _credit_scheme_identifier: str - :param _mandate_identifier: The mandate id provided by the counterparty for - DIRECT_DEBIT inquiries. - :type _mandate_identifier: str - :param _eligible_whitelist_id: The whitelist id for this action or null. - :type _eligible_whitelist_id: int - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] + :param _category: The category. + :type _category: str + :param _category_translated: The translated category. + :type _category_translated: str + :param _category_color: The color of the category. + :type _category_color: str + :param _category_icon: The icon of the category. + :type _category_icon: str + :param _amount_total: The total amount of the transactions in the category. + :type _amount_total: object_.Amount + :param _number_of_transactions: The number of the transactions in the + category. + :type _number_of_transactions: int """ # Endpoint constants. - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}" - - # Field constants. - FIELD_AMOUNT_RESPONDED = "amount_responded" - FIELD_STATUS = "status" - FIELD_ADDRESS_SHIPPING = "address_shipping" - FIELD_ADDRESS_BILLING = "address_billing" + _ENDPOINT_URL_LISTING = "user/{}/insights" # Object type. - _OBJECT_TYPE_PUT = "RequestResponse" - _OBJECT_TYPE_GET = "RequestResponse" - - _id_ = None - _created = None - _updated = None - _time_responded = None - _time_expiry = None - _time_refund_requested = None - _time_refunded = None - _user_refund_requested = None - _monetary_account_id = None - _amount_inquired = None - _amount_responded = None - _status = None - _description = None - _alias = None - _counterparty_alias = None - _attachment = None - _minimum_age = None - _require_address = None - _geolocation = None - _type_ = None - _sub_type = None - _redirect_url = None - _address_billing = None - _address_shipping = None - _allow_chat = None - _credit_scheme_identifier = None - _mandate_identifier = None - _eligible_whitelist_id = None - _request_reference_split_the_bill = None - _amount_responded_field_for_request = None - _status_field_for_request = None - _address_shipping_field_for_request = None - _address_billing_field_for_request = None - - def __init__(self, status=None, amount_responded=None, - address_shipping=None, address_billing=None): - """ - :param status: The responding status of the RequestResponse. Can be ACCEPTED - or REJECTED. - :type status: str - :param amount_responded: The Amount the user decides to pay. - :type amount_responded: object_.Amount - :param address_shipping: The shipping Address to return to the user who - created the RequestInquiry. Should only be provided if 'require_address' is - set to SHIPPING, BILLING_SHIPPING or OPTIONAL. - :type address_shipping: object_.Address - :param address_billing: The billing Address to return to the user who - created the RequestInquiry. Should only be provided if 'require_address' is - set to BILLING, BILLING_SHIPPING or OPTIONAL. - :type address_billing: object_.Address - """ - - self._status_field_for_request = status - self._amount_responded_field_for_request = amount_responded - self._address_shipping_field_for_request = address_shipping - self._address_billing_field_for_request = address_billing - - @classmethod - def update(cls, request_response_id, monetary_account_id=None, - amount_responded=None, status=None, address_shipping=None, - address_billing=None, custom_headers=None): - """ - Update the status to accept or reject the RequestResponse. - - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :param amount_responded: The Amount the user decides to pay. - :type amount_responded: object_.Amount - :param status: The responding status of the RequestResponse. Can be - ACCEPTED or REJECTED. - :type status: str - :param address_shipping: The shipping Address to return to the user who - created the RequestInquiry. Should only be provided if 'require_address' - is set to SHIPPING, BILLING_SHIPPING or OPTIONAL. - :type address_shipping: object_.Address - :param address_billing: The billing Address to return to the user who - created the RequestInquiry. Should only be provided if 'require_address' - is set to BILLING, BILLING_SHIPPING or OPTIONAL. - :type address_billing: object_.Address - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseRequestResponse - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_AMOUNT_RESPONDED: amount_responded, - cls.FIELD_STATUS: status, - cls.FIELD_ADDRESS_SHIPPING: address_shipping, - cls.FIELD_ADDRESS_BILLING: address_billing - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + _OBJECT_TYPE_GET = "InsightCategory" - return BunqResponseRequestResponse.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_PUT) - ) + _category = None + _category_translated = None + _category_color = None + _category_icon = None + _amount_total = None + _number_of_transactions = None @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Get all RequestResponses for a MonetaryAccount. - :type user_id: int - :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseRequestResponseList + :rtype: BunqResponseInsightList """ if params is None: @@ -21952,367 +21028,155 @@ def list(cls, monetary_account_id=None, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseRequestResponseList.cast_from_bunq_response( + return BunqResponseInsightList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) - @classmethod - def get(cls, request_response_id, monetary_account_id=None, - custom_headers=None): - """ - Get the details for a specific existing RequestResponse. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseRequestResponse - """ - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_response_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseRequestResponse.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ - - @property - def created(self): - """ - :rtype: str - """ - - return self._created - - @property - def updated(self): - """ - :rtype: str - """ - - return self._updated - @property - def time_responded(self): + def category(self): """ :rtype: str """ - return self._time_responded + return self._category @property - def time_expiry(self): + def category_translated(self): """ :rtype: str """ - return self._time_expiry + return self._category_translated @property - def time_refund_requested(self): + def category_color(self): """ :rtype: str """ - return self._time_refund_requested + return self._category_color @property - def time_refunded(self): + def category_icon(self): """ :rtype: str """ - return self._time_refunded - - @property - def user_refund_requested(self): - """ - :rtype: object_.LabelUser - """ - - return self._user_refund_requested - - @property - def monetary_account_id(self): - """ - :rtype: int - """ - - return self._monetary_account_id - - @property - def amount_inquired(self): - """ - :rtype: object_.Amount - """ - - return self._amount_inquired + return self._category_icon @property - def amount_responded(self): + def amount_total(self): """ :rtype: object_.Amount """ - return self._amount_responded - - @property - def status(self): - """ - :rtype: str - """ - - return self._status - - @property - def description(self): - """ - :rtype: str - """ - - return self._description - - @property - def alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._alias - - @property - def counterparty_alias(self): - """ - :rtype: object_.MonetaryAccountReference - """ - - return self._counterparty_alias - - @property - def attachment(self): - """ - :rtype: list[object_.Attachment] - """ - - return self._attachment + return self._amount_total @property - def minimum_age(self): + def number_of_transactions(self): """ :rtype: int """ - return self._minimum_age + return self._number_of_transactions - @property - def require_address(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._require_address + if self._category is not None: + return False - @property - def geolocation(self): - """ - :rtype: object_.Geolocation - """ + if self._category_translated is not None: + return False - return self._geolocation + if self._category_color is not None: + return False - @property - def type_(self): - """ - :rtype: str - """ + if self._category_icon is not None: + return False - return self._type_ + if self._amount_total is not None: + return False - @property - def sub_type(self): - """ - :rtype: str - """ + if self._number_of_transactions is not None: + return False - return self._sub_type + return True - @property - def redirect_url(self): + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: InsightApiObject """ - return self._redirect_url - - @property - def address_billing(self): - """ - :rtype: object_.Address - """ + return converter.json_to_class(InsightApiObject, json_str) - return self._address_billing - @property - def address_shipping(self): - """ - :rtype: object_.Address - """ +class InstallationServerPublicKeyApiObject(BunqModel): + """ + Using /installation/_/server-public-key you can request the ServerPublicKey + again. This is done by referring to the id of the Installation. + + :param _server_public_key: The server's public key for this Installation. + :type _server_public_key: str + """ - return self._address_shipping + # Endpoint constants. + _ENDPOINT_URL_LISTING = "installation/{}/server-public-key" - @property - def allow_chat(self): - """ - :rtype: bool - """ + # Object type. + _OBJECT_TYPE_GET = "ServerPublicKey" - return self._allow_chat + _server_public_key = None - @property - def credit_scheme_identifier(self): + @classmethod + def list(cls,installation_id, params=None, custom_headers=None): """ - :rtype: str + Show the ServerPublicKey for this Installation. + + :type installation_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInstallationServerPublicKeyList """ - return self._credit_scheme_identifier - - @property - def mandate_identifier(self): - """ - :rtype: str - """ + if params is None: + params = {} - return self._mandate_identifier + if custom_headers is None: + custom_headers = {} - @property - def eligible_whitelist_id(self): - """ - :rtype: int - """ + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(installation_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return self._eligible_whitelist_id + return BunqResponseInstallationServerPublicKeyList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def request_reference_split_the_bill(self): + def server_public_key(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: str """ - return self._request_reference_split_the_bill + return self._server_public_key def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._time_responded is not None: - return False - - if self._time_expiry is not None: - return False - - if self._time_refund_requested is not None: - return False - - if self._time_refunded is not None: - return False - - if self._user_refund_requested is not None: - return False - - if self._monetary_account_id is not None: - return False - - if self._amount_inquired is not None: - return False - - if self._amount_responded is not None: - return False - - if self._status is not None: - return False - - if self._description is not None: - return False - - if self._alias is not None: - return False - - if self._counterparty_alias is not None: - return False - - if self._attachment is not None: - return False - - if self._minimum_age is not None: - return False - - if self._require_address is not None: - return False - - if self._geolocation is not None: - return False - - if self._type_ is not None: - return False - - if self._sub_type is not None: - return False - - if self._redirect_url is not None: - return False - - if self._address_billing is not None: - return False - - if self._address_shipping is not None: - return False - - if self._allow_chat is not None: - return False - - if self._credit_scheme_identifier is not None: - return False - - if self._mandate_identifier is not None: - return False - - if self._eligible_whitelist_id is not None: - return False - - if self._request_reference_split_the_bill is not None: + if self._server_public_key is not None: return False return True @@ -22322,106 +21186,367 @@ def from_json(json_str): """ :type json_str: str - :rtype: RequestResponse + :rtype: InstallationServerPublicKeyApiObject """ - return converter.json_to_class(RequestResponse, json_str) + return converter.json_to_class(InstallationServerPublicKeyApiObject, json_str) -class ScheduleInstance(core.BunqModel): +class MonetaryAccountBankApiObject(BunqModel): """ - view for reading, updating and listing the scheduled instance. + With MonetaryAccountBank you can create a new bank account, retrieve + information regarding your existing MonetaryAccountBanks and update specific + fields of an existing MonetaryAccountBank. Examples of fields that can be + updated are the description, the daily limit and the avatar of the + account.

Notification filters can be set on a monetary account + level to receive callbacks. For more information check the dedicated callbacks page. - :param _state: The state of the scheduleInstance. (FINISHED_SUCCESSFULLY, - RETRY, FAILED_USER_ERROR) - :type _state: str - :param _time_start: The schedule start time (UTC). - :type _time_start: str - :param _time_end: The schedule end time (UTC). - :type _time_end: str - :param _error_message: The message when the scheduled instance has run and - failed due to user error. - :type _error_message: list[object_.Error] - :param _scheduled_object: The scheduled object. (Payment, PaymentBatch) - :type _scheduled_object: object_.ScheduleAnchorObject - :param _result_object: The result object of this schedule instance. - (Payment, PaymentBatch) - :type _result_object: object_.ScheduleInstanceAnchorObject - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] - """ - - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance" - - # Field constants. - FIELD_STATE = "state" - - # Object type. - _OBJECT_TYPE_GET = "ScheduledInstance" - - _state = None - _time_start = None - _time_end = None - _error_message = None - _scheduled_object = None - _result_object = None - _request_reference_split_the_bill = None - _state_field_for_request = None + :param _currency: The currency of the MonetaryAccountBank as an ISO 4217 + formatted currency code. + :type _currency: str + :param _description: The description of the MonetaryAccountBank. Defaults to + 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the + MonetaryAccountBank's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountBank. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountBank providing + extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _display_name: The legal name of the user / company using this + monetary account. + :type _display_name: str + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _country_iban: The country of the monetary account IBAN. + :type _country_iban: str + :param _id_: The id of the MonetaryAccountBank. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountBank's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountBank's last update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountBank. + :type _avatar: object_.Avatar + :param _overdraft_limit: The maximum Amount the MonetaryAccountBank can be + 'in the red'. + :type _overdraft_limit: object_.Amount + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountBank's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the MonetaryAccountBank. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ - def __init__(self, state=None): + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account-bank" + _ENDPOINT_URL_READ = "user/{}/monetary-account-bank/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-bank/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-bank" + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_DISPLAY_NAME = "display_name" + FIELD_SETTING = "setting" + FIELD_COUNTRY_IBAN = "country_iban" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccountBank" + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _overdraft_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _user_id = None + _monetary_account_profile = None + _display_name = None + _setting = None + _all_auto_save_id = None + _fulfillments = None + _budget = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _display_name_field_for_request = None + _setting_field_for_request = None + _country_iban_field_for_request = None + + def __init__(self, currency, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, country_iban=None): """ - :param state: Change the state of the scheduleInstance from - FAILED_USER_ERROR to RETRY. - :type state: str + :param currency: The currency of the MonetaryAccountBank as an ISO 4217 + formatted currency code. + :type currency: str + :param description: The description of the MonetaryAccountBank. Defaults to + 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the + MonetaryAccountBank's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountBank. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountBank. When updating + the status and/or sub_status no other fields can be updated in the same + request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountBank providing extra + information regarding the status. Should be ignored for POST requests. In + case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountBank, can only be OTHER. Should only be specified if updating + the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountBank. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountBank. + :type setting: object_.MonetaryAccountSetting + :param country_iban: The country of the monetary account IBAN. + :type country_iban: str """ - self._state_field_for_request = state + self._currency_field_for_request = currency + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._display_name_field_for_request = display_name + self._setting_field_for_request = setting + self._country_iban_field_for_request = country_iban @classmethod - def get(cls, schedule_id, schedule_instance_id, monetary_account_id=None, - custom_headers=None): + def create(cls,currency, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, country_iban=None, custom_headers=None): """ - :type api_context: context.ApiContext + Create new MonetaryAccountBank. + :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int + :param currency: The currency of the MonetaryAccountBank as an ISO 4217 + formatted currency code. + :type currency: str + :param description: The description of the MonetaryAccountBank. Defaults + to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the + MonetaryAccountBank's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountBank. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountBank. When + updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountBank providing + extra information regarding the status. Should be ignored for POST + requests. In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountBank, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountBank. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountBank. + :type setting: object_.MonetaryAccountSetting + :param country_iban: The country of the monetary account IBAN. + :type country_iban: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseScheduleInstance + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CURRENCY : currency, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting, +cls.FIELD_COUNTRY_IBAN : country_iban +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, monetary_account_bank_id, custom_headers=None): + """ + Get a specific MonetaryAccountBank. + + :type api_context: ApiContext + :type user_id: int + :type monetary_account_bank_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountBank """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_bank_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseScheduleInstance.cast_from_bunq_response( + return BunqResponseMonetaryAccountBank.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, schedule_id, schedule_instance_id, monetary_account_id=None, - state=None, custom_headers=None): + def update(cls, monetary_account_bank_id, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, custom_headers=None): """ + Update a specific existing MonetaryAccountBank. + :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type schedule_instance_id: int - :param state: Change the state of the scheduleInstance from - FAILED_USER_ERROR to RETRY. - :type state: str + :type monetary_account_bank_id: int + :param description: The description of the MonetaryAccountBank. Defaults + to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountBank. Defaults to 1000 EUR. Currency must match the + MonetaryAccountBank's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountBank. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountBank. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountBank. When + updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountBank providing + extra information regarding the status. Should be ignored for POST + requests. In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountBank, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountBank. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountBank. + :type setting: object_.MonetaryAccountSetting :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -22430,38 +21555,40 @@ def update(cls, schedule_id, schedule_instance_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_STATE: state - } +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id, - schedule_instance_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_bank_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) @classmethod - def list(cls, schedule_id, monetary_account_id=None, params=None, - custom_headers=None): + def list(cls, params=None, custom_headers=None): """ + Gets a listing of all MonetaryAccountBanks of a given user. + :type user_id: int - :type monetary_account_id: int - :type schedule_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseScheduleInstanceList + :rtype: BunqResponseMonetaryAccountBankList """ if params is None: @@ -22470,336 +21597,245 @@ def list(cls, schedule_id, monetary_account_id=None, params=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - schedule_id) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseScheduleInstanceList.cast_from_bunq_response( + return BunqResponseMonetaryAccountBankList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def state(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._state + return self._id_ @property - def time_start(self): + def created(self): """ :rtype: str """ - return self._time_start + return self._created @property - def time_end(self): + def updated(self): """ :rtype: str """ - return self._time_end + return self._updated @property - def error_message(self): + def avatar(self): """ - :rtype: list[object_.Error] + :rtype: object_.Avatar """ - return self._error_message + return self._avatar @property - def scheduled_object(self): + def currency(self): """ - :rtype: object_.ScheduleAnchorObject + :rtype: str """ - return self._scheduled_object + return self._currency @property - def result_object(self): + def description(self): """ - :rtype: object_.ScheduleInstanceAnchorObject + :rtype: str """ - return self._result_object + return self._description @property - def request_reference_split_the_bill(self): + def daily_limit(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: object_.Amount """ - return self._request_reference_split_the_bill + return self._daily_limit - def is_all_field_none(self): + @property + def overdraft_limit(self): """ - :rtype: bool + :rtype: object_.Amount """ - if self._state is not None: - return False - - if self._time_start is not None: - return False - - if self._time_end is not None: - return False - - if self._error_message is not None: - return False - - if self._scheduled_object is not None: - return False - - if self._result_object is not None: - return False - - if self._request_reference_split_the_bill is not None: - return False - - return True + return self._overdraft_limit - @staticmethod - def from_json(json_str): + @property + def balance(self): """ - :type json_str: str - - :rtype: ScheduleInstance + :rtype: object_.Amount """ - return converter.json_to_class(ScheduleInstance, json_str) - + return self._balance -class TabResultResponse(core.BunqModel): - """ - Used to view TabResultResponse objects belonging to a tab. A - TabResultResponse is an object that holds details on a tab which has been - paid from the provided monetary account. - - :param _tab: The Tab details. - :type _tab: Tab - :param _payment: The payment made for the Tab. - :type _payment: Payment - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] - """ + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/tab-result-response/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/tab-result-response" + return self._alias - # Object type. - _OBJECT_TYPE_GET = "TabResultResponse" + @property + def public_uuid(self): + """ + :rtype: str + """ - _tab = None - _payment = None - _request_reference_split_the_bill = None + return self._public_uuid - @classmethod - def get(cls, tab_result_response_id, monetary_account_id=None, - custom_headers=None): + @property + def status(self): """ - Used to view a single TabResultResponse belonging to a tab. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type tab_result_response_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabResultResponse + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._status - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - tab_result_response_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def sub_status(self): + """ + :rtype: str + """ - return BunqResponseTabResultResponse.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._sub_status - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def reason(self): """ - Used to view a list of TabResultResponse objects belonging to a tab. - - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabResultResponseList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._reason - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def reason_description(self): + """ + :rtype: str + """ - return BunqResponseTabResultResponseList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._reason_description @property - def tab(self): + def share(self): """ - :rtype: Tab + :rtype: ShareInviteMonetaryAccountResponse """ - return self._tab + return self._share @property - def payment(self): + def relation_user(self): """ - :rtype: Payment + :rtype: RelationUser """ - return self._payment + return self._relation_user @property - def request_reference_split_the_bill(self): + def user_id(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: int """ - return self._request_reference_split_the_bill + return self._user_id - def is_all_field_none(self): + @property + def monetary_account_profile(self): """ - :rtype: bool + :rtype: MonetaryAccountProfile """ - if self._tab is not None: - return False - - if self._payment is not None: - return False + return self._monetary_account_profile - if self._request_reference_split_the_bill is not None: - return False + @property + def display_name(self): + """ + :rtype: str + """ - return True + return self._display_name - @staticmethod - def from_json(json_str): + @property + def setting(self): """ - :type json_str: str - - :rtype: TabResultResponse + :rtype: object_.MonetaryAccountSetting """ - return converter.json_to_class(TabResultResponse, json_str) - + return self._setting -class WhitelistResult(core.BunqModel): - """ - Whitelist an SDD so that when one comes in, it is automatically accepted. - - :param _id_: The ID of the whitelist entry. - :type _id_: int - :param _monetary_account_paying_id: The account from which payments will be - deducted when a transaction is matched with this whitelist. - :type _monetary_account_paying_id: int - :param _status: The status of the WhitelistResult. - :type _status: str - :param _error_message: The message when the whitelist result has failed due - to user error. - :type _error_message: list[object_.Error] - :param _whitelist: The corresponding whitelist. - :type _whitelist: Whitelist - :param _object_: The details of the external object the event was created - for. - :type _object_: object_.WhitelistResultViewAnchoredObject - :param _request_reference_split_the_bill: The reference to the object used - for split the bill. Can be RequestInquiry or RequestInquiryBatch - :type _request_reference_split_the_bill: - list[object_.RequestInquiryReference] - """ + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ - _id_ = None - _monetary_account_paying_id = None - _status = None - _error_message = None - _whitelist = None - _object_ = None - _request_reference_split_the_bill = None + return self._all_auto_save_id @property - def id_(self): + def fulfillments(self): """ - :rtype: int + :rtype: list[Fulfillment] """ - return self._id_ + return self._fulfillments @property - def monetary_account_paying_id(self): + def budget(self): """ - :rtype: int + :rtype: list[MonetaryAccountBudget] """ - return self._monetary_account_paying_id + return self._budget @property - def status(self): + def all_co_owner(self): """ - :rtype: str + :rtype: list[object_.CoOwner] """ - return self._status + return self._all_co_owner @property - def error_message(self): + def co_owner_invite(self): """ - :rtype: list[object_.Error] + :rtype: CoOwnerInviteResponse """ - return self._error_message + return self._co_owner_invite @property - def whitelist(self): + def open_banking_account(self): """ - :rtype: Whitelist + :rtype: OpenBankingAccount """ - return self._whitelist + return self._open_banking_account @property - def object_(self): + def birdee_investment_portfolio(self): """ - :rtype: object_.WhitelistResultViewAnchoredObject + :rtype: BirdeeInvestmentPortfolio """ - return self._object_ + return self._birdee_investment_portfolio @property - def request_reference_split_the_bill(self): + def all_access(self): """ - :rtype: list[object_.RequestInquiryReference] + :rtype: list[MonetaryAccountAccess] """ - return self._request_reference_split_the_bill + return self._all_access def is_all_field_none(self): """ @@ -22809,46 +21845,89 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._monetary_account_paying_id is not None: + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._overdraft_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: return False if self._status is not None: return False - if self._error_message is not None: + if self._sub_status is not None: return False - if self._whitelist is not None: + if self._reason is not None: return False - if self._object_ is not None: + if self._reason_description is not None: return False - if self._request_reference_split_the_bill is not None: + if self._share is not None: return False - return True + if self._relation_user is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: WhitelistResult - """ + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False - return converter.json_to_class(WhitelistResult, json_str) + if self._display_name is not None: + return False + if self._setting is not None: + return False -class Whitelist(core.BunqModel): - """ - Whitelist a Request so that when one comes in, it is automatically accepted. - """ + if self._all_auto_save_id is not None: + return False - def is_all_field_none(self): - """ - :rtype: bool - """ + if self._fulfillments is not None: + return False + + if self._budget is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False return True @@ -22857,262 +21936,200 @@ def from_json(json_str): """ :type json_str: str - :rtype: Whitelist + :rtype: MonetaryAccountBankApiObject """ - return converter.json_to_class(Whitelist, json_str) + return converter.json_to_class(MonetaryAccountBankApiObject, json_str) -class RequestInquiryBatch(core.BunqModel): +class MonetaryAccountProfileApiObject(BunqModel): """ - Create a batch of requests for payment, or show the request batches of a - monetary account. + Used to update and read up monetary account profiles, to keep the balance + between specific thresholds. - :param _request_inquiries: The list of requests that were made. - :type _request_inquiries: list[RequestInquiry] - :param _status: The status of the request. - :type _status: str - :param _total_amount_inquired: The total amount originally inquired for this - batch. - :type _total_amount_inquired: object_.Amount - :param _event_id: The ID of the associated event if the request batch was - made using 'split the bill'. - :type _event_id: int - :param _reference_split_the_bill: The reference to the object used for split - the bill. Can be Payment, PaymentBatch, ScheduleInstance, RequestResponse - and MasterCardAction - :type _reference_split_the_bill: - object_.RequestReferenceSplitTheBillAnchorObject + :param _profile_fill: The profile settings for triggering the fill of a + monetary account. + :type _profile_fill: object_.MonetaryAccountProfileFill + :param _profile_drain: The profile settings for moving excesses to a savings + account + :type _profile_drain: object_.MonetaryAccountProfileDrain """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch" - # Field constants. - FIELD_REQUEST_INQUIRIES = "request_inquiries" - FIELD_STATUS = "status" - FIELD_TOTAL_AMOUNT_INQUIRED = "total_amount_inquired" - FIELD_EVENT_ID = "event_id" + FIELD_PROFILE_FILL = "profile_fill" + FIELD_PROFILE_DRAIN = "profile_drain" - # Object type. - _OBJECT_TYPE_GET = "RequestInquiryBatch" - _request_inquiries = None - _total_amount_inquired = None - _reference_split_the_bill = None - _request_inquiries_field_for_request = None - _status_field_for_request = None - _total_amount_inquired_field_for_request = None - _event_id_field_for_request = None + _profile_fill = None + _profile_drain = None + _profile_fill_field_for_request = None + _profile_drain_field_for_request = None + + def __init__(self, profile_fill=None, profile_drain=None): + """ + :param profile_fill: The profile settings for triggering the fill of a + monetary account. + :type profile_fill: object_.MonetaryAccountProfileFill + :param profile_drain: The profile settings for moving excesses to a savings + account + :type profile_drain: object_.MonetaryAccountProfileDrain + """ + + self._profile_fill_field_for_request = profile_fill + self._profile_drain_field_for_request = profile_drain - def __init__(self, request_inquiries, total_amount_inquired, status=None, - event_id=None): + + + @property + def profile_fill(self): """ - :param request_inquiries: The list of request inquiries we want to send in 1 - batch. - :type request_inquiries: list[RequestInquiry] - :param total_amount_inquired: The total amount originally inquired for this - batch. - :type total_amount_inquired: object_.Amount - :param status: The status of the request. - :type status: str - :param event_id: The ID of the associated event if the request batch was - made using 'split the bill'. - :type event_id: int + :rtype: object_.MonetaryAccountProfileFill """ - self._request_inquiries_field_for_request = request_inquiries - self._total_amount_inquired_field_for_request = total_amount_inquired - self._status_field_for_request = status - self._event_id_field_for_request = event_id + return self._profile_fill - @classmethod - def create(cls, request_inquiries, total_amount_inquired, - monetary_account_id=None, status=None, event_id=None, - custom_headers=None): + @property + def profile_drain(self): """ - Create a request batch by sending an array of single request objects, - that will become part of the batch. - - :type user_id: int - :type monetary_account_id: int - :param request_inquiries: The list of request inquiries we want to send - in 1 batch. - :type request_inquiries: list[RequestInquiry] - :param total_amount_inquired: The total amount originally inquired for - this batch. - :type total_amount_inquired: object_.Amount - :param status: The status of the request. - :type status: str - :param event_id: The ID of the associated event if the request batch was - made using 'split the bill'. - :type event_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.MonetaryAccountProfileDrain """ - if custom_headers is None: - custom_headers = {} + return self._profile_drain - request_map = { - cls.FIELD_REQUEST_INQUIRIES: request_inquiries, - cls.FIELD_STATUS: status, - cls.FIELD_TOTAL_AMOUNT_INQUIRED: total_amount_inquired, - cls.FIELD_EVENT_ID: event_id - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + def is_all_field_none(self): + """ + :rtype: bool + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._profile_fill is not None: + return False - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + if self._profile_drain is not None: + return False - @classmethod - def update(cls, request_inquiry_batch_id, monetary_account_id=None, - status=None, custom_headers=None): + return True + + @staticmethod + def from_json(json_str): """ - Revoke a request batch. The status of all the requests will be set to - REVOKED. - - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :param status: The status of the request. - :type status: str - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: MonetaryAccountProfileApiObject """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) + return converter.json_to_class(MonetaryAccountProfileApiObject, json_str) - request_map = { - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) +class FulfillmentApiObject(BunqModel): + """ + Endpoint for getting information fulfillments for a user. + + :param _type_: Type of the information fulfillment. + :type _type_: str + :param _reason: The reason why this fulfillment is requested. + :type _reason: str + :param _reason_translated: The translated reason why this fulfillment is + requested. + :type _reason_translated: str + :param _status: Status of this fulfillment. + :type _status: str + :param _time_mandatory: Time when the information fulfillment becomes + mandatory. + :type _time_mandatory: str + :param _user_id: The user id this fulfillment is required for. + :type _user_id: int + :param _all_status_allowed: The allowed statusses for this fulfillment. + :type _all_status_allowed: list[str] + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + _type_ = None + _reason = None + _reason_translated = None + _status = None + _time_mandatory = None + _user_id = None + _all_status_allowed = None - @classmethod - def get(cls, request_inquiry_batch_id, monetary_account_id=None, - custom_headers=None): + @property + def type_(self): """ - Return the details of a specific request batch. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type request_inquiry_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseRequestInquiryBatch + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._type_ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - request_inquiry_batch_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def reason(self): + """ + :rtype: str + """ - return BunqResponseRequestInquiryBatch.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._reason - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def reason_translated(self): """ - Return all the request batches for a monetary account. - - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseRequestInquiryBatchList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._reason_translated - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def status(self): + """ + :rtype: str + """ - return BunqResponseRequestInquiryBatchList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._status @property - def request_inquiries(self): + def time_mandatory(self): """ - :rtype: list[RequestInquiry] + :rtype: str """ - return self._request_inquiries + return self._time_mandatory @property - def total_amount_inquired(self): + def user_id(self): """ - :rtype: object_.Amount + :rtype: int """ - return self._total_amount_inquired + return self._user_id @property - def reference_split_the_bill(self): + def all_status_allowed(self): """ - :rtype: object_.RequestReferenceSplitTheBillAnchorObject + :rtype: list[str] """ - return self._reference_split_the_bill + return self._all_status_allowed def is_all_field_none(self): """ :rtype: bool """ - if self._request_inquiries is not None: + if self._type_ is not None: return False - if self._total_amount_inquired is not None: + if self._reason is not None: return False - if self._reference_split_the_bill is not None: + if self._reason_translated is not None: + return False + + if self._status is not None: + return False + + if self._time_mandatory is not None: + return False + + if self._user_id is not None: + return False + + if self._all_status_allowed is not None: return False return True @@ -23122,446 +22139,538 @@ def from_json(json_str): """ :type json_str: str - :rtype: RequestInquiryBatch + :rtype: FulfillmentApiObject """ - return converter.json_to_class(RequestInquiryBatch, json_str) + return converter.json_to_class(FulfillmentApiObject, json_str) -class SchedulePayment(core.BunqModel): +class MonetaryAccountBudgetApiObject(BunqModel): """ - Endpoint for schedule payments. + Endpoint to read, list, or delete the budget for a monetary account. - :param _payment: The payment details. - :type _payment: object_.SchedulePaymentEntry - :param _schedule: The schedule details. - :type _schedule: Schedule + :param _all_category: DEPRECATED. The list of categories on which the user + wants to set the budget. + :type _all_category: list[str] + :param _amount: DEPRECATED. The amount for the budget. + :type _amount: object_.Amount + :param _recurrence_type: DEPRECATED. The recurrence type for the automatic + top-up. + :type _recurrence_type: str + :param _monetary_account_source_funding_id: DEPRECATED. The monetary + account's ID from/to which the missing/exceeding funds will be transferred. + :type _monetary_account_source_funding_id: int + :param _payment_day_of_month: DEPRECATED. The day of the month for the + automatic top-up. + :type _payment_day_of_month: int """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment/{}" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment/{}" - # Field constants. - FIELD_PAYMENT = "payment" - FIELD_SCHEDULE = "schedule" + FIELD_ALL_CATEGORY = "all_category" + FIELD_AMOUNT = "amount" + FIELD_RECURRENCE_TYPE = "recurrence_type" + FIELD_MONETARY_ACCOUNT_SOURCE_FUNDING_ID = "monetary_account_source_funding_id" + FIELD_PAYMENT_DAY_OF_MONTH = "payment_day_of_month" - # Object type. - _OBJECT_TYPE_GET = "ScheduledPayment" - _payment = None - _schedule = None - _payment_field_for_request = None - _schedule_field_for_request = None + _all_category_field_for_request = None + _amount_field_for_request = None + _recurrence_type_field_for_request = None + _monetary_account_source_funding_id_field_for_request = None + _payment_day_of_month_field_for_request = None - def __init__(self, payment=None, schedule=None): + def __init__(self, all_category=None, amount=None, recurrence_type=None, monetary_account_source_funding_id=None, payment_day_of_month=None): """ - :param payment: The payment details. - :type payment: object_.SchedulePaymentEntry - :param schedule: The schedule details when creating or updating a scheduled - payment. - :type schedule: Schedule + :param all_category: DEPRECATED. The list of categories on which the user + wants to set the budget. + :type all_category: list[str] + :param amount: DEPRECATED. The amount for the budget. + :type amount: object_.Amount + :param recurrence_type: DEPRECATED. The recurrence type for the automatic + top-up. + :type recurrence_type: str + :param monetary_account_source_funding_id: DEPRECATED. The monetary + account's ID from/to which the missing/exceeding funds will be transferred. + :type monetary_account_source_funding_id: int + :param payment_day_of_month: DEPRECATED. The day of the month for the + automatic top-up. + :type payment_day_of_month: int + """ + + self._all_category_field_for_request = all_category + self._amount_field_for_request = amount + self._recurrence_type_field_for_request = recurrence_type + self._monetary_account_source_funding_id_field_for_request = monetary_account_source_funding_id + self._payment_day_of_month_field_for_request = payment_day_of_month + + + + + def is_all_field_none(self): + """ + :rtype: bool """ - self._payment_field_for_request = payment - self._schedule_field_for_request = schedule + return True - @classmethod - def create(cls, payment, schedule, monetary_account_id=None, - custom_headers=None): + @staticmethod + def from_json(json_str): """ - :type user_id: int - :type monetary_account_id: int - :param payment: The payment details. - :type payment: object_.SchedulePaymentEntry - :param schedule: The schedule details when creating or updating a - scheduled payment. - :type schedule: Schedule - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseInt + :rtype: MonetaryAccountBudgetApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(MonetaryAccountBudgetApiObject, json_str) - request_map = { - cls.FIELD_PAYMENT: payment, - cls.FIELD_SCHEDULE: schedule - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) +class CoOwnerInviteResponseApiObject(BunqModel): + """ + Used to accept or reject a monetaryAccountJoint co-ownership. + + :param _status: The status of the invite. Can be PENDING, REVOKED (the user + deletes the share inquiry before it's accepted) or ACCEPTED + :type _status: str + :param _alias: The monetary account and user who get the invite for the + joint account. + :type _alias: object_.MonetaryAccountReference + :param _counter_alias: The monetary account and user who created the joint + account. + :type _counter_alias: object_.MonetaryAccountReference + :param _monetary_account_id: The ID of the monetaryAccount + :type _monetary_account_id: int + :param _monetary_account_type: The extension type of the monetaryAccount + :type _monetary_account_type: str + :param _freeze_status: The freeze_status of the invite. + :type _freeze_status: str + :param _label_freeze_user: The label of the user that froze the coowner + invite (if frozen). + :type _label_freeze_user: object_.LabelUser + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + # Field constants. + FIELD_STATUS = "status" - @classmethod - def delete(cls, schedule_payment_id, monetary_account_id=None, - custom_headers=None): + + _alias = None + _counter_alias = None + _monetary_account_id = None + _monetary_account_type = None + _status = None + _freeze_status = None + _label_freeze_user = None + _all_co_owner = None + _status_field_for_request = None + + def __init__(self, status=None): """ - :type user_id: int - :type monetary_account_id: int - :type schedule_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :param status: The status of the co-owner invite, can be ACCEPTED or + REJECTED. + :type status: str """ - if custom_headers is None: - custom_headers = {} + self._status_field_for_request = status - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_payment_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) - @classmethod - def get(cls, schedule_payment_id, monetary_account_id=None, - custom_headers=None): + @property + def alias(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type schedule_payment_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseSchedulePayment + :rtype: object_.MonetaryAccountReference """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_payment_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseSchedulePayment.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._alias - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def counter_alias(self): """ - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseSchedulePaymentList + :rtype: object_.MonetaryAccountReference """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._counter_alias - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def monetary_account_id(self): + """ + :rtype: int + """ - return BunqResponseSchedulePaymentList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._monetary_account_id - @classmethod - def update(cls, schedule_payment_id, monetary_account_id=None, payment=None, - schedule=None, custom_headers=None): + @property + def monetary_account_type(self): """ - :type user_id: int - :type monetary_account_id: int - :type schedule_payment_id: int - :param payment: The payment details. - :type payment: object_.SchedulePaymentEntry - :param schedule: The schedule details when creating or updating a - scheduled payment. - :type schedule: Schedule - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._monetary_account_type - api_client = client.ApiClient(cls._get_api_context()) + @property + def status(self): + """ + :rtype: str + """ - request_map = { - cls.FIELD_PAYMENT: payment, - cls.FIELD_SCHEDULE: schedule - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._status - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_payment_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def freeze_status(self): + """ + :rtype: str + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._freeze_status @property - def payment(self): + def label_freeze_user(self): """ - :rtype: object_.SchedulePaymentEntry + :rtype: object_.LabelUser """ - return self._payment + return self._label_freeze_user @property - def schedule(self): + def all_co_owner(self): """ - :rtype: Schedule + :rtype: list[object_.CoOwner] """ - return self._schedule + return self._all_co_owner def is_all_field_none(self): """ :rtype: bool """ - if self._payment is not None: + if self._alias is not None: return False - if self._schedule is not None: + if self._counter_alias is not None: return False - return True + if self._monetary_account_id is not None: + return False + + if self._monetary_account_type is not None: + return False + + if self._status is not None: + return False + + if self._freeze_status is not None: + return False + + if self._label_freeze_user is not None: + return False + + if self._all_co_owner is not None: + return False + + return True @staticmethod def from_json(json_str): """ :type json_str: str - :rtype: SchedulePayment + :rtype: CoOwnerInviteResponseApiObject """ - return converter.json_to_class(SchedulePayment, json_str) + return converter.json_to_class(CoOwnerInviteResponseApiObject, json_str) -class Schedule(core.BunqModel): +class OpenBankingAccountApiObject(BunqModel): """ - view for reading the scheduled definitions. + Post processor for open banking account to be returned in the monetary + account external post processor. - :param _time_start: The schedule start time (UTC). - :type _time_start: str - :param _time_end: The schedule end time (UTC). - :type _time_end: str - :param _recurrence_unit: The schedule recurrence unit, options: ONCE, - HOURLY, DAILY, WEEKLY, MONTHLY, YEARLY - :type _recurrence_unit: str - :param _recurrence_size: The schedule recurrence size. For example size 4 - and unit WEEKLY means the recurrence is every 4 weeks. - :type _recurrence_size: int - :param _status: The schedule status, options: ACTIVE, FINISHED, CANCELLED. + :param _status: The status of this account. :type _status: str - :param _object_: The scheduled object. (Payment, PaymentBatch) - :type _object_: object_.ScheduleAnchorObject + :param _iban: The iban of this account. + :type _iban: str + :param _time_synced_last: The timestamp of the last time the account was + synced with our open banking partner. + :type _time_synced_last: str + :param _provider_bank: The bank provider the account comes from. + :type _provider_bank: OpenBankingProviderBank + :param _balance_booked: The booked balance of the account. + :type _balance_booked: object_.Amount + :param _balance_available: The available balance of the account, if provided + by the other bank. + :type _balance_available: object_.Amount """ - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule" + _status = None + _iban = None + _time_synced_last = None + _provider_bank = None + _balance_booked = None + _balance_available = None - # Field constants. - FIELD_TIME_START = "time_start" - FIELD_TIME_END = "time_end" - FIELD_RECURRENCE_UNIT = "recurrence_unit" - FIELD_RECURRENCE_SIZE = "recurrence_size" + @property + def status(self): + """ + :rtype: str + """ - # Object type. - _OBJECT_TYPE_GET = "Schedule" + return self._status - _time_start = None - _time_end = None - _recurrence_unit = None - _recurrence_size = None - _status = None - _object_ = None - _time_start_field_for_request = None - _time_end_field_for_request = None - _recurrence_unit_field_for_request = None - _recurrence_size_field_for_request = None + @property + def iban(self): + """ + :rtype: str + """ - def __init__(self, time_start=None, recurrence_unit=None, - recurrence_size=None, time_end=None): + return self._iban + + @property + def time_synced_last(self): """ - :param time_start: The schedule start time (UTC). - :type time_start: str - :param recurrence_unit: The schedule recurrence unit, options: ONCE, HOURLY, - DAILY, WEEKLY, MONTHLY, YEARLY - :type recurrence_unit: str - :param recurrence_size: The schedule recurrence size. For example size 4 and - unit WEEKLY means the recurrence is every 4 weeks. - :type recurrence_size: int - :param time_end: The schedule end time (UTC). - :type time_end: str + :rtype: str """ - self._time_start_field_for_request = time_start - self._recurrence_unit_field_for_request = recurrence_unit - self._recurrence_size_field_for_request = recurrence_size - self._time_end_field_for_request = time_end + return self._time_synced_last - @classmethod - def get(cls, schedule_id, monetary_account_id=None, custom_headers=None): + @property + def provider_bank(self): """ - Get a specific schedule definition for a given monetary account. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type schedule_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseSchedule + :rtype: OpenBankingProviderBank """ - if custom_headers is None: - custom_headers = {} + return self._provider_bank - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def balance_booked(self): + """ + :rtype: object_.Amount + """ - return BunqResponseSchedule.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._balance_booked - @classmethod - def list(cls, monetary_account_id=None, params=None, custom_headers=None): + @property + def balance_available(self): """ - Get a collection of scheduled definition for a given monetary account. - You can add the parameter type to filter the response. When - type={SCHEDULE_DEFINITION_PAYMENT,SCHEDULE_DEFINITION_PAYMENT_BATCH} is - provided only schedule definition object that relate to these - definitions are returned. - - :type user_id: int - :type monetary_account_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None + :rtype: object_.Amount + """ + + return self._balance_available + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._status is not None: + return False + + if self._iban is not None: + return False + + if self._time_synced_last is not None: + return False + + if self._provider_bank is not None: + return False + + if self._balance_booked is not None: + return False + + if self._balance_available is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str - :rtype: BunqResponseScheduleList + :rtype: OpenBankingAccountApiObject """ - if params is None: - params = {} + return converter.json_to_class(OpenBankingAccountApiObject, json_str) - if custom_headers is None: - custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id)) - response_raw = api_client.get(endpoint_url, params, custom_headers) +class OpenBankingProviderBankApiObject(BunqModel): + """ + Lists open banking provider banks. + + :param _account_information_service_status: Whether we support Open Banking + budgeting using the bank provider. + :type _account_information_service_status: str + :param _payment_information_service_status: Whether we support top ups using + the bank provider. + :type _payment_information_service_status: str + :param _name: The name of the bank provider. + :type _name: str + :param _aiia_provider_id: The external identifier for this bank. + :type _aiia_provider_id: str + :param _country: Country of provider + :type _country: str + :param _all_payment_method_allowed_sepa: All payment methods allowed for + Sepa payments. + :type _all_payment_method_allowed_sepa: list[str] + :param _all_payment_method_allowed_domestic: All payment methods allowed for + Domestic payments. + :type _all_payment_method_allowed_domestic: list[str] + :param _audience_business_status: Whether business banking is supported by + the provider. + :type _audience_business_status: bool + :param _audience_private_status: Whether personal banking is supported by + the provider. + :type _audience_private_status: bool + :param _avatar: The avatar of the bank. + :type _avatar: object_.Avatar + """ + + # Field constants. + FIELD_ACCOUNT_INFORMATION_SERVICE_STATUS = "account_information_service_status" + FIELD_PAYMENT_INFORMATION_SERVICE_STATUS = "payment_information_service_status" + + + _name = None + _account_information_service_status = None + _payment_information_service_status = None + _aiia_provider_id = None + _country = None + _all_payment_method_allowed_sepa = None + _all_payment_method_allowed_domestic = None + _audience_business_status = None + _audience_private_status = None + _avatar = None + _account_information_service_status_field_for_request = None + _payment_information_service_status_field_for_request = None + + def __init__(self, account_information_service_status=None, payment_information_service_status=None): + """ + :param account_information_service_status: Whether we want to activate the + account information service for the bank provider. + :type account_information_service_status: str + :param payment_information_service_status: Whether we want to activate the + payment information service for the bank provider. + :type payment_information_service_status: str + """ + + self._account_information_service_status_field_for_request = account_information_service_status + self._payment_information_service_status_field_for_request = payment_information_service_status + - return BunqResponseScheduleList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) @property - def time_start(self): + def name(self): """ :rtype: str """ - return self._time_start + return self._name @property - def time_end(self): + def account_information_service_status(self): """ :rtype: str """ - return self._time_end + return self._account_information_service_status @property - def recurrence_unit(self): + def payment_information_service_status(self): """ :rtype: str """ - return self._recurrence_unit + return self._payment_information_service_status @property - def recurrence_size(self): + def aiia_provider_id(self): """ - :rtype: int + :rtype: str """ - return self._recurrence_size + return self._aiia_provider_id @property - def status(self): + def country(self): """ :rtype: str """ - return self._status + return self._country @property - def object_(self): + def all_payment_method_allowed_sepa(self): """ - :rtype: object_.ScheduleAnchorObject + :rtype: list[str] """ - return self._object_ + return self._all_payment_method_allowed_sepa + + @property + def all_payment_method_allowed_domestic(self): + """ + :rtype: list[str] + """ + + return self._all_payment_method_allowed_domestic + + @property + def audience_business_status(self): + """ + :rtype: bool + """ + + return self._audience_business_status + + @property + def audience_private_status(self): + """ + :rtype: bool + """ + + return self._audience_private_status + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar def is_all_field_none(self): """ :rtype: bool """ - if self._time_start is not None: + if self._name is not None: return False - if self._time_end is not None: + if self._account_information_service_status is not None: return False - if self._recurrence_unit is not None: + if self._payment_information_service_status is not None: return False - if self._recurrence_size is not None: + if self._aiia_provider_id is not None: return False - if self._status is not None: + if self._country is not None: return False - if self._object_ is not None: + if self._all_payment_method_allowed_sepa is not None: + return False + + if self._all_payment_method_allowed_domestic is not None: + return False + + if self._audience_business_status is not None: + return False + + if self._audience_private_status is not None: + return False + + if self._avatar is not None: return False return True @@ -23571,284 +22680,323 @@ def from_json(json_str): """ :type json_str: str - :rtype: Schedule + :rtype: OpenBankingProviderBankApiObject """ - return converter.json_to_class(Schedule, json_str) + return converter.json_to_class(OpenBankingProviderBankApiObject, json_str) -class TabResultInquiry(core.BunqModel): +class BirdeeInvestmentPortfolioApiObject(BunqModel): """ - Used to view TabResultInquiry objects belonging to a tab. A TabResultInquiry - is an object that holds details on both the tab and a single payment made - for that tab. + Endpoint for interacting with the investment portfolio opened at Birdee. - :param _tab: The Tab details. - :type _tab: Tab - :param _payment: The payment made for the Tab. - :type _payment: Payment + :param _risk_profile_type: The type of risk profile associated with the + portfolio. + :type _risk_profile_type: str + :param _investment_theme: The investment theme. + :type _investment_theme: str + :param _name: The name associated with the investment portfolio. + :type _name: str + :param _goal: The investment goal. + :type _goal: object_.BirdeeInvestmentPortfolioGoal + :param _status: Status of the portfolio. + :type _status: str + :param _number_of_strategy_change_annual_maximum: Maximum number of strategy + changes in a year. + :type _number_of_strategy_change_annual_maximum: int + :param _number_of_strategy_change_annual_used: Maximum number of strategy + changes used. + :type _number_of_strategy_change_annual_used: int + :param _external_identifier: The external identifier of the portfolio. + :type _external_identifier: str + :param _balance: The investment portfolio balance. + :type _balance: BirdeeInvestmentPortfolioBalance + :param _allocations: The allocations of the investment portfolio. + :type _allocations: list[BirdeePortfolioAllocation] """ - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-result-inquiry/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-result-inquiry" + # Field constants. + FIELD_RISK_PROFILE_TYPE = "risk_profile_type" + FIELD_INVESTMENT_THEME = "investment_theme" + FIELD_NAME = "name" + FIELD_GOAL = "goal" - # Object type. - _OBJECT_TYPE_GET = "TabResultInquiry" - _tab = None - _payment = None + _status = None + _risk_profile_type = None + _investment_theme = None + _number_of_strategy_change_annual_maximum = None + _number_of_strategy_change_annual_used = None + _name = None + _external_identifier = None + _goal = None + _balance = None + _allocations = None + _risk_profile_type_field_for_request = None + _investment_theme_field_for_request = None + _name_field_for_request = None + _goal_field_for_request = None - @classmethod - def get(cls, cash_register_id, tab_uuid, tab_result_inquiry_id, - monetary_account_id=None, custom_headers=None): + def __init__(self, risk_profile_type=None, investment_theme=None, name=None, goal=None): """ - Used to view a single TabResultInquiry belonging to a tab. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type tab_result_inquiry_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabResultInquiry + :param risk_profile_type: The type of risk profile associated with the + portfolio. + :type risk_profile_type: str + :param investment_theme: The investment theme. + :type investment_theme: str + :param name: The name associated with the investment portfolio. + :type name: str + :param goal: The investment goal. + :type goal: object_.BirdeeInvestmentPortfolioGoal """ - if custom_headers is None: - custom_headers = {} + self._risk_profile_type_field_for_request = risk_profile_type + self._investment_theme_field_for_request = investment_theme + self._name_field_for_request = name + self._goal_field_for_request = goal - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, tab_uuid, - tab_result_inquiry_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseTabResultInquiry.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - @classmethod - def list(cls, cash_register_id, tab_uuid, monetary_account_id=None, - params=None, custom_headers=None): + @property + def status(self): """ - Used to view a list of TabResultInquiry objects belonging to a tab. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabResultInquiryList + :rtype: str """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._status - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id, tab_uuid) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def risk_profile_type(self): + """ + :rtype: str + """ - return BunqResponseTabResultInquiryList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._risk_profile_type @property - def tab(self): + def investment_theme(self): """ - :rtype: Tab + :rtype: str """ - return self._tab + return self._investment_theme @property - def payment(self): + def number_of_strategy_change_annual_maximum(self): """ - :rtype: Payment + :rtype: int """ - return self._payment + return self._number_of_strategy_change_annual_maximum - def is_all_field_none(self): + @property + def number_of_strategy_change_annual_used(self): """ - :rtype: bool + :rtype: int """ - if self._tab is not None: - return False + return self._number_of_strategy_change_annual_used - if self._payment is not None: - return False + @property + def name(self): + """ + :rtype: str + """ - return True + return self._name - @staticmethod - def from_json(json_str): + @property + def external_identifier(self): """ - :type json_str: str - - :rtype: TabResultInquiry + :rtype: str """ - return converter.json_to_class(TabResultInquiry, json_str) + return self._external_identifier + @property + def goal(self): + """ + :rtype: object_.BirdeeInvestmentPortfolioGoal + """ -class User(core.BunqModel, core.AnchoredObjectInterface): - """ - Using this call you can retrieve information of the user you are logged in - as. This includes your user id, which is referred to in endpoints. - - :param _UserLight: - :type _UserLight: UserLight - :param _UserPerson: - :type _UserPerson: UserPerson - :param _UserCompany: - :type _UserCompany: UserCompany - :param _UserApiKey: - :type _UserApiKey: UserApiKey - """ + return self._goal - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + @property + def balance(self): + """ + :rtype: BirdeeInvestmentPortfolioBalance + """ - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}" - _ENDPOINT_URL_LISTING = "user" + return self._balance - # Object type. - _OBJECT_TYPE_GET = "User" + @property + def allocations(self): + """ + :rtype: list[BirdeePortfolioAllocation] + """ - _UserLight = None - _UserPerson = None - _UserCompany = None - _UserApiKey = None + return self._allocations - @classmethod - def get(cls, custom_headers=None): + def is_all_field_none(self): """ - Get a specific user. - - :type api_context: context.ApiContext - :type user_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseUser + :rtype: bool """ - if custom_headers is None: - custom_headers = {} + if self._status is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + if self._risk_profile_type is not None: + return False - return BunqResponseUser.cast_from_bunq_response( - cls._from_json(response_raw) - ) + if self._investment_theme is not None: + return False - @classmethod - def list(cls, params=None, custom_headers=None): + if self._number_of_strategy_change_annual_maximum is not None: + return False + + if self._number_of_strategy_change_annual_used is not None: + return False + + if self._name is not None: + return False + + if self._external_identifier is not None: + return False + + if self._goal is not None: + return False + + if self._balance is not None: + return False + + if self._allocations is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - Get a collection of all available users. - - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseUserList + :rtype: BirdeeInvestmentPortfolioApiObject """ - if params is None: - params = {} + return converter.json_to_class(BirdeeInvestmentPortfolioApiObject, json_str) - if custom_headers is None: - custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING - response_raw = api_client.get(endpoint_url, params, custom_headers) +class BirdeeInvestmentPortfolioBalanceApiObject(BunqModel): + """ + Endpoint for interacting with the birdee investment portfolio balance.. + + :param _amount_available: The current valuation of the portfolio, minus any + amount pending withdrawal. + :type _amount_available: object_.Amount + :param _amount_deposit_total: The total amount deposited. + :type _amount_deposit_total: object_.Amount + :param _amount_withdrawal_total: The total amount withdrawn. + :type _amount_withdrawal_total: object_.Amount + :param _amount_fee_total: The total fee amount. + :type _amount_fee_total: object_.Amount + :param _amount_profit: The difference between the netto deposited amount and + the current valuation. + :type _amount_profit: object_.Amount + :param _amount_deposit_pending: The amount that's sent to Birdee, but + pending investment on the portfolio. + :type _amount_deposit_pending: object_.Amount + :param _amount_withdrawal_pending: The amount that's sent to Birdee, but + pending withdrawal. + :type _amount_withdrawal_pending: object_.Amount + """ - return BunqResponseUserList.cast_from_bunq_response( - cls._from_json_list(response_raw) - ) + _amount_available = None + _amount_deposit_total = None + _amount_withdrawal_total = None + _amount_fee_total = None + _amount_profit = None + _amount_deposit_pending = None + _amount_withdrawal_pending = None @property - def UserLight(self): + def amount_available(self): """ - :rtype: UserLight + :rtype: object_.Amount """ - return self._UserLight + return self._amount_available @property - def UserPerson(self): + def amount_deposit_total(self): """ - :rtype: UserPerson + :rtype: object_.Amount """ - return self._UserPerson + return self._amount_deposit_total @property - def UserCompany(self): + def amount_withdrawal_total(self): """ - :rtype: UserCompany + :rtype: object_.Amount """ - return self._UserCompany + return self._amount_withdrawal_total @property - def UserApiKey(self): + def amount_fee_total(self): """ - :rtype: UserApiKey + :rtype: object_.Amount """ - return self._UserApiKey + return self._amount_fee_total - def get_referenced_object(self): + @property + def amount_profit(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: object_.Amount """ - if self._UserLight is not None: - return self._UserLight + return self._amount_profit - if self._UserPerson is not None: - return self._UserPerson + @property + def amount_deposit_pending(self): + """ + :rtype: object_.Amount + """ - if self._UserCompany is not None: - return self._UserCompany + return self._amount_deposit_pending - if self._UserApiKey is not None: - return self._UserApiKey + @property + def amount_withdrawal_pending(self): + """ + :rtype: object_.Amount + """ - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._amount_withdrawal_pending def is_all_field_none(self): """ :rtype: bool """ - if self._UserLight is not None: + if self._amount_available is not None: return False - if self._UserPerson is not None: + if self._amount_deposit_total is not None: return False - if self._UserCompany is not None: + if self._amount_withdrawal_total is not None: return False - if self._UserApiKey is not None: + if self._amount_fee_total is not None: + return False + + if self._amount_profit is not None: + return False + + if self._amount_deposit_pending is not None: + return False + + if self._amount_withdrawal_pending is not None: return False return True @@ -23858,600 +23006,663 @@ def from_json(json_str): """ :type json_str: str - :rtype: User + :rtype: BirdeeInvestmentPortfolioBalanceApiObject """ - return converter.json_to_class(User, json_str) + return converter.json_to_class(BirdeeInvestmentPortfolioBalanceApiObject, json_str) -class UserLight(core.BunqModel): +class BirdeePortfolioAllocationApiObject(BunqModel): """ - Show the authenticated user, if it is a light user. + Endpoint for viewing the allocations of the model portfolios Birdee offers. - :param _first_name: The user's first name. - :type _first_name: str - :param _middle_name: The user's middle name. - :type _middle_name: str - :param _last_name: The user's last name. - :type _last_name: str - :param _public_nick_name: The public nick name for the user. - :type _public_nick_name: str - :param _address_main: The user's main address. - :type _address_main: object_.Address - :param _address_postal: The user's postal address. - :type _address_postal: object_.Address - :param _avatar_uuid: The public UUID of the user's avatar. - :type _avatar_uuid: str - :param _social_security_number: The user's social security number. - :type _social_security_number: str - :param _tax_resident: The user's tax residence numbers for different - countries. - :type _tax_resident: list[object_.TaxResident] - :param _document_type: The type of identification document the user - registered with. - :type _document_type: str - :param _document_number: The identification document number the user - registered with. - :type _document_number: str - :param _document_country_of_issuance: The country which issued the - identification document the user registered with. - :type _document_country_of_issuance: str - :param _document_front_attachment_id: The reference to the uploaded - picture/scan of the front side of the identification document. - :type _document_front_attachment_id: int - :param _document_back_attachment_id: The reference to the uploaded - picture/scan of the back side of the identification document. - :type _document_back_attachment_id: int - :param _date_of_birth: The user's date of birth. Accepts ISO8601 date - formats. - :type _date_of_birth: str - :param _place_of_birth: The user's place of birth. - :type _place_of_birth: str - :param _country_of_birth: The user's country of birth. Formatted as a SO - 3166-1 alpha-2 country code. - :type _country_of_birth: str - :param _nationality: The user's nationality. Formatted as a SO 3166-1 - alpha-2 country code. - :type _nationality: str - :param _language: The user's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _language: str - :param _region: The user's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _region: str - :param _gender: The user's gender. Can be MALE, FEMALE or UNKNOWN. - :type _gender: str - :param _status: The user status. The user status. Can be: ACTIVE, BLOCKED, - SIGNUP, DENIED or ABORTED. - :type _status: str - :param _sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, - APPROVAL_PARENT, AWAITING_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or - SUBMIT. - :type _sub_status: str - :param _legal_guardian_alias: The legal guardian of the user. Required for - minors. - :type _legal_guardian_alias: object_.Pointer - :param _session_timeout: The setting for the session timeout of the user in - seconds. - :type _session_timeout: int - :param _daily_limit_without_confirmation_login: The amount the user can pay - in the session without asking for credentials. - :type _daily_limit_without_confirmation_login: object_.Amount - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserLight. - :type _notification_filters: list[object_.NotificationFilter] - :param _id_: The id of the user. - :type _id_: int - :param _created: The timestamp of the user object's creation. - :type _created: str - :param _updated: The timestamp of the user object's last update. - :type _updated: str - :param _public_uuid: The user's public UUID. - :type _public_uuid: str - :param _legal_name: The user's legal name. - :type _legal_name: str - :param _display_name: The display name for the user. - :type _display_name: str - :param _alias: The aliases of the user. - :type _alias: list[object_.Pointer] - :param _avatar: The user's avatar. - :type _avatar: object_.Avatar - :param _version_terms_of_service: The version of the terms of service - accepted by the user. - :type _version_terms_of_service: str + :param _instrument_currency: Currency of the instrument. + :type _instrument_currency: str + :param _instrument_asset_class: Asset Class of the instrument. + :type _instrument_asset_class: str + :param _instrument_asset_class_name: Name of the asset class. + :type _instrument_asset_class_name: str + :param _instrument_isin: ISIN code of the instrument. + :type _instrument_isin: str + :param _instrument_name: Name of the instrument. + :type _instrument_name: str + :param _instrument_region_name: Name of the geographical region covered by + the instrument + :type _instrument_region_name: str + :param _instrument_key_information_document_uri: Key Information Document of + the instrument. + :type _instrument_key_information_document_uri: str + :param _weight: Weight of the financial instrument in the model portfolio. + :type _weight: str + :param _quantity: Quantity of the financial instrument in the portfolio. + :type _quantity: str + :param _price: Unit price of the financial instrument. + :type _price: str + :param _amount: Monetary amount of the financial instrument in the + portfolio. + :type _amount: str """ - # Endpoint constants. - _ENDPOINT_URL_READ = "user-light/{}" + _instrument_currency = None + _instrument_asset_class = None + _instrument_asset_class_name = None + _instrument_isin = None + _instrument_name = None + _instrument_region_name = None + _instrument_key_information_document_uri = None + _weight = None + _quantity = None + _price = None + _amount = None - # Field constants. - FIELD_FIRST_NAME = "first_name" - FIELD_MIDDLE_NAME = "middle_name" - FIELD_LAST_NAME = "last_name" - FIELD_PUBLIC_NICK_NAME = "public_nick_name" - FIELD_ADDRESS_MAIN = "address_main" - FIELD_ADDRESS_POSTAL = "address_postal" - FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_SOCIAL_SECURITY_NUMBER = "social_security_number" - FIELD_TAX_RESIDENT = "tax_resident" - FIELD_DOCUMENT_TYPE = "document_type" - FIELD_DOCUMENT_NUMBER = "document_number" - FIELD_DOCUMENT_COUNTRY_OF_ISSUANCE = "document_country_of_issuance" - FIELD_DOCUMENT_FRONT_ATTACHMENT_ID = "document_front_attachment_id" - FIELD_DOCUMENT_BACK_ATTACHMENT_ID = "document_back_attachment_id" - FIELD_DATE_OF_BIRTH = "date_of_birth" - FIELD_PLACE_OF_BIRTH = "place_of_birth" - FIELD_COUNTRY_OF_BIRTH = "country_of_birth" - FIELD_NATIONALITY = "nationality" - FIELD_LANGUAGE = "language" - FIELD_REGION = "region" - FIELD_GENDER = "gender" - FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_LEGAL_GUARDIAN_ALIAS = "legal_guardian_alias" - FIELD_SESSION_TIMEOUT = "session_timeout" - FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login" - FIELD_NOTIFICATION_FILTERS = "notification_filters" - - # Object type. - _OBJECT_TYPE_GET = "UserPerson" + @property + def instrument_currency(self): + """ + :rtype: str + """ - _id_ = None - _created = None - _updated = None - _public_uuid = None - _first_name = None - _middle_name = None - _last_name = None - _legal_name = None - _display_name = None - _public_nick_name = None - _alias = None - _social_security_number = None - _tax_resident = None - _document_type = None - _document_number = None - _document_country_of_issuance = None - _address_main = None - _address_postal = None - _date_of_birth = None - _place_of_birth = None - _country_of_birth = None - _nationality = None - _language = None - _region = None - _gender = None - _avatar = None - _version_terms_of_service = None - _status = None - _sub_status = None - _session_timeout = None - _daily_limit_without_confirmation_login = None - _notification_filters = None - _first_name_field_for_request = None - _middle_name_field_for_request = None - _last_name_field_for_request = None - _public_nick_name_field_for_request = None - _address_main_field_for_request = None - _address_postal_field_for_request = None - _avatar_uuid_field_for_request = None - _social_security_number_field_for_request = None - _tax_resident_field_for_request = None - _document_type_field_for_request = None - _document_number_field_for_request = None - _document_country_of_issuance_field_for_request = None - _document_front_attachment_id_field_for_request = None - _document_back_attachment_id_field_for_request = None - _date_of_birth_field_for_request = None - _place_of_birth_field_for_request = None - _country_of_birth_field_for_request = None - _nationality_field_for_request = None - _language_field_for_request = None - _region_field_for_request = None - _gender_field_for_request = None - _status_field_for_request = None - _sub_status_field_for_request = None - _legal_guardian_alias_field_for_request = None - _session_timeout_field_for_request = None - _daily_limit_without_confirmation_login_field_for_request = None - _notification_filters_field_for_request = None + return self._instrument_currency - def __init__(self, social_security_number=None, legal_guardian_alias=None, - gender=None, nationality=None, country_of_birth=None, - place_of_birth=None, document_back_attachment_id=None, - document_front_attachment_id=None, - document_country_of_issuance=None, document_number=None, - document_type=None, tax_resident=None, address_postal=None, - first_name=None, middle_name=None, - daily_limit_without_confirmation_login=None, - session_timeout=None, sub_status=None, status=None, - region=None, language=None, date_of_birth=None, - avatar_uuid=None, address_main=None, public_nick_name=None, - last_name=None, notification_filters=None): - """ - :param first_name: The user's first name. - :type first_name: str - :param last_name: The user's last name. - :type last_name: str - :param public_nick_name: The user's public nick name. - :type public_nick_name: str - :param address_main: The user's main address. - :type address_main: object_.Address - :param avatar_uuid: The public UUID of the user's avatar. - :type avatar_uuid: str - :param date_of_birth: The user's date of birth. Accepts ISO8601 date - formats. - :type date_of_birth: str - :param language: The user's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type language: str - :param region: The user's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type region: str - :param status: The user status. You are not allowed to update the status via - PUT. - :type status: str - :param sub_status: The user sub-status. Can be updated to SUBMIT to apply - for a full bunq account. - :type sub_status: str - :param session_timeout: The setting for the session timeout of the user in - seconds. - :type session_timeout: int - :param daily_limit_without_confirmation_login: The amount the user can pay - in the session without asking for credentials. - :type daily_limit_without_confirmation_login: object_.Amount - :param middle_name: The user's middle name. - :type middle_name: str - :param address_postal: The user's postal address. - :type address_postal: object_.Address - :param social_security_number: The user's social security number. - :type social_security_number: str - :param tax_resident: The user's tax residence numbers for different - countries. - :type tax_resident: list[object_.TaxResident] - :param document_type: The type of identification document the user - registered with. - :type document_type: str - :param document_number: The identification document number the user - registered with. - :type document_number: str - :param document_country_of_issuance: The country which issued the - identification document the user registered with. - :type document_country_of_issuance: str - :param document_front_attachment_id: The reference to the uploaded - picture/scan of the front side of the identification document. - :type document_front_attachment_id: int - :param document_back_attachment_id: The reference to the uploaded - picture/scan of the back side of the identification document. - :type document_back_attachment_id: int - :param place_of_birth: The user's place of birth. - :type place_of_birth: str - :param country_of_birth: The user's country of birth. Formatted as a SO - 3166-1 alpha-2 country code. - :type country_of_birth: str - :param nationality: The user's nationality. Formatted as a SO 3166-1 alpha-2 - country code. - :type nationality: str - :param gender: The user's gender. Can be: MALE, FEMALE and UNKNOWN. - :type gender: str - :param legal_guardian_alias: The legal guardian of the user. Required for - minors. - :type legal_guardian_alias: object_.Pointer - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserLight. - :type notification_filters: list[object_.NotificationFilter] + @property + def instrument_asset_class(self): + """ + :rtype: str """ - self._first_name_field_for_request = first_name - self._last_name_field_for_request = last_name - self._public_nick_name_field_for_request = public_nick_name - self._address_main_field_for_request = address_main - self._avatar_uuid_field_for_request = avatar_uuid - self._date_of_birth_field_for_request = date_of_birth - self._language_field_for_request = language - self._region_field_for_request = region - self._status_field_for_request = status - self._sub_status_field_for_request = sub_status - self._session_timeout_field_for_request = session_timeout - self._daily_limit_without_confirmation_login_field_for_request = daily_limit_without_confirmation_login - self._middle_name_field_for_request = middle_name - self._address_postal_field_for_request = address_postal - self._social_security_number_field_for_request = social_security_number - self._tax_resident_field_for_request = tax_resident - self._document_type_field_for_request = document_type - self._document_number_field_for_request = document_number - self._document_country_of_issuance_field_for_request = document_country_of_issuance - self._document_front_attachment_id_field_for_request = document_front_attachment_id - self._document_back_attachment_id_field_for_request = document_back_attachment_id - self._place_of_birth_field_for_request = place_of_birth - self._country_of_birth_field_for_request = country_of_birth - self._nationality_field_for_request = nationality - self._gender_field_for_request = gender - self._legal_guardian_alias_field_for_request = legal_guardian_alias - self._notification_filters_field_for_request = notification_filters + return self._instrument_asset_class - @classmethod - def get(cls, user_light_id, custom_headers=None): + @property + def instrument_asset_class_name(self): """ - Get a specific bunq light user. - - :type api_context: context.ApiContext - :type user_light_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseUserLight + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._instrument_asset_class_name - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(user_light_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def instrument_isin(self): + """ + :rtype: str + """ - return BunqResponseUserLight.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._instrument_isin @property - def id_(self): + def instrument_name(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._instrument_name @property - def created(self): + def instrument_region_name(self): """ :rtype: str """ - return self._created + return self._instrument_region_name @property - def updated(self): + def instrument_key_information_document_uri(self): """ :rtype: str """ - return self._updated + return self._instrument_key_information_document_uri @property - def public_uuid(self): + def weight(self): """ :rtype: str """ - return self._public_uuid + return self._weight @property - def first_name(self): + def quantity(self): """ :rtype: str """ - return self._first_name + return self._quantity @property - def middle_name(self): + def price(self): """ :rtype: str """ - return self._middle_name + return self._price @property - def last_name(self): + def amount(self): """ :rtype: str """ - return self._last_name + return self._amount + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._instrument_currency is not None: + return False + + if self._instrument_asset_class is not None: + return False + + if self._instrument_asset_class_name is not None: + return False + + if self._instrument_isin is not None: + return False + + if self._instrument_name is not None: + return False + + if self._instrument_region_name is not None: + return False + + if self._instrument_key_information_document_uri is not None: + return False + + if self._weight is not None: + return False + + if self._quantity is not None: + return False + + if self._price is not None: + return False + + if self._amount is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: BirdeePortfolioAllocationApiObject + """ + + return converter.json_to_class(BirdeePortfolioAllocationApiObject, json_str) + + +class MonetaryAccountAccessApiObject(BunqModel): + """ + You can use MonetaryAccountAccess to retrieve all + MonetaryAccountAccessModels for the given MonetaryAccount + + :param _access_type: The access type of the monetary account access. + :type _access_type: str + """ + + # Field constants. + FIELD_ACCESS_TYPE = "access_type" + + + _access_type = None + _access_type_field_for_request = None + + def __init__(self, access_type=None): + """ + :param access_type: The access type of the monetary account access. + :type access_type: str + """ + + self._access_type_field_for_request = access_type + + @property - def legal_name(self): + def access_type(self): """ :rtype: str """ - return self._legal_name + return self._access_type + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._access_type is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountAccessApiObject + """ + + return converter.json_to_class(MonetaryAccountAccessApiObject, json_str) + + +class MonetaryAccountCardApiObject(BunqModel): + """ + :param _id_: The id of the MonetaryAccountCard. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountCard's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountCard's last update. + :type _updated: str + :param _currency: The currency of the MonetaryAccountCard as an ISO 4217 + formatted currency code. + :type _currency: str + :param _description: The description of the MonetaryAccountCard. Defaults to + 'prepaid credit card'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountCard. + :type _daily_limit: object_.Amount + :param _overdraft_limit: The maximum Amount the MonetaryAccountCard can be + 'in the red'. + :type _overdraft_limit: object_.Amount + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _balance_real: The current real balance Amount of the + MonetaryAccountCard. + :type _balance_real: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountCard's public UUID. + :type _public_uuid: str + :param _status: The status of the MonetaryAccountCard. + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountCard providing + extra information regarding the status. + :type _sub_status: str + :param _user_id: The id of the User who owns the MonetaryAccountCard. + :type _user_id: int + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/monetary-account-card/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-card/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-card" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccountCard" + + _id_ = None + _created = None + _updated = None + _currency = None + _description = None + _daily_limit = None + _overdraft_limit = None + _balance = None + _balance_real = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _user_id = None + _relation_user = None + _monetary_account_profile = None + _setting = None + _budget = None + _reason = None + _reason_description = None + _share = None + _all_auto_save_id = None + _fulfillments = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + + @classmethod + def get(cls, monetary_account_card_id, custom_headers=None): + """ + Get a specific MonetaryAccountCard. + + :type api_context: ApiContext + :type user_id: int + :type monetary_account_card_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountCard + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_card_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccountCard.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, monetary_account_card_id, custom_headers=None): + """ + Update a specific existing MonetaryAccountCard. + + :type user_id: int + :type monetary_account_card_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { + +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_card_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Gets a listing of all MonetaryAccountCard of a given user. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountCardList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountCardList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def display_name(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._display_name + return self._id_ @property - def public_nick_name(self): + def created(self): """ :rtype: str """ - return self._public_nick_name + return self._created @property - def alias(self): + def updated(self): """ - :rtype: list[object_.Pointer] + :rtype: str """ - return self._alias + return self._updated @property - def social_security_number(self): + def currency(self): """ :rtype: str """ - return self._social_security_number + return self._currency @property - def tax_resident(self): + def description(self): """ - :rtype: list[object_.TaxResident] + :rtype: str """ - return self._tax_resident + return self._description @property - def document_type(self): + def daily_limit(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._document_type + return self._daily_limit @property - def document_number(self): + def overdraft_limit(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._document_number + return self._overdraft_limit @property - def document_country_of_issuance(self): + def balance(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._document_country_of_issuance + return self._balance @property - def address_main(self): + def balance_real(self): """ - :rtype: object_.Address + :rtype: object_.Amount """ - return self._address_main + return self._balance_real @property - def address_postal(self): + def alias(self): """ - :rtype: object_.Address + :rtype: list[object_.Pointer] """ - return self._address_postal + return self._alias @property - def date_of_birth(self): + def public_uuid(self): """ :rtype: str """ - return self._date_of_birth + return self._public_uuid @property - def place_of_birth(self): + def status(self): """ :rtype: str """ - return self._place_of_birth + return self._status @property - def country_of_birth(self): + def sub_status(self): """ :rtype: str """ - return self._country_of_birth + return self._sub_status @property - def nationality(self): + def user_id(self): """ - :rtype: str + :rtype: int """ - return self._nationality + return self._user_id @property - def language(self): + def relation_user(self): """ - :rtype: str + :rtype: RelationUser """ - return self._language + return self._relation_user @property - def region(self): + def monetary_account_profile(self): """ - :rtype: str + :rtype: MonetaryAccountProfile """ - return self._region + return self._monetary_account_profile @property - def gender(self): + def setting(self): """ - :rtype: str + :rtype: object_.MonetaryAccountSetting """ - return self._gender + return self._setting @property - def avatar(self): + def budget(self): """ - :rtype: object_.Avatar + :rtype: list[MonetaryAccountBudget] """ - return self._avatar + return self._budget @property - def version_terms_of_service(self): + def reason(self): """ :rtype: str """ - return self._version_terms_of_service + return self._reason @property - def status(self): + def reason_description(self): """ :rtype: str """ - return self._status + return self._reason_description @property - def sub_status(self): + def share(self): """ - :rtype: str + :rtype: ShareInviteMonetaryAccountResponse """ - return self._sub_status + return self._share @property - def session_timeout(self): + def all_auto_save_id(self): """ - :rtype: int + :rtype: list[object_.BunqId] """ - return self._session_timeout + return self._all_auto_save_id @property - def daily_limit_without_confirmation_login(self): + def fulfillments(self): """ - :rtype: object_.Amount + :rtype: list[Fulfillment] """ - return self._daily_limit_without_confirmation_login + return self._fulfillments @property - def notification_filters(self): + def all_co_owner(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: list[object_.CoOwner] """ - return self._notification_filters + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access def is_all_field_none(self): """ @@ -24467,91 +23678,79 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._public_uuid is not None: + if self._currency is not None: return False - if self._first_name is not None: + if self._description is not None: return False - if self._middle_name is not None: + if self._daily_limit is not None: return False - if self._last_name is not None: - return False - - if self._legal_name is not None: + if self._overdraft_limit is not None: return False - if self._display_name is not None: + if self._balance is not None: return False - if self._public_nick_name is not None: + if self._balance_real is not None: return False if self._alias is not None: return False - if self._social_security_number is not None: - return False - - if self._tax_resident is not None: - return False - - if self._document_type is not None: - return False - - if self._document_number is not None: + if self._public_uuid is not None: return False - if self._document_country_of_issuance is not None: + if self._status is not None: return False - if self._address_main is not None: + if self._sub_status is not None: return False - if self._address_postal is not None: + if self._user_id is not None: return False - if self._date_of_birth is not None: + if self._relation_user is not None: return False - if self._place_of_birth is not None: + if self._monetary_account_profile is not None: return False - if self._country_of_birth is not None: + if self._setting is not None: return False - if self._nationality is not None: + if self._budget is not None: return False - if self._language is not None: + if self._reason is not None: return False - if self._region is not None: + if self._reason_description is not None: return False - if self._gender is not None: + if self._share is not None: return False - if self._avatar is not None: + if self._all_auto_save_id is not None: return False - if self._version_terms_of_service is not None: + if self._fulfillments is not None: return False - if self._status is not None: + if self._all_co_owner is not None: return False - if self._sub_status is not None: + if self._co_owner_invite is not None: return False - if self._session_timeout is not None: + if self._open_banking_account is not None: return False - if self._daily_limit_without_confirmation_login is not None: + if self._birdee_investment_portfolio is not None: return False - if self._notification_filters is not None: + if self._all_access is not None: return False return True @@ -24561,447 +23760,21239 @@ def from_json(json_str): """ :type json_str: str - :rtype: UserLight + :rtype: MonetaryAccountCardApiObject """ - return converter.json_to_class(UserLight, json_str) + return converter.json_to_class(MonetaryAccountCardApiObject, json_str) -class UserPerson(core.BunqModel): +class MonetaryAccountExternalSavingsApiObject(BunqModel): """ - With UserPerson you can retrieve information regarding the authenticated - UserPerson and update specific fields.

Notification filters can be - set on a UserPerson level to receive callbacks. For more information check - the dedicated callbacks page. + Endpoint for managing monetary account savings which are connected to + external services. - :param _first_name: The person's first name. - :type _first_name: str - :param _middle_name: The person's middle name. - :type _middle_name: str - :param _last_name: The person's last name. - :type _last_name: str - :param _public_nick_name: The public nick name for the person. - :type _public_nick_name: str - :param _address_main: The person's main address. - :type _address_main: object_.Address - :param _address_postal: The person's postal address. - :type _address_postal: object_.Address - :param _avatar_uuid: The public UUID of the user's avatar. + :param _currency: The currency of the MonetaryAccountExternalSavings as an + ISO 4217 formatted currency code. + :type _currency: str + :param _service: The service the MonetaryAccountExternalSavings is connected + with. + :type _service: str + :param _description: The description of the MonetaryAccountExternalSavings. + Defaults to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountExternalSavings. Defaults to 1000 EUR. Currency must match + the MonetaryAccountExternalSavings's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternalSavings. :type _avatar_uuid: str - :param _tax_resident: The user's tax residence numbers for different - countries. - :type _tax_resident: list[object_.TaxResident] - :param _document_type: The type of identification document the person - registered with. - :type _document_type: str - :param _document_number: The identification document number the person - registered with. - :type _document_number: str - :param _document_country_of_issuance: The country which issued the - identification document the person registered with. - :type _document_country_of_issuance: str - :param _document_front_attachment_id: The reference to the uploaded - picture/scan of the front side of the identification document. - :type _document_front_attachment_id: int - :param _document_back_attachment_id: The reference to the uploaded - picture/scan of the back side of the identification document. - :type _document_back_attachment_id: int - :param _date_of_birth: The person's date of birth. Accepts ISO8601 date - formats. - :type _date_of_birth: str - :param _place_of_birth: The person's place of birth. - :type _place_of_birth: str - :param _country_of_birth: The person's country of birth. Formatted as a SO - 3166-1 alpha-2 country code. - :type _country_of_birth: str - :param _nationality: The person's nationality. Formatted as a SO 3166-1 - alpha-2 country code. - :type _nationality: str - :param _language: The person's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _language: str - :param _region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _region: str - :param _gender: The person's gender. Can be MALE, FEMALE or UNKNOWN. - :type _gender: str - :param _status: The user status. The user status. Can be: ACTIVE, BLOCKED, - SIGNUP, RECOVERY, DENIED or ABORTED. + :param _status: The status of the MonetaryAccountExternalSavings. Can be: + ACTIVE, BLOCKED, CANCELLED or PENDING_REOPEN :type _status: str - :param _sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, - APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or - SUBMIT. + :param _sub_status: The sub-status of the MonetaryAccountExternalSavings + providing extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. :type _sub_status: str - :param _legal_guardian_alias: The legal guardian of the user. Required for - minors. - :type _legal_guardian_alias: object_.Pointer - :param _session_timeout: The setting for the session timeout of the user in - seconds. - :type _session_timeout: int - :param _card_ids: Card ids used for centralized card limits. - :type _card_ids: list[object_.BunqId] - :param _card_limits: The centralized limits for user's cards. - :type _card_limits: list[object_.CardLimit] - :param _daily_limit_without_confirmation_login: The amount the user can pay - in the session without asking for credentials. - :type _daily_limit_without_confirmation_login: object_.Amount - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserPerson. - :type _notification_filters: list[object_.NotificationFilter] - :param _id_: The id of the modified person object. + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _display_name: The legal name of the user / company using this + monetary account. + :type _display_name: str + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _savings_goal: The Savings Goal set for this + MonetaryAccountExternalSavings. + :type _savings_goal: object_.Amount + :param _id_: The id of the MonetaryAccountExternalSavings. :type _id_: int - :param _created: The timestamp of the person object's creation. + :param _created: The timestamp of the MonetaryAccountExternalSavings's + creation. :type _created: str - :param _updated: The timestamp of the person object's last update. + :param _updated: The timestamp of the MonetaryAccountExternalSavings's last + update. :type _updated: str - :param _public_uuid: The person's public UUID. - :type _public_uuid: str - :param _legal_name: The person's legal name. - :type _legal_name: str - :param _display_name: The display name for the person. - :type _display_name: str - :param _alias: The aliases of the user. - :type _alias: list[object_.Pointer] - :param _avatar: The user's avatar. + :param _avatar: The Avatar of the MonetaryAccountExternalSavings. :type _avatar: object_.Avatar - :param _version_terms_of_service: The version of the terms of service - accepted by the user. - :type _version_terms_of_service: str + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountExternalSavings's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the + MonetaryAccountExternalSavings. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _savings_goal_progress: The progress in percentages for the Savings + Goal set for this MonetaryAccountExternalSavings. + :type _savings_goal_progress: float + :param _number_of_payment_remaining: The number of payments that can be made + from this savings account + :type _number_of_payment_remaining: str + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] """ # Endpoint constants. - _ENDPOINT_URL_READ = "user-person/{}" - _ENDPOINT_URL_UPDATE = "user-person/{}" + _ENDPOINT_URL_CREATE = "user/{}/monetary-account-external-savings" + _ENDPOINT_URL_READ = "user/{}/monetary-account-external-savings/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-external-savings/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-external-savings" # Field constants. - FIELD_FIRST_NAME = "first_name" - FIELD_MIDDLE_NAME = "middle_name" - FIELD_LAST_NAME = "last_name" - FIELD_PUBLIC_NICK_NAME = "public_nick_name" - FIELD_ADDRESS_MAIN = "address_main" - FIELD_ADDRESS_POSTAL = "address_postal" + FIELD_CURRENCY = "currency" + FIELD_SERVICE = "service" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_TAX_RESIDENT = "tax_resident" - FIELD_DOCUMENT_TYPE = "document_type" - FIELD_DOCUMENT_NUMBER = "document_number" - FIELD_DOCUMENT_COUNTRY_OF_ISSUANCE = "document_country_of_issuance" - FIELD_DOCUMENT_FRONT_ATTACHMENT_ID = "document_front_attachment_id" - FIELD_DOCUMENT_BACK_ATTACHMENT_ID = "document_back_attachment_id" - FIELD_DATE_OF_BIRTH = "date_of_birth" - FIELD_PLACE_OF_BIRTH = "place_of_birth" - FIELD_COUNTRY_OF_BIRTH = "country_of_birth" - FIELD_NATIONALITY = "nationality" - FIELD_LANGUAGE = "language" - FIELD_REGION = "region" - FIELD_GENDER = "gender" FIELD_STATUS = "status" FIELD_SUB_STATUS = "sub_status" - FIELD_LEGAL_GUARDIAN_ALIAS = "legal_guardian_alias" - FIELD_SESSION_TIMEOUT = "session_timeout" - FIELD_CARD_IDS = "card_ids" - FIELD_CARD_LIMITS = "card_limits" - FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login" - FIELD_NOTIFICATION_FILTERS = "notification_filters" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_DISPLAY_NAME = "display_name" + FIELD_SETTING = "setting" + FIELD_SAVINGS_GOAL = "savings_goal" # Object type. - _OBJECT_TYPE_GET = "UserPerson" + _OBJECT_TYPE_GET = "MonetaryAccountExternalSavings" _id_ = None _created = None _updated = None - _public_uuid = None - _first_name = None - _middle_name = None - _last_name = None - _legal_name = None - _display_name = None - _public_nick_name = None - _alias = None - _tax_resident = None - _document_type = None - _document_number = None - _document_country_of_issuance = None - _address_main = None - _address_postal = None - _date_of_birth = None - _place_of_birth = None - _country_of_birth = None - _nationality = None - _language = None - _region = None - _gender = None _avatar = None - _version_terms_of_service = None + _currency = None + _description = None + _daily_limit = None + _balance = None + _alias = None + _public_uuid = None _status = None _sub_status = None - _session_timeout = None - _daily_limit_without_confirmation_login = None - _notification_filters = None - _first_name_field_for_request = None - _middle_name_field_for_request = None - _last_name_field_for_request = None - _public_nick_name_field_for_request = None - _address_main_field_for_request = None - _address_postal_field_for_request = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _user_id = None + _monetary_account_profile = None + _display_name = None + _setting = None + _all_auto_save_id = None + _fulfillments = None + _savings_goal = None + _savings_goal_progress = None + _number_of_payment_remaining = None + _budget = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _service_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None _avatar_uuid_field_for_request = None - _tax_resident_field_for_request = None - _document_type_field_for_request = None - _document_number_field_for_request = None - _document_country_of_issuance_field_for_request = None - _document_front_attachment_id_field_for_request = None - _document_back_attachment_id_field_for_request = None - _date_of_birth_field_for_request = None - _place_of_birth_field_for_request = None - _country_of_birth_field_for_request = None - _nationality_field_for_request = None - _language_field_for_request = None - _region_field_for_request = None - _gender_field_for_request = None _status_field_for_request = None _sub_status_field_for_request = None - _legal_guardian_alias_field_for_request = None - _session_timeout_field_for_request = None - _card_ids_field_for_request = None - _card_limits_field_for_request = None - _daily_limit_without_confirmation_login_field_for_request = None - _notification_filters_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _display_name_field_for_request = None + _setting_field_for_request = None + _savings_goal_field_for_request = None - def __init__(self, sub_status=None, card_limits=None, card_ids=None, - document_back_attachment_id=None, tax_resident=None, - address_postal=None, public_nick_name=None, last_name=None, - middle_name=None, first_name=None, - daily_limit_without_confirmation_login=None, - session_timeout=None, legal_guardian_alias=None, status=None, - address_main=None, gender=None, region=None, language=None, - nationality=None, country_of_birth=None, place_of_birth=None, - date_of_birth=None, document_front_attachment_id=None, - document_country_of_issuance=None, document_number=None, - document_type=None, avatar_uuid=None, - notification_filters=None): + def __init__(self, currency, service, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, savings_goal=None): """ - :param address_main: The user's main address. - :type address_main: object_.Address - :param avatar_uuid: The public UUID of the user's avatar. + :param currency: The currency of the MonetaryAccountExternalSavings as an + ISO 4217 formatted currency code. + :type currency: str + :param service: The service the MonetaryAccountExternalSavings is connected + with. + :type service: str + :param description: The description of the MonetaryAccountExternalSavings. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternalSavings. Defaults to 1000 EUR. Currency must match + the MonetaryAccountExternalSavings's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternalSavings. :type avatar_uuid: str - :param document_type: The type of identification document the person - registered with. - :type document_type: str - :param document_number: The identification document number the person - registered with. - :type document_number: str - :param document_country_of_issuance: The country which issued the - identification document the person registered with. - :type document_country_of_issuance: str - :param document_front_attachment_id: The reference to the uploaded - picture/scan of the front side of the identification document. - :type document_front_attachment_id: int - :param date_of_birth: The person's date of birth. Accepts ISO8601 date - formats. - :type date_of_birth: str - :param place_of_birth: The person's place of birth. - :type place_of_birth: str - :param country_of_birth: The person's country of birth. Formatted as a SO - 3166-1 alpha-2 country code. - :type country_of_birth: str - :param nationality: The person's nationality. Formatted as a SO 3166-1 - alpha-2 country code. - :type nationality: str - :param language: The person's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type language: str - :param region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type region: str - :param gender: The person's gender. Can be: MALE, FEMALE and UNKNOWN. - :type gender: str - :param status: The user status. You are not allowed to update the status via - PUT. + :param status: The status of the MonetaryAccountExternalSavings. Ignored in + POST requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountExternalSavings. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). :type status: str - :param sub_status: The user sub-status. Can be updated to SUBMIT if status - is RECOVERY. + :param sub_status: The sub-status of the MonetaryAccountExternalSavings + providing extra information regarding the status. Should be ignored for POST + requests. In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). :type sub_status: str - :param legal_guardian_alias: The legal guardian of the user. Required for - minors. - :type legal_guardian_alias: object_.Pointer - :param session_timeout: The setting for the session timeout of the user in - seconds. - :type session_timeout: int - :param daily_limit_without_confirmation_login: The amount the user can pay - in the session without asking for credentials. - :type daily_limit_without_confirmation_login: object_.Amount - :param first_name: The person's first name. - :type first_name: str - :param middle_name: The person's middle name. - :type middle_name: str - :param last_name: The person's last name. - :type last_name: str - :param public_nick_name: The person's public nick name. - :type public_nick_name: str - :param address_postal: The person's postal address. - :type address_postal: object_.Address - :param tax_resident: The user's tax residence numbers for different - countries. - :type tax_resident: list[object_.TaxResident] - :param document_back_attachment_id: The reference to the uploaded - picture/scan of the back side of the identification document. - :type document_back_attachment_id: int - :param card_ids: Card ids used for centralized card limits. - :type card_ids: list[object_.BunqId] - :param card_limits: The centralized limits for user's cards. - :type card_limits: list[object_.CardLimit] - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserPerson. - :type notification_filters: list[object_.NotificationFilter] + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternalSavings, can only be OTHER. Should only be specified + if updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternalSavings. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternalSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this MonetaryAccountSavings. + :type savings_goal: object_.Amount """ - self._address_main_field_for_request = address_main + self._currency_field_for_request = currency + self._service_field_for_request = service + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit self._avatar_uuid_field_for_request = avatar_uuid - self._document_type_field_for_request = document_type - self._document_number_field_for_request = document_number - self._document_country_of_issuance_field_for_request = document_country_of_issuance - self._document_front_attachment_id_field_for_request = document_front_attachment_id - self._date_of_birth_field_for_request = date_of_birth - self._place_of_birth_field_for_request = place_of_birth - self._country_of_birth_field_for_request = country_of_birth - self._nationality_field_for_request = nationality - self._language_field_for_request = language - self._region_field_for_request = region - self._gender_field_for_request = gender self._status_field_for_request = status self._sub_status_field_for_request = sub_status - self._legal_guardian_alias_field_for_request = legal_guardian_alias - self._session_timeout_field_for_request = session_timeout - self._daily_limit_without_confirmation_login_field_for_request = daily_limit_without_confirmation_login - self._first_name_field_for_request = first_name - self._middle_name_field_for_request = middle_name - self._last_name_field_for_request = last_name - self._public_nick_name_field_for_request = public_nick_name - self._address_postal_field_for_request = address_postal - self._tax_resident_field_for_request = tax_resident - self._document_back_attachment_id_field_for_request = document_back_attachment_id - self._card_ids_field_for_request = card_ids - self._card_limits_field_for_request = card_limits - self._notification_filters_field_for_request = notification_filters + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._display_name_field_for_request = display_name + self._setting_field_for_request = setting + self._savings_goal_field_for_request = savings_goal + + @classmethod + def create(cls,currency, service, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, savings_goal=None, custom_headers=None): + """ + :type user_id: int + :param currency: The currency of the MonetaryAccountExternalSavings as + an ISO 4217 formatted currency code. + :type currency: str + :param service: The service the MonetaryAccountExternalSavings is + connected with. + :type service: str + :param description: The description of the + MonetaryAccountExternalSavings. Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternalSavings. Defaults to 1000 EUR. Currency must + match the MonetaryAccountExternalSavings's currency. Limited to 10000 + EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternalSavings. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountExternalSavings. Ignored + in POST requests (always set to ACTIVE) can be CANCELLED or + PENDING_REOPEN in PUT requests to cancel (close) or reopen the + MonetaryAccountExternalSavings. When updating the status and/or + sub_status no other fields can be updated in the same request (and vice + versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountExternalSavings + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternalSavings, can only be OTHER. Should only be + specified if updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternalSavings. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternalSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this + MonetaryAccountSavings. + :type savings_goal: object_.Amount + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CURRENCY : currency, +cls.FIELD_SERVICE : service, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting, +cls.FIELD_SAVINGS_GOAL : savings_goal +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, monetary_account_external_savings_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_external_savings_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountExternalSavings + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_external_savings_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccountExternalSavings.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, monetary_account_external_savings_id, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, savings_goal=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_external_savings_id: int + :param description: The description of the + MonetaryAccountExternalSavings. Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternalSavings. Defaults to 1000 EUR. Currency must + match the MonetaryAccountExternalSavings's currency. Limited to 10000 + EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternalSavings. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountExternalSavings. Ignored + in POST requests (always set to ACTIVE) can be CANCELLED or + PENDING_REOPEN in PUT requests to cancel (close) or reopen the + MonetaryAccountExternalSavings. When updating the status and/or + sub_status no other fields can be updated in the same request (and vice + versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountExternalSavings + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternalSavings, can only be OTHER. Should only be + specified if updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternalSavings. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternalSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this + MonetaryAccountSavings. + :type savings_goal: object_.Amount + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting, +cls.FIELD_SAVINGS_GOAL : savings_goal +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_external_savings_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) @classmethod - def get(cls, custom_headers=None): + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountExternalSavingsList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountExternalSavingsList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def savings_goal(self): + """ + :rtype: object_.Amount + """ + + return self._savings_goal + + @property + def savings_goal_progress(self): + """ + :rtype: float + """ + + return self._savings_goal_progress + + @property + def number_of_payment_remaining(self): + """ + :rtype: str + """ + + return self._number_of_payment_remaining + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._display_name is not None: + return False + + if self._setting is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._savings_goal is not None: + return False + + if self._savings_goal_progress is not None: + return False + + if self._number_of_payment_remaining is not None: + return False + + if self._budget is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountExternalSavingsApiObject + """ + + return converter.json_to_class(MonetaryAccountExternalSavingsApiObject, json_str) + + +class MonetaryAccountExternalApiObject(BunqModel): + """ + Endpoint for managing monetary accounts which are connected to external + services. + + :param _currency: The currency of the MonetaryAccountExternal as an ISO 4217 + formatted currency code. + :type _currency: str + :param _service: The external service the Monetary Account is connected + with. + :type _service: str + :param _description: The description of the MonetaryAccountExternal. + Defaults to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountExternal. Defaults to 1000 EUR. Currency must match the + MonetaryAccountExternal's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountExternal. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountExternal. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountExternal providing + extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _display_name: The legal name of the user / company using this + monetary account. + :type _display_name: str + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _id_: The id of the MonetaryAccountExternal. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountExternal's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountExternal's last update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountExternal. + :type _avatar: object_.Avatar + :param _overdraft_limit: The maximum Amount the MonetaryAccountExternal can + be 'in the red'. + :type _overdraft_limit: object_.Amount + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountExternal's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the MonetaryAccountExternal. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account-external" + _ENDPOINT_URL_READ = "user/{}/monetary-account-external/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-external/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-external" + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_SERVICE = "service" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_DISPLAY_NAME = "display_name" + FIELD_SETTING = "setting" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccountExternal" + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _overdraft_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _user_id = None + _monetary_account_profile = None + _display_name = None + _setting = None + _all_auto_save_id = None + _fulfillments = None + _service = None + _open_banking_account = None + _budget = None + _all_co_owner = None + _co_owner_invite = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _service_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _display_name_field_for_request = None + _setting_field_for_request = None + + def __init__(self, currency, service, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None): + """ + :param currency: The currency of the MonetaryAccountExternal as an ISO 4217 + formatted currency code. + :type currency: str + :param service: The service the MonetaryAccountExternal is connected with. + :type service: str + :param description: The description of the MonetaryAccountExternal. Defaults + to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternal. Defaults to 1000 EUR. Currency must match the + MonetaryAccountExternal's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountExternal. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountExternal. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountExternal. When + updating the status and/or sub_status no other fields can be updated in the + same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountExternal providing + extra information regarding the status. Should be ignored for POST requests. + In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternal, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternal. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternal. + :type setting: object_.MonetaryAccountSetting + """ + + self._currency_field_for_request = currency + self._service_field_for_request = service + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._display_name_field_for_request = display_name + self._setting_field_for_request = setting + + @classmethod + def create(cls,currency, service, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, custom_headers=None): + """ + :type user_id: int + :param currency: The currency of the MonetaryAccountExternal as an ISO + 4217 formatted currency code. + :type currency: str + :param service: The service the MonetaryAccountExternal is connected + with. + :type service: str + :param description: The description of the MonetaryAccountExternal. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternal. Defaults to 1000 EUR. Currency must match the + MonetaryAccountExternal's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternal. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountExternal. Ignored in + POST requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN + in PUT requests to cancel (close) or reopen the MonetaryAccountExternal. + When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountExternal + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternal, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternal. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternal. + :type setting: object_.MonetaryAccountSetting + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CURRENCY : currency, +cls.FIELD_SERVICE : service, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, monetary_account_external_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_external_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountExternal + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_external_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccountExternal.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, monetary_account_external_id, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_external_id: int + :param description: The description of the MonetaryAccountExternal. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountExternal. Defaults to 1000 EUR. Currency must match the + MonetaryAccountExternal's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountExternal. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountExternal. Ignored in + POST requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN + in PUT requests to cancel (close) or reopen the MonetaryAccountExternal. + When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountExternal + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountExternal, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountExternal. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountExternal. + :type setting: object_.MonetaryAccountSetting + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_DISPLAY_NAME : display_name, +cls.FIELD_SETTING : setting +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_external_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountExternalList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountExternalList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def overdraft_limit(self): + """ + :rtype: object_.Amount + """ + + return self._overdraft_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def service(self): + """ + :rtype: str + """ + + return self._service + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._overdraft_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._display_name is not None: + return False + + if self._setting is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._service is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._budget is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountExternalApiObject + """ + + return converter.json_to_class(MonetaryAccountExternalApiObject, json_str) + + +class MonetaryAccountJointApiObject(BunqModel): + """ + The endpoint for joint monetary accounts. + + :param _currency: The currency of the MonetaryAccountJoint as an ISO 4217 + formatted currency code. + :type _currency: str + :param _description: The description of the MonetaryAccountJoint. Defaults + to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the + MonetaryAccountJoint's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _overdraft_limit: The maximum Amount the MonetaryAccountJoint can be + 'in the red'. + :type _overdraft_limit: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountJoint. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountJoint providing + extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _id_: The id of the MonetaryAccountJoint. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountJoint's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountJoint's last update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountJoint. + :type _avatar: object_.Avatar + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _public_uuid: The MonetaryAccountJoint's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the MonetaryAccountJoint. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account-joint" + _ENDPOINT_URL_READ = "user/{}/monetary-account-joint/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-joint/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-joint" + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_OVERDRAFT_LIMIT = "overdraft_limit" + FIELD_ALIAS = "alias" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_ALL_CO_OWNER = "all_co_owner" + FIELD_SETTING = "setting" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccountJoint" + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _overdraft_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _all_co_owner = None + _user_id = None + _monetary_account_profile = None + _setting = None + _all_auto_save_id = None + _fulfillments = None + _co_owner_invite = None + _budget = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _overdraft_limit_field_for_request = None + _alias_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _all_co_owner_field_for_request = None + _setting_field_for_request = None + + def __init__(self, currency, all_co_owner, description=None, daily_limit=None, overdraft_limit=None, alias=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, setting=None): + """ + :param currency: The currency of the MonetaryAccountJoint as an ISO 4217 + formatted currency code. + :type currency: str + :param all_co_owner: The users the account will be joint with. + :type all_co_owner: list[object_.CoOwner] + :param description: The description of the MonetaryAccountJoint. Defaults to + 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the + MonetaryAccountJoint's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param overdraft_limit: The maximum Amount the MonetaryAccountJoint can be + 'in the red'. Must be 0 EUR or omitted. + :type overdraft_limit: object_.Amount + :param alias: The Aliases to add to MonetaryAccountJoint. Must all be + confirmed first. Can mostly be ignored. + :type alias: list[object_.Pointer] + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountJoint. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountJoint. When updating + the status and/or sub_status no other fields can be updated in the same + request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountJoint providing + extra information regarding the status. Should be ignored for POST requests. + In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountJoint, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountJoint. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param setting: The settings of the MonetaryAccountJoint. + :type setting: object_.MonetaryAccountSetting + """ + + self._currency_field_for_request = currency + self._all_co_owner_field_for_request = all_co_owner + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._overdraft_limit_field_for_request = overdraft_limit + self._alias_field_for_request = alias + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._setting_field_for_request = setting + + @classmethod + def create(cls,currency, all_co_owner, description=None, daily_limit=None, overdraft_limit=None, alias=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, setting=None, custom_headers=None): + """ + :type user_id: int + :param currency: The currency of the MonetaryAccountJoint as an ISO 4217 + formatted currency code. + :type currency: str + :param all_co_owner: The users the account will be joint with. + :type all_co_owner: list[object_.CoOwner] + :param description: The description of the MonetaryAccountJoint. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the + MonetaryAccountJoint's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param overdraft_limit: The maximum Amount the MonetaryAccountJoint can + be 'in the red'. Must be 0 EUR or omitted. + :type overdraft_limit: object_.Amount + :param alias: The Aliases to add to MonetaryAccountJoint. Must all be + confirmed first. Can mostly be ignored. + :type alias: list[object_.Pointer] + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountJoint. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountJoint. When + updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountJoint providing + extra information regarding the status. Should be ignored for POST + requests. In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountJoint, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountJoint. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param setting: The settings of the MonetaryAccountJoint. + :type setting: object_.MonetaryAccountSetting + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CURRENCY : currency, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_OVERDRAFT_LIMIT : overdraft_limit, +cls.FIELD_ALIAS : alias, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_ALL_CO_OWNER : all_co_owner, +cls.FIELD_SETTING : setting +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, monetary_account_joint_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_joint_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountJoint + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_joint_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccountJoint.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, monetary_account_joint_id, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, setting=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_joint_id: int + :param description: The description of the MonetaryAccountJoint. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountJoint. Defaults to 1000 EUR. Currency must match the + MonetaryAccountJoint's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountJoint. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountJoint. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountJoint. When + updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountJoint providing + extra information regarding the status. Should be ignored for POST + requests. In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountJoint, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountJoint. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param setting: The settings of the MonetaryAccountJoint. + :type setting: object_.MonetaryAccountSetting + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_SETTING : setting +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_joint_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountJointList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountJointList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def overdraft_limit(self): + """ + :rtype: object_.Amount + """ + + return self._overdraft_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._overdraft_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._setting is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._budget is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountJointApiObject + """ + + return converter.json_to_class(MonetaryAccountJointApiObject, json_str) + + +class MonetaryAccountSavingsApiObject(BunqModel): + """ + With MonetaryAccountSavings you can create a new savings account. + + :param _currency: The currency of the MonetaryAccountSavings as an ISO 4217 + formatted currency code. + :type _currency: str + :param _description: The description of the MonetaryAccountSavings. Defaults + to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountSavings. Defaults to 1000 EUR. Currency must match the + MonetaryAccountSavings's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountSavings. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountSavings. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountSavings providing + extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _savings_goal: The Savings Goal set for this MonetaryAccountSavings. + :type _savings_goal: object_.Amount + :param _id_: The id of the MonetaryAccountSavings. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountSavings's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountSavings's last update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountSavings. + :type _avatar: object_.Avatar + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountSavings's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the MonetaryAccountSavings. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _savings_goal_progress: The progress in percentages for the Savings + Goal set for this MonetaryAccountSavings. + :type _savings_goal_progress: float + :param _number_of_payment_remaining: The number of payments that can be made + from this savings account + :type _number_of_payment_remaining: str + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account-savings" + _ENDPOINT_URL_READ = "user/{}/monetary-account-savings/{}" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account-savings/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account-savings" + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_ALL_CO_OWNER = "all_co_owner" + FIELD_SETTING = "setting" + FIELD_SAVINGS_GOAL = "savings_goal" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccountSavings" + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _all_co_owner = None + _user_id = None + _monetary_account_profile = None + _setting = None + _savings_goal = None + _savings_goal_progress = None + _number_of_payment_remaining = None + _all_auto_save_id = None + _fulfillments = None + _co_owner_invite = None + _budget = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _all_co_owner_field_for_request = None + _setting_field_for_request = None + _savings_goal_field_for_request = None + + def __init__(self, currency, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, all_co_owner=None, setting=None, savings_goal=None): + """ + :param currency: The currency of the MonetaryAccountSavings as an ISO 4217 + formatted currency code. + :type currency: str + :param description: The description of the MonetaryAccountSavings. Defaults + to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountSavings. Defaults to 1000 EUR. Currency must match the + MonetaryAccountSavings's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountSavings. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountSavings. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountSavings. When + updating the status and/or sub_status no other fields can be updated in the + same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountSavings providing + extra information regarding the status. Should be ignored for POST requests. + In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountSavings, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountSavings. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param all_co_owner: The users the account will be joint with. + :type all_co_owner: list[object_.CoOwner] + :param setting: The settings of the MonetaryAccountSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this MonetaryAccountSavings. + :type savings_goal: object_.Amount + """ + + self._currency_field_for_request = currency + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._all_co_owner_field_for_request = all_co_owner + self._setting_field_for_request = setting + self._savings_goal_field_for_request = savings_goal + + @classmethod + def create(cls,currency, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, all_co_owner=None, setting=None, savings_goal=None, custom_headers=None): + """ + Create new MonetaryAccountSavings. + + :type user_id: int + :param currency: The currency of the MonetaryAccountSavings as an ISO + 4217 formatted currency code. + :type currency: str + :param description: The description of the MonetaryAccountSavings. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountSavings. Defaults to 1000 EUR. Currency must match the + MonetaryAccountSavings's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountSavings. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountSavings. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountSavings. + When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountSavings + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountSavings, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountSavings. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param all_co_owner: The users the account will be joint with. + :type all_co_owner: list[object_.CoOwner] + :param setting: The settings of the MonetaryAccountSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this + MonetaryAccountSavings. + :type savings_goal: object_.Amount + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CURRENCY : currency, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_ALL_CO_OWNER : all_co_owner, +cls.FIELD_SETTING : setting, +cls.FIELD_SAVINGS_GOAL : savings_goal +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, monetary_account_savings_id, custom_headers=None): + """ + Get a specific MonetaryAccountSavings. + + :type api_context: ApiContext + :type user_id: int + :type monetary_account_savings_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountSavings + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), monetary_account_savings_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccountSavings.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, monetary_account_savings_id, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, setting=None, savings_goal=None, custom_headers=None): + """ + Update a specific existing MonetaryAccountSavings. + + :type user_id: int + :type monetary_account_savings_id: int + :param description: The description of the MonetaryAccountSavings. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountSavings. Defaults to 1000 EUR. Currency must match the + MonetaryAccountSavings's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the + MonetaryAccountSavings. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountSavings. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in + PUT requests to cancel (close) or reopen the MonetaryAccountSavings. + When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountSavings + providing extra information regarding the status. Should be ignored for + POST requests. In case of PUT requests with status CANCELLED it can only + be REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be + NONE. When updating the status and/or sub_status no other fields can be + updated in the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountSavings, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountSavings. Can be any user + provided message. Should only be specified if updating the status to + CANCELLED. + :type reason_description: str + :param setting: The settings of the MonetaryAccountSavings. + :type setting: object_.MonetaryAccountSetting + :param savings_goal: The Savings Goal set for this + MonetaryAccountSavings. + :type savings_goal: object_.Amount + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_DAILY_LIMIT : daily_limit, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_REASON : reason, +cls.FIELD_REASON_DESCRIPTION : reason_description, +cls.FIELD_SETTING : setting, +cls.FIELD_SAVINGS_GOAL : savings_goal +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), monetary_account_savings_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Gets a listing of all MonetaryAccountSavingss of a given user. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountSavingsList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountSavingsList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def savings_goal(self): + """ + :rtype: object_.Amount + """ + + return self._savings_goal + + @property + def savings_goal_progress(self): + """ + :rtype: float + """ + + return self._savings_goal_progress + + @property + def number_of_payment_remaining(self): + """ + :rtype: str + """ + + return self._number_of_payment_remaining + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._setting is not None: + return False + + if self._savings_goal is not None: + return False + + if self._savings_goal_progress is not None: + return False + + if self._number_of_payment_remaining is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._budget is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountSavingsApiObject + """ + + return converter.json_to_class(MonetaryAccountSavingsApiObject, json_str) + + +class MonetaryAccountApiObject(BunqModel): + """ + Used to show the MonetaryAccounts that you can access. Currently the only + MonetaryAccount type is MonetaryAccountBank. See also: + monetary-account-bank.

Notification filters can be set on a + monetary account level to receive callbacks. For more information check the + dedicated callbacks page. + + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + :param _MonetaryAccountLight: + :type _MonetaryAccountLight: MonetaryAccountLight + :param _MonetaryAccountBank: + :type _MonetaryAccountBank: MonetaryAccountBank + :param _MonetaryAccountExternal: + :type _MonetaryAccountExternal: MonetaryAccountExternal + :param _MonetaryAccountInvestment: + :type _MonetaryAccountInvestment: MonetaryAccountInvestment + :param _MonetaryAccountJoint: + :type _MonetaryAccountJoint: MonetaryAccountJoint + :param _MonetaryAccountSavings: + :type _MonetaryAccountSavings: MonetaryAccountSavings + :param _MonetaryAccountSwitchService: + :type _MonetaryAccountSwitchService: MonetaryAccountSwitchService + :param _MonetaryAccountExternalSavings: + :type _MonetaryAccountExternalSavings: MonetaryAccountExternalSavings + :param _MonetaryAccountCard: + :type _MonetaryAccountCard: MonetaryAccountCard + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account" + + # Object type. + _OBJECT_TYPE_GET = "MonetaryAccount" + + _alias = None + _balance = None + _monetary_account_profile = None + _setting = None + _budget = None + _reason = None + _reason_description = None + _share = None + _all_auto_save_id = None + _fulfillments = None + _relation_user = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _MonetaryAccountLight = None + _MonetaryAccountBank = None + _MonetaryAccountExternal = None + _MonetaryAccountInvestment = None + _MonetaryAccountJoint = None + _MonetaryAccountSavings = None + _MonetaryAccountSwitchService = None + _MonetaryAccountExternalSavings = None + _MonetaryAccountCard = None + + @classmethod + def get(cls, monetary_account_id, custom_headers=None): + """ + Get a specific MonetaryAccount. + + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccount + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseMonetaryAccount.cast_from_bunq_response( + cls._from_json(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Get a collection of all your MonetaryAccounts. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMonetaryAccountList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMonetaryAccountList.cast_from_bunq_response( + cls._from_json_list(response_raw) + ) + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + @property + def MonetaryAccountLight(self): + """ + :rtype: MonetaryAccountLight + """ + + return self._MonetaryAccountLight + + @property + def MonetaryAccountBank(self): + """ + :rtype: MonetaryAccountBank + """ + + return self._MonetaryAccountBank + + @property + def MonetaryAccountExternal(self): + """ + :rtype: MonetaryAccountExternal + """ + + return self._MonetaryAccountExternal + + @property + def MonetaryAccountInvestment(self): + """ + :rtype: MonetaryAccountInvestment + """ + + return self._MonetaryAccountInvestment + + @property + def MonetaryAccountJoint(self): + """ + :rtype: MonetaryAccountJoint + """ + + return self._MonetaryAccountJoint + + @property + def MonetaryAccountSavings(self): + """ + :rtype: MonetaryAccountSavings + """ + + return self._MonetaryAccountSavings + + @property + def MonetaryAccountSwitchService(self): + """ + :rtype: MonetaryAccountSwitchService + """ + + return self._MonetaryAccountSwitchService + + @property + def MonetaryAccountExternalSavings(self): + """ + :rtype: MonetaryAccountExternalSavings + """ + + return self._MonetaryAccountExternalSavings + + @property + def MonetaryAccountCard(self): + """ + :rtype: MonetaryAccountCard + """ + + return self._MonetaryAccountCard + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._alias is not None: + return False + + if self._balance is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._setting is not None: + return False + + if self._budget is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._relation_user is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + if self._MonetaryAccountLight is not None: + return False + + if self._MonetaryAccountBank is not None: + return False + + if self._MonetaryAccountExternal is not None: + return False + + if self._MonetaryAccountInvestment is not None: + return False + + if self._MonetaryAccountJoint is not None: + return False + + if self._MonetaryAccountSavings is not None: + return False + + if self._MonetaryAccountSwitchService is not None: + return False + + if self._MonetaryAccountExternalSavings is not None: + return False + + if self._MonetaryAccountCard is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountApiObject + """ + + return converter.json_to_class(MonetaryAccountApiObject, json_str) + + +class MonetaryAccountLightApiObject(BunqModel): + """ + With MonetaryAccountLight is a monetary account for bunq light users. + Through this endpoint you can retrieve information regarding your existing + MonetaryAccountLights and update specific fields of an existing + MonetaryAccountLight. Examples of fields that can be updated are the + description, the daily limit and the avatar of the account. + + :param _currency: The currency of the MonetaryAccountLight as an ISO 4217 + formatted currency code. + :type _currency: str + :param _description: The description of the MonetaryAccountLight. Defaults + to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the + MonetaryAccountLight's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountLight. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountLight providing + extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _id_: The id of the MonetaryAccountLight. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountLight's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountLight's last update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountLight. + :type _avatar: object_.Avatar + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountLight's public UUID. + :type _public_uuid: str + :param _user_id: The id of the User who owns the MonetaryAccountLight. + :type _user_id: int + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _balance_maximum: The maximum balance Amount of the + MonetaryAccountLight. + :type _balance_maximum: object_.Amount + :param _budget_month_used: The amount of the monthly budget used. + :type _budget_month_used: object_.Amount + :param _budget_month_maximum: The total amount of the monthly budget. + :type _budget_month_maximum: object_.Amount + :param _budget_year_used: The amount of the yearly budget used. + :type _budget_year_used: object_.Amount + :param _budget_year_maximum: The total amount of the yearly budget. + :type _budget_year_maximum: object_.Amount + :param _budget_withdrawal_year_used: The amount of the yearly withdrawal + budget used. + :type _budget_withdrawal_year_used: object_.Amount + :param _budget_withdrawal_year_maximum: The total amount of the yearly + withdrawal budget. + :type _budget_withdrawal_year_maximum: object_.Amount + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_SETTING = "setting" + + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _user_id = None + _share = None + _relation_user = None + _balance_maximum = None + _budget_month_used = None + _budget_month_maximum = None + _budget_year_used = None + _budget_year_maximum = None + _budget_withdrawal_year_used = None + _budget_withdrawal_year_maximum = None + _setting = None + _fulfillments = None + _monetary_account_profile = None + _budget = None + _all_auto_save_id = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + _currency_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _setting_field_for_request = None + + def __init__(self, currency, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, setting=None): + """ + :param currency: The currency of the MonetaryAccountLight as an ISO 4217 + formatted currency code. + :type currency: str + :param description: The description of the MonetaryAccountLight. Defaults to + 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountLight. Defaults to 1000 EUR. Currency must match the + MonetaryAccountLight's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountLight. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountLight. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountLight. When updating + the status and/or sub_status no other fields can be updated in the same + request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountLight providing + extra information regarding the status. Should be ignored for POST requests + and can only be REDEMPTION_VOLUNTARY for PUT requests with status CANCELLED. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountBank, can only be OTHER. Should only be specified if updating + the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountBank. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param setting: The settings of the MonetaryAccountLight. + :type setting: object_.MonetaryAccountSetting + """ + + self._currency_field_for_request = currency + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._setting_field_for_request = setting + + + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def balance_maximum(self): + """ + :rtype: object_.Amount + """ + + return self._balance_maximum + + @property + def budget_month_used(self): + """ + :rtype: object_.Amount + """ + + return self._budget_month_used + + @property + def budget_month_maximum(self): + """ + :rtype: object_.Amount + """ + + return self._budget_month_maximum + + @property + def budget_year_used(self): + """ + :rtype: object_.Amount + """ + + return self._budget_year_used + + @property + def budget_year_maximum(self): + """ + :rtype: object_.Amount + """ + + return self._budget_year_maximum + + @property + def budget_withdrawal_year_used(self): + """ + :rtype: object_.Amount + """ + + return self._budget_withdrawal_year_used + + @property + def budget_withdrawal_year_maximum(self): + """ + :rtype: object_.Amount + """ + + return self._budget_withdrawal_year_maximum + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._user_id is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._balance_maximum is not None: + return False + + if self._budget_month_used is not None: + return False + + if self._budget_month_maximum is not None: + return False + + if self._budget_year_used is not None: + return False + + if self._budget_year_maximum is not None: + return False + + if self._budget_withdrawal_year_used is not None: + return False + + if self._budget_withdrawal_year_maximum is not None: + return False + + if self._setting is not None: + return False + + if self._fulfillments is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._budget is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountLightApiObject + """ + + return converter.json_to_class(MonetaryAccountLightApiObject, json_str) + + +class MonetaryAccountInvestmentApiObject(BunqModel): + """ + Endpoint for managing investment monetary accounts. + + :param _currency: The currency of the MonetaryAccountInvestment as an ISO + 4217 formatted currency code. + :type _currency: str + :param _provider: The provider of the investment service. + :type _provider: str + :param _description: The description of the MonetaryAccountInvestment. + Defaults to 'bunq account'. + :type _description: str + :param _daily_limit: The daily spending limit Amount of the + MonetaryAccountInvestment. Defaults to 1000 EUR. Currency must match the + MonetaryAccountInvestment's currency. Limited to 10000 EUR. + :type _daily_limit: object_.Amount + :param _avatar_uuid: The UUID of the Avatar of the + MonetaryAccountInvestment. + :type _avatar_uuid: str + :param _status: The status of the MonetaryAccountInvestment. Can be: ACTIVE, + BLOCKED, CANCELLED or PENDING_REOPEN + :type _status: str + :param _sub_status: The sub-status of the MonetaryAccountInvestment + providing extra information regarding the status. Will be NONE for ACTIVE or + PENDING_REOPEN, COMPLETELY or ONLY_ACCEPTING_INCOMING for BLOCKED and + REDEMPTION_INVOLUNTARY, REDEMPTION_VOLUNTARY or PERMANENT for CANCELLED. + :type _sub_status: str + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _display_name: The legal name of the user / company using this + monetary account. + :type _display_name: str + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _monetary_account_deposit_initial_id: ID of the MA to be used for the + initial deposit to the investment account. + :type _monetary_account_deposit_initial_id: int + :param _amount_deposit_initial: The amount to be transferred to the + investment account as the initial deposit. + :type _amount_deposit_initial: object_.Amount + :param _id_: The id of the MonetaryAccountInvestment. + :type _id_: int + :param _created: The timestamp of the MonetaryAccountInvestment's creation. + :type _created: str + :param _updated: The timestamp of the MonetaryAccountInvestment's last + update. + :type _updated: str + :param _avatar: The Avatar of the MonetaryAccountInvestment. + :type _avatar: object_.Avatar + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _public_uuid: The MonetaryAccountInvestment's public UUID. + :type _public_uuid: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _user_id: The id of the User who owns the MonetaryAccountInvestment. + :type _user_id: int + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + # Field constants. + FIELD_CURRENCY = "currency" + FIELD_PROVIDER = "provider" + FIELD_DESCRIPTION = "description" + FIELD_DAILY_LIMIT = "daily_limit" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_REASON = "reason" + FIELD_REASON_DESCRIPTION = "reason_description" + FIELD_DISPLAY_NAME = "display_name" + FIELD_SETTING = "setting" + FIELD_BIRDEE_INVESTMENT_PORTFOLIO = "birdee_investment_portfolio" + FIELD_MONETARY_ACCOUNT_DEPOSIT_INITIAL_ID = "monetary_account_deposit_initial_id" + FIELD_AMOUNT_DEPOSIT_INITIAL = "amount_deposit_initial" + + + _id_ = None + _created = None + _updated = None + _avatar = None + _currency = None + _description = None + _daily_limit = None + _balance = None + _alias = None + _public_uuid = None + _status = None + _sub_status = None + _reason = None + _reason_description = None + _share = None + _relation_user = None + _user_id = None + _monetary_account_profile = None + _display_name = None + _setting = None + _all_auto_save_id = None + _fulfillments = None + _birdee_investment_portfolio = None + _budget = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _all_access = None + _currency_field_for_request = None + _provider_field_for_request = None + _description_field_for_request = None + _daily_limit_field_for_request = None + _avatar_uuid_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _reason_field_for_request = None + _reason_description_field_for_request = None + _display_name_field_for_request = None + _setting_field_for_request = None + _birdee_investment_portfolio_field_for_request = None + _monetary_account_deposit_initial_id_field_for_request = None + _amount_deposit_initial_field_for_request = None + + def __init__(self, currency, provider, description=None, daily_limit=None, avatar_uuid=None, status=None, sub_status=None, reason=None, reason_description=None, display_name=None, setting=None, birdee_investment_portfolio=None, monetary_account_deposit_initial_id=None, amount_deposit_initial=None): + """ + :param currency: The currency of the MonetaryAccountInvestment as an ISO + 4217 formatted currency code. + :type currency: str + :param provider: The provider of the investment service. + :type provider: str + :param description: The description of the MonetaryAccountInvestment. + Defaults to 'bunq account'. + :type description: str + :param daily_limit: The daily spending limit Amount of the + MonetaryAccountInvestment. Defaults to 1000 EUR. Currency must match the + MonetaryAccountInvestment's currency. Limited to 10000 EUR. + :type daily_limit: object_.Amount + :param avatar_uuid: The UUID of the Avatar of the MonetaryAccountInvestment. + :type avatar_uuid: str + :param status: The status of the MonetaryAccountInvestment. Ignored in POST + requests (always set to ACTIVE) can be CANCELLED or PENDING_REOPEN in PUT + requests to cancel (close) or reopen the MonetaryAccountInvestment. When + updating the status and/or sub_status no other fields can be updated in the + same request (and vice versa). + :type status: str + :param sub_status: The sub-status of the MonetaryAccountInvestment providing + extra information regarding the status. Should be ignored for POST requests. + In case of PUT requests with status CANCELLED it can only be + REDEMPTION_VOLUNTARY, while with status PENDING_REOPEN it can only be NONE. + When updating the status and/or sub_status no other fields can be updated in + the same request (and vice versa). + :type sub_status: str + :param reason: The reason for voluntarily cancelling (closing) the + MonetaryAccountInvestment, can only be OTHER. Should only be specified if + updating the status to CANCELLED. + :type reason: str + :param reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccountInvestment. Can be any user provided + message. Should only be specified if updating the status to CANCELLED. + :type reason_description: str + :param display_name: The legal name of the user / company using this + monetary account. + :type display_name: str + :param setting: The settings of the MonetaryAccountInvestment. + :type setting: object_.MonetaryAccountSetting + :param birdee_investment_portfolio: The Birdee investment portfolio. + :type birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param monetary_account_deposit_initial_id: ID of the MA to be used for the + initial deposit to the investment account. + :type monetary_account_deposit_initial_id: int + :param amount_deposit_initial: The amount to be transferred to the + investment account as the initial deposit. + :type amount_deposit_initial: object_.Amount + """ + + self._currency_field_for_request = currency + self._provider_field_for_request = provider + self._description_field_for_request = description + self._daily_limit_field_for_request = daily_limit + self._avatar_uuid_field_for_request = avatar_uuid + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._reason_field_for_request = reason + self._reason_description_field_for_request = reason_description + self._display_name_field_for_request = display_name + self._setting_field_for_request = setting + self._birdee_investment_portfolio_field_for_request = birdee_investment_portfolio + self._monetary_account_deposit_initial_id_field_for_request = monetary_account_deposit_initial_id + self._amount_deposit_initial_field_for_request = amount_deposit_initial + + + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def daily_limit(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def user_id(self): + """ + :rtype: int + """ + + return self._user_id + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._avatar is not None: + return False + + if self._currency is not None: + return False + + if self._description is not None: + return False + + if self._daily_limit is not None: + return False + + if self._balance is not None: + return False + + if self._alias is not None: + return False + + if self._public_uuid is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._relation_user is not None: + return False + + if self._user_id is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._display_name is not None: + return False + + if self._setting is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._budget is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountInvestmentApiObject + """ + + return converter.json_to_class(MonetaryAccountInvestmentApiObject, json_str) + + +class MonetaryAccountSwitchServiceApiObject(BunqModel): + """ + View for MonetaryAccountSwitchService + + :param _id_: The id of the monetary account. + :type _id_: int + :param _created: The timestamp of the monetary account's creation. + :type _created: str + :param _description: The description for the bank account. + :type _description: str + :param _status: The status of the account. + :type _status: str + :param _sub_status: The sub-status of the account. + :type _sub_status: str + :param _alias: The aliases for the MonetaryAccount. + :type _alias: list[object_.Pointer] + :param _balance: The current available balance amount of the + MonetaryAccount. + :type _balance: object_.Amount + :param _monetary_account_profile: The profiles of the account. + :type _monetary_account_profile: MonetaryAccountProfile + :param _setting: The settings of the MonetaryAccount. + :type _setting: object_.MonetaryAccountSetting + :param _budget: The budgets of the MonetaryAccount. + :type _budget: list[MonetaryAccountBudget] + :param _reason: The reason for voluntarily cancelling (closing) the + MonetaryAccount. + :type _reason: str + :param _reason_description: The optional free-form reason for voluntarily + cancelling (closing) the MonetaryAccount. Can be any user provided message. + :type _reason_description: str + :param _share: The ShareInviteBankResponse when the MonetaryAccount is + accessed by the User via a share/connect. + :type _share: ShareInviteMonetaryAccountResponse + :param _all_auto_save_id: The ids of the AutoSave. + :type _all_auto_save_id: list[object_.BunqId] + :param _fulfillments: The fulfillments for this MonetaryAccount. + :type _fulfillments: list[Fulfillment] + :param _relation_user: The RelationUser when the MonetaryAccount is accessed + by the User via a share/connect. + :type _relation_user: RelationUser + :param _all_co_owner: The users the account will be joint with. + :type _all_co_owner: list[object_.CoOwner] + :param _co_owner_invite: The CoOwnerInvite when the MonetaryAccount is + accessed by the User via a CoOwnerInvite. + :type _co_owner_invite: CoOwnerInviteResponse + :param _open_banking_account: The open banking account for information about + the external account. + :type _open_banking_account: OpenBankingAccount + :param _birdee_investment_portfolio: The Birdee investment portfolio. + :type _birdee_investment_portfolio: BirdeeInvestmentPortfolio + :param _all_access: The access of this Monetary Account. + :type _all_access: list[MonetaryAccountAccess] + """ + + _id_ = None + _created = None + _description = None + _status = None + _sub_status = None + _alias = None + _balance = None + _monetary_account_profile = None + _setting = None + _budget = None + _reason = None + _reason_description = None + _share = None + _all_auto_save_id = None + _fulfillments = None + _relation_user = None + _all_co_owner = None + _co_owner_invite = None + _open_banking_account = None + _birdee_investment_portfolio = None + _all_access = None + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def balance(self): + """ + :rtype: object_.Amount + """ + + return self._balance + + @property + def monetary_account_profile(self): + """ + :rtype: MonetaryAccountProfile + """ + + return self._monetary_account_profile + + @property + def setting(self): + """ + :rtype: object_.MonetaryAccountSetting + """ + + return self._setting + + @property + def budget(self): + """ + :rtype: list[MonetaryAccountBudget] + """ + + return self._budget + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def reason_description(self): + """ + :rtype: str + """ + + return self._reason_description + + @property + def share(self): + """ + :rtype: ShareInviteMonetaryAccountResponse + """ + + return self._share + + @property + def all_auto_save_id(self): + """ + :rtype: list[object_.BunqId] + """ + + return self._all_auto_save_id + + @property + def fulfillments(self): + """ + :rtype: list[Fulfillment] + """ + + return self._fulfillments + + @property + def relation_user(self): + """ + :rtype: RelationUser + """ + + return self._relation_user + + @property + def all_co_owner(self): + """ + :rtype: list[object_.CoOwner] + """ + + return self._all_co_owner + + @property + def co_owner_invite(self): + """ + :rtype: CoOwnerInviteResponse + """ + + return self._co_owner_invite + + @property + def open_banking_account(self): + """ + :rtype: OpenBankingAccount + """ + + return self._open_banking_account + + @property + def birdee_investment_portfolio(self): + """ + :rtype: BirdeeInvestmentPortfolio + """ + + return self._birdee_investment_portfolio + + @property + def all_access(self): + """ + :rtype: list[MonetaryAccountAccess] + """ + + return self._all_access + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._description is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._alias is not None: + return False + + if self._balance is not None: + return False + + if self._monetary_account_profile is not None: + return False + + if self._setting is not None: + return False + + if self._budget is not None: + return False + + if self._reason is not None: + return False + + if self._reason_description is not None: + return False + + if self._share is not None: + return False + + if self._all_auto_save_id is not None: + return False + + if self._fulfillments is not None: + return False + + if self._relation_user is not None: + return False + + if self._all_co_owner is not None: + return False + + if self._co_owner_invite is not None: + return False + + if self._open_banking_account is not None: + return False + + if self._birdee_investment_portfolio is not None: + return False + + if self._all_access is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MonetaryAccountSwitchServiceApiObject + """ + + return converter.json_to_class(MonetaryAccountSwitchServiceApiObject, json_str) + + +class NoteAttachmentAdyenCardTransactionApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,adyen_card_transaction_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, adyen_card_transaction_id, note_attachment_adyen_card_transaction_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_attachment_adyen_card_transaction_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_attachment_adyen_card_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, adyen_card_transaction_id, note_attachment_adyen_card_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_attachment_adyen_card_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_attachment_adyen_card_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,adyen_card_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentAdyenCardTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentAdyenCardTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, adyen_card_transaction_id, note_attachment_adyen_card_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_attachment_adyen_card_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentAdyenCardTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_attachment_adyen_card_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentAdyenCardTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentAdyenCardTransactionApiObject + """ + + return converter.json_to_class(NoteAttachmentAdyenCardTransactionApiObject, json_str) + + +class NoteTextAdyenCardTransactionApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/adyen-card-transaction/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,adyen_card_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, adyen_card_transaction_id, note_text_adyen_card_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_text_adyen_card_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_text_adyen_card_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, adyen_card_transaction_id, note_text_adyen_card_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_text_adyen_card_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_text_adyen_card_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,adyen_card_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextAdyenCardTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextAdyenCardTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, adyen_card_transaction_id, note_text_adyen_card_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type adyen_card_transaction_id: int + :type note_text_adyen_card_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextAdyenCardTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), adyen_card_transaction_id, note_text_adyen_card_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextAdyenCardTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextAdyenCardTransactionApiObject + """ + + return converter.json_to_class(NoteTextAdyenCardTransactionApiObject, json_str) + + +class NoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/switch-service-payment/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,switch_service_payment_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type + note_attachment_bank_switch_service_netherlands_incoming_payment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type + note_attachment_bank_switch_service_netherlands_incoming_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,switch_service_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: + BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type + note_attachment_bank_switch_service_netherlands_incoming_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: + BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_attachment_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: + NoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentApiObject + """ + + return converter.json_to_class(NoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentApiObject, json_str) + + +class NoteTextBankSwitchServiceNetherlandsIncomingPaymentApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/switch-service-payment/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,switch_service_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type note_text_bank_switch_service_netherlands_incoming_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type note_text_bank_switch_service_netherlands_incoming_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,switch_service_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: + BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type switch_service_payment_id: int + :type note_text_bank_switch_service_netherlands_incoming_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), switch_service_payment_id, note_text_bank_switch_service_netherlands_incoming_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextBankSwitchServiceNetherlandsIncomingPaymentApiObject + """ + + return converter.json_to_class(NoteTextBankSwitchServiceNetherlandsIncomingPaymentApiObject, json_str) + + +class NoteAttachmentBunqMeFundraiserResultApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,bunqme_fundraiser_result_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_attachment_bunq_me_fundraiser_result_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_attachment_bunq_me_fundraiser_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,bunqme_fundraiser_result_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentBunqMeFundraiserResultList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentBunqMeFundraiserResultList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_attachment_bunq_me_fundraiser_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentBunqMeFundraiserResult + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_attachment_bunq_me_fundraiser_result_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentBunqMeFundraiserResult.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentBunqMeFundraiserResultApiObject + """ + + return converter.json_to_class(NoteAttachmentBunqMeFundraiserResultApiObject, json_str) + + +class NoteTextBunqMeFundraiserResultApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/bunqme-fundraiser-result/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,bunqme_fundraiser_result_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_text_bunq_me_fundraiser_result_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_text_bunq_me_fundraiser_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,bunqme_fundraiser_result_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextBunqMeFundraiserResultList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextBunqMeFundraiserResultList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type bunqme_fundraiser_result_id: int + :type note_text_bunq_me_fundraiser_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextBunqMeFundraiserResult + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), bunqme_fundraiser_result_id, note_text_bunq_me_fundraiser_result_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextBunqMeFundraiserResult.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextBunqMeFundraiserResultApiObject + """ + + return converter.json_to_class(NoteTextBunqMeFundraiserResultApiObject, json_str) + + +class NoteAttachmentDraftPaymentApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,draft_payment_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, draft_payment_id, note_attachment_draft_payment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_attachment_draft_payment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_attachment_draft_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, draft_payment_id, note_attachment_draft_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_attachment_draft_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_attachment_draft_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,draft_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentDraftPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentDraftPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, draft_payment_id, note_attachment_draft_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_attachment_draft_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentDraftPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_attachment_draft_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentDraftPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentDraftPaymentApiObject + """ + + return converter.json_to_class(NoteAttachmentDraftPaymentApiObject, json_str) + + +class NoteTextDraftPaymentApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/draft-payment/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/draft-payment/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/draft-payment/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,draft_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, draft_payment_id, note_text_draft_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_text_draft_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_text_draft_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, draft_payment_id, note_text_draft_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_text_draft_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_text_draft_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,draft_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextDraftPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextDraftPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, draft_payment_id, note_text_draft_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type draft_payment_id: int + :type note_text_draft_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextDraftPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), draft_payment_id, note_text_draft_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextDraftPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextDraftPaymentApiObject + """ + + return converter.json_to_class(NoteTextDraftPaymentApiObject, json_str) + + +class NoteAttachmentIdealMerchantTransactionApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,ideal_merchant_transaction_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_attachment_ideal_merchant_transaction_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_attachment_ideal_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,ideal_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentIdealMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentIdealMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_attachment_ideal_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentIdealMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_attachment_ideal_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentIdealMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentIdealMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteAttachmentIdealMerchantTransactionApiObject, json_str) + + +class NoteTextIdealMerchantTransactionApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/ideal-merchant-transaction/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,ideal_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_text_ideal_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_text_ideal_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,ideal_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextIdealMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextIdealMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type ideal_merchant_transaction_id: int + :type note_text_ideal_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextIdealMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), ideal_merchant_transaction_id, note_text_ideal_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextIdealMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextIdealMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteTextIdealMerchantTransactionApiObject, json_str) + + +class NoteAttachmentMasterCardActionApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param description: Optional description of the attachment. + :type description: str + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + """ + + self._description_field_for_request = description + self._attachment_id_field_for_request = attachment_id + + @classmethod + def create(cls,mastercard_action_id, description, attachment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :param description: Optional description of the attachment. + :type description: str + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, mastercard_action_id, note_attachment_master_card_action_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_attachment_master_card_action_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_attachment_master_card_action_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, mastercard_action_id, note_attachment_master_card_action_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_attachment_master_card_action_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_attachment_master_card_action_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,mastercard_action_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentMasterCardActionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentMasterCardActionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, mastercard_action_id, note_attachment_master_card_action_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_attachment_master_card_action_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentMasterCardAction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_attachment_master_card_action_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentMasterCardAction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentMasterCardActionApiObject + """ + + return converter.json_to_class(NoteAttachmentMasterCardActionApiObject, json_str) + + +class NoteTextMasterCardActionApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/mastercard-action/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,mastercard_action_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, mastercard_action_id, note_text_master_card_action_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_text_master_card_action_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_text_master_card_action_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, mastercard_action_id, note_text_master_card_action_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_text_master_card_action_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_text_master_card_action_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,mastercard_action_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextMasterCardActionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextMasterCardActionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, mastercard_action_id, note_text_master_card_action_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type note_text_master_card_action_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextMasterCardAction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id, note_text_master_card_action_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextMasterCardAction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextMasterCardActionApiObject + """ + + return converter.json_to_class(NoteTextMasterCardActionApiObject, json_str) + + +class NoteAttachmentOpenBankingMerchantTransactionApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,open_banking_merchant_transaction_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_attachment_open_banking_merchant_transaction_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_attachment_open_banking_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,open_banking_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentOpenBankingMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentOpenBankingMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_attachment_open_banking_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentOpenBankingMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_attachment_open_banking_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentOpenBankingMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentOpenBankingMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteAttachmentOpenBankingMerchantTransactionApiObject, json_str) + + +class NoteTextOpenBankingMerchantTransactionApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/open-banking-merchant-transaction/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,open_banking_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_text_open_banking_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_text_open_banking_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,open_banking_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextOpenBankingMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextOpenBankingMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type open_banking_merchant_transaction_id: int + :type note_text_open_banking_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextOpenBankingMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), open_banking_merchant_transaction_id, note_text_open_banking_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextOpenBankingMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextOpenBankingMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteTextOpenBankingMerchantTransactionApiObject, json_str) + + +class NoteAttachmentPaymentBatchApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,payment_batch_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_batch_id, note_attachment_payment_batch_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_attachment_payment_batch_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_attachment_payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_batch_id, note_attachment_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_attachment_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_attachment_payment_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPaymentBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentPaymentBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_batch_id, note_attachment_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_attachment_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPaymentBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_attachment_payment_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentPaymentBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentPaymentBatchApiObject + """ + + return converter.json_to_class(NoteAttachmentPaymentBatchApiObject, json_str) + + +class NoteTextPaymentBatchApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-batch/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-batch/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-batch/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,payment_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_batch_id, note_text_payment_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_text_payment_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_text_payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_batch_id, note_text_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_text_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_text_payment_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPaymentBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextPaymentBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_batch_id, note_text_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_batch_id: int + :type note_text_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPaymentBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_batch_id, note_text_payment_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextPaymentBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextPaymentBatchApiObject + """ + + return converter.json_to_class(NoteTextPaymentBatchApiObject, json_str) + + +class NoteAttachmentPaymentDelayedApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-delayed/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-delayed/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-delayed/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-delayed/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-delayed/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,payment_delayed_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_delayed_id, note_attachment_payment_delayed_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_attachment_payment_delayed_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_attachment_payment_delayed_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_delayed_id, note_attachment_payment_delayed_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_attachment_payment_delayed_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_attachment_payment_delayed_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_delayed_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPaymentDelayedList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentPaymentDelayedList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_delayed_id, note_attachment_payment_delayed_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_attachment_payment_delayed_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPaymentDelayed + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_attachment_payment_delayed_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentPaymentDelayed.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentPaymentDelayedApiObject + """ + + return converter.json_to_class(NoteAttachmentPaymentDelayedApiObject, json_str) + + +class NoteTextPaymentDelayedApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-delayed/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-delayed/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-delayed/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-delayed/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-delayed/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,payment_delayed_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_delayed_id, note_text_payment_delayed_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_text_payment_delayed_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_text_payment_delayed_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_delayed_id, note_text_payment_delayed_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_text_payment_delayed_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_text_payment_delayed_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_delayed_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPaymentDelayedList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextPaymentDelayedList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_delayed_id, note_text_payment_delayed_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_delayed_id: int + :type note_text_payment_delayed_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPaymentDelayed + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_delayed_id, note_text_payment_delayed_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextPaymentDelayed.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextPaymentDelayedApiObject + """ + + return converter.json_to_class(NoteTextPaymentDelayedApiObject, json_str) + + +class NoteAttachmentPaymentApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,payment_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_id, note_attachment_payment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_attachment_payment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_attachment_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_id, note_attachment_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_attachment_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_attachment_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_id, note_attachment_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_attachment_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_attachment_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentPaymentApiObject + """ + + return converter.json_to_class(NoteAttachmentPaymentApiObject, json_str) + + +class NoteTextPaymentApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_id, note_text_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_text_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_text_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_id, note_text_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_text_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_text_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_id, note_text_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_id: int + :type note_text_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_id, note_text_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextPaymentApiObject + """ + + return converter.json_to_class(NoteTextPaymentApiObject, json_str) + + +class NoteAttachmentRequestInquiryBatchApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,request_inquiry_batch_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_inquiry_batch_id, note_attachment_request_inquiry_batch_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_attachment_request_inquiry_batch_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_attachment_request_inquiry_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_inquiry_batch_id, note_attachment_request_inquiry_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_attachment_request_inquiry_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_attachment_request_inquiry_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_inquiry_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestInquiryBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentRequestInquiryBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_inquiry_batch_id, note_attachment_request_inquiry_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_attachment_request_inquiry_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestInquiryBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_attachment_request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentRequestInquiryBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentRequestInquiryBatchApiObject + """ + + return converter.json_to_class(NoteAttachmentRequestInquiryBatchApiObject, json_str) + + +class NoteTextRequestInquiryBatchApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry-batch/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,request_inquiry_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_inquiry_batch_id, note_text_request_inquiry_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_text_request_inquiry_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_text_request_inquiry_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_inquiry_batch_id, note_text_request_inquiry_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_text_request_inquiry_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_text_request_inquiry_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_inquiry_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestInquiryBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextRequestInquiryBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_inquiry_batch_id, note_text_request_inquiry_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_batch_id: int + :type note_text_request_inquiry_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestInquiryBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_batch_id, note_text_request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextRequestInquiryBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextRequestInquiryBatchApiObject + """ + + return converter.json_to_class(NoteTextRequestInquiryBatchApiObject, json_str) + + +class NoteAttachmentRequestInquiryApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,request_inquiry_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_inquiry_id, note_attachment_request_inquiry_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_attachment_request_inquiry_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_attachment_request_inquiry_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_inquiry_id, note_attachment_request_inquiry_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_attachment_request_inquiry_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_attachment_request_inquiry_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_inquiry_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestInquiryList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentRequestInquiryList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_inquiry_id, note_attachment_request_inquiry_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_attachment_request_inquiry_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestInquiry + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_attachment_request_inquiry_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentRequestInquiry.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentRequestInquiryApiObject + """ + + return converter.json_to_class(NoteAttachmentRequestInquiryApiObject, json_str) + + +class NoteTextRequestInquiryApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-inquiry/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-inquiry/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,request_inquiry_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_inquiry_id, note_text_request_inquiry_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_text_request_inquiry_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_text_request_inquiry_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_inquiry_id, note_text_request_inquiry_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_text_request_inquiry_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_text_request_inquiry_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_inquiry_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestInquiryList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextRequestInquiryList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_inquiry_id, note_text_request_inquiry_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_inquiry_id: int + :type note_text_request_inquiry_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestInquiry + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_inquiry_id, note_text_request_inquiry_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextRequestInquiry.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextRequestInquiryApiObject + """ + + return converter.json_to_class(NoteTextRequestInquiryApiObject, json_str) + + +class NoteAttachmentRequestResponseApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-response/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,request_response_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_response_id, note_attachment_request_response_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_attachment_request_response_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_attachment_request_response_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_response_id, note_attachment_request_response_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_attachment_request_response_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_attachment_request_response_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_response_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestResponseList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentRequestResponseList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_response_id, note_attachment_request_response_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_attachment_request_response_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentRequestResponse + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_attachment_request_response_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentRequestResponse.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentRequestResponseApiObject + """ + + return converter.json_to_class(NoteAttachmentRequestResponseApiObject, json_str) + + +class NoteTextRequestResponseApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/request-response/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/request-response/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/request-response/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,request_response_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, request_response_id, note_text_request_response_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_text_request_response_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_text_request_response_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, request_response_id, note_text_request_response_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_text_request_response_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_text_request_response_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,request_response_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestResponseList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextRequestResponseList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, request_response_id, note_text_request_response_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type request_response_id: int + :type note_text_request_response_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextRequestResponse + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), request_response_id, note_text_request_response_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextRequestResponse.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextRequestResponseApiObject + """ + + return converter.json_to_class(NoteTextRequestResponseApiObject, json_str) + + +class NoteAttachmentScheduleInstanceApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,schedule_id, schedule_instance_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_id, schedule_instance_id, note_attachment_schedule_instance_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_attachment_schedule_instance_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_attachment_schedule_instance_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_id, schedule_instance_id, note_attachment_schedule_instance_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_attachment_schedule_instance_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_attachment_schedule_instance_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_id, schedule_instance_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleInstanceList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentScheduleInstanceList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_id, schedule_instance_id, note_attachment_schedule_instance_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_attachment_schedule_instance_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleInstance + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_attachment_schedule_instance_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentScheduleInstance.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentScheduleInstanceApiObject + """ + + return converter.json_to_class(NoteAttachmentScheduleInstanceApiObject, json_str) + + +class NoteTextScheduleInstanceApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule/{}/schedule-instance/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,schedule_id, schedule_instance_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_id, schedule_instance_id, note_text_schedule_instance_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_text_schedule_instance_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_text_schedule_instance_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_id, schedule_instance_id, note_text_schedule_instance_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_text_schedule_instance_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_text_schedule_instance_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_id, schedule_instance_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleInstanceList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextScheduleInstanceList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_id, schedule_instance_id, note_text_schedule_instance_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_id: int + :type schedule_instance_id: int + :type note_text_schedule_instance_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleInstance + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_id, schedule_instance_id, note_text_schedule_instance_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextScheduleInstance.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextScheduleInstanceApiObject + """ + + return converter.json_to_class(NoteTextScheduleInstanceApiObject, json_str) + + +class NoteAttachmentSchedulePaymentBatchApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,schedule_payment_batch_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_payment_batch_id, note_attachment_schedule_payment_batch_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_attachment_schedule_payment_batch_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_attachment_schedule_payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_payment_batch_id, note_attachment_schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_attachment_schedule_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_attachment_schedule_payment_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_payment_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSchedulePaymentBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentSchedulePaymentBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_payment_batch_id, note_attachment_schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_attachment_schedule_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSchedulePaymentBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_attachment_schedule_payment_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentSchedulePaymentBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentSchedulePaymentBatchApiObject + """ + + return converter.json_to_class(NoteAttachmentSchedulePaymentBatchApiObject, json_str) + + +class NoteTextSchedulePaymentBatchApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment-batch/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,schedule_payment_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_payment_batch_id, note_text_schedule_payment_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_text_schedule_payment_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_text_schedule_payment_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_payment_batch_id, note_text_schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_text_schedule_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_text_schedule_payment_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_payment_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSchedulePaymentBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextSchedulePaymentBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_payment_batch_id, note_text_schedule_payment_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_batch_id: int + :type note_text_schedule_payment_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSchedulePaymentBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_batch_id, note_text_schedule_payment_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextSchedulePaymentBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextSchedulePaymentBatchApiObject + """ + + return converter.json_to_class(NoteTextSchedulePaymentBatchApiObject, json_str) + + +class NoteAttachmentSchedulePaymentApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,schedule_payment_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_payment_id, note_attachment_schedule_payment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_attachment_schedule_payment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_attachment_schedule_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_payment_id, note_attachment_schedule_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_attachment_schedule_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_attachment_schedule_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSchedulePaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentSchedulePaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_payment_id, note_attachment_schedule_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_attachment_schedule_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSchedulePayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_attachment_schedule_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentSchedulePayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentSchedulePaymentApiObject + """ + + return converter.json_to_class(NoteAttachmentSchedulePaymentApiObject, json_str) + + +class NoteTextSchedulePaymentApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-payment/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-payment/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,schedule_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_payment_id, note_text_schedule_payment_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_text_schedule_payment_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_text_schedule_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_payment_id, note_text_schedule_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_text_schedule_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_text_schedule_payment_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_payment_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSchedulePaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextSchedulePaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_payment_id, note_text_schedule_payment_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_payment_id: int + :type note_text_schedule_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSchedulePayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_payment_id, note_text_schedule_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextSchedulePayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextSchedulePaymentApiObject + """ + + return converter.json_to_class(NoteTextSchedulePaymentApiObject, json_str) + + +class NoteAttachmentScheduleRequestBatchApiObject(BunqModel): + """ + Used to manage attachment notes for a scheduled request. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,schedule_request_inquiry_batch_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_attachment_schedule_request_batch_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_attachment_schedule_request_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_request_inquiry_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a scheduled request. + + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleRequestBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentScheduleRequestBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_attachment_schedule_request_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleRequestBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_attachment_schedule_request_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentScheduleRequestBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentScheduleRequestBatchApiObject + """ + + return converter.json_to_class(NoteAttachmentScheduleRequestBatchApiObject, json_str) + + +class NoteTextScheduleRequestBatchApiObject(BunqModel): + """ + Used to manage text notes for a scheduled request. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-request-inquiry-batch/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,schedule_request_inquiry_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_text_schedule_request_batch_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_text_schedule_request_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_request_inquiry_batch_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given schedule request. + + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleRequestBatchList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextScheduleRequestBatchList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_batch_id: int + :type note_text_schedule_request_batch_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleRequestBatch + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_batch_id, note_text_schedule_request_batch_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextScheduleRequestBatch.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextScheduleRequestBatchApiObject + """ + + return converter.json_to_class(NoteTextScheduleRequestBatchApiObject, json_str) + + +class NoteAttachmentScheduleRequestApiObject(BunqModel): + """ + Used to manage attachment notes for a scheduled request. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,schedule_request_inquiry_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_request_inquiry_id, note_attachment_schedule_request_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_attachment_schedule_request_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_attachment_schedule_request_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_request_inquiry_id, note_attachment_schedule_request_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_attachment_schedule_request_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_attachment_schedule_request_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_request_inquiry_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a scheduled request. + + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleRequestList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentScheduleRequestList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_request_inquiry_id, note_attachment_schedule_request_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_attachment_schedule_request_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentScheduleRequest + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_attachment_schedule_request_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentScheduleRequest.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentScheduleRequestApiObject + """ + + return converter.json_to_class(NoteAttachmentScheduleRequestApiObject, json_str) + + +class NoteTextScheduleRequestApiObject(BunqModel): + """ + Used to manage text notes for a scheduled request. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/schedule-request-inquiry/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,schedule_request_inquiry_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, schedule_request_inquiry_id, note_text_schedule_request_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_text_schedule_request_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_text_schedule_request_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, schedule_request_inquiry_id, note_text_schedule_request_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_text_schedule_request_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_text_schedule_request_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,schedule_request_inquiry_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given schedule request. + + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleRequestList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextScheduleRequestList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, schedule_request_inquiry_id, note_text_schedule_request_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type schedule_request_inquiry_id: int + :type note_text_schedule_request_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextScheduleRequest + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), schedule_request_inquiry_id, note_text_schedule_request_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextScheduleRequest.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextScheduleRequestApiObject + """ + + return converter.json_to_class(NoteTextScheduleRequestApiObject, json_str) + + +class NoteAttachmentSofortMerchantTransactionApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,sofort_merchant_transaction_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_attachment_sofort_merchant_transaction_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_attachment_sofort_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,sofort_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSofortMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentSofortMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_attachment_sofort_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentSofortMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_attachment_sofort_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentSofortMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentSofortMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteAttachmentSofortMerchantTransactionApiObject, json_str) + + +class NoteTextSofortMerchantTransactionApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/sofort-merchant-transaction/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,sofort_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_text_sofort_merchant_transaction_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_text_sofort_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,sofort_merchant_transaction_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSofortMerchantTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextSofortMerchantTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type sofort_merchant_transaction_id: int + :type note_text_sofort_merchant_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextSofortMerchantTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), sofort_merchant_transaction_id, note_text_sofort_merchant_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextSofortMerchantTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextSofortMerchantTransactionApiObject + """ + + return converter.json_to_class(NoteTextSofortMerchantTransactionApiObject, json_str) + + +class NoteAttachmentWhitelistResultApiObject(BunqModel): + """ + Used to manage attachment notes. + + :param _description: Optional description of the attachment. + :type _description: str + :param _attachment_id: The reference to the uploaded file to attach to this + note. + :type _attachment_id: int + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + :param _attachment: The attachment attached to the note. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-attachment/{}" + + # Field constants. + FIELD_DESCRIPTION = "description" + FIELD_ATTACHMENT_ID = "attachment_id" + + # Object type. + _OBJECT_TYPE_GET = "NoteAttachment" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _description = None + _attachment = None + _description_field_for_request = None + _attachment_id_field_for_request = None + + def __init__(self, attachment_id, description=None): + """ + :param attachment_id: The reference to the uploaded file to attach to this + note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + """ + + self._attachment_id_field_for_request = attachment_id + self._description_field_for_request = description + + @classmethod + def create(cls,whitelist_id, whitelist_result_id, attachment_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :param attachment_id: The reference to the uploaded file to attach to + this note. + :type attachment_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_DESCRIPTION : description, +cls.FIELD_ATTACHMENT_ID : attachment_id +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id, monetary_account_id=None, description=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_attachment_whitelist_result_id: int + :param description: Optional description of the attachment. + :type description: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DESCRIPTION : description +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_attachment_whitelist_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,whitelist_id, whitelist_result_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentWhitelistResultList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteAttachmentWhitelistResultList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_attachment_whitelist_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteAttachmentWhitelistResult + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_attachment_whitelist_result_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteAttachmentWhitelistResult.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteAttachmentWhitelistResultApiObject + """ + + return converter.json_to_class(NoteAttachmentWhitelistResultApiObject, json_str) + + +class NoteTextWhitelistResultApiObject(BunqModel): + """ + Used to manage text notes. + + :param _content: The content of the note. + :type _content: str + :param _id_: The id of the note. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _label_user_creator: The label of the user who created this note. + :type _label_user_creator: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/whitelist/{}/whitelist-result/{}/note-text/{}" + + # Field constants. + FIELD_CONTENT = "content" + + # Object type. + _OBJECT_TYPE_GET = "NoteText" + + _id_ = None + _created = None + _updated = None + _label_user_creator = None + _content = None + _content_field_for_request = None + + def __init__(self, content=None): + """ + :param content: The content of the note. + :type content: str + """ + + self._content_field_for_request = content + + @classmethod + def create(cls,whitelist_id, whitelist_result_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, whitelist_id, whitelist_result_id, note_text_whitelist_result_id, monetary_account_id=None, content=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_text_whitelist_result_id: int + :param content: The content of the note. + :type content: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_CONTENT : content +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_text_whitelist_result_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, whitelist_id, whitelist_result_id, note_text_whitelist_result_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_text_whitelist_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_text_whitelist_result_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls,whitelist_id, whitelist_result_id, monetary_account_id=None, params=None, custom_headers=None): + """ + Manage the notes for a given user. + + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextWhitelistResultList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNoteTextWhitelistResultList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, whitelist_id, whitelist_result_id, note_text_whitelist_result_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type whitelist_id: int + :type whitelist_result_id: int + :type note_text_whitelist_result_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNoteTextWhitelistResult + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_id, whitelist_result_id, note_text_whitelist_result_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseNoteTextWhitelistResult.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def label_user_creator(self): + """ + :rtype: object_.LabelUser + """ + + return self._label_user_creator + + @property + def content(self): + """ + :rtype: str + """ + + return self._content + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._label_user_creator is not None: + return False + + if self._content is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NoteTextWhitelistResultApiObject + """ + + return converter.json_to_class(NoteTextWhitelistResultApiObject, json_str) + + +class NotificationFilterEmailApiObject(BunqModel): + """ + Manage the email notification filters for a user. + + :param _notification_filters: The types of notifications that will result in + a email notification for this user. + :type _notification_filters: list[object_.NotificationFilterEmail] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/notification-filter-email" + _ENDPOINT_URL_LISTING = "user/{}/notification-filter-email" + + # Field constants. + FIELD_NOTIFICATION_FILTERS = "notification_filters" + + # Object type. + _OBJECT_TYPE_POST = "NotificationFilterEmail" + _OBJECT_TYPE_GET = "NotificationFilterEmail" + + _notification_filters = None + _notification_filters_field_for_request = None + + def __init__(self, notification_filters=None): + """ + :param notification_filters: The types of notifications that will result in + a email notification for this user. + :type notification_filters: list[object_.NotificationFilterEmail] + """ + + self._notification_filters_field_for_request = notification_filters + + @classmethod + def create(cls,notification_filters=None, custom_headers=None): + """ + :type user_id: int + :param notification_filters: The types of notifications that will result + in a email notification for this user. + :type notification_filters: list[object_.NotificationFilterEmail] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterEmail + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_NOTIFICATION_FILTERS : notification_filters +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseNotificationFilterEmail.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterEmailList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNotificationFilterEmailList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilterEmail] + """ + + return self._notification_filters + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._notification_filters is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterEmailApiObject + """ + + return converter.json_to_class(NotificationFilterEmailApiObject, json_str) + + +class NotificationFilterFailureApiObject(BunqModel): + """ + Manage the url notification filters for a user. + + :param _notification_filter_failed_ids: The IDs to retry. + :type _notification_filter_failed_ids: str + :param _notification_filters: The types of notifications that will result in + a url notification for this user. + :type _notification_filters: list[object_.NotificationFilter] + :param _category: The category of the failed notification. + :type _category: str + :param _event_type: The event type of the failed notification. + :type _event_type: str + :param _object_id: The object id used to generate the body of the + notification. + :type _object_id: int + :param _exception_message: The exception bunq encountered when processing + the callback. + :type _exception_message: str + :param _response_code: The response code (or null) received from the + endpoint. + :type _response_code: int + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/notification-filter-failure" + _ENDPOINT_URL_LISTING = "user/{}/notification-filter-failure" + + # Field constants. + FIELD_NOTIFICATION_FILTER_FAILED_IDS = "notification_filter_failed_ids" + + # Object type. + _OBJECT_TYPE_GET = "NotificationFilterFailure" + + _notification_filters = None + _category = None + _event_type = None + _object_id = None + _exception_message = None + _response_code = None + _notification_filter_failed_ids_field_for_request = None + + def __init__(self, notification_filter_failed_ids): + """ + :param notification_filter_failed_ids: The IDs to retry. + :type notification_filter_failed_ids: str + """ + + self._notification_filter_failed_ids_field_for_request = notification_filter_failed_ids + + @classmethod + def create(cls,notification_filter_failed_ids, custom_headers=None): + """ + :type user_id: int + :param notification_filter_failed_ids: The IDs to retry. + :type notification_filter_failed_ids: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_NOTIFICATION_FILTER_FAILED_IDS : notification_filter_failed_ids +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterFailureList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNotificationFilterFailureList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilter] + """ + + return self._notification_filters + + @property + def category(self): + """ + :rtype: str + """ + + return self._category + + @property + def event_type(self): + """ + :rtype: str + """ + + return self._event_type + + @property + def object_id(self): + """ + :rtype: int + """ + + return self._object_id + + @property + def exception_message(self): + """ + :rtype: str + """ + + return self._exception_message + + @property + def response_code(self): + """ + :rtype: int + """ + + return self._response_code + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._notification_filters is not None: + return False + + if self._category is not None: + return False + + if self._event_type is not None: + return False + + if self._object_id is not None: + return False + + if self._exception_message is not None: + return False + + if self._response_code is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterFailureApiObject + """ + + return converter.json_to_class(NotificationFilterFailureApiObject, json_str) + + +class NotificationFilterPushApiObject(BunqModel): + """ + Manage the push notification filters for a user. + + :param _notification_filters: The types of notifications that will result in + a push notification for this user. + :type _notification_filters: list[object_.NotificationFilterPush] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/notification-filter-push" + _ENDPOINT_URL_LISTING = "user/{}/notification-filter-push" + + # Field constants. + FIELD_NOTIFICATION_FILTERS = "notification_filters" + + # Object type. + _OBJECT_TYPE_POST = "NotificationFilterPush" + _OBJECT_TYPE_GET = "NotificationFilterPush" + + _notification_filters = None + _notification_filters_field_for_request = None + + def __init__(self, notification_filters=None): + """ + :param notification_filters: The types of notifications that will result in + a push notification for this user. + :type notification_filters: list[object_.NotificationFilterPush] + """ + + self._notification_filters_field_for_request = notification_filters + + @classmethod + def create(cls,notification_filters=None, custom_headers=None): + """ + :type user_id: int + :param notification_filters: The types of notifications that will result + in a push notification for this user. + :type notification_filters: list[object_.NotificationFilterPush] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterPush + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_NOTIFICATION_FILTERS : notification_filters +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseNotificationFilterPush.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterPushList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNotificationFilterPushList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilterPush] + """ + + return self._notification_filters + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._notification_filters is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterPushApiObject + """ + + return converter.json_to_class(NotificationFilterPushApiObject, json_str) + + +class NotificationFilterUrlApiObject(BunqModel): + """ + Manage the url notification filters for a user. + + :param _notification_filters: The types of notifications that will result in + a url notification for this user. + :type _notification_filters: list[object_.NotificationFilterUrl] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/notification-filter-url" + _ENDPOINT_URL_LISTING = "user/{}/notification-filter-url" + + # Field constants. + FIELD_NOTIFICATION_FILTERS = "notification_filters" + + # Object type. + _OBJECT_TYPE_GET = "NotificationFilterUrl" + + _notification_filters = None + _notification_filters_field_for_request = None + + def __init__(self, notification_filters=None): + """ + :param notification_filters: The types of notifications that will result in + a url notification for this user. + :type notification_filters: list[object_.NotificationFilterUrl] + """ + + self._notification_filters_field_for_request = notification_filters + + @classmethod + def create(cls,notification_filters=None, custom_headers=None): + """ + :type user_id: int + :param notification_filters: The types of notifications that will result + in a url notification for this user. + :type notification_filters: list[object_.NotificationFilterUrl] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_NOTIFICATION_FILTERS : notification_filters +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterUrlList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNotificationFilterUrlList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilterUrl] + """ + + return self._notification_filters + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._notification_filters is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterUrlApiObject + """ + + return converter.json_to_class(NotificationFilterUrlApiObject, json_str) + + +class NotificationFilterUrlMonetaryAccountApiObject(BunqModel): + """ + Manage the url notification filters for a user. + + :param _notification_filters: The types of notifications that will result in + a url notification for this monetary account. + :type _notification_filters: list[object_.NotificationFilterUrl] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/notification-filter-url" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/notification-filter-url" + + # Field constants. + FIELD_NOTIFICATION_FILTERS = "notification_filters" + + # Object type. + _OBJECT_TYPE_GET = "NotificationFilterUrl" + + _notification_filters = None + _notification_filters_field_for_request = None + + def __init__(self, notification_filters=None): + """ + :param notification_filters: The types of notifications that will result in + a url notification for this monetary account. + :type notification_filters: list[object_.NotificationFilterUrl] + """ + + self._notification_filters_field_for_request = notification_filters + + @classmethod + def create(cls,monetary_account_id=None, notification_filters=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :param notification_filters: The types of notifications that will result + in a url notification for this monetary account. + :type notification_filters: list[object_.NotificationFilterUrl] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_NOTIFICATION_FILTERS : notification_filters +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls,monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNotificationFilterUrlMonetaryAccountList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseNotificationFilterUrlMonetaryAccountList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilterUrl] + """ + + return self._notification_filters + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._notification_filters is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterUrlMonetaryAccountApiObject + """ + + return converter.json_to_class(NotificationFilterUrlMonetaryAccountApiObject, json_str) + + +class ChatMessageApiObject(BunqModel): + """ + Endpoint for retrieving the messages that are part of a conversation. + """ + + + def is_all_field_none(self): + """ + :rtype: bool + """ + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ChatMessageApiObject + """ + + return converter.json_to_class(ChatMessageApiObject, json_str) + + +class UserApiObject(BunqModel, AnchorObjectInterface): + """ + Using this call you can retrieve information of the user you are logged in + as. This includes your user id, which is referred to in endpoints. + + :param _UserPerson: + :type _UserPerson: UserPerson + :param _UserCompany: + :type _UserCompany: UserCompany + :param _UserApiKey: + :type _UserApiKey: UserApiKey + :param _UserPaymentServiceProvider: + :type _UserPaymentServiceProvider: UserPaymentServiceProvider + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}" + _ENDPOINT_URL_LISTING = "user" + + # Object type. + _OBJECT_TYPE_GET = "User" + + _UserPerson = None + _UserCompany = None + _UserApiKey = None + _UserPaymentServiceProvider = None + + @classmethod + def get(cls, custom_headers=None): + """ + Get a specific user. + + :type api_context: ApiContext + :type user_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUser + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseUser.cast_from_bunq_response( + cls._from_json(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Get a collection of all available users. + + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUserList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseUserList.cast_from_bunq_response( + cls._from_json_list(response_raw) + ) + + @property + def UserPerson(self): + """ + :rtype: UserPerson + """ + + return self._UserPerson + + @property + def UserCompany(self): + """ + :rtype: UserCompany + """ + + return self._UserCompany + + @property + def UserApiKey(self): + """ + :rtype: UserApiKey + """ + + return self._UserApiKey + + @property + def UserPaymentServiceProvider(self): + """ + :rtype: UserPaymentServiceProvider + """ + + return self._UserPaymentServiceProvider + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._UserPerson is not None: + return self._UserPerson + + if self._UserCompany is not None: + return self._UserCompany + + if self._UserApiKey is not None: + return self._UserApiKey + + if self._UserPaymentServiceProvider is not None: + return self._UserPaymentServiceProvider + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._UserPerson is not None: + return False + + if self._UserCompany is not None: + return False + + if self._UserApiKey is not None: + return False + + if self._UserPaymentServiceProvider is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: UserApiObject + """ + + return converter.json_to_class(UserApiObject, json_str) + + +class UserPersonApiObject(BunqModel): + """ + With UserPerson you can retrieve information regarding the authenticated + UserPerson and update specific fields.

Notification filters can be + set on a UserPerson level to receive callbacks. For more information check + the dedicated callbacks page. + + :param _subscription_type: The subscription type the user should start on. + :type _subscription_type: str + :param _first_name: The person's first name. + :type _first_name: str + :param _middle_name: The person's middle name. + :type _middle_name: str + :param _last_name: The person's last name. + :type _last_name: str + :param _public_nick_name: The public nick name for the person. + :type _public_nick_name: str + :param _address_main: The person's main address. + :type _address_main: object_.Address + :param _address_postal: The person's postal address. + :type _address_postal: object_.Address + :param _avatar_uuid: The public UUID of the user's avatar. + :type _avatar_uuid: str + :param _tax_resident: The user's tax residence numbers for different + countries. + :type _tax_resident: list[object_.TaxResident] + :param _document_type: The type of identification document the person + registered with. + :type _document_type: str + :param _document_number: The identification document number the person + registered with. + :type _document_number: str + :param _document_country_of_issuance: The country which issued the + identification document the person registered with. + :type _document_country_of_issuance: str + :param _document_front_attachment_id: The reference to the uploaded + picture/scan of the front side of the identification document. + :type _document_front_attachment_id: int + :param _document_back_attachment_id: The reference to the uploaded + picture/scan of the back side of the identification document. + :type _document_back_attachment_id: int + :param _date_of_birth: The person's date of birth. Accepts ISO8601 date + formats. + :type _date_of_birth: str + :param _nationality: The person's nationality. Formatted as a SO 3166-1 + alpha-2 country code. + :type _nationality: str + :param _all_nationality: All of the person's nationalities. + :type _all_nationality: list[str] + :param _language: The person's preferred language. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type _language: str + :param _region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type _region: str + :param _gender: The person's gender. Can be MALE, FEMALE or UNKNOWN. + :type _gender: str + :param _status: The user status. The user status. Can be: ACTIVE, BLOCKED, + SIGNUP, RECOVERY, DENIED or ABORTED. + :type _status: str + :param _sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, + APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or + SUBMIT. + :type _sub_status: str + :param _legal_guardian_alias: The legal guardian of the user. Required for + minors. + :type _legal_guardian_alias: object_.Pointer + :param _session_timeout: The setting for the session timeout of the user in + seconds. + :type _session_timeout: int + :param _daily_limit_without_confirmation_login: The amount the user can pay + in the session without asking for credentials. + :type _daily_limit_without_confirmation_login: object_.Amount + :param _display_name: The display name for the person. + :type _display_name: str + :param _signup_track_type: The type of signup track the user is following. + :type _signup_track_type: str + :param _id_: The id of the modified person object. + :type _id_: int + :param _created: The timestamp of the person object's creation. + :type _created: str + :param _updated: The timestamp of the person object's last update. + :type _updated: str + :param _public_uuid: The person's public UUID. + :type _public_uuid: str + :param _legal_name: The person's legal name. + :type _legal_name: str + :param _alias: The aliases of the user. + :type _alias: list[object_.Pointer] + :param _address_shipping: The person's shipping address. + :type _address_shipping: object_.Address + :param _place_of_birth: The person's place of birth. + :type _place_of_birth: str + :param _country_of_birth: The person's country of birth. Formatted as a SO + 3166-1 alpha-2 country code. + :type _country_of_birth: str + :param _avatar: The user's avatar. + :type _avatar: object_.Avatar + :param _version_terms_of_service: The version of the terms of service + accepted by the user. + :type _version_terms_of_service: str + :param _notification_filters: The types of notifications that will result in + a push notification or URL callback for this UserPerson. + :type _notification_filters: list[object_.NotificationFilter] + :param _relations: The relations for this user. + :type _relations: list[RelationUser] + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user-person/{}" + _ENDPOINT_URL_UPDATE = "user-person/{}" + + # Field constants. + FIELD_SUBSCRIPTION_TYPE = "subscription_type" + FIELD_FIRST_NAME = "first_name" + FIELD_MIDDLE_NAME = "middle_name" + FIELD_LAST_NAME = "last_name" + FIELD_PUBLIC_NICK_NAME = "public_nick_name" + FIELD_ADDRESS_MAIN = "address_main" + FIELD_ADDRESS_POSTAL = "address_postal" + FIELD_AVATAR_UUID = "avatar_uuid" + FIELD_TAX_RESIDENT = "tax_resident" + FIELD_DOCUMENT_TYPE = "document_type" + FIELD_DOCUMENT_NUMBER = "document_number" + FIELD_DOCUMENT_COUNTRY_OF_ISSUANCE = "document_country_of_issuance" + FIELD_DOCUMENT_FRONT_ATTACHMENT_ID = "document_front_attachment_id" + FIELD_DOCUMENT_BACK_ATTACHMENT_ID = "document_back_attachment_id" + FIELD_DATE_OF_BIRTH = "date_of_birth" + FIELD_NATIONALITY = "nationality" + FIELD_ALL_NATIONALITY = "all_nationality" + FIELD_LANGUAGE = "language" + FIELD_REGION = "region" + FIELD_GENDER = "gender" + FIELD_STATUS = "status" + FIELD_SUB_STATUS = "sub_status" + FIELD_LEGAL_GUARDIAN_ALIAS = "legal_guardian_alias" + FIELD_SESSION_TIMEOUT = "session_timeout" + FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login" + FIELD_DISPLAY_NAME = "display_name" + FIELD_SIGNUP_TRACK_TYPE = "signup_track_type" + + # Object type. + _OBJECT_TYPE_GET = "UserPerson" + + _id_ = None + _created = None + _updated = None + _public_uuid = None + _first_name = None + _middle_name = None + _last_name = None + _legal_name = None + _display_name = None + _public_nick_name = None + _alias = None + _tax_resident = None + _address_main = None + _address_postal = None + _address_shipping = None + _date_of_birth = None + _place_of_birth = None + _country_of_birth = None + _nationality = None + _all_nationality = None + _language = None + _region = None + _gender = None + _avatar = None + _version_terms_of_service = None + _status = None + _sub_status = None + _session_timeout = None + _daily_limit_without_confirmation_login = None + _notification_filters = None + _relations = None + _subscription_type_field_for_request = None + _first_name_field_for_request = None + _middle_name_field_for_request = None + _last_name_field_for_request = None + _public_nick_name_field_for_request = None + _address_main_field_for_request = None + _address_postal_field_for_request = None + _avatar_uuid_field_for_request = None + _tax_resident_field_for_request = None + _document_type_field_for_request = None + _document_number_field_for_request = None + _document_country_of_issuance_field_for_request = None + _document_front_attachment_id_field_for_request = None + _document_back_attachment_id_field_for_request = None + _date_of_birth_field_for_request = None + _nationality_field_for_request = None + _all_nationality_field_for_request = None + _language_field_for_request = None + _region_field_for_request = None + _gender_field_for_request = None + _status_field_for_request = None + _sub_status_field_for_request = None + _legal_guardian_alias_field_for_request = None + _session_timeout_field_for_request = None + _daily_limit_without_confirmation_login_field_for_request = None + _display_name_field_for_request = None + _signup_track_type_field_for_request = None + + def __init__(self, subscription_type=None, first_name=None, middle_name=None, last_name=None, public_nick_name=None, address_main=None, address_postal=None, avatar_uuid=None, tax_resident=None, document_type=None, document_number=None, document_country_of_issuance=None, document_front_attachment_id=None, document_back_attachment_id=None, date_of_birth=None, nationality=None, all_nationality=None, language=None, region=None, gender=None, status=None, sub_status=None, legal_guardian_alias=None, session_timeout=None, daily_limit_without_confirmation_login=None, display_name=None, signup_track_type=None): + """ + :param subscription_type: The subscription type the user should start on. + :type subscription_type: str + :param first_name: The person's first name. + :type first_name: str + :param middle_name: The person's middle name. + :type middle_name: str + :param last_name: The person's last name. + :type last_name: str + :param public_nick_name: The person's public nick name. + :type public_nick_name: str + :param address_main: The user's main address. + :type address_main: object_.Address + :param address_postal: The person's postal address. + :type address_postal: object_.Address + :param avatar_uuid: The public UUID of the user's avatar. + :type avatar_uuid: str + :param tax_resident: The user's tax residence numbers for different + countries. + :type tax_resident: list[object_.TaxResident] + :param document_type: The type of identification document the person + registered with. + :type document_type: str + :param document_number: The identification document number the person + registered with. + :type document_number: str + :param document_country_of_issuance: The country which issued the + identification document the person registered with. + :type document_country_of_issuance: str + :param document_front_attachment_id: The reference to the uploaded + picture/scan of the front side of the identification document. + :type document_front_attachment_id: int + :param document_back_attachment_id: The reference to the uploaded + picture/scan of the back side of the identification document. + :type document_back_attachment_id: int + :param date_of_birth: The person's date of birth. Accepts ISO8601 date + formats. + :type date_of_birth: str + :param nationality: DEPRECATED. The person's nationality. Formatted as a SO + 3166-1 alpha-2 country code. + :type nationality: str + :param all_nationality: All of the person's nationalities. + :type all_nationality: list[str] + :param language: The person's preferred language. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type language: str + :param region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type region: str + :param gender: The person's gender. Can be: MALE, FEMALE and UNKNOWN. + :type gender: str + :param status: The user status. You are not allowed to update the status via + PUT. + :type status: str + :param sub_status: The user sub-status. Can be updated to SUBMIT if status + is RECOVERY. + :type sub_status: str + :param legal_guardian_alias: The legal guardian of the user. Required for + minors. + :type legal_guardian_alias: object_.Pointer + :param session_timeout: The setting for the session timeout of the user in + seconds. + :type session_timeout: int + :param daily_limit_without_confirmation_login: The amount the user can pay + in the session without asking for credentials. + :type daily_limit_without_confirmation_login: object_.Amount + :param display_name: The person's legal name. Available legal names can be + listed via the 'user/{user_id}/legal-name' endpoint. + :type display_name: str + :param signup_track_type: The type of signup track the user is following. + :type signup_track_type: str + """ + + self._subscription_type_field_for_request = subscription_type + self._first_name_field_for_request = first_name + self._middle_name_field_for_request = middle_name + self._last_name_field_for_request = last_name + self._public_nick_name_field_for_request = public_nick_name + self._address_main_field_for_request = address_main + self._address_postal_field_for_request = address_postal + self._avatar_uuid_field_for_request = avatar_uuid + self._tax_resident_field_for_request = tax_resident + self._document_type_field_for_request = document_type + self._document_number_field_for_request = document_number + self._document_country_of_issuance_field_for_request = document_country_of_issuance + self._document_front_attachment_id_field_for_request = document_front_attachment_id + self._document_back_attachment_id_field_for_request = document_back_attachment_id + self._date_of_birth_field_for_request = date_of_birth + self._nationality_field_for_request = nationality + self._all_nationality_field_for_request = all_nationality + self._language_field_for_request = language + self._region_field_for_request = region + self._gender_field_for_request = gender + self._status_field_for_request = status + self._sub_status_field_for_request = sub_status + self._legal_guardian_alias_field_for_request = legal_guardian_alias + self._session_timeout_field_for_request = session_timeout + self._daily_limit_without_confirmation_login_field_for_request = daily_limit_without_confirmation_login + self._display_name_field_for_request = display_name + self._signup_track_type_field_for_request = signup_track_type + + @classmethod + def get(cls, custom_headers=None): + """ + Get a specific person. + + :type api_context: ApiContext + :type user_person_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUserPerson + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseUserPerson.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, first_name=None, middle_name=None, last_name=None, public_nick_name=None, address_main=None, address_postal=None, avatar_uuid=None, tax_resident=None, document_type=None, document_number=None, document_country_of_issuance=None, document_front_attachment_id=None, document_back_attachment_id=None, date_of_birth=None, nationality=None, all_nationality=None, language=None, region=None, gender=None, status=None, sub_status=None, legal_guardian_alias=None, session_timeout=None, daily_limit_without_confirmation_login=None, display_name=None, custom_headers=None): + """ + Modify a specific person object's data. + + :type user_person_id: int + :param first_name: The person's first name. + :type first_name: str + :param middle_name: The person's middle name. + :type middle_name: str + :param last_name: The person's last name. + :type last_name: str + :param public_nick_name: The person's public nick name. + :type public_nick_name: str + :param address_main: The user's main address. + :type address_main: object_.Address + :param address_postal: The person's postal address. + :type address_postal: object_.Address + :param avatar_uuid: The public UUID of the user's avatar. + :type avatar_uuid: str + :param tax_resident: The user's tax residence numbers for different + countries. + :type tax_resident: list[object_.TaxResident] + :param document_type: The type of identification document the person + registered with. + :type document_type: str + :param document_number: The identification document number the person + registered with. + :type document_number: str + :param document_country_of_issuance: The country which issued the + identification document the person registered with. + :type document_country_of_issuance: str + :param document_front_attachment_id: The reference to the uploaded + picture/scan of the front side of the identification document. + :type document_front_attachment_id: int + :param document_back_attachment_id: The reference to the uploaded + picture/scan of the back side of the identification document. + :type document_back_attachment_id: int + :param date_of_birth: The person's date of birth. Accepts ISO8601 date + formats. + :type date_of_birth: str + :param nationality: DEPRECATED. The person's nationality. Formatted as a + SO 3166-1 alpha-2 country code. + :type nationality: str + :param all_nationality: All of the person's nationalities. + :type all_nationality: list[str] + :param language: The person's preferred language. Formatted as a ISO + 639-1 language code plus a ISO 3166-1 alpha-2 country code, seperated by + an underscore. + :type language: str + :param region: The person's preferred region. Formatted as a ISO 639-1 + language code plus a ISO 3166-1 alpha-2 country code, seperated by an + underscore. + :type region: str + :param gender: The person's gender. Can be: MALE, FEMALE and UNKNOWN. + :type gender: str + :param status: The user status. You are not allowed to update the status + via PUT. + :type status: str + :param sub_status: The user sub-status. Can be updated to SUBMIT if + status is RECOVERY. + :type sub_status: str + :param legal_guardian_alias: The legal guardian of the user. Required + for minors. + :type legal_guardian_alias: object_.Pointer + :param session_timeout: The setting for the session timeout of the user + in seconds. + :type session_timeout: int + :param daily_limit_without_confirmation_login: The amount the user can + pay in the session without asking for credentials. + :type daily_limit_without_confirmation_login: object_.Amount + :param display_name: The person's legal name. Available legal names can + be listed via the 'user/{user_id}/legal-name' endpoint. + :type display_name: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_FIRST_NAME : first_name, +cls.FIELD_MIDDLE_NAME : middle_name, +cls.FIELD_LAST_NAME : last_name, +cls.FIELD_PUBLIC_NICK_NAME : public_nick_name, +cls.FIELD_ADDRESS_MAIN : address_main, +cls.FIELD_ADDRESS_POSTAL : address_postal, +cls.FIELD_AVATAR_UUID : avatar_uuid, +cls.FIELD_TAX_RESIDENT : tax_resident, +cls.FIELD_DOCUMENT_TYPE : document_type, +cls.FIELD_DOCUMENT_NUMBER : document_number, +cls.FIELD_DOCUMENT_COUNTRY_OF_ISSUANCE : document_country_of_issuance, +cls.FIELD_DOCUMENT_FRONT_ATTACHMENT_ID : document_front_attachment_id, +cls.FIELD_DOCUMENT_BACK_ATTACHMENT_ID : document_back_attachment_id, +cls.FIELD_DATE_OF_BIRTH : date_of_birth, +cls.FIELD_NATIONALITY : nationality, +cls.FIELD_ALL_NATIONALITY : all_nationality, +cls.FIELD_LANGUAGE : language, +cls.FIELD_REGION : region, +cls.FIELD_GENDER : gender, +cls.FIELD_STATUS : status, +cls.FIELD_SUB_STATUS : sub_status, +cls.FIELD_LEGAL_GUARDIAN_ALIAS : legal_guardian_alias, +cls.FIELD_SESSION_TIMEOUT : session_timeout, +cls.FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN : daily_limit_without_confirmation_login, +cls.FIELD_DISPLAY_NAME : display_name +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id()) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def first_name(self): + """ + :rtype: str + """ + + return self._first_name + + @property + def middle_name(self): + """ + :rtype: str + """ + + return self._middle_name + + @property + def last_name(self): + """ + :rtype: str + """ + + return self._last_name + + @property + def legal_name(self): + """ + :rtype: str + """ + + return self._legal_name + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def public_nick_name(self): + """ + :rtype: str + """ + + return self._public_nick_name + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def tax_resident(self): + """ + :rtype: list[object_.TaxResident] + """ + + return self._tax_resident + + @property + def address_main(self): + """ + :rtype: object_.Address + """ + + return self._address_main + + @property + def address_postal(self): + """ + :rtype: object_.Address + """ + + return self._address_postal + + @property + def address_shipping(self): + """ + :rtype: object_.Address + """ + + return self._address_shipping + + @property + def date_of_birth(self): + """ + :rtype: str + """ + + return self._date_of_birth + + @property + def place_of_birth(self): + """ + :rtype: str + """ + + return self._place_of_birth + + @property + def country_of_birth(self): + """ + :rtype: str + """ + + return self._country_of_birth + + @property + def nationality(self): + """ + :rtype: str + """ + + return self._nationality + + @property + def all_nationality(self): + """ + :rtype: list[str] + """ + + return self._all_nationality + + @property + def language(self): + """ + :rtype: str + """ + + return self._language + + @property + def region(self): + """ + :rtype: str + """ + + return self._region + + @property + def gender(self): + """ + :rtype: str + """ + + return self._gender + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def version_terms_of_service(self): + """ + :rtype: str + """ + + return self._version_terms_of_service + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def session_timeout(self): + """ + :rtype: int + """ + + return self._session_timeout + + @property + def daily_limit_without_confirmation_login(self): + """ + :rtype: object_.Amount + """ + + return self._daily_limit_without_confirmation_login + + @property + def notification_filters(self): + """ + :rtype: list[object_.NotificationFilter] + """ + + return self._notification_filters + + @property + def relations(self): + """ + :rtype: list[RelationUser] + """ + + return self._relations + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._public_uuid is not None: + return False + + if self._first_name is not None: + return False + + if self._middle_name is not None: + return False + + if self._last_name is not None: + return False + + if self._legal_name is not None: + return False + + if self._display_name is not None: + return False + + if self._public_nick_name is not None: + return False + + if self._alias is not None: + return False + + if self._tax_resident is not None: + return False + + if self._address_main is not None: + return False + + if self._address_postal is not None: + return False + + if self._address_shipping is not None: + return False + + if self._date_of_birth is not None: + return False + + if self._place_of_birth is not None: + return False + + if self._country_of_birth is not None: + return False + + if self._nationality is not None: + return False + + if self._all_nationality is not None: + return False + + if self._language is not None: + return False + + if self._region is not None: + return False + + if self._gender is not None: + return False + + if self._avatar is not None: + return False + + if self._version_terms_of_service is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._session_timeout is not None: + return False + + if self._daily_limit_without_confirmation_login is not None: + return False + + if self._notification_filters is not None: + return False + + if self._relations is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: UserPersonApiObject + """ + + return converter.json_to_class(UserPersonApiObject, json_str) + + +class UserApiKeyApiObject(BunqModel): + """ + Used to view OAuth request detais in events. + + :param _id_: The id of the user. + :type _id_: int + :param _created: The timestamp of the user object's creation. + :type _created: str + :param _updated: The timestamp of the user object's last update. + :type _updated: str + :param _requested_by_user: The user who requested access. + :type _requested_by_user: object_.UserApiKeyAnchoredUser + :param _granted_by_user: The user who granted access. + :type _granted_by_user: object_.UserApiKeyAnchoredUser + """ + + _id_ = None + _created = None + _updated = None + _requested_by_user = None + _granted_by_user = None + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def requested_by_user(self): + """ + :rtype: object_.UserApiKeyAnchoredUser + """ + + return self._requested_by_user + + @property + def granted_by_user(self): + """ + :rtype: object_.UserApiKeyAnchoredUser + """ + + return self._granted_by_user + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._requested_by_user is not None: + return False + + if self._granted_by_user is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: UserApiKeyApiObject + """ + + return converter.json_to_class(UserApiKeyApiObject, json_str) + + +class UserPaymentServiceProviderApiObject(BunqModel): + """ + Used to view UserPaymentServiceProvider for session creation. + + :param _id_: The id of the user. + :type _id_: int + :param _created: The timestamp of the user object's creation. + :type _created: str + :param _updated: The timestamp of the user object's last update. + :type _updated: str + :param _certificate_distinguished_name: The distinguished name from the + certificate used to identify this user. + :type _certificate_distinguished_name: str + :param _alias: The aliases of the user. + :type _alias: list[object_.Pointer] + :param _avatar: The user's avatar. + :type _avatar: object_.Avatar + :param _status: The user status. The user status. Can be: ACTIVE, BLOCKED or + DENIED. + :type _status: str + :param _sub_status: The user sub-status. Can be: NONE + :type _sub_status: str + :param _public_uuid: The providers's public UUID. + :type _public_uuid: str + :param _display_name: The display name for the provider. + :type _display_name: str + :param _public_nick_name: The public nick name for the provider. + :type _public_nick_name: str + :param _language: The provider's language. Formatted as a ISO 639-1 language + code plus a ISO 3166-1 alpha-2 country code, separated by an underscore. + :type _language: str + :param _region: The provider's region. Formatted as a ISO 639-1 language + code plus a ISO 3166-1 alpha-2 country code, separated by an underscore. + :type _region: str + :param _session_timeout: The setting for the session timeout of the user in + seconds. + :type _session_timeout: int + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user-payment-service-provider/{}" + + # Object type. + _OBJECT_TYPE_GET = "UserPaymentServiceProvider" + + _id_ = None + _created = None + _updated = None + _certificate_distinguished_name = None + _alias = None + _avatar = None + _status = None + _sub_status = None + _public_uuid = None + _display_name = None + _public_nick_name = None + _language = None + _region = None + _session_timeout = None + + @classmethod + def get(cls, user_payment_service_provider_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_payment_service_provider_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUserPaymentServiceProvider + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(user_payment_service_provider_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseUserPaymentServiceProvider.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def certificate_distinguished_name(self): + """ + :rtype: str + """ + + return self._certificate_distinguished_name + + @property + def alias(self): + """ + :rtype: list[object_.Pointer] + """ + + return self._alias + + @property + def avatar(self): + """ + :rtype: object_.Avatar + """ + + return self._avatar + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def sub_status(self): + """ + :rtype: str + """ + + return self._sub_status + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def public_nick_name(self): + """ + :rtype: str + """ + + return self._public_nick_name + + @property + def language(self): + """ + :rtype: str + """ + + return self._language + + @property + def region(self): + """ + :rtype: str + """ + + return self._region + + @property + def session_timeout(self): + """ + :rtype: int + """ + + return self._session_timeout + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._certificate_distinguished_name is not None: + return False + + if self._alias is not None: + return False + + if self._avatar is not None: + return False + + if self._status is not None: + return False + + if self._sub_status is not None: + return False + + if self._public_uuid is not None: + return False + + if self._display_name is not None: + return False + + if self._public_nick_name is not None: + return False + + if self._language is not None: + return False + + if self._region is not None: + return False + + if self._session_timeout is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: UserPaymentServiceProviderApiObject + """ + + return converter.json_to_class(UserPaymentServiceProviderApiObject, json_str) + + +class OauthCallbackUrlApiObject(BunqModel): + """ + Used for managing OAuth Client Callback URLs. + + :param _url: The URL for this callback. + :type _url: str + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/oauth-client/{}/callback-url/{}" + _ENDPOINT_URL_CREATE = "user/{}/oauth-client/{}/callback-url" + _ENDPOINT_URL_UPDATE = "user/{}/oauth-client/{}/callback-url/{}" + _ENDPOINT_URL_LISTING = "user/{}/oauth-client/{}/callback-url" + _ENDPOINT_URL_DELETE = "user/{}/oauth-client/{}/callback-url/{}" + + # Field constants. + FIELD_URL = "url" + + # Object type. + _OBJECT_TYPE_GET = "OauthCallbackUrl" + + _url = None + _url_field_for_request = None + + def __init__(self, url=None): + """ + :param url: The URL for this callback. + :type url: str + """ + + self._url_field_for_request = url + + @classmethod + def get(cls, oauth_client_id, oauth_callback_url_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type oauth_client_id: int + :type oauth_callback_url_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseOauthCallbackUrl + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), oauth_client_id, oauth_callback_url_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseOauthCallbackUrl.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def create(cls,oauth_client_id, url, custom_headers=None): + """ + :type user_id: int + :type oauth_client_id: int + :param url: The URL for this callback. + :type url: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_URL : url +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), oauth_client_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, oauth_client_id, oauth_callback_url_id, url=None, custom_headers=None): + """ + :type user_id: int + :type oauth_client_id: int + :type oauth_callback_url_id: int + :param url: The URL for this callback. + :type url: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_URL : url +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), oauth_client_id, oauth_callback_url_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls,oauth_client_id, params=None, custom_headers=None): + """ + :type user_id: int + :type oauth_client_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseOauthCallbackUrlList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), oauth_client_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseOauthCallbackUrlList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def delete(cls, oauth_client_id, oauth_callback_url_id, custom_headers=None): + """ + :type user_id: int + :type oauth_client_id: int + :type oauth_callback_url_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), oauth_client_id, oauth_callback_url_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @property + def url(self): + """ + :rtype: str + """ + + return self._url + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._url is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: OauthCallbackUrlApiObject + """ + + return converter.json_to_class(OauthCallbackUrlApiObject, json_str) + + +class OauthClientApiObject(BunqModel): + """ + Used for managing OAuth Clients. + + :param _status: The status of the pack group, can be ACTIVE, CANCELLED or + CANCELLED_PENDING. + :type _status: str + :param _id_: Id of the client. + :type _id_: int + :param _display_name: The display name of this Oauth Client + :type _display_name: str + :param _client_id: The Client ID associated with this Oauth Client + :type _client_id: str + :param _secret: Secret associated with this Oauth Client + :type _secret: str + :param _callback_url: The callback URLs which are bound to this Oauth Client + :type _callback_url: list[object_.OauthCallbackUrl] + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/oauth-client/{}" + _ENDPOINT_URL_CREATE = "user/{}/oauth-client" + _ENDPOINT_URL_UPDATE = "user/{}/oauth-client/{}" + _ENDPOINT_URL_LISTING = "user/{}/oauth-client" + + # Field constants. + FIELD_STATUS = "status" + + # Object type. + _OBJECT_TYPE_GET = "OauthClient" + + _id_ = None + _status = None + _display_name = None + _client_id = None + _secret = None + _callback_url = None + _status_field_for_request = None + + def __init__(self, status=None): + """ + :param status: The status of the Oauth Client, can be ACTIVE or CANCELLED. + :type status: str + """ + + self._status_field_for_request = status + + @classmethod + def get(cls, oauth_client_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type oauth_client_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseOauthClient + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), oauth_client_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseOauthClient.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def create(cls,status=None, custom_headers=None): + """ + :type user_id: int + :param status: The status of the Oauth Client, can be ACTIVE or + CANCELLED. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, oauth_client_id, status=None, custom_headers=None): + """ + :type user_id: int + :type oauth_client_id: int + :param status: The status of the Oauth Client, can be ACTIVE or + CANCELLED. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), oauth_client_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseOauthClientList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseOauthClientList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def display_name(self): + """ + :rtype: str + """ + + return self._display_name + + @property + def client_id(self): + """ + :rtype: str + """ + + return self._client_id + + @property + def secret(self): + """ + :rtype: str + """ + + return self._secret + + @property + def callback_url(self): + """ + :rtype: list[object_.OauthCallbackUrl] + """ + + return self._callback_url + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._status is not None: + return False + + if self._display_name is not None: + return False + + if self._client_id is not None: + return False + + if self._secret is not None: + return False + + if self._callback_url is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: OauthClientApiObject + """ + + return converter.json_to_class(OauthClientApiObject, json_str) + + +class PaymentAutoAllocateDefinitionApiObject(BunqModel): + """ + List all the definitions in a payment auto allocate. + + :param _type_: The type of definition. + :type _type_: str + :param _counterparty_alias: The alias of the party we are allocating the + money to. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description for the payment. + :type _description: str + :param _amount: The amount to allocate. + :type _amount: object_.Amount + :param _fraction: The percentage of the triggering payment's amount to + allocate. + :type _fraction: float + :param _id_: The id of the PaymentAutoAllocateDefinition. + :type _id_: int + :param _created: The timestamp when the PaymentAutoAllocateDefinition was + created. + :type _created: str + :param _updated: The timestamp when the PaymentAutoAllocateDefinition was + last updated. + :type _updated: str + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-auto-allocate/{}/definition" + + # Field constants. + FIELD_TYPE = "type" + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" + FIELD_DESCRIPTION = "description" + FIELD_AMOUNT = "amount" + FIELD_FRACTION = "fraction" + + # Object type. + _OBJECT_TYPE_GET = "PaymentAutoAllocateDefinition" + + _id_ = None + _created = None + _updated = None + _counterparty_alias = None + _description = None + _amount = None + _fraction = None + _type__field_for_request = None + _counterparty_alias_field_for_request = None + _description_field_for_request = None + _amount_field_for_request = None + _fraction_field_for_request = None + + def __init__(self, type_=None, counterparty_alias=None, description=None, amount=None, fraction=None): + """ + :param type_: The type of definition. + :type type_: str + :param counterparty_alias: The alias of the party we are allocating the + money to. + :type counterparty_alias: object_.Pointer + :param description: The description for the payment. + :type description: str + :param amount: The amount to allocate. + :type amount: object_.Amount + :param fraction: The percentage of the triggering payment's amount to + allocate. + :type fraction: float + """ + + self._type__field_for_request = type_ + self._counterparty_alias_field_for_request = counterparty_alias + self._description_field_for_request = description + self._amount_field_for_request = amount + self._fraction_field_for_request = fraction + + @classmethod + def list(cls,payment_auto_allocate_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentAutoAllocateDefinitionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePaymentAutoAllocateDefinitionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def amount(self): + """ + :rtype: object_.Amount + """ + + return self._amount + + @property + def fraction(self): + """ + :rtype: float + """ + + return self._fraction + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._amount is not None: + return False + + if self._fraction is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentAutoAllocateDefinitionApiObject + """ + + return converter.json_to_class(PaymentAutoAllocateDefinitionApiObject, json_str) + + +class PaymentAutoAllocateApiObject(BunqModel): + """ + Manage a users automatic payment auto allocated settings. + + :param _payment_id: The payment that should be used to define the triggers + for the payment auto allocate. + :type _payment_id: int + :param _type_: The type. + :type _type_: str + :param _definition: The definition of how the money should be allocated. + :type _definition: list[PaymentAutoAllocateDefinition] + :param _id_: The id of the PaymentAutoAllocate. + :type _id_: int + :param _created: The timestamp when the PaymentAutoAllocate was created. + :type _created: str + :param _updated: The timestamp when the PaymentAutoAllocate was last + updated. + :type _updated: str + :param _status: The status. + :type _status: str + :param _trigger_amount: The amount on which this payment auto allocate will + be triggered. + :type _trigger_amount: object_.Amount + :param _payment: DEPRECATED: superseded by `payment_original` and + `payment_latest` + :type _payment: Payment + :param _payment_original: The payment that was used to define the triggers + for this payment auto allocate. + :type _payment_original: Payment + :param _payment_latest: The latest payment allocated using this payment auto + allocate. + :type _payment_latest: Payment + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/payment-auto-allocate" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/payment-auto-allocate/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/payment-auto-allocate" + _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/payment-auto-allocate/{}" + _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/payment-auto-allocate/{}" + + # Field constants. + FIELD_PAYMENT_ID = "payment_id" + FIELD_TYPE = "type" + FIELD_DEFINITION = "definition" + + # Object type. + _OBJECT_TYPE_GET = "PaymentAutoAllocate" + + _id_ = None + _created = None + _updated = None + _type_ = None + _status = None + _trigger_amount = None + _payment = None + _payment_original = None + _payment_latest = None + _payment_id_field_for_request = None + _type__field_for_request = None + _definition_field_for_request = None + + def __init__(self, payment_id, type_, definition=None): + """ + :param payment_id: The payment that should be used to define the triggers + for the payment auto allocate. + :type payment_id: int + :param type_: Whether a payment should be sorted ONCE or RECURRING. + :type type_: str + :param definition: The definition of how the money should be allocated. + :type definition: list[PaymentAutoAllocateDefinition] + """ + + self._payment_id_field_for_request = payment_id + self._type__field_for_request = type_ + self._definition_field_for_request = definition + + @classmethod + def create(cls,payment_id, type_, definition, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :param payment_id: The payment that should be used to define the + triggers for the payment auto allocate. + :type payment_id: int + :param type_: Whether a payment should be sorted ONCE or RECURRING. + :type type_: str + :param definition: The definition of how the money should be allocated. + :type definition: list[PaymentAutoAllocateDefinition] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_PAYMENT_ID : payment_id, +cls.FIELD_TYPE : type_, +cls.FIELD_DEFINITION : definition +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, payment_auto_allocate_id, monetary_account_id=None, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentAutoAllocate + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponsePaymentAutoAllocate.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def list(cls,monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentAutoAllocateList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePaymentAutoAllocateList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, payment_auto_allocate_id, monetary_account_id=None, definition=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :param definition: The definition of how the money should be allocated. + :type definition: list[PaymentAutoAllocateDefinition] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_DEFINITION : definition +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, payment_auto_allocate_id, monetary_account_id=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type payment_auto_allocate_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), payment_auto_allocate_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def trigger_amount(self): + """ + :rtype: object_.Amount + """ + + return self._trigger_amount + + @property + def payment(self): + """ + :rtype: Payment + """ + + return self._payment + + @property + def payment_original(self): + """ + :rtype: Payment + """ + + return self._payment_original + + @property + def payment_latest(self): + """ + :rtype: Payment + """ + + return self._payment_latest + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._type_ is not None: + return False + + if self._status is not None: + return False + + if self._trigger_amount is not None: + return False + + if self._payment is not None: + return False + + if self._payment_original is not None: + return False + + if self._payment_latest is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentAutoAllocateApiObject + """ + + return converter.json_to_class(PaymentAutoAllocateApiObject, json_str) + + +class PaymentAutoAllocateUserApiObject(BunqModel, AnchorObjectInterface): + """ + List a users automatic payment auto allocated settings. + + :param _PaymentAutoAllocate: + :type _PaymentAutoAllocate: PaymentAutoAllocate + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/payment-auto-allocate" + + # Object type. + _OBJECT_TYPE_GET = "PaymentAutoAllocate" + + _PaymentAutoAllocate = None + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentAutoAllocateUserList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePaymentAutoAllocateUserList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def PaymentAutoAllocate(self): + """ + :rtype: PaymentAutoAllocate + """ + + return self._PaymentAutoAllocate + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._PaymentAutoAllocate is not None: + return self._PaymentAutoAllocate + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._PaymentAutoAllocate is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentAutoAllocateUserApiObject + """ + + return converter.json_to_class(PaymentAutoAllocateUserApiObject, json_str) + + +class PaymentServiceProviderCredentialApiObject(BunqModel): + """ + Register a Payment Service Provider and provide credentials + + :param _client_payment_service_provider_certificate: Payment Services + Directive 2 compatible QSEAL certificate + :type _client_payment_service_provider_certificate: str + :param _client_payment_service_provider_certificate_chain: Intermediate and + root certificate belonging to the provided certificate. + :type _client_payment_service_provider_certificate_chain: str + :param _client_public_key_signature: The Base64 encoded signature of the + public key provided during installation and with the installation token + appended as a nonce. Signed with the private key belonging to the QSEAL + certificate. + :type _client_public_key_signature: str + :param _id_: The id of the credential. + :type _id_: int + :param _created: The timestamp of the credential object's creation. + :type _created: str + :param _updated: The timestamp of the credential object's last update. + :type _updated: str + :param _status: The status of the credential. + :type _status: str + :param _expiry_time: When the status is PENDING_FIRST_USE: when the + credential expires. + :type _expiry_time: str + :param _token_value: When the status is PENDING_FIRST_USE: the value of the + token. + :type _token_value: str + :param _permitted_device: When the status is ACTIVE: the details of the + device that may use the credential. + :type _permitted_device: object_.PermittedDevice + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "payment-service-provider-credential/{}" + _ENDPOINT_URL_CREATE = "payment-service-provider-credential" + + # Field constants. + FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE = "client_payment_service_provider_certificate" + FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE_CHAIN = "client_payment_service_provider_certificate_chain" + FIELD_CLIENT_PUBLIC_KEY_SIGNATURE = "client_public_key_signature" + + # Object type. + _OBJECT_TYPE_GET = "CredentialPasswordIp" + + _id_ = None + _created = None + _updated = None + _status = None + _expiry_time = None + _token_value = None + _permitted_device = None + _client_payment_service_provider_certificate_field_for_request = None + _client_payment_service_provider_certificate_chain_field_for_request = None + _client_public_key_signature_field_for_request = None + + def __init__(self, client_payment_service_provider_certificate, client_payment_service_provider_certificate_chain, client_public_key_signature): + """ + :param client_payment_service_provider_certificate: Payment Services + Directive 2 compatible QSEAL certificate + :type client_payment_service_provider_certificate: str + :param client_payment_service_provider_certificate_chain: Intermediate and + root certificate belonging to the provided certificate. + :type client_payment_service_provider_certificate_chain: str + :param client_public_key_signature: The Base64 encoded signature of the + public key provided during installation and with the installation token + appended as a nonce. Signed with the private key belonging to the QSEAL + certificate. + :type client_public_key_signature: str + """ + + self._client_payment_service_provider_certificate_field_for_request = client_payment_service_provider_certificate + self._client_payment_service_provider_certificate_chain_field_for_request = client_payment_service_provider_certificate_chain + self._client_public_key_signature_field_for_request = client_public_key_signature + + @classmethod + def get(cls, payment_service_provider_credential_id, custom_headers=None): + """ + :type api_context: ApiContext + :type payment_service_provider_credential_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentServiceProviderCredential + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(payment_service_provider_credential_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponsePaymentServiceProviderCredential.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def create(cls,client_payment_service_provider_certificate, client_payment_service_provider_certificate_chain, client_public_key_signature, custom_headers=None): + """ + :param client_payment_service_provider_certificate: Payment Services + Directive 2 compatible QSEAL certificate + :type client_payment_service_provider_certificate: str + :param client_payment_service_provider_certificate_chain: Intermediate + and root certificate belonging to the provided certificate. + :type client_payment_service_provider_certificate_chain: str + :param client_public_key_signature: The Base64 encoded signature of the + public key provided during installation and with the installation token + appended as a nonce. Signed with the private key belonging to the QSEAL + certificate. + :type client_public_key_signature: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE : client_payment_service_provider_certificate, +cls.FIELD_CLIENT_PAYMENT_SERVICE_PROVIDER_CERTIFICATE_CHAIN : client_payment_service_provider_certificate_chain, +cls.FIELD_CLIENT_PUBLIC_KEY_SIGNATURE : client_public_key_signature +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def expiry_time(self): + """ + :rtype: str + """ + + return self._expiry_time + + @property + def token_value(self): + """ + :rtype: str + """ + + return self._token_value + + @property + def permitted_device(self): + """ + :rtype: object_.PermittedDevice + """ + + return self._permitted_device + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._status is not None: + return False + + if self._expiry_time is not None: + return False + + if self._token_value is not None: + return False + + if self._permitted_device is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentServiceProviderCredentialApiObject + """ + + return converter.json_to_class(PaymentServiceProviderCredentialApiObject, json_str) + + +class PaymentServiceProviderDraftPaymentApiObject(BunqModel): + """ + Manage the PaymentServiceProviderDraftPayment's for a PISP. + + :param _sender_iban: The sender IBAN. + :type _sender_iban: str + :param _sender_name: The name of the sender. + :type _sender_name: str + :param _counterparty_iban: The IBAN of the counterparty. + :type _counterparty_iban: str + :param _counterparty_name: The name of the counterparty. + :type _counterparty_name: str + :param _description: Description of the payment. + :type _description: str + :param _amount: The amount of the draft payment + :type _amount: object_.Amount + :param _status: The status of the draft payment + :type _status: str + :param _receiver_iban: The sender IBAN. + :type _receiver_iban: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/payment-service-provider-draft-payment" + _ENDPOINT_URL_UPDATE = "user/{}/payment-service-provider-draft-payment/{}" + _ENDPOINT_URL_LISTING = "user/{}/payment-service-provider-draft-payment" + _ENDPOINT_URL_READ = "user/{}/payment-service-provider-draft-payment/{}" + + # Field constants. + FIELD_SENDER_IBAN = "sender_iban" + FIELD_SENDER_NAME = "sender_name" + FIELD_COUNTERPARTY_IBAN = "counterparty_iban" + FIELD_COUNTERPARTY_NAME = "counterparty_name" + FIELD_DESCRIPTION = "description" + FIELD_AMOUNT = "amount" + FIELD_STATUS = "status" + + # Object type. + _OBJECT_TYPE_GET = "PaymentServiceProviderDraftPayment" + + _sender_iban = None + _receiver_iban = None + _amount = None + _status = None + _sender_iban_field_for_request = None + _sender_name_field_for_request = None + _counterparty_iban_field_for_request = None + _counterparty_name_field_for_request = None + _description_field_for_request = None + _amount_field_for_request = None + _status_field_for_request = None + + def __init__(self, sender_iban, counterparty_iban, counterparty_name, description, amount, sender_name=None, status=None): + """ + :param sender_iban: The IBAN of the sender. + :type sender_iban: str + :param counterparty_iban: The IBAN of the counterparty. + :type counterparty_iban: str + :param counterparty_name: The name of the counterparty. + :type counterparty_name: str + :param description: Description of the payment. + :type description: str + :param amount: The Amount to transfer with the Payment. Must be bigger than + 0. + :type amount: object_.Amount + :param sender_name: The name of the sender. + :type sender_name: str + :param status: The new status of the Draft Payment. Can only be set to + REJECTED or CANCELLED by update. + :type status: str + """ + + self._sender_iban_field_for_request = sender_iban + self._counterparty_iban_field_for_request = counterparty_iban + self._counterparty_name_field_for_request = counterparty_name + self._description_field_for_request = description + self._amount_field_for_request = amount + self._sender_name_field_for_request = sender_name + self._status_field_for_request = status + + @classmethod + def create(cls,sender_iban, counterparty_iban, counterparty_name, description, amount, sender_name=None, status=None, custom_headers=None): + """ + :type user_id: int + :param sender_iban: The IBAN of the sender. + :type sender_iban: str + :param counterparty_iban: The IBAN of the counterparty. + :type counterparty_iban: str + :param counterparty_name: The name of the counterparty. + :type counterparty_name: str + :param description: Description of the payment. + :type description: str + :param amount: The Amount to transfer with the Payment. Must be bigger + than 0. + :type amount: object_.Amount + :param sender_name: The name of the sender. + :type sender_name: str + :param status: The new status of the Draft Payment. Can only be set to + REJECTED or CANCELLED by update. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_SENDER_IBAN : sender_iban, +cls.FIELD_SENDER_NAME : sender_name, +cls.FIELD_COUNTERPARTY_IBAN : counterparty_iban, +cls.FIELD_COUNTERPARTY_NAME : counterparty_name, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_AMOUNT : amount, +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, payment_service_provider_draft_payment_id, status=None, custom_headers=None): + """ + :type user_id: int + :type payment_service_provider_draft_payment_id: int + :param status: The new status of the Draft Payment. Can only be set to + REJECTED or CANCELLED by update. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), payment_service_provider_draft_payment_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentServiceProviderDraftPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePaymentServiceProviderDraftPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def get(cls, payment_service_provider_draft_payment_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type payment_service_provider_draft_payment_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentServiceProviderDraftPayment + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), payment_service_provider_draft_payment_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponsePaymentServiceProviderDraftPayment.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def sender_iban(self): + """ + :rtype: str + """ + + return self._sender_iban + + @property + def receiver_iban(self): + """ + :rtype: str + """ + + return self._receiver_iban + + @property + def amount(self): + """ + :rtype: object_.Amount + """ + + return self._amount + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._sender_iban is not None: + return False + + if self._receiver_iban is not None: + return False + + if self._amount is not None: + return False + + if self._status is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentServiceProviderDraftPaymentApiObject + """ + + return converter.json_to_class(PaymentServiceProviderDraftPaymentApiObject, json_str) + + +class PaymentServiceProviderIssuerTransactionApiObject(BunqModel): + """ + The endpoint for payment service provider issuer transactions + + :param _counterparty_alias: The counter party this transaction should be + sent to. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _amount: The money amount of this transaction + :type _amount: object_.Amount + :param _description: The description of this transaction, to be shown to the + user and to the counter party. + :type _description: str + :param _url_redirect: The url to which the user should be redirected once + the transaction is accepted or rejected. + :type _url_redirect: str + :param _time_expiry: The (optional) expiration time of the transaction. + Defaults to 10 minutes. + :type _time_expiry: str + :param _status: The status of the transaction. Can only be used for + cancelling the transaction. + :type _status: str + :param _id_: The id of this transaction. + :type _id_: int + :param _created: The time this transaction was created. + :type _created: str + :param _updated: The time this transaction was last updated. + :type _updated: str + :param _public_uuid: The public uuid used to identify this transaction. + :type _public_uuid: str + :param _alias: The monetary account this transaction is made from. + :type _alias: object_.MonetaryAccountReference + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/payment-service-provider-issuer-transaction" + _ENDPOINT_URL_READ = "user/{}/payment-service-provider-issuer-transaction/{}" + _ENDPOINT_URL_UPDATE = "user/{}/payment-service-provider-issuer-transaction/{}" + _ENDPOINT_URL_LISTING = "user/{}/payment-service-provider-issuer-transaction" + + # Field constants. + FIELD_COUNTERPARTY_ALIAS = "counterparty_alias" + FIELD_AMOUNT = "amount" + FIELD_DESCRIPTION = "description" + FIELD_URL_REDIRECT = "url_redirect" + FIELD_TIME_EXPIRY = "time_expiry" + FIELD_STATUS = "status" + + # Object type. + _OBJECT_TYPE_GET = "PaymentServiceProviderIssuerTransaction" + + _id_ = None + _created = None + _updated = None + _public_uuid = None + _counterparty_alias = None + _amount = None + _description = None + _url_redirect = None + _time_expiry = None + _status = None + _alias = None + _counterparty_alias_field_for_request = None + _amount_field_for_request = None + _description_field_for_request = None + _url_redirect_field_for_request = None + _time_expiry_field_for_request = None + _status_field_for_request = None + + def __init__(self, counterparty_alias, amount, description, url_redirect, time_expiry=None, status=None): + """ + :param counterparty_alias: The counter party this transaction should be sent + to. + :type counterparty_alias: object_.Pointer + :param amount: The money amount of this transaction + :type amount: object_.Amount + :param description: The description of this transaction, to be shown to the + user and to the counter party. + :type description: str + :param url_redirect: The url to which the user should be redirected once the + transaction is accepted or rejected. + :type url_redirect: str + :param time_expiry: The (optional) expiration time of the transaction. + Defaults to 10 minutes. + :type time_expiry: str + :param status: The status of the transaction. Can only be used for + cancelling the transaction. + :type status: str + """ + + self._counterparty_alias_field_for_request = counterparty_alias + self._amount_field_for_request = amount + self._description_field_for_request = description + self._url_redirect_field_for_request = url_redirect + self._time_expiry_field_for_request = time_expiry + self._status_field_for_request = status + + @classmethod + def create(cls,counterparty_alias, amount, description, url_redirect, time_expiry=None, status=None, custom_headers=None): + """ + :type user_id: int + :param counterparty_alias: The counter party this transaction should be + sent to. + :type counterparty_alias: object_.Pointer + :param amount: The money amount of this transaction + :type amount: object_.Amount + :param description: The description of this transaction, to be shown to + the user and to the counter party. + :type description: str + :param url_redirect: The url to which the user should be redirected once + the transaction is accepted or rejected. + :type url_redirect: str + :param time_expiry: The (optional) expiration time of the transaction. + Defaults to 10 minutes. + :type time_expiry: str + :param status: The status of the transaction. Can only be used for + cancelling the transaction. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_COUNTERPARTY_ALIAS : counterparty_alias, +cls.FIELD_AMOUNT : amount, +cls.FIELD_DESCRIPTION : description, +cls.FIELD_URL_REDIRECT : url_redirect, +cls.FIELD_TIME_EXPIRY : time_expiry, +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, payment_service_provider_issuer_transaction_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type payment_service_provider_issuer_transaction_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentServiceProviderIssuerTransaction + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), payment_service_provider_issuer_transaction_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponsePaymentServiceProviderIssuerTransaction.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, payment_service_provider_issuer_transaction_id, status=None, custom_headers=None): + """ + :type user_id: int + :type payment_service_provider_issuer_transaction_id: int + :param status: The status of the transaction. Can only be used for + cancelling the transaction. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), payment_service_provider_issuer_transaction_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePaymentServiceProviderIssuerTransactionList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePaymentServiceProviderIssuerTransactionList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def created(self): + """ + :rtype: str + """ + + return self._created + + @property + def updated(self): + """ + :rtype: str + """ + + return self._updated + + @property + def public_uuid(self): + """ + :rtype: str + """ + + return self._public_uuid + + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def amount(self): + """ + :rtype: object_.Amount + """ + + return self._amount + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def url_redirect(self): + """ + :rtype: str + """ + + return self._url_redirect + + @property + def time_expiry(self): + """ + :rtype: str + """ + + return self._time_expiry + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._alias + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._public_uuid is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._amount is not None: + return False + + if self._description is not None: + return False + + if self._url_redirect is not None: + return False + + if self._time_expiry is not None: + return False + + if self._status is not None: + return False + + if self._alias is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PaymentServiceProviderIssuerTransactionApiObject + """ + + return converter.json_to_class(PaymentServiceProviderIssuerTransactionApiObject, json_str) + + +class PermittedIpApiObject(BunqModel): + """ + Manage the IPs which may be used for a credential of a user for server + authentication. + + :param _ip: The IP address. + :type _ip: str + :param _status: The status of the IP. May be "ACTIVE" or "INACTIVE". It is + only possible to make requests from "ACTIVE" IP addresses. Only "ACTIVE" IPs + will be billed. + :type _status: str + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/credential-password-ip/{}/ip/{}" + _ENDPOINT_URL_CREATE = "user/{}/credential-password-ip/{}/ip" + _ENDPOINT_URL_LISTING = "user/{}/credential-password-ip/{}/ip" + _ENDPOINT_URL_UPDATE = "user/{}/credential-password-ip/{}/ip/{}" + + # Field constants. + FIELD_IP = "ip" + FIELD_STATUS = "status" + + # Object type. + _OBJECT_TYPE_GET = "PermittedIp" + + _ip = None + _status = None + _ip_field_for_request = None + _status_field_for_request = None + + def __init__(self, ip, status=None): + """ + :param ip: The IP address. + :type ip: str + :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It is + only possible to make requests from "ACTIVE" IP addresses. Only "ACTIVE" IPs + will be billed. + :type status: str + """ + + self._ip_field_for_request = ip + self._status_field_for_request = status + + @classmethod + def get(cls, credential_password_ip_id, permitted_ip_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type credential_password_ip_id: int + :type permitted_ip_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePermittedIp + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), credential_password_ip_id, permitted_ip_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponsePermittedIp.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def create(cls,credential_password_ip_id, ip, status=None, custom_headers=None): + """ + :type user_id: int + :type credential_password_ip_id: int + :param ip: The IP address. + :type ip: str + :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It + is only possible to make requests from "ACTIVE" IP addresses. Only + "ACTIVE" IPs will be billed. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_IP : ip, +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), credential_password_ip_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls,credential_password_ip_id, params=None, custom_headers=None): + """ + :type user_id: int + :type credential_password_ip_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponsePermittedIpList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), credential_password_ip_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponsePermittedIpList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def update(cls, credential_password_ip_id, permitted_ip_id, status=None, custom_headers=None): + """ + :type user_id: int + :type credential_password_ip_id: int + :type permitted_ip_id: int + :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It + is only possible to make requests from "ACTIVE" IP addresses. Only + "ACTIVE" IPs will be billed. + :type status: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_STATUS : status +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), credential_password_ip_id, permitted_ip_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @property + def ip(self): + """ + :rtype: str + """ + + return self._ip + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._ip is not None: + return False + + if self._status is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: PermittedIpApiObject + """ + + return converter.json_to_class(PermittedIpApiObject, json_str) + + +class SandboxUserCompanyApiObject(BunqModel): + """ + Used to create a sandbox userCompany. + + :param _api_key: The API key of the newly created sandbox userCompany. + :type _api_key: str + :param _user: The user which was created. + :type _user: User + :param _login_code: The login code which the developer can use to log into + their sandbox user. + :type _login_code: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "sandbox-user-company" + + # Object type. + _OBJECT_TYPE_POST = "ApiKey" + + _api_key = None + _user = None + _login_code = None + + @classmethod + def create(cls, custom_headers=None): + """ + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseSandboxUserCompany + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { + +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseSandboxUserCompany.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + @property + def api_key(self): + """ + :rtype: str + """ + + return self._api_key + + @property + def user(self): + """ + :rtype: User + """ + + return self._user + + @property + def login_code(self): + """ + :rtype: str + """ + + return self._login_code + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._api_key is not None: + return False + + if self._user is not None: + return False + + if self._login_code is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: SandboxUserCompanyApiObject + """ + + return converter.json_to_class(SandboxUserCompanyApiObject, json_str) + + +class SandboxUserPersonApiObject(BunqModel): + """ + Used to create a sandbox userPerson. + + :param _api_key: The API key of the newly created sandbox userPerson. + :type _api_key: str + :param _user: The user which was created. + :type _user: User + :param _login_code: The login code which the developer can use to log into + their sandbox user. + :type _login_code: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "sandbox-user-person" + + # Object type. + _OBJECT_TYPE_POST = "ApiKey" + + _api_key = None + _user = None + _login_code = None + + @classmethod + def create(cls, custom_headers=None): + """ + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseSandboxUserPerson + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { + +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseSandboxUserPerson.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + @property + def api_key(self): + """ + :rtype: str + """ + + return self._api_key + + @property + def user(self): + """ + :rtype: User + """ + + return self._user + + @property + def login_code(self): + """ + :rtype: str + """ + + return self._login_code + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._api_key is not None: + return False + + if self._user is not None: + return False + + if self._login_code is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: SandboxUserPersonApiObject + """ + + return converter.json_to_class(SandboxUserPersonApiObject, json_str) + + +class ScheduleUserApiObject(BunqModel): + """ + view for reading the scheduled definitions. + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/schedule" + + # Object type. + _OBJECT_TYPE_GET = "ScheduleUser" + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Get a collection of scheduled definition for all accessible monetary + accounts of the user. You can add the parameter type to filter the + response. When + type={SCHEDULE_DEFINITION_PAYMENT,SCHEDULE_DEFINITION_PAYMENT_BATCH} is + provided only schedule definition object that relate to these + definitions are returned. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseScheduleUserList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseScheduleUserList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + + def is_all_field_none(self): + """ + :rtype: bool + """ + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ScheduleUserApiObject + """ + + return converter.json_to_class(ScheduleUserApiObject, json_str) + + +class SessionApiObject(BunqModel): + """ + Endpoint for operations over the current session. + """ + + # Endpoint constants. + _ENDPOINT_URL_DELETE = "session/{}" + + + @classmethod + def delete(cls, session_id, custom_headers=None): + """ + Deletes the current session. + + :type session_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(session_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + + def is_all_field_none(self): + """ + :rtype: bool + """ + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: SessionApiObject + """ + + return converter.json_to_class(SessionApiObject, json_str) + + +class TokenQrRequestIdealApiObject(BunqModel): + """ + Using this call you create a request for payment from an external token + provided with an ideal transaction. Make sure your iDEAL payments are + compliant with the iDEAL standards, by following the following manual: + https://www.bunq.com/terms-idealstandards. It's very important to keep these + points in mind when you are using the endpoint to make iDEAL payments from + your application. + + :param _token: The token passed from a site or read from a QR code. + :type _token: str + :param _id_: The id of the RequestResponse. + :type _id_: int + :param _time_responded: The timestamp of when the RequestResponse was + responded to. + :type _time_responded: str + :param _time_expiry: The timestamp of when the RequestResponse expired or + will expire. + :type _time_expiry: str + :param _monetary_account_id: The id of the MonetaryAccount the + RequestResponse was received on. + :type _monetary_account_id: int + :param _amount_inquired: The requested Amount. + :type _amount_inquired: object_.Amount + :param _amount_responded: The Amount the RequestResponse was accepted with. + :type _amount_responded: object_.Amount + :param _alias: The LabelMonetaryAccount with the public information of the + MonetaryAccount this RequestResponse was received on. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The LabelMonetaryAccount with the public + information of the MonetaryAccount that is requesting money with this + RequestResponse. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description for the RequestResponse provided by the + requesting party. Maximum 9000 characters. + :type _description: str + :param _attachment: The Attachments attached to the RequestResponse. + :type _attachment: list[object_.Attachment] + :param _status: The status of the created RequestResponse. Can only be + PENDING. + :type _status: str + :param _minimum_age: The minimum age the user accepting the RequestResponse + must have. + :type _minimum_age: int + :param _require_address: Whether or not an address must be provided on + accept. + :type _require_address: str + :param _address_shipping: The shipping address provided by the accepting + user if an address was requested. + :type _address_shipping: object_.Address + :param _address_billing: The billing address provided by the accepting user + if an address was requested. + :type _address_billing: object_.Address + :param _geolocation: The Geolocation where the RequestResponse was created. + :type _geolocation: object_.Geolocation + :param _redirect_url: The URL which the user is sent to after accepting or + rejecting the Request. + :type _redirect_url: str + :param _type_: The type of the RequestResponse. Can be only be IDEAL. + :type _type_: str + :param _sub_type: The subtype of the RequestResponse. Can be only be NONE. + :type _sub_type: str + :param _eligible_whitelist_id: The whitelist id for this action or null. + :type _eligible_whitelist_id: int + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/token-qr-request-ideal" + + # Field constants. + FIELD_TOKEN = "token" + + # Object type. + _OBJECT_TYPE_POST = "RequestResponse" + + _id_ = None + _time_responded = None + _time_expiry = None + _monetary_account_id = None + _amount_inquired = None + _amount_responded = None + _alias = None + _counterparty_alias = None + _description = None + _attachment = None + _status = None + _minimum_age = None + _require_address = None + _address_shipping = None + _address_billing = None + _geolocation = None + _redirect_url = None + _type_ = None + _sub_type = None + _eligible_whitelist_id = None + _token_field_for_request = None + + def __init__(self, token): + """ + :param token: The token passed from a site or read from a QR code. + :type token: str + """ + + self._token_field_for_request = token + + @classmethod + def create(cls,token, custom_headers=None): + """ + Create a request from an ideal transaction. + + :type user_id: int + :param token: The token passed from a site or read from a QR code. + :type token: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTokenQrRequestIdeal + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_TOKEN : token +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseTokenQrRequestIdeal.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def time_responded(self): + """ + :rtype: str + """ + + return self._time_responded + + @property + def time_expiry(self): + """ + :rtype: str + """ + + return self._time_expiry + + @property + def monetary_account_id(self): + """ + :rtype: int + """ + + return self._monetary_account_id + + @property + def amount_inquired(self): + """ + :rtype: object_.Amount + """ + + return self._amount_inquired + + @property + def amount_responded(self): + """ + :rtype: object_.Amount + """ + + return self._amount_responded + + @property + def alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._alias + + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[object_.Attachment] + """ + + return self._attachment + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def minimum_age(self): + """ + :rtype: int + """ + + return self._minimum_age + + @property + def require_address(self): + """ + :rtype: str + """ + + return self._require_address + + @property + def address_shipping(self): + """ + :rtype: object_.Address + """ + + return self._address_shipping + + @property + def address_billing(self): + """ + :rtype: object_.Address + """ + + return self._address_billing + + @property + def geolocation(self): + """ + :rtype: object_.Geolocation + """ + + return self._geolocation + + @property + def redirect_url(self): + """ + :rtype: str + """ + + return self._redirect_url + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def sub_type(self): + """ + :rtype: str + """ + + return self._sub_type + + @property + def eligible_whitelist_id(self): + """ + :rtype: int + """ + + return self._eligible_whitelist_id + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._time_responded is not None: + return False + + if self._time_expiry is not None: + return False + + if self._monetary_account_id is not None: + return False + + if self._amount_inquired is not None: + return False + + if self._amount_responded is not None: + return False + + if self._alias is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + if self._status is not None: + return False + + if self._minimum_age is not None: + return False + + if self._require_address is not None: + return False + + if self._address_shipping is not None: + return False + + if self._address_billing is not None: + return False + + if self._geolocation is not None: + return False + + if self._redirect_url is not None: + return False + + if self._type_ is not None: + return False + + if self._sub_type is not None: + return False + + if self._eligible_whitelist_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TokenQrRequestIdealApiObject + """ + + return converter.json_to_class(TokenQrRequestIdealApiObject, json_str) + + +class TokenQrRequestSofortApiObject(BunqModel): + """ + Using this call you can create a SOFORT Request assigned to your User by + providing the Token of the request. + + :param _token: The token passed from a site or read from a QR code. + :type _token: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/token-qr-request-sofort" + + # Field constants. + FIELD_TOKEN = "token" + + # Object type. + _OBJECT_TYPE_POST = "RequestResponse" + + _token_field_for_request = None + + def __init__(self, token): + """ + :param token: The token passed from a site or read from a QR code. + :type token: str + """ + + self._token_field_for_request = token + + @classmethod + def create(cls,token, custom_headers=None): + """ + Create a request from an SOFORT transaction. + + :type user_id: int + :param token: The token passed from a site or read from a QR code. + :type token: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTokenQrRequestSofort + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_TOKEN : token +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseTokenQrRequestSofort.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_POST) + ) + + + def is_all_field_none(self): + """ + :rtype: bool + """ + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TokenQrRequestSofortApiObject + """ + + return converter.json_to_class(TokenQrRequestSofortApiObject, json_str) + + +class TransferwiseAccountQuoteApiObject(BunqModel): + """ + Used to manage recipient accounts with Transferwise. + + :param _country: The country of the account. + :type _country: str + :param _name_account_holder: The name of the account holder. + :type _name_account_holder: str + :param _type_: The chosen recipient account type. The possible options are + provided dynamically in the response endpoint. + :type _type_: str + :param _detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type _detail: list[object_.TransferwiseRequirementField] + :param _account_id: Transferwise's id of the account. + :type _account_id: str + :param _currency: The currency the account. + :type _currency: str + :param _account_number: The account number. + :type _account_number: str + :param _bank_code: The bank code. + :type _bank_code: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote/{}/transferwise-recipient" + _ENDPOINT_URL_READ = "user/{}/transferwise-quote/{}/transferwise-recipient/{}" + _ENDPOINT_URL_LISTING = "user/{}/transferwise-quote/{}/transferwise-recipient" + _ENDPOINT_URL_DELETE = "user/{}/transferwise-quote/{}/transferwise-recipient/{}" + + # Field constants. + FIELD_COUNTRY = "country" + FIELD_NAME_ACCOUNT_HOLDER = "name_account_holder" + FIELD_TYPE = "type" + FIELD_DETAIL = "detail" + + # Object type. + _OBJECT_TYPE_GET = "TransferwiseRecipient" + + _account_id = None + _currency = None + _country = None + _name_account_holder = None + _account_number = None + _bank_code = None + _country_field_for_request = None + _name_account_holder_field_for_request = None + _type__field_for_request = None + _detail_field_for_request = None + + def __init__(self, name_account_holder, type_, country=None, detail=None): + """ + :param name_account_holder: The name of the account holder. + :type name_account_holder: str + :param type_: The chosen recipient account type. The possible options are + provided dynamically in the response endpoint. + :type type_: str + :param country: The country of the receiving account. + :type country: str + :param detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] + """ + + self._name_account_holder_field_for_request = name_account_holder + self._type__field_for_request = type_ + self._country_field_for_request = country + self._detail_field_for_request = detail + + @classmethod + def create(cls,transferwise_quote_id, name_account_holder, type_, country=None, detail=None, custom_headers=None): + """ + :type user_id: int + :type transferwise_quote_id: int + :param name_account_holder: The name of the account holder. + :type name_account_holder: str + :param type_: The chosen recipient account type. The possible options + are provided dynamically in the response endpoint. + :type type_: str + :param country: The country of the receiving account. + :type country: str + :param detail: The fields which were specified as "required" and have + since been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_COUNTRY : country, +cls.FIELD_NAME_ACCOUNT_HOLDER : name_account_holder, +cls.FIELD_TYPE : type_, +cls.FIELD_DETAIL : detail +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def get(cls, transferwise_quote_id, transferwise_account_quote_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type transferwise_quote_id: int + :type transferwise_account_quote_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseAccountQuote + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), transferwise_quote_id, transferwise_account_quote_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseTransferwiseAccountQuote.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def list(cls,transferwise_quote_id, params=None, custom_headers=None): + """ + :type user_id: int + :type transferwise_quote_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseAccountQuoteList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseTransferwiseAccountQuoteList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def delete(cls, transferwise_quote_id, transferwise_account_quote_id, custom_headers=None): + """ + :type user_id: int + :type transferwise_quote_id: int + :type transferwise_account_quote_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), transferwise_quote_id, transferwise_account_quote_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @property + def account_id(self): + """ + :rtype: str + """ + + return self._account_id + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def country(self): + """ + :rtype: str + """ + + return self._country + + @property + def name_account_holder(self): + """ + :rtype: str + """ + + return self._name_account_holder + + @property + def account_number(self): + """ + :rtype: str + """ + + return self._account_number + + @property + def bank_code(self): + """ + :rtype: str + """ + + return self._bank_code + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._account_id is not None: + return False + + if self._currency is not None: + return False + + if self._country is not None: + return False + + if self._name_account_holder is not None: + return False + + if self._account_number is not None: + return False + + if self._bank_code is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TransferwiseAccountQuoteApiObject + """ + + return converter.json_to_class(TransferwiseAccountQuoteApiObject, json_str) + + +class TransferwiseAccountRequirementApiObject(BunqModel): + """ + Used to determine the recipient account requirements for Transferwise + transfers. + + :param _country: The country of the receiving account. + :type _country: str + :param _name_account_holder: The name of the account holder. + :type _name_account_holder: str + :param _type_: A possible recipient account type. + :type _type_: str + :param _detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type _detail: list[object_.TransferwiseRequirementField] + :param _label: The label of the possible recipient account type to show to + the user. + :type _label: str + :param _fields: The fields which the user needs to fill. + :type _fields: list[object_.TransferwiseRequirementField] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote/{}/transferwise-recipient-requirement" + _ENDPOINT_URL_LISTING = "user/{}/transferwise-quote/{}/transferwise-recipient-requirement" + + # Field constants. + FIELD_COUNTRY = "country" + FIELD_NAME_ACCOUNT_HOLDER = "name_account_holder" + FIELD_TYPE = "type" + FIELD_DETAIL = "detail" + + # Object type. + _OBJECT_TYPE_GET = "TransferwiseRequirement" + + _type_ = None + _label = None + _fields = None + _country_field_for_request = None + _name_account_holder_field_for_request = None + _type__field_for_request = None + _detail_field_for_request = None + + def __init__(self, name_account_holder, type_, country=None, detail=None): + """ + :param name_account_holder: The name of the account holder. + :type name_account_holder: str + :param type_: The chosen recipient account type. The possible options are + provided dynamically in the response endpoint. + :type type_: str + :param country: The country of the receiving account. + :type country: str + :param detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] + """ + + self._name_account_holder_field_for_request = name_account_holder + self._type__field_for_request = type_ + self._country_field_for_request = country + self._detail_field_for_request = detail + + @classmethod + def create(cls,transferwise_quote_id, name_account_holder, type_, country=None, detail=None, custom_headers=None): + """ + :type user_id: int + :type transferwise_quote_id: int + :param name_account_holder: The name of the account holder. + :type name_account_holder: str + :param type_: The chosen recipient account type. The possible options + are provided dynamically in the response endpoint. + :type type_: str + :param country: The country of the receiving account. + :type country: str + :param detail: The fields which were specified as "required" and have + since been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt + """ + + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_COUNTRY : country, +cls.FIELD_NAME_ACCOUNT_HOLDER : name_account_holder, +cls.FIELD_TYPE : type_, +cls.FIELD_DETAIL : detail +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls,transferwise_quote_id, params=None, custom_headers=None): + """ + :type user_id: int + :type transferwise_quote_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseAccountRequirementList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseTransferwiseAccountRequirementList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def label(self): + """ + :rtype: str + """ + + return self._label + + @property + def fields(self): + """ + :rtype: list[object_.TransferwiseRequirementField] + """ + + return self._fields + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._type_ is not None: + return False + + if self._label is not None: + return False + + if self._fields is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TransferwiseAccountRequirementApiObject + """ + + return converter.json_to_class(TransferwiseAccountRequirementApiObject, json_str) + + +class TransferwiseCurrencyApiObject(BunqModel): + """ + Used to get a list of supported currencies for Transferwise. + + :param _currency: The currency code. + :type _currency: str + :param _name: The currency name. + :type _name: str + :param _country: The country code associated with the currency. + :type _country: str + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/transferwise-currency" + + # Object type. + _OBJECT_TYPE_GET = "TransferwiseCurrency" + + _currency = None + _name = None + _country = None + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseCurrencyList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseTransferwiseCurrencyList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def name(self): + """ + :rtype: str + """ + + return self._name + + @property + def country(self): + """ + :rtype: str + """ + + return self._country + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._currency is not None: + return False + + if self._name is not None: + return False + + if self._country is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - Get a specific person. - - :type api_context: context.ApiContext - :type user_person_id: int - :type custom_headers: dict[str, str]|None + :type json_str: str - :rtype: BunqResponseUserPerson + :rtype: TransferwiseCurrencyApiObject """ - if custom_headers is None: - custom_headers = {} + return converter.json_to_class(TransferwiseCurrencyApiObject, json_str) - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseUserPerson.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) +class TransferwiseQuoteTemporaryApiObject(BunqModel): + """ + Used to get temporary quotes from Transferwise. These cannot be used to + initiate payments + + :param _currency_source: The source currency. + :type _currency_source: str + :param _currency_target: The target currency. + :type _currency_target: str + :param _amount_source: The source amount. + :type _amount_source: object_.Amount + :param _amount_target: The target amount. + :type _amount_target: object_.Amount + :param _id_: The id of the quote. + :type _id_: int + :param _created: The timestamp of the note's creation. + :type _created: str + :param _updated: The timestamp of the note's last update. + :type _updated: str + :param _time_expiry: The expiration timestamp of the quote. Will always be + null for temporary quotes. + :type _time_expiry: str + :param _quote_id: The quote id Transferwise needs. Will always be null for + temporary quotes. + :type _quote_id: str + :param _rate: The rate. + :type _rate: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote-temporary" + _ENDPOINT_URL_READ = "user/{}/transferwise-quote-temporary/{}" + + # Field constants. + FIELD_CURRENCY_SOURCE = "currency_source" + FIELD_CURRENCY_TARGET = "currency_target" + FIELD_AMOUNT_SOURCE = "amount_source" + FIELD_AMOUNT_TARGET = "amount_target" + + # Object type. + _OBJECT_TYPE_GET = "TransferwiseQuote" + + _id_ = None + _created = None + _updated = None + _time_expiry = None + _quote_id = None + _amount_source = None + _amount_target = None + _rate = None + _currency_source_field_for_request = None + _currency_target_field_for_request = None + _amount_source_field_for_request = None + _amount_target_field_for_request = None + + def __init__(self, currency_source, currency_target, amount_source=None, amount_target=None): + """ + :param currency_source: The source currency. + :type currency_source: str + :param currency_target: The target currency. + :type currency_target: str + :param amount_source: The source amount. Required if target amount is left + empty. + :type amount_source: object_.Amount + :param amount_target: The target amount. Required if source amount is left + empty. + :type amount_target: object_.Amount + """ + + self._currency_source_field_for_request = currency_source + self._currency_target_field_for_request = currency_target + self._amount_source_field_for_request = amount_source + self._amount_target_field_for_request = amount_target @classmethod - def update(cls, first_name=None, middle_name=None, last_name=None, - public_nick_name=None, address_main=None, address_postal=None, - avatar_uuid=None, tax_resident=None, document_type=None, - document_number=None, document_country_of_issuance=None, - document_front_attachment_id=None, - document_back_attachment_id=None, date_of_birth=None, - place_of_birth=None, country_of_birth=None, nationality=None, - language=None, region=None, gender=None, status=None, - sub_status=None, legal_guardian_alias=None, session_timeout=None, - card_ids=None, card_limits=None, - daily_limit_without_confirmation_login=None, - notification_filters=None, custom_headers=None): + def create(cls,currency_source, currency_target, amount_source=None, amount_target=None, custom_headers=None): """ - Modify a specific person object's data. - - :type user_person_id: int - :param first_name: The person's first name. - :type first_name: str - :param middle_name: The person's middle name. - :type middle_name: str - :param last_name: The person's last name. - :type last_name: str - :param public_nick_name: The person's public nick name. - :type public_nick_name: str - :param address_main: The user's main address. - :type address_main: object_.Address - :param address_postal: The person's postal address. - :type address_postal: object_.Address - :param avatar_uuid: The public UUID of the user's avatar. - :type avatar_uuid: str - :param tax_resident: The user's tax residence numbers for different - countries. - :type tax_resident: list[object_.TaxResident] - :param document_type: The type of identification document the person - registered with. - :type document_type: str - :param document_number: The identification document number the person - registered with. - :type document_number: str - :param document_country_of_issuance: The country which issued the - identification document the person registered with. - :type document_country_of_issuance: str - :param document_front_attachment_id: The reference to the uploaded - picture/scan of the front side of the identification document. - :type document_front_attachment_id: int - :param document_back_attachment_id: The reference to the uploaded - picture/scan of the back side of the identification document. - :type document_back_attachment_id: int - :param date_of_birth: The person's date of birth. Accepts ISO8601 date - formats. - :type date_of_birth: str - :param place_of_birth: The person's place of birth. - :type place_of_birth: str - :param country_of_birth: The person's country of birth. Formatted as a - SO 3166-1 alpha-2 country code. - :type country_of_birth: str - :param nationality: The person's nationality. Formatted as a SO 3166-1 - alpha-2 country code. - :type nationality: str - :param language: The person's preferred language. Formatted as a ISO - 639-1 language code plus a ISO 3166-1 alpha-2 country code, seperated by - an underscore. - :type language: str - :param region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type region: str - :param gender: The person's gender. Can be: MALE, FEMALE and UNKNOWN. - :type gender: str - :param status: The user status. You are not allowed to update the status - via PUT. - :type status: str - :param sub_status: The user sub-status. Can be updated to SUBMIT if - status is RECOVERY. - :type sub_status: str - :param legal_guardian_alias: The legal guardian of the user. Required - for minors. - :type legal_guardian_alias: object_.Pointer - :param session_timeout: The setting for the session timeout of the user - in seconds. - :type session_timeout: int - :param card_ids: Card ids used for centralized card limits. - :type card_ids: list[object_.BunqId] - :param card_limits: The centralized limits for user's cards. - :type card_limits: list[object_.CardLimit] - :param daily_limit_without_confirmation_login: The amount the user can - pay in the session without asking for credentials. - :type daily_limit_without_confirmation_login: object_.Amount - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this UserPerson. - :type notification_filters: list[object_.NotificationFilter] + :type user_id: int + :param currency_source: The source currency. + :type currency_source: str + :param currency_target: The target currency. + :type currency_target: str + :param amount_source: The source amount. Required if target amount is + left empty. + :type amount_source: object_.Amount + :param amount_target: The target amount. Required if source amount is + left empty. + :type amount_target: object_.Amount :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -25010,50 +45001,46 @@ def update(cls, first_name=None, middle_name=None, last_name=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - request_map = { - cls.FIELD_FIRST_NAME: first_name, - cls.FIELD_MIDDLE_NAME: middle_name, - cls.FIELD_LAST_NAME: last_name, - cls.FIELD_PUBLIC_NICK_NAME: public_nick_name, - cls.FIELD_ADDRESS_MAIN: address_main, - cls.FIELD_ADDRESS_POSTAL: address_postal, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_TAX_RESIDENT: tax_resident, - cls.FIELD_DOCUMENT_TYPE: document_type, - cls.FIELD_DOCUMENT_NUMBER: document_number, - cls.FIELD_DOCUMENT_COUNTRY_OF_ISSUANCE: document_country_of_issuance, - cls.FIELD_DOCUMENT_FRONT_ATTACHMENT_ID: document_front_attachment_id, - cls.FIELD_DOCUMENT_BACK_ATTACHMENT_ID: document_back_attachment_id, - cls.FIELD_DATE_OF_BIRTH: date_of_birth, - cls.FIELD_PLACE_OF_BIRTH: place_of_birth, - cls.FIELD_COUNTRY_OF_BIRTH: country_of_birth, - cls.FIELD_NATIONALITY: nationality, - cls.FIELD_LANGUAGE: language, - cls.FIELD_REGION: region, - cls.FIELD_GENDER: gender, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_LEGAL_GUARDIAN_ALIAS: legal_guardian_alias, - cls.FIELD_SESSION_TIMEOUT: session_timeout, - cls.FIELD_CARD_IDS: card_ids, - cls.FIELD_CARD_LIMITS: card_limits, - cls.FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN: daily_limit_without_confirmation_login, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters - } +cls.FIELD_CURRENCY_SOURCE : currency_source, +cls.FIELD_CURRENCY_TARGET : currency_target, +cls.FIELD_AMOUNT_SOURCE : amount_source, +cls.FIELD_AMOUNT_TARGET : amount_target +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) + api_client = ApiClient(cls._get_api_context()) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id()) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) + @classmethod + def get(cls, transferwise_quote_temporary_id, custom_headers=None): + """ + :type api_context: ApiContext + :type user_id: int + :type transferwise_quote_temporary_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseQuoteTemporary + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), transferwise_quote_temporary_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseTransferwiseQuoteTemporary.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + @property def id_(self): """ @@ -25079,228 +45066,364 @@ def updated(self): return self._updated @property - def public_uuid(self): + def time_expiry(self): """ :rtype: str """ - return self._public_uuid + return self._time_expiry @property - def first_name(self): + def quote_id(self): """ :rtype: str """ - return self._first_name + return self._quote_id @property - def middle_name(self): + def amount_source(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._middle_name + return self._amount_source @property - def last_name(self): + def amount_target(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._last_name + return self._amount_target @property - def legal_name(self): + def rate(self): """ :rtype: str """ - return self._legal_name + return self._rate - @property - def display_name(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._display_name + if self._id_ is not None: + return False - @property - def public_nick_name(self): - """ - :rtype: str - """ + if self._created is not None: + return False - return self._public_nick_name + if self._updated is not None: + return False - @property - def alias(self): - """ - :rtype: list[object_.Pointer] - """ + if self._time_expiry is not None: + return False - return self._alias + if self._quote_id is not None: + return False - @property - def tax_resident(self): - """ - :rtype: list[object_.TaxResident] - """ + if self._amount_source is not None: + return False - return self._tax_resident + if self._amount_target is not None: + return False - @property - def document_type(self): - """ - :rtype: str - """ + if self._rate is not None: + return False - return self._document_type + return True - @property - def document_number(self): + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: TransferwiseQuoteTemporaryApiObject """ - return self._document_number + return converter.json_to_class(TransferwiseQuoteTemporaryApiObject, json_str) - @property - def document_country_of_issuance(self): - """ - :rtype: str - """ - return self._document_country_of_issuance +class TransferwiseTransferRequirementApiObject(BunqModel): + """ + Used to determine the account requirements for Transferwise transfers. + + :param _recipient_id: The id of the target account. + :type _recipient_id: str + :param _detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type _detail: list[object_.TransferwiseRequirementField] + :param _type_: A possible transfer type. + :type _type_: str + :param _label: The label of the possible transfer type to show to the user. + :type _label: str + :param _fields: The fields which the user needs to fill. + :type _fields: list[object_.TransferwiseRequirementField] + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-quote/{}/transferwise-transfer-requirement" - @property - def address_main(self): + # Field constants. + FIELD_RECIPIENT_ID = "recipient_id" + FIELD_DETAIL = "detail" + + + _type_ = None + _label = None + _fields = None + _recipient_id_field_for_request = None + _detail_field_for_request = None + + def __init__(self, recipient_id, detail=None): """ - :rtype: object_.Address + :param recipient_id: The id of the target account. + :type recipient_id: str + :param detail: The fields which were specified as "required" and have since + been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] """ - return self._address_main + self._recipient_id_field_for_request = recipient_id + self._detail_field_for_request = detail - @property - def address_postal(self): + @classmethod + def create(cls,transferwise_quote_id, recipient_id, detail=None, custom_headers=None): """ - :rtype: object_.Address + :type user_id: int + :type transferwise_quote_id: int + :param recipient_id: The id of the target account. + :type recipient_id: str + :param detail: The fields which were specified as "required" and have + since been filled by the user. Always provide the full list. + :type detail: list[object_.TransferwiseRequirementField] + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._address_postal + if custom_headers is None: + custom_headers = {} + + request_map = { +cls.FIELD_RECIPIENT_ID : recipient_id, +cls.FIELD_DETAIL : detail +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), transferwise_quote_id) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) @property - def date_of_birth(self): + def type_(self): """ :rtype: str """ - return self._date_of_birth + return self._type_ @property - def place_of_birth(self): + def label(self): """ :rtype: str """ - return self._place_of_birth + return self._label @property - def country_of_birth(self): + def fields(self): """ - :rtype: str + :rtype: list[object_.TransferwiseRequirementField] """ - return self._country_of_birth + return self._fields - @property - def nationality(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._nationality + if self._type_ is not None: + return False - @property - def language(self): + if self._label is not None: + return False + + if self._fields is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: TransferwiseTransferRequirementApiObject """ - return self._language + return converter.json_to_class(TransferwiseTransferRequirementApiObject, json_str) - @property - def region(self): + +class TransferwiseUserApiObject(BunqModel): + """ + Used to manage Transferwise users. + + :param _oauth_code: The OAuth code returned by Transferwise we should be + using to gain access to the user's Transferwise account. + :type _oauth_code: str + :param _id_: The id of the TransferwiseUser. + :type _id_: int + :param _created: The timestamp of the TransferwiseUser's creation. + :type _created: str + :param _updated: The timestamp of the TransferwiseUser's last update. + :type _updated: str + :param _name: The name the user is registered with at TransferWise. + :type _name: str + :param _email: The email the user is registered with at TransferWise. + :type _email: str + :param _source: The source of the user at TransferWise. + :type _source: str + """ + + # Endpoint constants. + _ENDPOINT_URL_CREATE = "user/{}/transferwise-user" + _ENDPOINT_URL_LISTING = "user/{}/transferwise-user" + + # Field constants. + FIELD_OAUTH_CODE = "oauth_code" + + # Object type. + _OBJECT_TYPE_GET = "TransferwiseUser" + + _id_ = None + _created = None + _updated = None + _name = None + _email = None + _source = None + _oauth_code_field_for_request = None + + def __init__(self, oauth_code=None): """ - :rtype: str + :param oauth_code: The OAuth code returned by Transferwise we should be + using to gain access to the user's Transferwise account. + :type oauth_code: str """ - return self._region + self._oauth_code_field_for_request = oauth_code - @property - def gender(self): + @classmethod + def create(cls,oauth_code=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :param oauth_code: The OAuth code returned by Transferwise we should be + using to gain access to the user's Transferwise account. + :type oauth_code: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._gender + if custom_headers is None: + custom_headers = {} - @property - def avatar(self): + request_map = { +cls.FIELD_OAUTH_CODE : oauth_code +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): """ - :rtype: object_.Avatar + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTransferwiseUserList """ - return self._avatar + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseTransferwiseUserList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def version_terms_of_service(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._version_terms_of_service + return self._id_ @property - def status(self): + def created(self): """ :rtype: str """ - return self._status + return self._created @property - def sub_status(self): + def updated(self): """ :rtype: str """ - return self._sub_status + return self._updated @property - def session_timeout(self): + def name(self): """ - :rtype: int + :rtype: str """ - return self._session_timeout + return self._name @property - def daily_limit_without_confirmation_login(self): + def email(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._daily_limit_without_confirmation_login + return self._email @property - def notification_filters(self): + def source(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: str """ - return self._notification_filters + return self._source def is_all_field_none(self): """ @@ -25316,88 +45439,125 @@ def is_all_field_none(self): if self._updated is not None: return False - if self._public_uuid is not None: + if self._name is not None: return False - if self._first_name is not None: + if self._email is not None: return False - if self._middle_name is not None: + if self._source is not None: return False - if self._last_name is not None: - return False + return True - if self._legal_name is not None: - return False + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TransferwiseUserApiObject + """ - if self._display_name is not None: - return False + return converter.json_to_class(TransferwiseUserApiObject, json_str) - if self._public_nick_name is not None: - return False - if self._alias is not None: - return False +class TreeProgressApiObject(BunqModel): + """ + See how many trees this user has planted. + + :param _number_of_tree: The number of trees this user and all users have + planted. + :type _number_of_tree: float + :param _progress_tree_next: The progress towards the next tree. + :type _progress_tree_next: float + :param _url_invite_profile: URL of the invite profile. + :type _url_invite_profile: str + :param _label_user: The label of the user the progress belongs to. + :type _label_user: object_.LabelUser + """ - if self._tax_resident is not None: - return False + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/tree-progress" - if self._document_type is not None: - return False + # Object type. + _OBJECT_TYPE_GET = "TreeProgress" - if self._document_number is not None: - return False + _number_of_tree = None + _progress_tree_next = None + _url_invite_profile = None + _label_user = None - if self._document_country_of_issuance is not None: - return False + @classmethod + def list(cls, params=None, custom_headers=None): + """ + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseTreeProgressList + """ - if self._address_main is not None: - return False + if params is None: + params = {} - if self._address_postal is not None: - return False + if custom_headers is None: + custom_headers = {} - if self._date_of_birth is not None: - return False + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) - if self._place_of_birth is not None: - return False + return BunqResponseTreeProgressList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) - if self._country_of_birth is not None: - return False + @property + def number_of_tree(self): + """ + :rtype: float + """ - if self._nationality is not None: - return False + return self._number_of_tree - if self._language is not None: - return False + @property + def progress_tree_next(self): + """ + :rtype: float + """ - if self._region is not None: - return False + return self._progress_tree_next - if self._gender is not None: - return False + @property + def url_invite_profile(self): + """ + :rtype: str + """ - if self._avatar is not None: - return False + return self._url_invite_profile - if self._version_terms_of_service is not None: - return False + @property + def label_user(self): + """ + :rtype: object_.LabelUser + """ - if self._status is not None: - return False + return self._label_user - if self._sub_status is not None: + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._number_of_tree is not None: return False - if self._session_timeout is not None: + if self._progress_tree_next is not None: return False - if self._daily_limit_without_confirmation_login is not None: + if self._url_invite_profile is not None: return False - if self._notification_filters is not None: + if self._label_user is not None: return False return True @@ -25407,348 +45567,167 @@ def from_json(json_str): """ :type json_str: str - :rtype: UserPerson + :rtype: TreeProgressApiObject """ - return converter.json_to_class(UserPerson, json_str) + return converter.json_to_class(TreeProgressApiObject, json_str) -class UserCompany(core.BunqModel): +class UserCompanyNameApiObject(BunqModel): """ - With UserCompany you can retrieve information regarding the authenticated - UserCompany and update specific fields.

Notification filters can be - set on a UserCompany level to receive callbacks. For more information check - the dedicated callbacks page. + Endpoint for getting all the known (trade) names for a user company. This is + needed for updating the user name, as we only accept legal or trade names. - :param _name: The company name. - :type _name: str - :param _public_nick_name: The company's public nick name. - :type _public_nick_name: str - :param _avatar_uuid: The public UUID of the company's avatar. - :type _avatar_uuid: str - :param _address_main: The company's main address. - :type _address_main: object_.Address - :param _address_postal: The company's postal address. - :type _address_postal: object_.Address - :param _language: The person's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _language: str - :param _region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type _region: str - :param _country: The country as an ISO 3166-1 alpha-2 country code.. - :type _country: str - :param _ubo: The names of the company's ultimate beneficiary owners. Minimum - zero, maximum four. - :type _ubo: list[object_.Ubo] - :param _chamber_of_commerce_number: The company's chamber of commerce - number. - :type _chamber_of_commerce_number: str - :param _status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. - :type _status: str - :param _sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, - APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or - SUBMIT. - :type _sub_status: str - :param _session_timeout: The setting for the session timeout of the company - in seconds. - :type _session_timeout: int - :param _daily_limit_without_confirmation_login: The amount the company can - pay in the session without asking for credentials. - :type _daily_limit_without_confirmation_login: object_.Amount - :param _notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserCompany. - :type _notification_filters: list[object_.NotificationFilter] - :param _id_: The id of the modified company. + :param _name_array: All known (trade) names for a user company. + :type _name_array: list[str] + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user-company/{}/name" + + # Object type. + _OBJECT_TYPE_GET = "UserCompanyNameArray" + + _name_array = None + + @classmethod + def list(cls,user_company_id, params=None, custom_headers=None): + """ + Return all the known (trade) names for a specific user company. + + :type user_company_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUserCompanyNameList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseUserCompanyNameList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + + @property + def name_array(self): + """ + :rtype: list[str] + """ + + return self._name_array + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._name_array is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: UserCompanyNameApiObject + """ + + return converter.json_to_class(UserCompanyNameApiObject, json_str) + + +class UserCredentialPasswordIpApiObject(BunqModel): + """ + Create a credential of a user for server authentication, or delete the + credential of a user for server authentication. + + :param _id_: The id of the credential. :type _id_: int - :param _created: The timestamp of the company object's creation. + :param _created: The timestamp of the credential object's creation. :type _created: str - :param _updated: The timestamp of the company object's last update. + :param _updated: The timestamp of the credential object's last update. :type _updated: str - :param _public_uuid: The company's public UUID. - :type _public_uuid: str - :param _display_name: The company's display name. - :type _display_name: str - :param _alias: The aliases of the account. - :type _alias: list[object_.Pointer] - :param _type_of_business_entity: The type of business entity. - :type _type_of_business_entity: str - :param _sector_of_industry: The sector of industry. - :type _sector_of_industry: str - :param _counter_bank_iban: The company's other bank account IBAN, through - which we verify it. - :type _counter_bank_iban: str - :param _avatar: The company's avatar. - :type _avatar: object_.Avatar - :param _version_terms_of_service: The version of the terms of service - accepted by the user. - :type _version_terms_of_service: str - :param _director_alias: The existing bunq user alias for the company's - director. - :type _director_alias: object_.LabelUser - :param _card_ids: Card ids used for centralized card limits. - :type _card_ids: list[object_.BunqId] - :param _card_limits: The centralized limits for user's cards. - :type _card_limits: list[object_.CardLimit] - :param _customer: The customer profile of the company. - :type _customer: Customer - :param _customer_limit: The customer limits of the company. - :type _customer_limit: CustomerLimit - :param _billing_contract: The subscription of the company. - :type _billing_contract: list[BillingContractSubscription] + :param _status: The status of the credential. + :type _status: str + :param _expiry_time: When the status is PENDING_FIRST_USE: when the + credential expires. + :type _expiry_time: str + :param _token_value: When the status is PENDING_FIRST_USE: the value of the + token. + :type _token_value: str + :param _permitted_device: When the status is ACTIVE: the details of the + device that may use the credential. + :type _permitted_device: object_.PermittedDevice """ # Endpoint constants. - _ENDPOINT_URL_READ = "user-company/{}" - _ENDPOINT_URL_UPDATE = "user-company/{}" - - # Field constants. - FIELD_NAME = "name" - FIELD_PUBLIC_NICK_NAME = "public_nick_name" - FIELD_AVATAR_UUID = "avatar_uuid" - FIELD_ADDRESS_MAIN = "address_main" - FIELD_ADDRESS_POSTAL = "address_postal" - FIELD_LANGUAGE = "language" - FIELD_REGION = "region" - FIELD_COUNTRY = "country" - FIELD_UBO = "ubo" - FIELD_CHAMBER_OF_COMMERCE_NUMBER = "chamber_of_commerce_number" - FIELD_STATUS = "status" - FIELD_SUB_STATUS = "sub_status" - FIELD_SESSION_TIMEOUT = "session_timeout" - FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login" - FIELD_NOTIFICATION_FILTERS = "notification_filters" + _ENDPOINT_URL_READ = "user/{}/credential-password-ip/{}" + _ENDPOINT_URL_LISTING = "user/{}/credential-password-ip" # Object type. - _OBJECT_TYPE_GET = "UserCompany" + _OBJECT_TYPE_GET = "CredentialPasswordIp" _id_ = None _created = None _updated = None - _public_uuid = None - _name = None - _display_name = None - _public_nick_name = None - _alias = None - _chamber_of_commerce_number = None - _type_of_business_entity = None - _sector_of_industry = None - _counter_bank_iban = None - _avatar = None - _address_main = None - _address_postal = None - _version_terms_of_service = None - _director_alias = None - _language = None - _country = None - _region = None - _ubo = None _status = None - _sub_status = None - _session_timeout = None - _card_ids = None - _card_limits = None - _daily_limit_without_confirmation_login = None - _notification_filters = None - _customer = None - _customer_limit = None - _billing_contract = None - _name_field_for_request = None - _public_nick_name_field_for_request = None - _avatar_uuid_field_for_request = None - _address_main_field_for_request = None - _address_postal_field_for_request = None - _language_field_for_request = None - _region_field_for_request = None - _country_field_for_request = None - _ubo_field_for_request = None - _chamber_of_commerce_number_field_for_request = None - _status_field_for_request = None - _sub_status_field_for_request = None - _session_timeout_field_for_request = None - _daily_limit_without_confirmation_login_field_for_request = None - _notification_filters_field_for_request = None - - def __init__(self, address_main=None, language=None, region=None, name=None, - public_nick_name=None, avatar_uuid=None, address_postal=None, - country=None, ubo=None, chamber_of_commerce_number=None, - status=None, sub_status=None, session_timeout=None, - daily_limit_without_confirmation_login=None, - notification_filters=None): - """ - :param address_main: The user's main address. - :type address_main: object_.Address - :param language: The person's preferred language. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type language: str - :param region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type region: str - :param name: The company name. - :type name: str - :param public_nick_name: The company's nick name. - :type public_nick_name: str - :param avatar_uuid: The public UUID of the company's avatar. - :type avatar_uuid: str - :param address_postal: The company's postal address. - :type address_postal: object_.Address - :param country: The country where the company is registered. - :type country: str - :param ubo: The names and birth dates of the company's ultimate beneficiary - owners. Minimum zero, maximum four. - :type ubo: list[object_.Ubo] - :param chamber_of_commerce_number: The company's chamber of commerce number. - :type chamber_of_commerce_number: str - :param status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. - :type status: str - :param sub_status: The user sub-status. Can be: NONE, FACE_RESET, APPROVAL, - APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, COUNTER_IBAN, IDEAL or - SUBMIT. - :type sub_status: str - :param session_timeout: The setting for the session timeout of the company - in seconds. - :type session_timeout: int - :param daily_limit_without_confirmation_login: The amount the company can - pay in the session without asking for credentials. - :type daily_limit_without_confirmation_login: object_.Amount - :param notification_filters: The types of notifications that will result in - a push notification or URL callback for this UserCompany. - :type notification_filters: list[object_.NotificationFilter] - """ - - self._address_main_field_for_request = address_main - self._language_field_for_request = language - self._region_field_for_request = region - self._name_field_for_request = name - self._public_nick_name_field_for_request = public_nick_name - self._avatar_uuid_field_for_request = avatar_uuid - self._address_postal_field_for_request = address_postal - self._country_field_for_request = country - self._ubo_field_for_request = ubo - self._chamber_of_commerce_number_field_for_request = chamber_of_commerce_number - self._status_field_for_request = status - self._sub_status_field_for_request = sub_status - self._session_timeout_field_for_request = session_timeout - self._daily_limit_without_confirmation_login_field_for_request = daily_limit_without_confirmation_login - self._notification_filters_field_for_request = notification_filters + _expiry_time = None + _token_value = None + _permitted_device = None @classmethod - def get(cls, custom_headers=None): + def get(cls, user_credential_password_ip_id, custom_headers=None): """ - Get a specific company. - - :type api_context: context.ApiContext - :type user_company_id: int + :type api_context: ApiContext + :type user_id: int + :type user_credential_password_ip_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseUserCompany + :rtype: BunqResponseUserCredentialPasswordIp """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), user_credential_password_ip_id) response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseUserCompany.cast_from_bunq_response( + return BunqResponseUserCredentialPasswordIp.cast_from_bunq_response( cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, name=None, public_nick_name=None, avatar_uuid=None, - address_main=None, address_postal=None, language=None, - region=None, country=None, ubo=None, - chamber_of_commerce_number=None, status=None, sub_status=None, - session_timeout=None, - daily_limit_without_confirmation_login=None, - notification_filters=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Modify a specific company's data. - - :type user_company_id: int - :param name: The company name. - :type name: str - :param public_nick_name: The company's nick name. - :type public_nick_name: str - :param avatar_uuid: The public UUID of the company's avatar. - :type avatar_uuid: str - :param address_main: The user's main address. - :type address_main: object_.Address - :param address_postal: The company's postal address. - :type address_postal: object_.Address - :param language: The person's preferred language. Formatted as a ISO - 639-1 language code plus a ISO 3166-1 alpha-2 country code, seperated by - an underscore. - :type language: str - :param region: The person's preferred region. Formatted as a ISO 639-1 - language code plus a ISO 3166-1 alpha-2 country code, seperated by an - underscore. - :type region: str - :param country: The country where the company is registered. - :type country: str - :param ubo: The names and birth dates of the company's ultimate - beneficiary owners. Minimum zero, maximum four. - :type ubo: list[object_.Ubo] - :param chamber_of_commerce_number: The company's chamber of commerce - number. - :type chamber_of_commerce_number: str - :param status: The user status. Can be: ACTIVE, SIGNUP, RECOVERY. - :type status: str - :param sub_status: The user sub-status. Can be: NONE, FACE_RESET, - APPROVAL, APPROVAL_DIRECTOR, APPROVAL_PARENT, APPROVAL_SUPPORT, - COUNTER_IBAN, IDEAL or SUBMIT. - :type sub_status: str - :param session_timeout: The setting for the session timeout of the - company in seconds. - :type session_timeout: int - :param daily_limit_without_confirmation_login: The amount the company - can pay in the session without asking for credentials. - :type daily_limit_without_confirmation_login: object_.Amount - :param notification_filters: The types of notifications that will result - in a push notification or URL callback for this UserCompany. - :type notification_filters: list[object_.NotificationFilter] + :type user_id: int + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseUserCredentialPasswordIpList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_NAME: name, - cls.FIELD_PUBLIC_NICK_NAME: public_nick_name, - cls.FIELD_AVATAR_UUID: avatar_uuid, - cls.FIELD_ADDRESS_MAIN: address_main, - cls.FIELD_ADDRESS_POSTAL: address_postal, - cls.FIELD_LANGUAGE: language, - cls.FIELD_REGION: region, - cls.FIELD_COUNTRY: country, - cls.FIELD_UBO: ubo, - cls.FIELD_CHAMBER_OF_COMMERCE_NUMBER: chamber_of_commerce_number, - cls.FIELD_STATUS: status, - cls.FIELD_SUB_STATUS: sub_status, - cls.FIELD_SESSION_TIMEOUT: session_timeout, - cls.FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN: daily_limit_without_confirmation_login, - cls.FIELD_NOTIFICATION_FILTERS: notification_filters - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id()) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseUserCredentialPasswordIpList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property @@ -25776,228 +45755,492 @@ def updated(self): return self._updated @property - def public_uuid(self): + def status(self): """ :rtype: str """ - return self._public_uuid + return self._status @property - def name(self): + def expiry_time(self): """ :rtype: str """ - return self._name + return self._expiry_time @property - def display_name(self): + def token_value(self): """ :rtype: str """ - return self._display_name + return self._token_value @property - def public_nick_name(self): + def permitted_device(self): """ - :rtype: str + :rtype: object_.PermittedDevice """ - return self._public_nick_name + return self._permitted_device - @property - def alias(self): + def is_all_field_none(self): """ - :rtype: list[object_.Pointer] + :rtype: bool """ - return self._alias + if self._id_ is not None: + return False - @property - def chamber_of_commerce_number(self): - """ - :rtype: str - """ + if self._created is not None: + return False - return self._chamber_of_commerce_number + if self._updated is not None: + return False - @property - def type_of_business_entity(self): + if self._status is not None: + return False + + if self._expiry_time is not None: + return False + + if self._token_value is not None: + return False + + if self._permitted_device is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: UserCredentialPasswordIpApiObject """ - return self._type_of_business_entity + return converter.json_to_class(UserCredentialPasswordIpApiObject, json_str) - @property - def sector_of_industry(self): + +class UserLegalNameApiObject(BunqModel): + """ + Endpoint for getting available legal names that can be used by the user. + + :param _legal_names: All legal names that can be used by the user + :type _legal_names: list[str] + """ + + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/legal-name" + + # Object type. + _OBJECT_TYPE_GET = "UserLegalNameArray" + + _legal_names = None + + @classmethod + def list(cls, params=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseUserLegalNameList """ - return self._sector_of_industry + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseUserLegalNameList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def counter_bank_iban(self): + def legal_names(self): """ - :rtype: str + :rtype: list[str] """ - return self._counter_bank_iban + return self._legal_names - @property - def avatar(self): + def is_all_field_none(self): """ - :rtype: object_.Avatar + :rtype: bool """ - return self._avatar + if self._legal_names is not None: + return False - @property - def address_main(self): + return True + + @staticmethod + def from_json(json_str): """ - :rtype: object_.Address + :type json_str: str + + :rtype: UserLegalNameApiObject """ - return self._address_main + return converter.json_to_class(UserLegalNameApiObject, json_str) - @property - def address_postal(self): + +class WhitelistSddOneOffApiObject(BunqModel): + """ + Whitelist an one off SDD so that when another one off SDD from the creditor + comes in, it is automatically accepted. + + :param _monetary_account_paying_id: The account from which payments will be + deducted when a transaction is matched with this whitelist. + :type _monetary_account_paying_id: int + :param _request_id: ID of the request for which you want to whitelist the + originating SDD. + :type _request_id: int + :param _maximum_amount_per_month: The monthly maximum amount that can be + deducted from the target account. + :type _maximum_amount_per_month: object_.Amount + :param _maximum_amount_per_payment: The maximum amount per payment that can + be deducted from the target account. + :type _maximum_amount_per_payment: object_.Amount + :param _routing_type: The type of routing for this whitelist. + :type _routing_type: str + :param _id_: The ID of the whitelist entry. + :type _id_: int + :param _monetary_account_incoming_id: The account to which payments will + come in before possibly being 'redirected' by the whitelist. + :type _monetary_account_incoming_id: int + :param _type_: The type of the SDD whitelist, can be CORE or B2B. + :type _type_: str + :param _status: The status of the whitelist. + :type _status: str + :param _credit_scheme_identifier: The credit scheme ID provided by the + counterparty. + :type _credit_scheme_identifier: str + :param _counterparty_alias: The account to which payments will be paid. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _user_alias_created: The user who created the whitelist entry. + :type _user_alias_created: object_.LabelUser + """ + + # Endpoint constants. + _ENDPOINT_URL_READ = "user/{}/whitelist-sdd-one-off/{}" + _ENDPOINT_URL_CREATE = "user/{}/whitelist-sdd-one-off" + _ENDPOINT_URL_UPDATE = "user/{}/whitelist-sdd-one-off/{}" + _ENDPOINT_URL_DELETE = "user/{}/whitelist-sdd-one-off/{}" + _ENDPOINT_URL_LISTING = "user/{}/whitelist-sdd-one-off" + + # Field constants. + FIELD_MONETARY_ACCOUNT_PAYING_ID = "monetary_account_paying_id" + FIELD_REQUEST_ID = "request_id" + FIELD_MAXIMUM_AMOUNT_PER_MONTH = "maximum_amount_per_month" + FIELD_MAXIMUM_AMOUNT_PER_PAYMENT = "maximum_amount_per_payment" + FIELD_ROUTING_TYPE = "routing_type" + + # Object type. + _OBJECT_TYPE_GET = "WhitelistSddOneOff" + + _id_ = None + _monetary_account_incoming_id = None + _monetary_account_paying_id = None + _type_ = None + _status = None + _credit_scheme_identifier = None + _counterparty_alias = None + _maximum_amount_per_month = None + _maximum_amount_per_payment = None + _user_alias_created = None + _routing_type = None + _monetary_account_paying_id_field_for_request = None + _request_id_field_for_request = None + _maximum_amount_per_month_field_for_request = None + _maximum_amount_per_payment_field_for_request = None + _routing_type_field_for_request = None + + def __init__(self, request_id, monetary_account_paying_id=None, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None): """ - :rtype: object_.Address + :param monetary_account_paying_id: ID of the monetary account of which you + want to pay from. + :type monetary_account_paying_id: int + :param request_id: ID of the request for which you want to whitelist the + originating SDD. + :type request_id: int + :param maximum_amount_per_month: The maximum amount of money that is allowed + to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str """ - return self._address_postal + self._monetary_account_paying_id_field_for_request = monetary_account_paying_id + self._request_id_field_for_request = request_id + self._maximum_amount_per_month_field_for_request = maximum_amount_per_month + self._maximum_amount_per_payment_field_for_request = maximum_amount_per_payment + self._routing_type_field_for_request = routing_type - @property - def version_terms_of_service(self): + @classmethod + def get(cls, whitelist_sdd_one_off_id, custom_headers=None): """ - :rtype: str + Get a specific one off SDD whitelist entry. + + :type api_context: ApiContext + :type user_id: int + :type whitelist_sdd_one_off_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseWhitelistSddOneOff """ - return self._version_terms_of_service + if custom_headers is None: + custom_headers = {} - @property - def director_alias(self): + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), whitelist_sdd_one_off_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseWhitelistSddOneOff.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + ) + + @classmethod + def create(cls,monetary_account_paying_id, request_id, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None, custom_headers=None): """ - :rtype: object_.LabelUser + Create a new one off SDD whitelist entry. + + :type user_id: int + :param monetary_account_paying_id: ID of the monetary account of which + you want to pay from. + :type monetary_account_paying_id: int + :param request_id: ID of the request for which you want to whitelist the + originating SDD. + :type request_id: int + :param maximum_amount_per_month: The maximum amount of money that is + allowed to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._director_alias + if custom_headers is None: + custom_headers = {} - @property - def language(self): + request_map = { +cls.FIELD_MONETARY_ACCOUNT_PAYING_ID : monetary_account_paying_id, +cls.FIELD_REQUEST_ID : request_id, +cls.FIELD_MAXIMUM_AMOUNT_PER_MONTH : maximum_amount_per_month, +cls.FIELD_MAXIMUM_AMOUNT_PER_PAYMENT : maximum_amount_per_payment, +cls.FIELD_ROUTING_TYPE : routing_type +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def update(cls, whitelist_sdd_one_off_id, monetary_account_paying_id=None, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None, custom_headers=None): """ - :rtype: str + :type user_id: int + :type whitelist_sdd_one_off_id: int + :param monetary_account_paying_id: ID of the monetary account of which + you want to pay from. + :type monetary_account_paying_id: int + :param maximum_amount_per_month: The maximum amount of money that is + allowed to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseInt """ - return self._language + if custom_headers is None: + custom_headers = {} - @property - def country(self): + api_client = ApiClient(cls._get_api_context()) + + request_map = { +cls.FIELD_MONETARY_ACCOUNT_PAYING_ID : monetary_account_paying_id, +cls.FIELD_MAXIMUM_AMOUNT_PER_MONTH : maximum_amount_per_month, +cls.FIELD_MAXIMUM_AMOUNT_PER_PAYMENT : maximum_amount_per_payment, +cls.FIELD_ROUTING_TYPE : routing_type +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) + + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), whitelist_sdd_one_off_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) + ) + + @classmethod + def delete(cls, whitelist_sdd_one_off_id, custom_headers=None): """ - :rtype: str + :type user_id: int + :type whitelist_sdd_one_off_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone """ - return self._country + if custom_headers is None: + custom_headers = {} - @property - def region(self): + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), whitelist_sdd_one_off_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): """ - :rtype: str + Get a listing of all one off SDD whitelist entries for a target monetary + account. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseWhitelistSddOneOffList """ - return self._region + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseWhitelistSddOneOffList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property - def ubo(self): + def id_(self): """ - :rtype: list[object_.Ubo] + :rtype: int """ - return self._ubo + return self._id_ @property - def status(self): + def monetary_account_incoming_id(self): """ - :rtype: str + :rtype: int """ - return self._status + return self._monetary_account_incoming_id @property - def sub_status(self): + def monetary_account_paying_id(self): """ - :rtype: str + :rtype: int """ - return self._sub_status + return self._monetary_account_paying_id @property - def session_timeout(self): + def type_(self): """ - :rtype: int + :rtype: str """ - return self._session_timeout + return self._type_ @property - def card_ids(self): + def status(self): """ - :rtype: list[object_.BunqId] + :rtype: str """ - return self._card_ids + return self._status @property - def card_limits(self): + def credit_scheme_identifier(self): """ - :rtype: list[object_.CardLimit] + :rtype: str """ - return self._card_limits + return self._credit_scheme_identifier @property - def daily_limit_without_confirmation_login(self): + def counterparty_alias(self): """ - :rtype: object_.Amount + :rtype: object_.MonetaryAccountReference """ - return self._daily_limit_without_confirmation_login + return self._counterparty_alias @property - def notification_filters(self): + def maximum_amount_per_month(self): """ - :rtype: list[object_.NotificationFilter] + :rtype: object_.Amount """ - return self._notification_filters + return self._maximum_amount_per_month @property - def customer(self): + def maximum_amount_per_payment(self): """ - :rtype: Customer + :rtype: object_.Amount """ - return self._customer + return self._maximum_amount_per_payment @property - def customer_limit(self): + def user_alias_created(self): """ - :rtype: CustomerLimit + :rtype: object_.LabelUser """ - return self._customer_limit + return self._user_alias_created @property - def billing_contract(self): + def routing_type(self): """ - :rtype: list[BillingContractSubscription] + :rtype: str """ - return self._billing_contract + return self._routing_type def is_all_field_none(self): """ @@ -26007,94 +46250,34 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._public_uuid is not None: - return False - - if self._name is not None: - return False - - if self._display_name is not None: - return False - - if self._public_nick_name is not None: - return False - - if self._alias is not None: - return False - - if self._chamber_of_commerce_number is not None: - return False - - if self._type_of_business_entity is not None: - return False - - if self._sector_of_industry is not None: - return False - - if self._counter_bank_iban is not None: - return False - - if self._avatar is not None: - return False - - if self._address_main is not None: - return False - - if self._address_postal is not None: - return False - - if self._version_terms_of_service is not None: - return False - - if self._director_alias is not None: - return False - - if self._language is not None: - return False - - if self._country is not None: + if self._monetary_account_incoming_id is not None: return False - if self._region is not None: + if self._monetary_account_paying_id is not None: return False - if self._ubo is not None: + if self._type_ is not None: return False if self._status is not None: return False - if self._sub_status is not None: - return False - - if self._session_timeout is not None: - return False - - if self._card_ids is not None: - return False - - if self._card_limits is not None: + if self._credit_scheme_identifier is not None: return False - if self._daily_limit_without_confirmation_login is not None: + if self._counterparty_alias is not None: return False - if self._notification_filters is not None: + if self._maximum_amount_per_month is not None: return False - if self._customer is not None: + if self._maximum_amount_per_payment is not None: return False - if self._customer_limit is not None: + if self._user_alias_created is not None: return False - if self._billing_contract is not None: + if self._routing_type is not None: return False return True @@ -26104,121 +46287,200 @@ def from_json(json_str): """ :type json_str: str - :rtype: UserCompany + :rtype: WhitelistSddOneOffApiObject """ - return converter.json_to_class(UserCompany, json_str) + return converter.json_to_class(WhitelistSddOneOffApiObject, json_str) -class Customer(core.BunqModel): +class WhitelistSddRecurringApiObject(BunqModel): """ - Used to view a customer. + Whitelist a recurring SDD so that when another recurrence comes in, it is + automatically accepted. - :param _billing_account_id: The primary billing account account's id. - :type _billing_account_id: str - :param _invoice_notification_preference: The preferred notification type for - invoices. - :type _invoice_notification_preference: str - :param _id_: The id of the customer. + :param _monetary_account_paying_id: The account from which payments will be + deducted when a transaction is matched with this whitelist. + :type _monetary_account_paying_id: int + :param _request_id: ID of the request for which you want to whitelist the + originating SDD. + :type _request_id: int + :param _maximum_amount_per_month: The monthly maximum amount that can be + deducted from the target account. + :type _maximum_amount_per_month: object_.Amount + :param _maximum_amount_per_payment: The maximum amount per payment that can + be deducted from the target account. + :type _maximum_amount_per_payment: object_.Amount + :param _routing_type: The type of routing for this whitelist. + :type _routing_type: str + :param _id_: The ID of the whitelist entry. :type _id_: int - :param _created: The timestamp of the customer object's creation. - :type _created: str - :param _updated: The timestamp of the customer object's last update. - :type _updated: str + :param _monetary_account_incoming_id: The account to which payments will + come in before possibly being 'redirected' by the whitelist. + :type _monetary_account_incoming_id: int + :param _type_: The type of the SDD whitelist, can be CORE or B2B. + :type _type_: str + :param _status: The status of the whitelist. + :type _status: str + :param _credit_scheme_identifier: The credit scheme ID provided by the + counterparty. + :type _credit_scheme_identifier: str + :param _mandate_identifier: The mandate ID provided by the counterparty. + :type _mandate_identifier: str + :param _counterparty_alias: The account to which payments will be paid. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _user_alias_created: The user who created the whitelist entry. + :type _user_alias_created: object_.LabelUser """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/customer" - _ENDPOINT_URL_READ = "user/{}/customer/{}" - _ENDPOINT_URL_UPDATE = "user/{}/customer/{}" + _ENDPOINT_URL_READ = "user/{}/whitelist-sdd-recurring/{}" + _ENDPOINT_URL_CREATE = "user/{}/whitelist-sdd-recurring" + _ENDPOINT_URL_UPDATE = "user/{}/whitelist-sdd-recurring/{}" + _ENDPOINT_URL_DELETE = "user/{}/whitelist-sdd-recurring/{}" + _ENDPOINT_URL_LISTING = "user/{}/whitelist-sdd-recurring" # Field constants. - FIELD_BILLING_ACCOUNT_ID = "billing_account_id" - FIELD_INVOICE_NOTIFICATION_PREFERENCE = "invoice_notification_preference" + FIELD_MONETARY_ACCOUNT_PAYING_ID = "monetary_account_paying_id" + FIELD_REQUEST_ID = "request_id" + FIELD_MAXIMUM_AMOUNT_PER_MONTH = "maximum_amount_per_month" + FIELD_MAXIMUM_AMOUNT_PER_PAYMENT = "maximum_amount_per_payment" + FIELD_ROUTING_TYPE = "routing_type" # Object type. - _OBJECT_TYPE_GET = "Customer" + _OBJECT_TYPE_GET = "WhitelistSddRecurring" _id_ = None - _created = None - _updated = None - _billing_account_id = None - _invoice_notification_preference = None - _billing_account_id_field_for_request = None - _invoice_notification_preference_field_for_request = None + _monetary_account_incoming_id = None + _monetary_account_paying_id = None + _type_ = None + _status = None + _credit_scheme_identifier = None + _mandate_identifier = None + _counterparty_alias = None + _maximum_amount_per_month = None + _maximum_amount_per_payment = None + _user_alias_created = None + _routing_type = None + _monetary_account_paying_id_field_for_request = None + _request_id_field_for_request = None + _maximum_amount_per_month_field_for_request = None + _maximum_amount_per_payment_field_for_request = None + _routing_type_field_for_request = None - def __init__(self, billing_account_id=None, - invoice_notification_preference=None): + def __init__(self, request_id, monetary_account_paying_id=None, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None): """ - :param billing_account_id: The primary billing account account's id. - :type billing_account_id: str - :param invoice_notification_preference: The preferred notification type for - invoices - :type invoice_notification_preference: str + :param monetary_account_paying_id: ID of the monetary account of which you + want to pay from. + :type monetary_account_paying_id: int + :param request_id: ID of the request for which you want to whitelist the + originating SDD. + :type request_id: int + :param maximum_amount_per_month: The maximum amount of money that is allowed + to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str """ - self._billing_account_id_field_for_request = billing_account_id - self._invoice_notification_preference_field_for_request = invoice_notification_preference + self._monetary_account_paying_id_field_for_request = monetary_account_paying_id + self._request_id_field_for_request = request_id + self._maximum_amount_per_month_field_for_request = maximum_amount_per_month + self._maximum_amount_per_payment_field_for_request = maximum_amount_per_payment + self._routing_type_field_for_request = routing_type @classmethod - def list(cls, params=None, custom_headers=None): + def get(cls, whitelist_sdd_recurring_id, custom_headers=None): """ + Get a specific recurring SDD whitelist entry. + + :type api_context: ApiContext :type user_id: int - :type params: dict[str, str]|None + :type whitelist_sdd_recurring_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCustomerList + :rtype: BunqResponseWhitelistSddRecurring """ - if params is None: - params = {} - if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), whitelist_sdd_recurring_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseCustomerList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseWhitelistSddRecurring.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def get(cls, customer_id, custom_headers=None): + def create(cls,monetary_account_paying_id, request_id, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None, custom_headers=None): """ - :type api_context: context.ApiContext + Create a new recurring SDD whitelist entry. + :type user_id: int - :type customer_id: int + :param monetary_account_paying_id: ID of the monetary account of which + you want to pay from. + :type monetary_account_paying_id: int + :param request_id: ID of the request for which you want to whitelist the + originating SDD. + :type request_id: int + :param maximum_amount_per_month: The maximum amount of money that is + allowed to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCustomer + :rtype: BunqResponseInt """ if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - customer_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + request_map = { +cls.FIELD_MONETARY_ACCOUNT_PAYING_ID : monetary_account_paying_id, +cls.FIELD_REQUEST_ID : request_id, +cls.FIELD_MAXIMUM_AMOUNT_PER_MONTH : maximum_amount_per_month, +cls.FIELD_MAXIMUM_AMOUNT_PER_PAYMENT : maximum_amount_per_payment, +cls.FIELD_ROUTING_TYPE : routing_type +} + request_map_string = converter.class_to_json(request_map) + request_map_string = cls._remove_field_for_request(request_map_string) - return BunqResponseCustomer.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) + api_client = ApiClient(cls._get_api_context()) + request_bytes = request_map_string.encode() + endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) + response_raw = api_client.post(endpoint_url, request_bytes, custom_headers) + + return BunqResponseInt.cast_from_bunq_response( + cls._process_for_id(response_raw) ) @classmethod - def update(cls, customer_id, billing_account_id=None, - invoice_notification_preference=None, custom_headers=None): + def update(cls, whitelist_sdd_recurring_id, monetary_account_paying_id=None, maximum_amount_per_month=None, maximum_amount_per_payment=None, routing_type=None, custom_headers=None): """ :type user_id: int - :type customer_id: int - :param billing_account_id: The primary billing account account's id. - :type billing_account_id: str - :param invoice_notification_preference: The preferred notification type - for invoices - :type invoice_notification_preference: str + :type whitelist_sdd_recurring_id: int + :param monetary_account_paying_id: ID of the monetary account of which + you want to pay from. + :type monetary_account_paying_id: int + :param maximum_amount_per_month: The maximum amount of money that is + allowed to be deducted per month based on the whitelist. + :type maximum_amount_per_month: object_.Amount + :param maximum_amount_per_payment: The maximum amount of money that is + allowed to be deducted per payment based on the whitelist. + :type maximum_amount_per_payment: object_.Amount + :param routing_type: The type of routing for this whitelist. Should be + changed to non-optional CIT/technical#12806. + :type routing_type: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -26227,25 +46489,73 @@ def update(cls, customer_id, billing_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_BILLING_ACCOUNT_ID: billing_account_id, - cls.FIELD_INVOICE_NOTIFICATION_PREFERENCE: invoice_notification_preference - } +cls.FIELD_MONETARY_ACCOUNT_PAYING_ID : monetary_account_paying_id, +cls.FIELD_MAXIMUM_AMOUNT_PER_MONTH : maximum_amount_per_month, +cls.FIELD_MAXIMUM_AMOUNT_PER_PAYMENT : maximum_amount_per_payment, +cls.FIELD_ROUTING_TYPE : routing_type +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - customer_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), whitelist_sdd_recurring_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) + @classmethod + def delete(cls, whitelist_sdd_recurring_id, custom_headers=None): + """ + :type user_id: int + :type whitelist_sdd_recurring_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseNone + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), whitelist_sdd_recurring_id) + response_raw = api_client.delete(endpoint_url, custom_headers) + + return BunqResponseNone.cast_from_bunq_response( + BunqResponse(None, response_raw.headers) + ) + + @classmethod + def list(cls, params=None, custom_headers=None): + """ + Get a listing of all recurring SDD whitelist entries for a target + monetary account. + + :type user_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseWhitelistSddRecurringList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseWhitelistSddRecurringList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) + @property def id_(self): """ @@ -26255,36 +46565,92 @@ def id_(self): return self._id_ @property - def created(self): + def monetary_account_incoming_id(self): + """ + :rtype: int + """ + + return self._monetary_account_incoming_id + + @property + def monetary_account_paying_id(self): + """ + :rtype: int + """ + + return self._monetary_account_paying_id + + @property + def type_(self): """ :rtype: str """ - return self._created + return self._type_ @property - def updated(self): + def status(self): """ :rtype: str """ - return self._updated + return self._status @property - def billing_account_id(self): + def credit_scheme_identifier(self): """ :rtype: str """ - return self._billing_account_id + return self._credit_scheme_identifier @property - def invoice_notification_preference(self): + def mandate_identifier(self): """ :rtype: str """ - return self._invoice_notification_preference + return self._mandate_identifier + + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def maximum_amount_per_month(self): + """ + :rtype: object_.Amount + """ + + return self._maximum_amount_per_month + + @property + def maximum_amount_per_payment(self): + """ + :rtype: object_.Amount + """ + + return self._maximum_amount_per_payment + + @property + def user_alias_created(self): + """ + :rtype: object_.LabelUser + """ + + return self._user_alias_created + + @property + def routing_type(self): + """ + :rtype: str + """ + + return self._routing_type def is_all_field_none(self): """ @@ -26294,16 +46660,37 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: + if self._monetary_account_incoming_id is not None: return False - if self._updated is not None: + if self._monetary_account_paying_id is not None: return False - if self._billing_account_id is not None: + if self._type_ is not None: return False - if self._invoice_notification_preference is not None: + if self._status is not None: + return False + + if self._credit_scheme_identifier is not None: + return False + + if self._mandate_identifier is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._maximum_amount_per_month is not None: + return False + + if self._maximum_amount_per_payment is not None: + return False + + if self._user_alias_created is not None: + return False + + if self._routing_type is not None: return False return True @@ -26313,63 +46700,123 @@ def from_json(json_str): """ :type json_str: str - :rtype: Customer + :rtype: WhitelistSddRecurringApiObject """ - return converter.json_to_class(Customer, json_str) + return converter.json_to_class(WhitelistSddRecurringApiObject, json_str) -class CustomerLimit(core.BunqModel): +class WhitelistSddApiObject(BunqModel): """ - Show the limits for the authenticated user. + Depreciated route, replaced with whitelist-sdd-recurring - :param _limit_monetary_account: The limit of monetary accounts. - :type _limit_monetary_account: int - :param _limit_card_debit_maestro: The limit of Maestro cards. - :type _limit_card_debit_maestro: int - :param _limit_card_debit_mastercard: The limit of MasterCard cards. - :type _limit_card_debit_mastercard: int - :param _limit_card_debit_wildcard: The limit of wildcards, e.g. Maestro or - MasterCard cards. - :type _limit_card_debit_wildcard: int - :param _limit_card_debit_replacement: The limit of free replacement cards. - :type _limit_card_debit_replacement: int - :param _limit_invite_user_premium_limited: The number of "PREMIUM_LIMITED" - invites the user has remaining. - :type _limit_invite_user_premium_limited: int - :param _limit_amount_monthly: The maximum amount a user is allowed to spend - in a month. - :type _limit_amount_monthly: object_.Amount - :param _spent_amount_monthly: The amount the user has spent in the last - month. - :type _spent_amount_monthly: object_.Amount + :param _monetary_account_paying_id: The account from which payments will be + deducted when a transaction is matched with this whitelist. + :type _monetary_account_paying_id: int + :param _request_id: ID of the request for which you want to whitelist the + originating SDD. + :type _request_id: int + :param _maximum_amount_per_month: The monthly maximum amount that can be + deducted from the target account. + :type _maximum_amount_per_month: object_.Amount + :param _id_: The ID of the whitelist entry. + :type _id_: int + :param _monetary_account_incoming_id: The account to which payments will + come in before possibly being 'redirected' by the whitelist. + :type _monetary_account_incoming_id: int + :param _type_: The type of the SDD whitelist, can be CORE or B2B. + :type _type_: str + :param _status: The status of the whitelist. + :type _status: str + :param _credit_scheme_identifier: The credit scheme ID provided by the + counterparty. + :type _credit_scheme_identifier: str + :param _mandate_identifier: The mandate ID provided by the counterparty. + :type _mandate_identifier: str + :param _counterparty_alias: The account to which payments will be paid. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _user_alias_created: The user who created the whitelist entry. + :type _user_alias_created: object_.LabelUser """ # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/limit" + _ENDPOINT_URL_READ = "user/{}/whitelist-sdd/{}" + _ENDPOINT_URL_LISTING = "user/{}/whitelist-sdd" + + # Field constants. + FIELD_MONETARY_ACCOUNT_PAYING_ID = "monetary_account_paying_id" + FIELD_REQUEST_ID = "request_id" + FIELD_MAXIMUM_AMOUNT_PER_MONTH = "maximum_amount_per_month" # Object type. - _OBJECT_TYPE_GET = "CustomerLimit" + _OBJECT_TYPE_GET = "Whitelist" - _limit_monetary_account = None - _limit_card_debit_maestro = None - _limit_card_debit_mastercard = None - _limit_card_debit_wildcard = None - _limit_card_debit_replacement = None - _limit_invite_user_premium_limited = None - _limit_amount_monthly = None - _spent_amount_monthly = None + _id_ = None + _monetary_account_incoming_id = None + _monetary_account_paying_id = None + _type_ = None + _status = None + _credit_scheme_identifier = None + _mandate_identifier = None + _counterparty_alias = None + _maximum_amount_per_month = None + _user_alias_created = None + _monetary_account_paying_id_field_for_request = None + _request_id_field_for_request = None + _maximum_amount_per_month_field_for_request = None + + def __init__(self, request_id, monetary_account_paying_id=None, maximum_amount_per_month=None): + """ + :param monetary_account_paying_id: ID of the monetary account of which you + want to pay from. + :type monetary_account_paying_id: int + :param request_id: ID of the request for which you want to whitelist the + originating SDD. + :type request_id: int + :param maximum_amount_per_month: The maximum amount of money that is allowed + to be deducted based on the whitelist. + :type maximum_amount_per_month: object_.Amount + """ + + self._monetary_account_paying_id_field_for_request = monetary_account_paying_id + self._request_id_field_for_request = request_id + self._maximum_amount_per_month_field_for_request = maximum_amount_per_month + + @classmethod + def get(cls, whitelist_sdd_id, custom_headers=None): + """ + Get a specific recurring SDD whitelist entry. + + :type api_context: ApiContext + :type user_id: int + :type whitelist_sdd_id: int + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseWhitelistSdd + """ + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), whitelist_sdd_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) + + return BunqResponseWhitelistSdd.cast_from_bunq_response( + cls._from_json(response_raw) + ) @classmethod def list(cls, params=None, custom_headers=None): """ - Get all limits for the authenticated user. + Get a listing of all recurring SDD whitelist entries for a target + monetary account. :type user_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseCustomerLimitList + :rtype: BunqResponseWhitelistSddList """ if params is None: @@ -26378,106 +46825,127 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id()) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseCustomerLimitList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + return BunqResponseWhitelistSddList.cast_from_bunq_response( + cls._from_json_list(response_raw) ) @property - def limit_monetary_account(self): + def id_(self): """ :rtype: int """ - return self._limit_monetary_account + return self._id_ @property - def limit_card_debit_maestro(self): + def monetary_account_incoming_id(self): """ :rtype: int """ - return self._limit_card_debit_maestro + return self._monetary_account_incoming_id @property - def limit_card_debit_mastercard(self): + def monetary_account_paying_id(self): """ :rtype: int """ - return self._limit_card_debit_mastercard + return self._monetary_account_paying_id @property - def limit_card_debit_wildcard(self): + def type_(self): """ - :rtype: int + :rtype: str """ - return self._limit_card_debit_wildcard + return self._type_ @property - def limit_card_debit_replacement(self): + def status(self): """ - :rtype: int + :rtype: str """ - return self._limit_card_debit_replacement + return self._status @property - def limit_invite_user_premium_limited(self): + def credit_scheme_identifier(self): """ - :rtype: int + :rtype: str """ - return self._limit_invite_user_premium_limited + return self._credit_scheme_identifier @property - def limit_amount_monthly(self): + def mandate_identifier(self): """ - :rtype: object_.Amount + :rtype: str """ - return self._limit_amount_monthly + return self._mandate_identifier @property - def spent_amount_monthly(self): + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def maximum_amount_per_month(self): """ :rtype: object_.Amount """ - return self._spent_amount_monthly + return self._maximum_amount_per_month + + @property + def user_alias_created(self): + """ + :rtype: object_.LabelUser + """ + + return self._user_alias_created def is_all_field_none(self): """ :rtype: bool """ - if self._limit_monetary_account is not None: + if self._id_ is not None: return False - if self._limit_card_debit_maestro is not None: + if self._monetary_account_incoming_id is not None: return False - if self._limit_card_debit_mastercard is not None: + if self._monetary_account_paying_id is not None: return False - if self._limit_card_debit_wildcard is not None: + if self._type_ is not None: return False - if self._limit_card_debit_replacement is not None: + if self._status is not None: return False - if self._limit_invite_user_premium_limited is not None: + if self._credit_scheme_identifier is not None: return False - if self._limit_amount_monthly is not None: + if self._mandate_identifier is not None: return False - if self._spent_amount_monthly is not None: + if self._counterparty_alias is not None: + return False + + if self._maximum_amount_per_month is not None: + return False + + if self._user_alias_created is not None: return False return True @@ -26487,113 +46955,97 @@ def from_json(json_str): """ :type json_str: str - :rtype: CustomerLimit + :rtype: WhitelistSddApiObject """ - return converter.json_to_class(CustomerLimit, json_str) + return converter.json_to_class(WhitelistSddApiObject, json_str) -class BillingContractSubscription(core.BunqModel): +class WhitelistSddMonetaryAccountPayingApiObject(BunqModel): """ - Show the subscription billing contract for the authenticated user. + Whitelist an SDD so that when one comes in, it is automatically accepted. - :param _subscription_type: The subscription type of the user. Can be one of - PERSON_SUPER_LIGHT_V1, PERSON_LIGHT_V1, PERSON_MORE_V1, PERSON_FREE_V1, - PERSON_PREMIUM_V1, COMPANY_V1, or COMPANY_V2. - :type _subscription_type: str - :param _id_: The id of the billing contract. + :param _id_: The ID of the whitelist entry. :type _id_: int - :param _created: The timestamp when the billing contract was made. - :type _created: str - :param _updated: The timestamp when the billing contract was last updated. - :type _updated: str - :param _contract_date_start: The date from when the billing contract is - valid. - :type _contract_date_start: str - :param _contract_date_end: The date until when the billing contract is - valid. - :type _contract_date_end: str - :param _contract_version: The version of the billing contract. - :type _contract_version: int - :param _status: The subscription status. + :param _monetary_account_incoming_id: The account to which payments will + come in before possibly being 'redirected' by the whitelist. + :type _monetary_account_incoming_id: int + :param _monetary_account_paying_id: The account from which payments will be + deducted when a transaction is matched with this whitelist. + :type _monetary_account_paying_id: int + :param _type_: The type of the SDD whitelist, can be CORE or B2B. + :type _type_: str + :param _status: The status of the whitelist. :type _status: str - :param _sub_status: The subscription substatus. - :type _sub_status: str + :param _credit_scheme_identifier: The credit scheme ID provided by the + counterparty. + :type _credit_scheme_identifier: str + :param _mandate_identifier: The mandate ID provided by the counterparty. + :type _mandate_identifier: str + :param _counterparty_alias: The account to which payments will be paid. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _maximum_amount_per_month: The monthly maximum amount that can be + deducted from the target account. + :type _maximum_amount_per_month: object_.Amount + :param _user_alias_created: The user who created the whitelist entry. + :type _user_alias_created: object_.LabelUser """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/billing-contract-subscription" - _ENDPOINT_URL_LISTING = "user/{}/billing-contract-subscription" - - # Field constants. - FIELD_SUBSCRIPTION_TYPE = "subscription_type" + _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/whitelist-sdd/{}" + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/whitelist-sdd" # Object type. - _OBJECT_TYPE_GET = "BillingContractSubscription" + _OBJECT_TYPE_GET = "WhitelistSdd" _id_ = None - _created = None - _updated = None - _contract_date_start = None - _contract_date_end = None - _contract_version = None - _subscription_type = None + _monetary_account_incoming_id = None + _monetary_account_paying_id = None + _type_ = None _status = None - _sub_status = None - _subscription_type_field_for_request = None - - def __init__(self, subscription_type): - """ - :param subscription_type: The subscription type of the user. Can be one of - PERSON_LIGHT_V1, PERSON_MORE_V1, PERSON_FREE_V1, PERSON_PREMIUM_V1, - COMPANY_V1, or COMPANY_V2. - :type subscription_type: str - """ - - self._subscription_type_field_for_request = subscription_type + _credit_scheme_identifier = None + _mandate_identifier = None + _counterparty_alias = None + _maximum_amount_per_month = None + _user_alias_created = None @classmethod - def create(cls, subscription_type, custom_headers=None): + def get(cls, whitelist_sdd_monetary_account_paying_id, monetary_account_id=None, custom_headers=None): """ + Get a specific SDD whitelist entry. + + :type api_context: ApiContext :type user_id: int - :param subscription_type: The subscription type of the user. Can be one - of PERSON_LIGHT_V1, PERSON_MORE_V1, PERSON_FREE_V1, PERSON_PREMIUM_V1, - COMPANY_V1, or COMPANY_V2. - :type subscription_type: str + :type monetary_account_id: int + :type whitelist_sdd_monetary_account_paying_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseWhitelistSddMonetaryAccountPaying """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_SUBSCRIPTION_TYPE: subscription_type - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), whitelist_sdd_monetary_account_paying_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseWhitelistSddMonetaryAccountPaying.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def list(cls, params=None, custom_headers=None): + def list(cls,monetary_account_id=None, params=None, custom_headers=None): """ - Get all subscription billing contract for the authenticated user. + Get a listing of all SDD whitelist entries for a target monetary + account. :type user_id: int + :type monetary_account_id: int :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseBillingContractSubscriptionList + :rtype: BunqResponseWhitelistSddMonetaryAccountPayingList """ if params is None: @@ -26602,12 +47054,11 @@ def list(cls, params=None, custom_headers=None): if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id)) response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseBillingContractSubscriptionList.cast_from_bunq_response( + return BunqResponseWhitelistSddMonetaryAccountPayingList.cast_from_bunq_response( cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @@ -26620,68 +47071,76 @@ def id_(self): return self._id_ @property - def created(self): + def monetary_account_incoming_id(self): """ - :rtype: str + :rtype: int """ - return self._created + return self._monetary_account_incoming_id @property - def updated(self): + def monetary_account_paying_id(self): """ - :rtype: str + :rtype: int """ - return self._updated + return self._monetary_account_paying_id @property - def contract_date_start(self): + def type_(self): """ :rtype: str """ - return self._contract_date_start + return self._type_ @property - def contract_date_end(self): + def status(self): """ :rtype: str """ - return self._contract_date_end + return self._status @property - def contract_version(self): + def credit_scheme_identifier(self): """ - :rtype: int + :rtype: str """ - return self._contract_version + return self._credit_scheme_identifier @property - def subscription_type(self): + def mandate_identifier(self): """ :rtype: str """ - return self._subscription_type + return self._mandate_identifier @property - def status(self): + def counterparty_alias(self): """ - :rtype: str + :rtype: object_.MonetaryAccountReference """ - return self._status + return self._counterparty_alias @property - def sub_status(self): + def maximum_amount_per_month(self): """ - :rtype: str + :rtype: object_.Amount """ - return self._sub_status + return self._maximum_amount_per_month + + @property + def user_alias_created(self): + """ + :rtype: object_.LabelUser + """ + + return self._user_alias_created def is_all_field_none(self): """ @@ -26691,28 +47150,31 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._created is not None: + if self._monetary_account_incoming_id is not None: return False - if self._updated is not None: + if self._monetary_account_paying_id is not None: return False - if self._contract_date_start is not None: + if self._type_ is not None: return False - if self._contract_date_end is not None: + if self._status is not None: return False - if self._contract_version is not None: + if self._credit_scheme_identifier is not None: return False - if self._subscription_type is not None: + if self._mandate_identifier is not None: return False - if self._status is not None: + if self._counterparty_alias is not None: return False - if self._sub_status is not None: + if self._maximum_amount_per_month is not None: + return False + + if self._user_alias_created is not None: return False return True @@ -26722,33 +47184,157 @@ def from_json(json_str): """ :type json_str: str - :rtype: BillingContractSubscription + :rtype: WhitelistSddMonetaryAccountPayingApiObject """ - return converter.json_to_class(BillingContractSubscription, json_str) + return converter.json_to_class(WhitelistSddMonetaryAccountPayingApiObject, json_str) -class UserApiKey(core.BunqModel): +class MasterCardPaymentApiObject(BunqModel): """ - Used to view OAuth request detais in events. + MasterCard transaction view. - :param _id_: The id of the user. + :param _id_: The id of the Payment. :type _id_: int - :param _created: The timestamp of the user object's creation. + :param _created: The timestamp when the Payment was done. :type _created: str - :param _updated: The timestamp of the user object's last update. + :param _updated: The timestamp when the Payment was last updated (will be + updated when chat messages are received). :type _updated: str - :param _requested_by_user: The user who requested access. - :type _requested_by_user: object_.UserApiKeyAnchoredUser - :param _granted_by_user: The user who granted access. - :type _granted_by_user: object_.UserApiKeyAnchoredUser + :param _monetary_account_id: The id of the MonetaryAccount the Payment was + made to or from (depending on whether this is an incoming or outgoing + Payment). + :type _monetary_account_id: int + :param _amount: The Amount transferred by the Payment. Will be negative for + outgoing Payments and positive for incoming Payments (relative to the + MonetaryAccount indicated by monetary_account_id). + :type _amount: object_.Amount + :param _alias: The LabelMonetaryAccount containing the public information of + 'this' (party) side of the Payment. + :type _alias: object_.MonetaryAccountReference + :param _counterparty_alias: The LabelMonetaryAccount containing the public + information of the other (counterparty) side of the Payment. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _description: The description for the Payment. Maximum 140 characters + for Payments to external IBANs, 9000 characters for Payments to only other + bunq MonetaryAccounts. + :type _description: str + :param _type_: The type of Payment, can be BUNQ, EBA_SCT, EBA_SDD, IDEAL, + SWIFT or FIS (card). + :type _type_: str + :param _sub_type: The sub-type of the Payment, can be PAYMENT, WITHDRAWAL, + REVERSAL, REQUEST, BILLING, SCT, SDD or NLO. + :type _sub_type: str + :param _payment_arrival_expected: Information about the expected arrival of + the payment. + :type _payment_arrival_expected: object_.PaymentArrivalExpected + :param _bunqto_status: The status of the bunq.to payment. + :type _bunqto_status: str + :param _bunqto_sub_status: The sub status of the bunq.to payment. + :type _bunqto_sub_status: str + :param _bunqto_share_url: The status of the bunq.to payment. + :type _bunqto_share_url: str + :param _bunqto_expiry: When bunq.to payment is about to expire. + :type _bunqto_expiry: str + :param _bunqto_time_responded: The timestamp of when the bunq.to payment was + responded to. + :type _bunqto_time_responded: str + :param _attachment: The Attachments attached to the Payment. + :type _attachment: list[object_.AttachmentMonetaryAccountPayment] + :param _merchant_reference: Optional data included with the Payment specific + to the merchant. + :type _merchant_reference: str + :param _batch_id: The id of the PaymentBatch if this Payment was part of + one. + :type _batch_id: int + :param _scheduled_id: The id of the JobScheduled if the Payment was + scheduled. + :type _scheduled_id: int + :param _address_shipping: A shipping Address provided with the Payment, + currently unused. + :type _address_shipping: object_.Address + :param _address_billing: A billing Address provided with the Payment, + currently unused. + :type _address_billing: object_.Address + :param _geolocation: The Geolocation where the Payment was done from. + :type _geolocation: object_.Geolocation + :param _request_reference_split_the_bill: The reference to the object used + for split the bill. Can be RequestInquiry or RequestInquiryBatch + :type _request_reference_split_the_bill: + list[object_.RequestInquiryReference] + :param _balance_after_mutation: The new balance of the monetary account + after the mutation. + :type _balance_after_mutation: object_.Amount + :param _payment_auto_allocate_instance: A reference to the + PaymentAutoAllocateInstance if it exists. + :type _payment_auto_allocate_instance: PaymentAutoAllocateInstance + :param _payment_suspended_outgoing: A reference to the + PaymentSuspendedOutgoing if it exists. + :type _payment_suspended_outgoing: PaymentSuspendedOutgoing + :param _payment_fee: Incurred fee for the payment. + :type _payment_fee: object_.PaymentFee """ + # Endpoint constants. + _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/mastercard-action/{}/payment" + + # Object type. + _OBJECT_TYPE_GET = "Payment" + _id_ = None _created = None _updated = None - _requested_by_user = None - _granted_by_user = None + _monetary_account_id = None + _amount = None + _alias = None + _counterparty_alias = None + _description = None + _type_ = None + _sub_type = None + _payment_arrival_expected = None + _bunqto_status = None + _bunqto_sub_status = None + _bunqto_share_url = None + _bunqto_expiry = None + _bunqto_time_responded = None + _attachment = None + _merchant_reference = None + _batch_id = None + _scheduled_id = None + _address_shipping = None + _address_billing = None + _geolocation = None + _request_reference_split_the_bill = None + _balance_after_mutation = None + _payment_auto_allocate_instance = None + _payment_suspended_outgoing = None + _payment_fee = None + + @classmethod + def list(cls,mastercard_action_id, monetary_account_id=None, params=None, custom_headers=None): + """ + :type user_id: int + :type monetary_account_id: int + :type mastercard_action_id: int + :type params: dict[str, str]|None + :type custom_headers: dict[str, str]|None + + :rtype: BunqResponseMasterCardPaymentList + """ + + if params is None: + params = {} + + if custom_headers is None: + custom_headers = {} + + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id(), cls._determine_monetary_account_id(monetary_account_id), mastercard_action_id) + response_raw = api_client.get(endpoint_url, params, custom_headers) + + return BunqResponseMasterCardPaymentList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) + ) @property def id_(self): @@ -26775,323 +47361,292 @@ def updated(self): return self._updated @property - def requested_by_user(self): + def monetary_account_id(self): """ - :rtype: object_.UserApiKeyAnchoredUser + :rtype: int """ - return self._requested_by_user + return self._monetary_account_id @property - def granted_by_user(self): + def amount(self): """ - :rtype: object_.UserApiKeyAnchoredUser + :rtype: object_.Amount """ - return self._granted_by_user + return self._amount - def is_all_field_none(self): + @property + def alias(self): """ - :rtype: bool + :rtype: object_.MonetaryAccountReference """ - if self._id_ is not None: - return False + return self._alias - if self._created is not None: - return False + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - if self._updated is not None: - return False + return self._counterparty_alias - if self._requested_by_user is not None: - return False + @property + def description(self): + """ + :rtype: str + """ - if self._granted_by_user is not None: - return False + return self._description - return True + @property + def type_(self): + """ + :rtype: str + """ - @staticmethod - def from_json(json_str): + return self._type_ + + @property + def sub_type(self): """ - :type json_str: str - - :rtype: UserApiKey + :rtype: str """ - return converter.json_to_class(UserApiKey, json_str) + return self._sub_type + @property + def payment_arrival_expected(self): + """ + :rtype: object_.PaymentArrivalExpected + """ -class PermittedIp(core.BunqModel): - """ - Manage the IPs which may be used for a credential of a user for server - authentication. - - :param _ip: The IP address. - :type _ip: str - :param _status: The status of the IP. May be "ACTIVE" or "INACTIVE". It is - only possible to make requests from "ACTIVE" IP addresses. Only "ACTIVE" IPs - will be billed. - :type _status: str - """ + return self._payment_arrival_expected - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/credential-password-ip/{}/ip/{}" - _ENDPOINT_URL_CREATE = "user/{}/credential-password-ip/{}/ip" - _ENDPOINT_URL_LISTING = "user/{}/credential-password-ip/{}/ip" - _ENDPOINT_URL_UPDATE = "user/{}/credential-password-ip/{}/ip/{}" + @property + def bunqto_status(self): + """ + :rtype: str + """ - # Field constants. - FIELD_IP = "ip" - FIELD_STATUS = "status" + return self._bunqto_status - # Object type. - _OBJECT_TYPE_GET = "PermittedIp" + @property + def bunqto_sub_status(self): + """ + :rtype: str + """ - _ip = None - _status = None - _ip_field_for_request = None - _status_field_for_request = None + return self._bunqto_sub_status - def __init__(self, ip, status=None): + @property + def bunqto_share_url(self): """ - :param ip: The IP address. - :type ip: str - :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It is - only possible to make requests from "ACTIVE" IP addresses. Only "ACTIVE" IPs - will be billed. - :type status: str + :rtype: str """ - self._ip_field_for_request = ip - self._status_field_for_request = status + return self._bunqto_share_url - @classmethod - def get(cls, credential_password_ip_id, permitted_ip_id, - custom_headers=None): + @property + def bunqto_expiry(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type credential_password_ip_id: int - :type permitted_ip_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponsePermittedIp + :rtype: str """ - if custom_headers is None: - custom_headers = {} + return self._bunqto_expiry - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - credential_password_ip_id, - permitted_ip_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + @property + def bunqto_time_responded(self): + """ + :rtype: str + """ - return BunqResponsePermittedIp.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._bunqto_time_responded - @classmethod - def create(cls, credential_password_ip_id, ip, status=None, - custom_headers=None): + @property + def attachment(self): """ - :type user_id: int - :type credential_password_ip_id: int - :param ip: The IP address. - :type ip: str - :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It - is only possible to make requests from "ACTIVE" IP addresses. Only - "ACTIVE" IPs will be billed. - :type status: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: list[object_.AttachmentMonetaryAccountPayment] """ - if custom_headers is None: - custom_headers = {} + return self._attachment - request_map = { - cls.FIELD_IP: ip, - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + @property + def merchant_reference(self): + """ + :rtype: str + """ - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - credential_password_ip_id) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + return self._merchant_reference - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + @property + def batch_id(self): + """ + :rtype: int + """ - @classmethod - def list(cls, credential_password_ip_id, params=None, custom_headers=None): + return self._batch_id + + @property + def scheduled_id(self): """ - :type user_id: int - :type credential_password_ip_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponsePermittedIpList + :rtype: int """ - if params is None: - params = {} + return self._scheduled_id - if custom_headers is None: - custom_headers = {} + @property + def address_shipping(self): + """ + :rtype: object_.Address + """ - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), credential_password_ip_id) - response_raw = api_client.get(endpoint_url, params, custom_headers) + return self._address_shipping - return BunqResponsePermittedIpList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + @property + def address_billing(self): + """ + :rtype: object_.Address + """ - @classmethod - def update(cls, credential_password_ip_id, permitted_ip_id, status=None, - custom_headers=None): + return self._address_billing + + @property + def geolocation(self): """ - :type user_id: int - :type credential_password_ip_id: int - :type permitted_ip_id: int - :param status: The status of the IP. May be "ACTIVE" or "INACTIVE". It - is only possible to make requests from "ACTIVE" IP addresses. Only - "ACTIVE" IPs will be billed. - :type status: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: object_.Geolocation """ - if custom_headers is None: - custom_headers = {} + return self._geolocation - api_client = client.ApiClient(cls._get_api_context()) + @property + def request_reference_split_the_bill(self): + """ + :rtype: list[object_.RequestInquiryReference] + """ - request_map = { - cls.FIELD_STATUS: status - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + return self._request_reference_split_the_bill - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - credential_password_ip_id, - permitted_ip_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + @property + def balance_after_mutation(self): + """ + :rtype: object_.Amount + """ - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + return self._balance_after_mutation @property - def ip(self): + def payment_auto_allocate_instance(self): """ - :rtype: str + :rtype: PaymentAutoAllocateInstance """ - return self._ip + return self._payment_auto_allocate_instance @property - def status(self): + def payment_suspended_outgoing(self): """ - :rtype: str + :rtype: PaymentSuspendedOutgoing """ - return self._status + return self._payment_suspended_outgoing + + @property + def payment_fee(self): + """ + :rtype: object_.PaymentFee + """ + + return self._payment_fee def is_all_field_none(self): """ :rtype: bool """ - if self._ip is not None: + if self._id_ is not None: return False - if self._status is not None: + if self._created is not None: return False - return True + if self._updated is not None: + return False - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: PermittedIp - """ + if self._monetary_account_id is not None: + return False - return converter.json_to_class(PermittedIp, json_str) + if self._amount is not None: + return False + if self._alias is not None: + return False -class SandboxUser(core.BunqModel): - """ - Used to create a sandbox user. - - :param _api_key: The API key of the newly created sandbox user. - :type _api_key: str - """ + if self._counterparty_alias is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_CREATE = "sandbox-user" + if self._description is not None: + return False - # Object type. - _OBJECT_TYPE_POST = "ApiKey" + if self._type_ is not None: + return False - _api_key = None + if self._sub_type is not None: + return False + + if self._payment_arrival_expected is not None: + return False + + if self._bunqto_status is not None: + return False + + if self._bunqto_sub_status is not None: + return False + + if self._bunqto_share_url is not None: + return False + + if self._bunqto_expiry is not None: + return False + + if self._bunqto_time_responded is not None: + return False + + if self._attachment is not None: + return False + + if self._merchant_reference is not None: + return False - @classmethod - def create(cls, custom_headers=None): - """ - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseSandboxUser - """ + if self._batch_id is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._scheduled_id is not None: + return False - request_map = { + if self._address_shipping is not None: + return False - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + if self._address_billing is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + if self._geolocation is not None: + return False - return BunqResponseSandboxUser.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_POST) - ) + if self._request_reference_split_the_bill is not None: + return False - @property - def api_key(self): - """ - :rtype: str - """ + if self._balance_after_mutation is not None: + return False - return self._api_key + if self._payment_auto_allocate_instance is not None: + return False - def is_all_field_none(self): - """ - :rtype: bool - """ + if self._payment_suspended_outgoing is not None: + return False - if self._api_key is not None: + if self._payment_fee is not None: return False return True @@ -27101,95 +47656,104 @@ def from_json(json_str): """ :type json_str: str - :rtype: SandboxUser + :rtype: MasterCardPaymentApiObject """ - return converter.json_to_class(SandboxUser, json_str) + return converter.json_to_class(MasterCardPaymentApiObject, json_str) -class SchedulePaymentBatch(core.BunqModel): +class MasterCardIdentityCheckChallengeRequestUserApiObject(BunqModel): """ - Endpoint for schedule payment batches. + Endpoint for apps to fetch a challenge request. - :param _payments: The payment details. - :type _payments: list[object_.SchedulePaymentEntry] - :param _schedule: The schedule details. - :type _schedule: Schedule + :param _status: The status of the secure code. Can be PENDING, ACCEPTED, + REJECTED, EXPIRED. + :type _status: str + :param _amount: The transaction amount. + :type _amount: str + :param _expiry_time: When the identity check expires. + :type _expiry_time: str + :param _description: The description of the purchase. NULL if no description + is given. + :type _description: str + :param _decision_description: Textual explanation of the decision. + :type _decision_description: str + :param _decision_description_translated: Textual explanation of the decision + in user's language. + :type _decision_description_translated: str + :param _url_merchant_app: The return url for the merchant app after the + challenge is accepted or rejected. + :type _url_merchant_app: str + :param _counterparty_alias: The monetary account label of the counterparty. + :type _counterparty_alias: object_.MonetaryAccountReference + :param _event_id: The ID of the latest event for the identity check. + :type _event_id: int + :param _card_id: The ID of the card used for the authentication request of + the identity check. + :type _card_id: int """ # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/schedule-payment-batch" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/schedule-payment-batch/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/schedule-payment-batch/{}" + _ENDPOINT_URL_READ = "user/{}/challenge-request/{}" + _ENDPOINT_URL_UPDATE = "user/{}/challenge-request/{}" # Field constants. - FIELD_PAYMENTS = "payments" - FIELD_SCHEDULE = "schedule" + FIELD_STATUS = "status" - _payments = None - _schedule = None - _payments_field_for_request = None - _schedule_field_for_request = None + # Object type. + _OBJECT_TYPE_GET = "MasterCardIdentityCheckChallengeRequest" - def __init__(self, payments=None, schedule=None): + _amount = None + _expiry_time = None + _description = None + _status = None + _decision_description = None + _decision_description_translated = None + _url_merchant_app = None + _counterparty_alias = None + _event_id = None + _card_id = None + _status_field_for_request = None + + def __init__(self, status=None): """ - :param payments: The payment details. - :type payments: list[object_.SchedulePaymentEntry] - :param schedule: The schedule details when creating a scheduled payment. - :type schedule: Schedule + :param status: The status of the identity check. Can be + ACCEPTED_PENDING_RESPONSE or REJECTED_PENDING_RESPONSE. + :type status: str """ - self._payments_field_for_request = payments - self._schedule_field_for_request = schedule + self._status_field_for_request = status @classmethod - def create(cls, payments, schedule, monetary_account_id=None, - custom_headers=None): + def get(cls, master_card_identity_check_challenge_request_user_id, custom_headers=None): """ + :type api_context: ApiContext :type user_id: int - :type monetary_account_id: int - :param payments: The payment details. - :type payments: list[object_.SchedulePaymentEntry] - :param schedule: The schedule details when creating a scheduled payment. - :type schedule: Schedule + :type master_card_identity_check_challenge_request_user_id: int :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseMasterCardIdentityCheckChallengeRequestUser """ if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_PAYMENTS: payments, - cls.FIELD_SCHEDULE: schedule - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id)) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), master_card_identity_check_challenge_request_user_id) + response_raw = api_client.get(endpoint_url, {}, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseMasterCardIdentityCheckChallengeRequestUser.cast_from_bunq_response( + cls._from_json(response_raw, cls._OBJECT_TYPE_GET) ) @classmethod - def update(cls, schedule_payment_batch_id, monetary_account_id=None, - payments=None, schedule=None, custom_headers=None): + def update(cls, master_card_identity_check_challenge_request_user_id, status=None, custom_headers=None): """ :type user_id: int - :type monetary_account_id: int - :type schedule_payment_batch_id: int - :param payments: The payment details. - :type payments: list[object_.SchedulePaymentEntry] - :param schedule: The schedule details when creating a scheduled payment. - :type schedule: Schedule + :type master_card_identity_check_challenge_request_user_id: int + :param status: The status of the identity check. Can be + ACCEPTED_PENDING_RESPONSE or REJECTED_PENDING_RESPONSE. + :type status: str :type custom_headers: dict[str, str]|None :rtype: BunqResponseInt @@ -27198,188 +47762,136 @@ def update(cls, schedule_payment_batch_id, monetary_account_id=None, if custom_headers is None: custom_headers = {} - api_client = client.ApiClient(cls._get_api_context()) + api_client = ApiClient(cls._get_api_context()) request_map = { - cls.FIELD_PAYMENTS: payments, - cls.FIELD_SCHEDULE: schedule - } +cls.FIELD_STATUS : status +} request_map_string = converter.class_to_json(request_map) request_map_string = cls._remove_field_for_request(request_map_string) request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_payment_batch_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), master_card_identity_check_challenge_request_user_id) + response_raw = api_client.put(endpoint_url, request_bytes, custom_headers) return BunqResponseInt.cast_from_bunq_response( cls._process_for_id(response_raw) ) - @classmethod - def delete(cls, schedule_payment_batch_id, monetary_account_id=None, - custom_headers=None): + @property + def amount(self): """ - :type user_id: int - :type monetary_account_id: int - :type schedule_payment_batch_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: str """ - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - schedule_payment_batch_id) - response_raw = api_client.delete(endpoint_url, custom_headers) - - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + return self._amount @property - def payments(self): + def expiry_time(self): """ - :rtype: list[object_.SchedulePaymentEntry] + :rtype: str """ - return self._payments + return self._expiry_time @property - def schedule(self): + def description(self): """ - :rtype: Schedule + :rtype: str """ - return self._schedule + return self._description - def is_all_field_none(self): + @property + def status(self): """ - :rtype: bool + :rtype: str """ - if self._payments is not None: - return False + return self._status - if self._schedule is not None: - return False + @property + def decision_description(self): + """ + :rtype: str + """ - return True + return self._decision_description - @staticmethod - def from_json(json_str): + @property + def decision_description_translated(self): """ - :type json_str: str - - :rtype: SchedulePaymentBatch + :rtype: str """ - return converter.json_to_class(SchedulePaymentBatch, json_str) + return self._decision_description_translated + @property + def url_merchant_app(self): + """ + :rtype: str + """ -class ScheduleUser(core.BunqModel): - """ - view for reading the scheduled definitions. - """ + return self._url_merchant_app - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/schedule" + @property + def counterparty_alias(self): + """ + :rtype: object_.MonetaryAccountReference + """ - # Object type. - _OBJECT_TYPE_GET = "ScheduleUser" + return self._counterparty_alias - @classmethod - def list(cls, params=None, custom_headers=None): + @property + def event_id(self): """ - Get a collection of scheduled definition for all accessible monetary - accounts of the user. You can add the parameter type to filter the - response. When - type={SCHEDULE_DEFINITION_PAYMENT,SCHEDULE_DEFINITION_PAYMENT_BATCH} is - provided only schedule definition object that relate to these - definitions are returned. - - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseScheduleUserList + :rtype: int """ - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} + return self._event_id - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) + @property + def card_id(self): + """ + :rtype: int + """ - return BunqResponseScheduleUserList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + return self._card_id def is_all_field_none(self): """ :rtype: bool """ - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: ScheduleUser - """ + if self._amount is not None: + return False - return converter.json_to_class(ScheduleUser, json_str) + if self._expiry_time is not None: + return False + if self._description is not None: + return False -class Session(core.BunqModel): - """ - Endpoint for operations over the current session. - """ + if self._status is not None: + return False - # Endpoint constants. - _ENDPOINT_URL_DELETE = "session/{}" + if self._decision_description is not None: + return False - @classmethod - def delete(cls, session_id, custom_headers=None): - """ - Deletes the current session. - - :type session_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone - """ + if self._decision_description_translated is not None: + return False - if custom_headers is None: - custom_headers = {} + if self._url_merchant_app is not None: + return False - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(session_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + if self._counterparty_alias is not None: + return False - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + if self._event_id is not None: + return False - def is_all_field_none(self): - """ - :rtype: bool - """ + if self._card_id is not None: + return False return True @@ -27388,93 +47900,78 @@ def from_json(json_str): """ :type json_str: str - :rtype: Session + :rtype: MasterCardIdentityCheckChallengeRequestUserApiObject """ - return converter.json_to_class(Session, json_str) + return converter.json_to_class(MasterCardIdentityCheckChallengeRequestUserApiObject, json_str) -class TabItemShopBatch(core.BunqModel): +class HealthCheckApiObject(BunqModel, AnchorObjectInterface): """ - Create a batch of tab items. + Basic health check for uptime and instance health monitoring. - :param _tab_items: The list of tab items in the batch. - :type _tab_items: list[TabItemShop] + :param _HealthResult: + :type _HealthResult: object_.HealthCheckResult """ - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item-batch" - - # Field constants. - FIELD_TAB_ITEMS = "tab_items" + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - _tab_items = None - _tab_items_field_for_request = None + # Endpoint constants. + _ENDPOINT_URL_LISTING = "health-check" - def __init__(self, tab_items): - """ - :param tab_items: The list of tab items we want to create in a single batch. - Limited to 50 items per batch. - :type tab_items: list[TabItemShop] - """ + # Object type. + _OBJECT_TYPE_GET = "HealthCheckResult" - self._tab_items_field_for_request = tab_items + _HealthResult = None @classmethod - def create(cls, cash_register_id, tab_uuid, tab_items, - monetary_account_id=None, custom_headers=None): + def list(cls, params=None, custom_headers=None): """ - Create tab items as a batch. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :param tab_items: The list of tab items we want to create in a single - batch. Limited to 50 items per batch. - :type tab_items: list[TabItemShop] + :type params: dict[str, str]|None :type custom_headers: dict[str, str]|None - :rtype: BunqResponseInt + :rtype: BunqResponseHealthCheckList """ + if params is None: + params = {} + if custom_headers is None: custom_headers = {} - request_map = { - cls.FIELD_TAB_ITEMS: tab_items - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_uuid) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + api_client = ApiClient(cls._get_api_context()) + endpoint_url = cls._ENDPOINT_URL_LISTING + response_raw = api_client.get(endpoint_url, params, custom_headers) - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) + return BunqResponseHealthCheckList.cast_from_bunq_response( + cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) ) @property - def tab_items(self): + def HealthResult(self): + """ + :rtype: object_.HealthCheckResult + """ + + return self._HealthResult + def get_referenced_object(self): """ - :rtype: list[TabItemShop] + :rtype: BunqModel + :raise: BunqException """ - return self._tab_items + if self._HealthResult is not None: + return self._HealthResult + + raise BunqException(self._ERROR_NULL_FIELDS) def is_all_field_none(self): """ :rtype: bool """ - if self._tab_items is not None: + if self._HealthResult is not None: return False return True @@ -27484,2682 +47981,2497 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabItemShopBatch + :rtype: HealthCheckApiObject """ - return converter.json_to_class(TabItemShopBatch, json_str) - - -class TabItemShop(core.BunqModel): - """ - After you’ve created a Tab using /tab-usage-single or /tab-usage-multiple - you can add items and attachments using tab-item. You can only add or modify - TabItems of a Tab which status is OPEN. The amount of the TabItems will not - influence the total_amount of the corresponding Tab. However, if you've - created any TabItems for a Tab the sum of the amounts of these items must be - equal to the total_amount of the Tab when you change its status to - PAYABLE/WAITING_FOR_PAYMENT. + return converter.json_to_class(HealthCheckApiObject, json_str) - :param _description: The TabItem's brief description. - :type _description: str - :param _ean_code: The TabItem's EAN code. - :type _ean_code: str - :param _avatar_attachment_uuid: An AttachmentPublic UUID that used as an - avatar for the TabItem. - :type _avatar_attachment_uuid: str - :param _tab_attachment: A list of AttachmentTab attached to the TabItem. - :type _tab_attachment: list[object_.AttachmentTab] - :param _quantity: The quantity of the TabItem. - :type _quantity: float - :param _amount: The money amount of the TabItem. - :type _amount: object_.Amount - :param _id_: The id of the created TabItem. - :type _id_: int - :param _avatar_attachment: A struct with an AttachmentPublic UUID that used - as an avatar for the TabItem. - :type _avatar_attachment: object_.AttachmentPublic - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item" - _ENDPOINT_URL_UPDATE = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item/{}" - _ENDPOINT_URL_DELETE = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item/{}" - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item" - _ENDPOINT_URL_READ = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/tab-item/{}" - - # Field constants. - FIELD_DESCRIPTION = "description" - FIELD_EAN_CODE = "ean_code" - FIELD_AVATAR_ATTACHMENT_UUID = "avatar_attachment_uuid" - FIELD_TAB_ATTACHMENT = "tab_attachment" - FIELD_QUANTITY = "quantity" - FIELD_AMOUNT = "amount" - - # Object type. - _OBJECT_TYPE_GET = "TabItem" - - _id_ = None - _description = None - _ean_code = None - _avatar_attachment = None - _tab_attachment = None - _quantity = None - _amount = None - _description_field_for_request = None - _ean_code_field_for_request = None - _avatar_attachment_uuid_field_for_request = None - _tab_attachment_field_for_request = None - _quantity_field_for_request = None - _amount_field_for_request = None - - def __init__(self, description=None, ean_code=None, - avatar_attachment_uuid=None, tab_attachment=None, - quantity=None, amount=None): +class BunqResponseBillingContractSubscriptionList(BunqResponse): + @property + def value(self): """ - :param description: The TabItem's brief description. Can't be empty and must - be no longer than 100 characters - :type description: str - :param ean_code: The TabItem's EAN code. - :type ean_code: str - :param avatar_attachment_uuid: An AttachmentPublic UUID that used as an - avatar for the TabItem. - :type avatar_attachment_uuid: str - :param tab_attachment: A list of AttachmentTab attached to the TabItem. - :type tab_attachment: list[int] - :param quantity: The quantity of the TabItem. Formatted as a number - containing up to 15 digits, up to 15 decimals and using a dot. - :type quantity: str - :param amount: The money amount of the TabItem. Will not change the value of - the corresponding Tab. - :type amount: object_.Amount + :rtype: list[BillingContractSubscription] """ + + return super().value - self._description_field_for_request = description - self._ean_code_field_for_request = ean_code - self._avatar_attachment_uuid_field_for_request = avatar_attachment_uuid - self._tab_attachment_field_for_request = tab_attachment - self._quantity_field_for_request = quantity - self._amount_field_for_request = amount - - @classmethod - def create(cls, cash_register_id, tab_uuid, description, - monetary_account_id=None, ean_code=None, - avatar_attachment_uuid=None, tab_attachment=None, quantity=None, - amount=None, custom_headers=None): + +class BunqResponseCustomerLimitList(BunqResponse): + @property + def value(self): """ - Create a new TabItem for a given Tab. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :param description: The TabItem's brief description. Can't be empty and - must be no longer than 100 characters - :type description: str - :param ean_code: The TabItem's EAN code. - :type ean_code: str - :param avatar_attachment_uuid: An AttachmentPublic UUID that used as an - avatar for the TabItem. - :type avatar_attachment_uuid: str - :param tab_attachment: A list of AttachmentTab attached to the TabItem. - :type tab_attachment: list[int] - :param quantity: The quantity of the TabItem. Formatted as a number - containing up to 15 digits, up to 15 decimals and using a dot. - :type quantity: str - :param amount: The money amount of the TabItem. Will not change the - value of the corresponding Tab. - :type amount: object_.Amount - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: list[CustomerLimit] """ + + return super().value - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_EAN_CODE: ean_code, - cls.FIELD_AVATAR_ATTACHMENT_UUID: avatar_attachment_uuid, - cls.FIELD_TAB_ATTACHMENT: tab_attachment, - cls.FIELD_QUANTITY: quantity, - cls.FIELD_AMOUNT: amount - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_uuid) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) - - @classmethod - def update(cls, cash_register_id, tab_uuid, tab_item_shop_id, - monetary_account_id=None, description=None, ean_code=None, - avatar_attachment_uuid=None, tab_attachment=None, quantity=None, - amount=None, custom_headers=None): + +class BunqResponseInvoiceExportPdf(BunqResponse): + @property + def value(self): """ - Modify a TabItem from a given Tab. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type tab_item_shop_id: int - :param description: The TabItem's brief description. Can't be empty and - must be no longer than 100 characters - :type description: str - :param ean_code: The TabItem's EAN code. - :type ean_code: str - :param avatar_attachment_uuid: An AttachmentPublic UUID that used as an - avatar for the TabItem. - :type avatar_attachment_uuid: str - :param tab_attachment: A list of AttachmentTab attached to the TabItem. - :type tab_attachment: list[int] - :param quantity: The quantity of the TabItem. Formatted as a number - containing up to 15 digits, up to 15 decimals and using a dot. - :type quantity: str - :param amount: The money amount of the TabItem. Will not change the - value of the corresponding Tab. - :type amount: object_.Amount - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseInt + :rtype: InvoiceExportPdf """ + + return super().value - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - - request_map = { - cls.FIELD_DESCRIPTION: description, - cls.FIELD_EAN_CODE: ean_code, - cls.FIELD_AVATAR_ATTACHMENT_UUID: avatar_attachment_uuid, - cls.FIELD_TAB_ATTACHMENT: tab_attachment, - cls.FIELD_QUANTITY: quantity, - cls.FIELD_AMOUNT: amount - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_UPDATE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_uuid, - tab_item_shop_id) - response_raw = api_client.put(endpoint_url, request_bytes, - custom_headers) + +class BunqResponseInt(BunqResponse): + @property + def value(self): + """ + :rtype: int + """ + + return super().value - return BunqResponseInt.cast_from_bunq_response( - cls._process_for_id(response_raw) - ) + +class BunqResponseNone(BunqResponse): + @property + def value(self): + """ + :rtype: None + """ + + return super().value - @classmethod - def delete(cls, cash_register_id, tab_uuid, tab_item_shop_id, - monetary_account_id=None, custom_headers=None): + +class BunqResponseBytes(BunqResponse): + @property + def value(self): """ - Delete a specific TabItem from a Tab. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type tab_item_shop_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseNone + :rtype: bytes """ + + return super().value - if custom_headers is None: - custom_headers = {} + +class BunqResponseInvoiceList(BunqResponse): + @property + def value(self): + """ + :rtype: list[Invoice] + """ + + return super().value - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_DELETE.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, - tab_uuid, - tab_item_shop_id) - response_raw = api_client.delete(endpoint_url, custom_headers) + +class BunqResponseInvoice(BunqResponse): + @property + def value(self): + """ + :rtype: Invoice + """ + + return super().value - return BunqResponseNone.cast_from_bunq_response( - client.BunqResponse(None, response_raw.headers) - ) + +class BunqResponseInvoiceByUserList(BunqResponse): + @property + def value(self): + """ + :rtype: list[InvoiceByUser] + """ + + return super().value - @classmethod - def list(cls, cash_register_id, tab_uuid, monetary_account_id=None, - params=None, custom_headers=None): + +class BunqResponseInvoiceByUser(BunqResponse): + @property + def value(self): """ - Get a collection of TabItems from a given Tab. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabItemShopList + :rtype: InvoiceByUser """ + + return super().value - if params is None: - params = {} + +class BunqResponseAdditionalTransactionInformationCategoryList(BunqResponse): + @property + def value(self): + """ + :rtype: list[AdditionalTransactionInformationCategory] + """ + + return super().value - if custom_headers is None: - custom_headers = {} + +class BunqResponseStr(BunqResponse): + @property + def value(self): + """ + :rtype: str + """ + + return super().value - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id, tab_uuid) - response_raw = api_client.get(endpoint_url, params, custom_headers) + +class BunqResponseAttachmentPublic(BunqResponse): + @property + def value(self): + """ + :rtype: AttachmentPublic + """ + + return super().value - return BunqResponseTabItemShopList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) + +class BunqResponseAttachmentUser(BunqResponse): + @property + def value(self): + """ + :rtype: AttachmentUser + """ + + return super().value - @classmethod - def get(cls, cash_register_id, tab_uuid, tab_item_shop_id, - monetary_account_id=None, custom_headers=None): + +class BunqResponseAvatar(BunqResponse): + @property + def value(self): """ - Get a specific TabItem from a given Tab. - - :type api_context: context.ApiContext - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type tab_item_shop_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTabItemShop + :rtype: Avatar """ + + return super().value - if custom_headers is None: - custom_headers = {} + +class BunqResponseBankSwitchServiceNetherlandsIncomingPayment(BunqResponse): + @property + def value(self): + """ + :rtype: BankSwitchServiceNetherlandsIncomingPayment + """ + + return super().value - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - cls._determine_monetary_account_id( - monetary_account_id), - cash_register_id, tab_uuid, - tab_item_shop_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) + +class BunqResponsePayment(BunqResponse): + @property + def value(self): + """ + :rtype: Payment + """ + + return super().value - return BunqResponseTabItemShop.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) + +class BunqResponsePaymentList(BunqResponse): + @property + def value(self): + """ + :rtype: list[Payment] + """ + + return super().value + +class BunqResponsePaymentAutoAllocateInstanceList(BunqResponse): @property - def id_(self): + def value(self): """ - :rtype: int + :rtype: list[PaymentAutoAllocateInstance] """ + + return super().value - return self._id_ - + +class BunqResponsePaymentAutoAllocateInstance(BunqResponse): @property - def description(self): + def value(self): """ - :rtype: str + :rtype: PaymentAutoAllocateInstance """ + + return super().value - return self._description - + +class BunqResponsePaymentBatch(BunqResponse): @property - def ean_code(self): + def value(self): """ - :rtype: str + :rtype: PaymentBatch """ + + return super().value - return self._ean_code - + +class BunqResponsePaymentBatchList(BunqResponse): @property - def avatar_attachment(self): + def value(self): """ - :rtype: object_.AttachmentPublic + :rtype: list[PaymentBatch] """ + + return super().value - return self._avatar_attachment - + +class BunqResponseBunqMeFundraiserProfileUser(BunqResponse): @property - def tab_attachment(self): + def value(self): """ - :rtype: list[object_.AttachmentTab] + :rtype: BunqMeFundraiserProfileUser """ + + return super().value - return self._tab_attachment - + +class BunqResponseBunqMeFundraiserProfileUserList(BunqResponse): @property - def quantity(self): + def value(self): """ - :rtype: float + :rtype: list[BunqMeFundraiserProfileUser] """ + + return super().value - return self._quantity - + +class BunqResponseBunqMeFundraiserResult(BunqResponse): @property - def amount(self): + def value(self): """ - :rtype: object_.Amount + :rtype: BunqMeFundraiserResult """ + + return super().value - return self._amount - - def is_all_field_none(self): + +class BunqResponseBunqMeTabResultResponse(BunqResponse): + @property + def value(self): """ - :rtype: bool + :rtype: BunqMeTabResultResponse """ + + return super().value - if self._id_ is not None: - return False - - if self._description is not None: - return False - - if self._ean_code is not None: - return False - - if self._avatar_attachment is not None: - return False - - if self._tab_attachment is not None: - return False - - if self._quantity is not None: - return False - - if self._amount is not None: - return False - - return True - - @staticmethod - def from_json(json_str): + +class BunqResponseBunqMeTabList(BunqResponse): + @property + def value(self): """ - :type json_str: str - - :rtype: TabItemShop + :rtype: list[BunqMeTab] """ + + return super().value - return converter.json_to_class(TabItemShop, json_str) - - -class TabQrCodeContent(core.BunqModel): - """ - This call returns the raw content of the QR code that links to this Tab. - When a bunq user scans this QR code with the bunq app the Tab will be shown - on his/her device. - """ - - # Endpoint constants. - _ENDPOINT_URL_LISTING = "user/{}/monetary-account/{}/cash-register/{}/tab/{}/qr-code-content" - - # Object type. - _OBJECT_TYPE_GET = "TabQrCodeContent" - - @classmethod - def list(cls, cash_register_id, tab_uuid, monetary_account_id=None, - custom_headers=None): + +class BunqResponseBunqMeTab(BunqResponse): + @property + def value(self): """ - Returns the raw content of the QR code that links to this Tab. The raw - content is the binary representation of a file, without any JSON - wrapping. - - :type user_id: int - :type monetary_account_id: int - :type cash_register_id: int - :type tab_uuid: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseBytes + :rtype: BunqMeTab """ + + return super().value - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id(), - cls._determine_monetary_account_id(monetary_account_id), - cash_register_id, tab_uuid) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseBytes.cast_from_bunq_response( - client.BunqResponse(response_raw.body_bytes, response_raw.headers) - ) - - def is_all_field_none(self): + +class BunqResponseCardBatchReplace(BunqResponse): + @property + def value(self): """ - :rtype: bool + :rtype: CardBatchReplace """ + + return super().value - return True - - @staticmethod - def from_json(json_str): + +class BunqResponseCardBatch(BunqResponse): + @property + def value(self): """ - :type json_str: str - - :rtype: TabQrCodeContent + :rtype: CardBatch """ + + return super().value - return converter.json_to_class(TabQrCodeContent, json_str) - - -class TokenQrRequestIdeal(core.BunqModel): - """ - Using this call you create a request for payment from an external token - provided with an ideal transaction. Make sure your iDEAL payments are - compliant with the iDEAL standards, by following the following manual: - https://www.bunq.com/terms-idealstandards. It's very important to keep these - points in mind when you are using the endpoint to make iDEAL payments from - your application. - :param _token: The token passed from a site or read from a QR code. - :type _token: str - :param _id_: The id of the RequestResponse. - :type _id_: int - :param _time_responded: The timestamp of when the RequestResponse was - responded to. - :type _time_responded: str - :param _time_expiry: The timestamp of when the RequestResponse expired or - will expire. - :type _time_expiry: str - :param _monetary_account_id: The id of the MonetaryAccount the - RequestResponse was received on. - :type _monetary_account_id: int - :param _amount_inquired: The requested Amount. - :type _amount_inquired: object_.Amount - :param _amount_responded: The Amount the RequestResponse was accepted with. - :type _amount_responded: object_.Amount - :param _alias: The LabelMonetaryAccount with the public information of the - MonetaryAccount this RequestResponse was received on. - :type _alias: object_.MonetaryAccountReference - :param _counterparty_alias: The LabelMonetaryAccount with the public - information of the MonetaryAccount that is requesting money with this - RequestResponse. - :type _counterparty_alias: object_.MonetaryAccountReference - :param _description: The description for the RequestResponse provided by the - requesting party. Maximum 9000 characters. - :type _description: str - :param _attachment: The Attachments attached to the RequestResponse. - :type _attachment: list[object_.Attachment] - :param _status: The status of the created RequestResponse. Can only be - PENDING. - :type _status: str - :param _minimum_age: The minimum age the user accepting the RequestResponse - must have. - :type _minimum_age: int - :param _require_address: Whether or not an address must be provided on - accept. - :type _require_address: str - :param _address_shipping: The shipping address provided by the accepting - user if an address was requested. - :type _address_shipping: object_.Address - :param _address_billing: The billing address provided by the accepting user - if an address was requested. - :type _address_billing: object_.Address - :param _geolocation: The Geolocation where the RequestResponse was created. - :type _geolocation: object_.Geolocation - :param _redirect_url: The URL which the user is sent to after accepting or - rejecting the Request. - :type _redirect_url: str - :param _type_: The type of the RequestResponse. Can be only be IDEAL. - :type _type_: str - :param _sub_type: The subtype of the RequestResponse. Can be only be NONE. - :type _sub_type: str - :param _allow_chat: Whether or not chat messages are allowed. - :type _allow_chat: bool - :param _eligible_whitelist_id: The whitelist id for this action or null. - :type _eligible_whitelist_id: int - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/token-qr-request-ideal" +class BunqResponseCardCredit(BunqResponse): + @property + def value(self): + """ + :rtype: CardCredit + """ + + return super().value - # Field constants. - FIELD_TOKEN = "token" + +class BunqResponseCardGeneratedCvc2(BunqResponse): + @property + def value(self): + """ + :rtype: CardGeneratedCvc2 + """ + + return super().value - # Object type. - _OBJECT_TYPE_POST = "RequestResponse" + +class BunqResponseCardGeneratedCvc2List(BunqResponse): + @property + def value(self): + """ + :rtype: list[CardGeneratedCvc2] + """ + + return super().value - _id_ = None - _time_responded = None - _time_expiry = None - _monetary_account_id = None - _amount_inquired = None - _amount_responded = None - _alias = None - _counterparty_alias = None - _description = None - _attachment = None - _status = None - _minimum_age = None - _require_address = None - _address_shipping = None - _address_billing = None - _geolocation = None - _redirect_url = None - _type_ = None - _sub_type = None - _allow_chat = None - _eligible_whitelist_id = None - _token_field_for_request = None + +class BunqResponseCardDebit(BunqResponse): + @property + def value(self): + """ + :rtype: CardDebit + """ + + return super().value - def __init__(self, token): + +class BunqResponseCardNameList(BunqResponse): + @property + def value(self): """ - :param token: The token passed from a site or read from a QR code. - :type token: str + :rtype: list[CardName] """ + + return super().value - self._token_field_for_request = token + +class BunqResponseCard(BunqResponse): + @property + def value(self): + """ + :rtype: Card + """ + + return super().value - @classmethod - def create(cls, token, custom_headers=None): + +class BunqResponseCardList(BunqResponse): + @property + def value(self): """ - Create a request from an ideal transaction. - - :type user_id: int - :param token: The token passed from a site or read from a QR code. - :type token: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTokenQrRequestIdeal + :rtype: list[Card] """ + + return super().value - if custom_headers is None: - custom_headers = {} + +class BunqResponseCertificatePinnedList(BunqResponse): + @property + def value(self): + """ + :rtype: list[CertificatePinned] + """ + + return super().value - request_map = { - cls.FIELD_TOKEN: token - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) + +class BunqResponseCertificatePinned(BunqResponse): + @property + def value(self): + """ + :rtype: CertificatePinned + """ + + return super().value - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) + +class BunqResponseCompanyEmployeeSettingAdyenCardTransaction(BunqResponse): + @property + def value(self): + """ + :rtype: CompanyEmployeeSettingAdyenCardTransaction + """ + + return super().value - return BunqResponseTokenQrRequestIdeal.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_POST) - ) + +class BunqResponseCompany(BunqResponse): + @property + def value(self): + """ + :rtype: Company + """ + + return super().value + +class BunqResponseCompanyList(BunqResponse): @property - def id_(self): + def value(self): """ - :rtype: int + :rtype: list[Company] """ + + return super().value - return self._id_ + +class BunqResponseUserCompany(BunqResponse): + @property + def value(self): + """ + :rtype: UserCompany + """ + + return super().value + +class BunqResponseConfirmationOfFunds(BunqResponse): @property - def time_responded(self): + def value(self): """ - :rtype: str + :rtype: ConfirmationOfFunds """ + + return super().value - return self._time_responded + +class BunqResponseCurrencyCloudBeneficiaryRequirementList(BunqResponse): + @property + def value(self): + """ + :rtype: list[CurrencyCloudBeneficiaryRequirement] + """ + + return super().value + +class BunqResponseCurrencyCloudBeneficiary(BunqResponse): @property - def time_expiry(self): + def value(self): """ - :rtype: str + :rtype: CurrencyCloudBeneficiary """ + + return super().value - return self._time_expiry + +class BunqResponseCurrencyCloudBeneficiaryList(BunqResponse): + @property + def value(self): + """ + :rtype: list[CurrencyCloudBeneficiary] + """ + + return super().value + +class BunqResponseCurrencyConversionQuote(BunqResponse): @property - def monetary_account_id(self): + def value(self): """ - :rtype: int + :rtype: CurrencyConversionQuote """ + + return super().value - return self._monetary_account_id + +class BunqResponseCurrencyConversionList(BunqResponse): + @property + def value(self): + """ + :rtype: list[CurrencyConversion] + """ + + return super().value + +class BunqResponseCurrencyConversion(BunqResponse): @property - def amount_inquired(self): + def value(self): """ - :rtype: object_.Amount + :rtype: CurrencyConversion """ + + return super().value - return self._amount_inquired + +class BunqResponseDeviceServer(BunqResponse): + @property + def value(self): + """ + :rtype: DeviceServer + """ + + return super().value + +class BunqResponseDeviceServerList(BunqResponse): @property - def amount_responded(self): + def value(self): """ - :rtype: object_.Amount + :rtype: list[DeviceServer] """ + + return super().value - return self._amount_responded + +class BunqResponseDevice(BunqResponse): + @property + def value(self): + """ + :rtype: Device + """ + + return super().value + +class BunqResponseDeviceList(BunqResponse): @property - def alias(self): + def value(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: list[Device] """ + + return super().value - return self._alias + +class BunqResponseDraftPaymentList(BunqResponse): + @property + def value(self): + """ + :rtype: list[DraftPayment] + """ + + return super().value + +class BunqResponseDraftPayment(BunqResponse): @property - def counterparty_alias(self): + def value(self): """ - :rtype: object_.MonetaryAccountReference + :rtype: DraftPayment """ + + return super().value - return self._counterparty_alias + +class BunqResponseSchedule(BunqResponse): + @property + def value(self): + """ + :rtype: Schedule + """ + + return super().value + +class BunqResponseScheduleList(BunqResponse): @property - def description(self): + def value(self): """ - :rtype: str + :rtype: list[Schedule] """ + + return super().value - return self._description + +class BunqResponseEvent(BunqResponse): + @property + def value(self): + """ + :rtype: Event + """ + + return super().value + +class BunqResponseEventList(BunqResponse): @property - def attachment(self): + def value(self): """ - :rtype: list[object_.Attachment] + :rtype: list[Event] """ + + return super().value - return self._attachment + +class BunqResponseFeatureAnnouncement(BunqResponse): + @property + def value(self): + """ + :rtype: FeatureAnnouncement + """ + + return super().value + +class BunqResponseIdealMerchantTransaction(BunqResponse): @property - def status(self): + def value(self): """ - :rtype: str + :rtype: IdealMerchantTransaction """ + + return super().value - return self._status + +class BunqResponseIdealMerchantTransactionList(BunqResponse): + @property + def value(self): + """ + :rtype: list[IdealMerchantTransaction] + """ + + return super().value + +class BunqResponseSchedulePayment(BunqResponse): @property - def minimum_age(self): + def value(self): """ - :rtype: int + :rtype: SchedulePayment """ + + return super().value - return self._minimum_age + +class BunqResponseSchedulePaymentList(BunqResponse): + @property + def value(self): + """ + :rtype: list[SchedulePayment] + """ + + return super().value + +class BunqResponseSchedulePaymentBatch(BunqResponse): @property - def require_address(self): + def value(self): """ - :rtype: str + :rtype: SchedulePaymentBatch """ + + return super().value - return self._require_address + +class BunqResponseScheduleInstance(BunqResponse): + @property + def value(self): + """ + :rtype: ScheduleInstance + """ + + return super().value + +class BunqResponseScheduleInstanceList(BunqResponse): @property - def address_shipping(self): + def value(self): """ - :rtype: object_.Address + :rtype: list[ScheduleInstance] """ + + return super().value - return self._address_shipping + +class BunqResponseMasterCardAction(BunqResponse): + @property + def value(self): + """ + :rtype: MasterCardAction + """ + + return super().value + +class BunqResponseMasterCardActionList(BunqResponse): @property - def address_billing(self): + def value(self): """ - :rtype: object_.Address + :rtype: list[MasterCardAction] """ + + return super().value - return self._address_billing + +class BunqResponseRequestInquiryBatch(BunqResponse): + @property + def value(self): + """ + :rtype: RequestInquiryBatch + """ + + return super().value + +class BunqResponseRequestInquiryBatchList(BunqResponse): @property - def geolocation(self): + def value(self): """ - :rtype: object_.Geolocation + :rtype: list[RequestInquiryBatch] """ + + return super().value - return self._geolocation - + +class BunqResponseRequestInquiry(BunqResponse): @property - def redirect_url(self): + def value(self): """ - :rtype: str + :rtype: RequestInquiry """ + + return super().value - return self._redirect_url - + +class BunqResponseRequestInquiryList(BunqResponse): @property - def type_(self): + def value(self): """ - :rtype: str + :rtype: list[RequestInquiry] """ + + return super().value - return self._type_ - + +class BunqResponseRequestResponse(BunqResponse): @property - def sub_type(self): + def value(self): """ - :rtype: str + :rtype: RequestResponse """ + + return super().value - return self._sub_type - + +class BunqResponseRequestResponseList(BunqResponse): @property - def allow_chat(self): + def value(self): """ - :rtype: bool + :rtype: list[RequestResponse] """ + + return super().value - return self._allow_chat - + +class BunqResponseTransferwiseTransfer(BunqResponse): @property - def eligible_whitelist_id(self): + def value(self): """ - :rtype: int + :rtype: TransferwiseTransfer """ + + return super().value - return self._eligible_whitelist_id - - def is_all_field_none(self): + +class BunqResponseTransferwiseTransferList(BunqResponse): + @property + def value(self): """ - :rtype: bool + :rtype: list[TransferwiseTransfer] """ + + return super().value - if self._id_ is not None: - return False - - if self._time_responded is not None: - return False - - if self._time_expiry is not None: - return False - - if self._monetary_account_id is not None: - return False - - if self._amount_inquired is not None: - return False - - if self._amount_responded is not None: - return False - - if self._alias is not None: - return False - - if self._counterparty_alias is not None: - return False - - if self._description is not None: - return False - - if self._attachment is not None: - return False - - if self._status is not None: - return False - - if self._minimum_age is not None: - return False - - if self._require_address is not None: - return False - - if self._address_shipping is not None: - return False - - if self._address_billing is not None: - return False - - if self._geolocation is not None: - return False - - if self._redirect_url is not None: - return False - - if self._type_ is not None: - return False - - if self._sub_type is not None: - return False - - if self._allow_chat is not None: - return False - - if self._eligible_whitelist_id is not None: - return False - - return True - - @staticmethod - def from_json(json_str): + +class BunqResponseTransferwiseQuote(BunqResponse): + @property + def value(self): """ - :type json_str: str - - :rtype: TokenQrRequestIdeal + :rtype: TransferwiseQuote """ + + return super().value - return converter.json_to_class(TokenQrRequestIdeal, json_str) - - -class TokenQrRequestSofort(core.BunqModel): - """ - Using this call you can create a SOFORT Request assigned to your User by - providing the Token of the request. - :param _token: The token passed from a site or read from a QR code. - :type _token: str - """ - - # Endpoint constants. - _ENDPOINT_URL_CREATE = "user/{}/token-qr-request-sofort" - - # Field constants. - FIELD_TOKEN = "token" - - # Object type. - _OBJECT_TYPE_POST = "RequestResponse" - - _token_field_for_request = None - - def __init__(self, token): +class BunqResponseShareInviteMonetaryAccountInquiry(BunqResponse): + @property + def value(self): """ - :param token: The token passed from a site or read from a QR code. - :type token: str + :rtype: ShareInviteMonetaryAccountInquiry """ + + return super().value - self._token_field_for_request = token - - @classmethod - def create(cls, token, custom_headers=None): + +class BunqResponseShareInviteMonetaryAccountInquiryList(BunqResponse): + @property + def value(self): """ - Create a request from an SOFORT transaction. - - :type user_id: int - :param token: The token passed from a site or read from a QR code. - :type token: str - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseTokenQrRequestSofort + :rtype: list[ShareInviteMonetaryAccountInquiry] """ + + return super().value - if custom_headers is None: - custom_headers = {} - - request_map = { - cls.FIELD_TOKEN: token - } - request_map_string = converter.class_to_json(request_map) - request_map_string = cls._remove_field_for_request(request_map_string) - - api_client = client.ApiClient(cls._get_api_context()) - request_bytes = request_map_string.encode() - endpoint_url = cls._ENDPOINT_URL_CREATE.format(cls._determine_user_id()) - response_raw = api_client.post(endpoint_url, request_bytes, - custom_headers) - - return BunqResponseTokenQrRequestSofort.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_POST) - ) - - def is_all_field_none(self): + +class BunqResponseShareInviteMonetaryAccountResponse(BunqResponse): + @property + def value(self): """ - :rtype: bool + :rtype: ShareInviteMonetaryAccountResponse """ + + return super().value - return True - - @staticmethod - def from_json(json_str): + +class BunqResponseShareInviteMonetaryAccountResponseList(BunqResponse): + @property + def value(self): """ - :type json_str: str - - :rtype: TokenQrRequestSofort + :rtype: list[ShareInviteMonetaryAccountResponse] """ + + return super().value - return converter.json_to_class(TokenQrRequestSofort, json_str) - - -class UserCredentialPasswordIp(core.BunqModel): - """ - Create a credential of a user for server authentication, or delete the - credential of a user for server authentication. - :param _id_: The id of the credential. - :type _id_: int - :param _created: The timestamp of the credential object's creation. - :type _created: str - :param _updated: The timestamp of the credential object's last update. - :type _updated: str - :param _status: The status of the credential. - :type _status: str - :param _expiry_time: When the status is PENDING_FIRST_USE: when the - credential expires. - :type _expiry_time: str - :param _token_value: When the status is PENDING_FIRST_USE: the value of the - token. - :type _token_value: str - :param _permitted_device: When the status is ACTIVE: the details of the - device that may use the credential. - :type _permitted_device: object_.PermittedDevice - """ - - # Endpoint constants. - _ENDPOINT_URL_READ = "user/{}/credential-password-ip/{}" - _ENDPOINT_URL_LISTING = "user/{}/credential-password-ip" - - # Object type. - _OBJECT_TYPE_GET = "CredentialPasswordIp" - - _id_ = None - _created = None - _updated = None - _status = None - _expiry_time = None - _token_value = None - _permitted_device = None - - @classmethod - def get(cls, user_credential_password_ip_id, custom_headers=None): +class BunqResponseSofortMerchantTransaction(BunqResponse): + @property + def value(self): """ - :type api_context: context.ApiContext - :type user_id: int - :type user_credential_password_ip_id: int - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseUserCredentialPasswordIp + :rtype: SofortMerchantTransaction """ + + return super().value - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_READ.format(cls._determine_user_id(), - user_credential_password_ip_id) - response_raw = api_client.get(endpoint_url, {}, custom_headers) - - return BunqResponseUserCredentialPasswordIp.cast_from_bunq_response( - cls._from_json(response_raw, cls._OBJECT_TYPE_GET) - ) - - @classmethod - def list(cls, params=None, custom_headers=None): + +class BunqResponseSofortMerchantTransactionList(BunqResponse): + @property + def value(self): """ - :type user_id: int - :type params: dict[str, str]|None - :type custom_headers: dict[str, str]|None - - :rtype: BunqResponseUserCredentialPasswordIpList + :rtype: list[SofortMerchantTransaction] """ + + return super().value - if params is None: - params = {} - - if custom_headers is None: - custom_headers = {} - - api_client = client.ApiClient(cls._get_api_context()) - endpoint_url = cls._ENDPOINT_URL_LISTING.format( - cls._determine_user_id()) - response_raw = api_client.get(endpoint_url, params, custom_headers) - - return BunqResponseUserCredentialPasswordIpList.cast_from_bunq_response( - cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET) - ) - + +class BunqResponseExportAnnualOverview(BunqResponse): @property - def id_(self): + def value(self): """ - :rtype: int + :rtype: ExportAnnualOverview """ + + return super().value - return self._id_ - + +class BunqResponseExportAnnualOverviewList(BunqResponse): @property - def created(self): + def value(self): """ - :rtype: str + :rtype: list[ExportAnnualOverview] """ + + return super().value - return self._created - + +class BunqResponseExportRib(BunqResponse): @property - def updated(self): + def value(self): """ - :rtype: str + :rtype: ExportRib """ + + return super().value - return self._updated - + +class BunqResponseExportRibList(BunqResponse): @property - def status(self): + def value(self): """ - :rtype: str + :rtype: list[ExportRib] """ + + return super().value - return self._status - + +class BunqResponseExportStatementCardCsv(BunqResponse): @property - def expiry_time(self): + def value(self): """ - :rtype: str + :rtype: ExportStatementCardCsv """ + + return super().value - return self._expiry_time - + +class BunqResponseExportStatementCardCsvList(BunqResponse): @property - def token_value(self): + def value(self): """ - :rtype: str + :rtype: list[ExportStatementCardCsv] """ + + return super().value - return self._token_value - + +class BunqResponseExportStatementCardPdf(BunqResponse): @property - def permitted_device(self): + def value(self): """ - :rtype: object_.PermittedDevice + :rtype: ExportStatementCardPdf """ + + return super().value - return self._permitted_device - - def is_all_field_none(self): + +class BunqResponseExportStatementCardPdfList(BunqResponse): + @property + def value(self): """ - :rtype: bool + :rtype: list[ExportStatementCardPdf] """ + + return super().value - if self._id_ is not None: - return False - - if self._created is not None: - return False - - if self._updated is not None: - return False - - if self._status is not None: - return False - - if self._expiry_time is not None: - return False - - if self._token_value is not None: - return False - - if self._permitted_device is not None: - return False - - return True - - @staticmethod - def from_json(json_str): + +class BunqResponseExportStatementCard(BunqResponse): + @property + def value(self): """ - :type json_str: str - - :rtype: UserCredentialPasswordIp + :rtype: ExportStatementCard """ + + return super().value - return converter.json_to_class(UserCredentialPasswordIp, json_str) - - -class BunqResponseInvoiceList(client.BunqResponse): + +class BunqResponseExportStatementCardList(BunqResponse): @property def value(self): """ - :rtype: list[Invoice] + :rtype: list[ExportStatementCard] """ - + return super().value - -class BunqResponseInvoice(client.BunqResponse): + +class BunqResponseExportStatementPayment(BunqResponse): @property def value(self): """ - :rtype: Invoice + :rtype: ExportStatementPayment """ - + return super().value - -class BunqResponseInvoiceByUserList(client.BunqResponse): + +class BunqResponseExportStatement(BunqResponse): @property def value(self): """ - :rtype: list[InvoiceByUser] + :rtype: ExportStatement """ - + return super().value - -class BunqResponseInvoiceByUser(client.BunqResponse): + +class BunqResponseExportStatementList(BunqResponse): @property def value(self): """ - :rtype: InvoiceByUser + :rtype: list[ExportStatement] """ - + return super().value - -class BunqResponseBytes(client.BunqResponse): + +class BunqResponseInsightEventList(BunqResponse): @property def value(self): """ - :rtype: bytes + :rtype: list[InsightEvent] """ - + return super().value - -class BunqResponseInt(client.BunqResponse): + +class BunqResponseInsightPreferenceDateList(BunqResponse): @property def value(self): """ - :rtype: int + :rtype: list[InsightPreferenceDate] """ - + return super().value - -class BunqResponseStr(client.BunqResponse): + +class BunqResponseInsightList(BunqResponse): @property def value(self): """ - :rtype: str + :rtype: list[Insight] """ - + return super().value - -class BunqResponseAttachmentPublic(client.BunqResponse): + +class BunqResponseInstallationServerPublicKeyList(BunqResponse): @property def value(self): """ - :rtype: AttachmentPublic + :rtype: list[InstallationServerPublicKey] """ - + return super().value - -class BunqResponseAttachmentTab(client.BunqResponse): + +class BunqResponseMonetaryAccountBank(BunqResponse): @property def value(self): """ - :rtype: AttachmentTab + :rtype: MonetaryAccountBank """ - + return super().value - -class BunqResponseTabAttachmentTab(client.BunqResponse): + +class BunqResponseMonetaryAccountBankList(BunqResponse): @property def value(self): """ - :rtype: TabAttachmentTab + :rtype: list[MonetaryAccountBank] """ - + return super().value - -class BunqResponseAvatar(client.BunqResponse): + +class BunqResponseMonetaryAccountCard(BunqResponse): @property def value(self): """ - :rtype: Avatar + :rtype: MonetaryAccountCard """ - + return super().value - -class BunqResponseBunqMeTabList(client.BunqResponse): + +class BunqResponseMonetaryAccountCardList(BunqResponse): @property def value(self): """ - :rtype: list[BunqMeTab] + :rtype: list[MonetaryAccountCard] """ - + return super().value - -class BunqResponseBunqMeTab(client.BunqResponse): + +class BunqResponseMonetaryAccountExternalSavings(BunqResponse): @property def value(self): """ - :rtype: BunqMeTab + :rtype: MonetaryAccountExternalSavings """ - + return super().value - -class BunqResponsePayment(client.BunqResponse): + +class BunqResponseMonetaryAccountExternalSavingsList(BunqResponse): @property def value(self): """ - :rtype: Payment + :rtype: list[MonetaryAccountExternalSavings] """ - + return super().value - -class BunqResponsePaymentList(client.BunqResponse): + +class BunqResponseMonetaryAccountExternal(BunqResponse): @property def value(self): """ - :rtype: list[Payment] + :rtype: MonetaryAccountExternal """ - + return super().value - -class BunqResponseCardBatch(client.BunqResponse): + +class BunqResponseMonetaryAccountExternalList(BunqResponse): @property def value(self): """ - :rtype: CardBatch + :rtype: list[MonetaryAccountExternal] """ - + return super().value - -class BunqResponseCardDebit(client.BunqResponse): + +class BunqResponseMonetaryAccountJoint(BunqResponse): @property def value(self): """ - :rtype: CardDebit + :rtype: MonetaryAccountJoint """ - + return super().value - -class BunqResponseCardGeneratedCvc2(client.BunqResponse): + +class BunqResponseMonetaryAccountJointList(BunqResponse): @property def value(self): """ - :rtype: CardGeneratedCvc2 + :rtype: list[MonetaryAccountJoint] """ - + return super().value - -class BunqResponseCardGeneratedCvc2List(client.BunqResponse): + +class BunqResponseMonetaryAccountSavings(BunqResponse): @property def value(self): """ - :rtype: list[CardGeneratedCvc2] + :rtype: MonetaryAccountSavings """ - + return super().value - -class BunqResponseCardNameList(client.BunqResponse): + +class BunqResponseMonetaryAccountSavingsList(BunqResponse): @property def value(self): """ - :rtype: list[CardName] + :rtype: list[MonetaryAccountSavings] """ - + return super().value - -class BunqResponseCard(client.BunqResponse): + +class BunqResponseMonetaryAccount(BunqResponse): @property def value(self): """ - :rtype: Card + :rtype: MonetaryAccount """ - + return super().value - -class BunqResponseCardList(client.BunqResponse): + +class BunqResponseMonetaryAccountList(BunqResponse): @property def value(self): """ - :rtype: list[Card] + :rtype: list[MonetaryAccount] """ - + return super().value - -class BunqResponseCashRegisterQrCode(client.BunqResponse): + +class BunqResponseNoteAttachmentAdyenCardTransactionList(BunqResponse): @property def value(self): """ - :rtype: CashRegisterQrCode + :rtype: list[NoteAttachmentAdyenCardTransaction] """ - + return super().value - -class BunqResponseCashRegisterQrCodeList(client.BunqResponse): + +class BunqResponseNoteAttachmentAdyenCardTransaction(BunqResponse): @property def value(self): """ - :rtype: list[CashRegisterQrCode] + :rtype: NoteAttachmentAdyenCardTransaction """ - + return super().value - -class BunqResponseCashRegister(client.BunqResponse): + +class BunqResponseNoteTextAdyenCardTransactionList(BunqResponse): @property def value(self): """ - :rtype: CashRegister + :rtype: list[NoteTextAdyenCardTransaction] """ - + return super().value - -class BunqResponseCashRegisterList(client.BunqResponse): + +class BunqResponseNoteTextAdyenCardTransaction(BunqResponse): @property def value(self): """ - :rtype: list[CashRegister] + :rtype: NoteTextAdyenCardTransaction """ - + return super().value - -class BunqResponseTab(client.BunqResponse): + +class BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList(BunqResponse): @property def value(self): """ - :rtype: Tab + :rtype: list[NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment] """ - + return super().value - -class BunqResponseTabList(client.BunqResponse): + +class BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment(BunqResponse): @property def value(self): """ - :rtype: list[Tab] + :rtype: NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment """ - + return super().value - -class BunqResponseNone(client.BunqResponse): + +class BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList(BunqResponse): @property def value(self): """ - :rtype: None + :rtype: list[NoteTextBankSwitchServiceNetherlandsIncomingPayment] """ - + return super().value - -class BunqResponseTabUsageSingle(client.BunqResponse): + +class BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment(BunqResponse): @property def value(self): """ - :rtype: TabUsageSingle + :rtype: NoteTextBankSwitchServiceNetherlandsIncomingPayment """ - + return super().value - -class BunqResponseTabUsageSingleList(client.BunqResponse): + +class BunqResponseNoteAttachmentBunqMeFundraiserResultList(BunqResponse): @property def value(self): """ - :rtype: list[TabUsageSingle] + :rtype: list[NoteAttachmentBunqMeFundraiserResult] """ - + return super().value - -class BunqResponseTabUsageMultiple(client.BunqResponse): + +class BunqResponseNoteAttachmentBunqMeFundraiserResult(BunqResponse): @property def value(self): """ - :rtype: TabUsageMultiple + :rtype: NoteAttachmentBunqMeFundraiserResult """ - + return super().value - -class BunqResponseTabUsageMultipleList(client.BunqResponse): + +class BunqResponseNoteTextBunqMeFundraiserResultList(BunqResponse): @property def value(self): """ - :rtype: list[TabUsageMultiple] + :rtype: list[NoteTextBunqMeFundraiserResult] """ - + return super().value - -class BunqResponseCertificatePinnedList(client.BunqResponse): + +class BunqResponseNoteTextBunqMeFundraiserResult(BunqResponse): @property def value(self): """ - :rtype: list[CertificatePinned] + :rtype: NoteTextBunqMeFundraiserResult """ - + return super().value - -class BunqResponseCertificatePinned(client.BunqResponse): + +class BunqResponseNoteAttachmentDraftPaymentList(BunqResponse): @property def value(self): """ - :rtype: CertificatePinned + :rtype: list[NoteAttachmentDraftPayment] """ - + return super().value - -class BunqResponseDeviceServer(client.BunqResponse): + +class BunqResponseNoteAttachmentDraftPayment(BunqResponse): @property def value(self): """ - :rtype: DeviceServer + :rtype: NoteAttachmentDraftPayment """ - + return super().value - -class BunqResponseDeviceServerList(client.BunqResponse): + +class BunqResponseNoteTextDraftPaymentList(BunqResponse): @property def value(self): """ - :rtype: list[DeviceServer] + :rtype: list[NoteTextDraftPayment] """ - + return super().value - -class BunqResponseDevice(client.BunqResponse): + +class BunqResponseNoteTextDraftPayment(BunqResponse): @property def value(self): """ - :rtype: Device + :rtype: NoteTextDraftPayment """ - + return super().value - -class BunqResponseDeviceList(client.BunqResponse): + +class BunqResponseNoteAttachmentIdealMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[Device] + :rtype: list[NoteAttachmentIdealMerchantTransaction] """ - + return super().value - -class BunqResponseDraftPaymentList(client.BunqResponse): + +class BunqResponseNoteAttachmentIdealMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: list[DraftPayment] + :rtype: NoteAttachmentIdealMerchantTransaction """ - + return super().value - -class BunqResponseDraftPayment(client.BunqResponse): + +class BunqResponseNoteTextIdealMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: DraftPayment + :rtype: list[NoteTextIdealMerchantTransaction] """ - + return super().value - -class BunqResponsePaymentBatch(client.BunqResponse): + +class BunqResponseNoteTextIdealMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: PaymentBatch + :rtype: NoteTextIdealMerchantTransaction """ - + return super().value - -class BunqResponsePaymentBatchList(client.BunqResponse): + +class BunqResponseNoteAttachmentMasterCardActionList(BunqResponse): @property def value(self): """ - :rtype: list[PaymentBatch] + :rtype: list[NoteAttachmentMasterCardAction] """ - + return super().value - -class BunqResponseDraftShareInviteApiKey(client.BunqResponse): + +class BunqResponseNoteAttachmentMasterCardAction(BunqResponse): @property def value(self): """ - :rtype: DraftShareInviteApiKey + :rtype: NoteAttachmentMasterCardAction """ - + return super().value - -class BunqResponseDraftShareInviteApiKeyList(client.BunqResponse): + +class BunqResponseNoteTextMasterCardActionList(BunqResponse): @property def value(self): """ - :rtype: list[DraftShareInviteApiKey] + :rtype: list[NoteTextMasterCardAction] """ - + return super().value - -class BunqResponseDraftShareInviteBank(client.BunqResponse): + +class BunqResponseNoteTextMasterCardAction(BunqResponse): @property def value(self): """ - :rtype: DraftShareInviteBank + :rtype: NoteTextMasterCardAction """ - + return super().value - -class BunqResponseDraftShareInviteBankList(client.BunqResponse): + +class BunqResponseNoteAttachmentOpenBankingMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[DraftShareInviteBank] + :rtype: list[NoteAttachmentOpenBankingMerchantTransaction] """ - + return super().value - -class BunqResponseExportAnnualOverview(client.BunqResponse): + +class BunqResponseNoteAttachmentOpenBankingMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: ExportAnnualOverview + :rtype: NoteAttachmentOpenBankingMerchantTransaction """ - + return super().value - -class BunqResponseExportAnnualOverviewList(client.BunqResponse): + +class BunqResponseNoteTextOpenBankingMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[ExportAnnualOverview] + :rtype: list[NoteTextOpenBankingMerchantTransaction] """ - + return super().value - -class BunqResponseCustomerStatementExport(client.BunqResponse): + +class BunqResponseNoteTextOpenBankingMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: CustomerStatementExport + :rtype: NoteTextOpenBankingMerchantTransaction """ - + return super().value - -class BunqResponseCustomerStatementExportList(client.BunqResponse): + +class BunqResponseNoteAttachmentPaymentBatchList(BunqResponse): @property def value(self): """ - :rtype: list[CustomerStatementExport] + :rtype: list[NoteAttachmentPaymentBatch] """ - + return super().value - -class BunqResponseInstallationServerPublicKeyList(client.BunqResponse): + +class BunqResponseNoteAttachmentPaymentBatch(BunqResponse): @property def value(self): """ - :rtype: list[InstallationServerPublicKey] + :rtype: NoteAttachmentPaymentBatch """ - + return super().value - -class BunqResponseShareInviteBankInquiry(client.BunqResponse): + +class BunqResponseNoteTextPaymentBatchList(BunqResponse): @property def value(self): """ - :rtype: ShareInviteBankInquiry + :rtype: list[NoteTextPaymentBatch] """ - + return super().value - -class BunqResponseShareInviteBankInquiryList(client.BunqResponse): + +class BunqResponseNoteTextPaymentBatch(BunqResponse): @property def value(self): """ - :rtype: list[ShareInviteBankInquiry] + :rtype: NoteTextPaymentBatch """ - + return super().value - -class BunqResponseShareInviteBankResponse(client.BunqResponse): + +class BunqResponseNoteAttachmentPaymentDelayedList(BunqResponse): @property def value(self): """ - :rtype: ShareInviteBankResponse + :rtype: list[NoteAttachmentPaymentDelayed] """ - + return super().value - -class BunqResponseShareInviteBankResponseList(client.BunqResponse): + +class BunqResponseNoteAttachmentPaymentDelayed(BunqResponse): @property def value(self): """ - :rtype: list[ShareInviteBankResponse] + :rtype: NoteAttachmentPaymentDelayed """ - + return super().value - -class BunqResponseMonetaryAccountBank(client.BunqResponse): + +class BunqResponseNoteTextPaymentDelayedList(BunqResponse): @property def value(self): """ - :rtype: MonetaryAccountBank + :rtype: list[NoteTextPaymentDelayed] """ - + return super().value - -class BunqResponseMonetaryAccountBankList(client.BunqResponse): + +class BunqResponseNoteTextPaymentDelayed(BunqResponse): @property def value(self): """ - :rtype: list[MonetaryAccountBank] + :rtype: NoteTextPaymentDelayed """ - + return super().value - -class BunqResponseMonetaryAccount(client.BunqResponse): + +class BunqResponseNoteAttachmentPaymentList(BunqResponse): @property def value(self): """ - :rtype: MonetaryAccount + :rtype: list[NoteAttachmentPayment] """ - + return super().value - -class BunqResponseMonetaryAccountList(client.BunqResponse): + +class BunqResponseNoteAttachmentPayment(BunqResponse): @property def value(self): """ - :rtype: list[MonetaryAccount] + :rtype: NoteAttachmentPayment """ - + return super().value - -class BunqResponseMonetaryAccountJoint(client.BunqResponse): + +class BunqResponseNoteTextPaymentList(BunqResponse): @property def value(self): """ - :rtype: MonetaryAccountJoint + :rtype: list[NoteTextPayment] """ - + return super().value - -class BunqResponseMonetaryAccountJointList(client.BunqResponse): + +class BunqResponseNoteTextPayment(BunqResponse): @property def value(self): """ - :rtype: list[MonetaryAccountJoint] + :rtype: NoteTextPayment """ - + return super().value - -class BunqResponseMonetaryAccountLight(client.BunqResponse): + +class BunqResponseNoteAttachmentRequestInquiryBatchList(BunqResponse): @property def value(self): """ - :rtype: MonetaryAccountLight + :rtype: list[NoteAttachmentRequestInquiryBatch] """ - + return super().value - -class BunqResponseMonetaryAccountLightList(client.BunqResponse): + +class BunqResponseNoteAttachmentRequestInquiryBatch(BunqResponse): @property def value(self): """ - :rtype: list[MonetaryAccountLight] + :rtype: NoteAttachmentRequestInquiryBatch """ - + return super().value - -class BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPaymentList( - client.BunqResponse): + +class BunqResponseNoteTextRequestInquiryBatchList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment] + :rtype: list[NoteTextRequestInquiryBatch] """ - + return super().value - -class BunqResponseNoteAttachmentBankSwitchServiceNetherlandsIncomingPayment( - client.BunqResponse): + +class BunqResponseNoteTextRequestInquiryBatch(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentBankSwitchServiceNetherlandsIncomingPayment + :rtype: NoteTextRequestInquiryBatch """ - + return super().value - -class BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPaymentList( - client.BunqResponse): + +class BunqResponseNoteAttachmentRequestInquiryList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextBankSwitchServiceNetherlandsIncomingPayment] + :rtype: list[NoteAttachmentRequestInquiry] """ - + return super().value - -class BunqResponseNoteTextBankSwitchServiceNetherlandsIncomingPayment( - client.BunqResponse): + +class BunqResponseNoteAttachmentRequestInquiry(BunqResponse): @property def value(self): """ - :rtype: NoteTextBankSwitchServiceNetherlandsIncomingPayment + :rtype: NoteAttachmentRequestInquiry """ - + return super().value - -class BunqResponseNoteAttachmentBunqMeFundraiserResultList(client.BunqResponse): + +class BunqResponseNoteTextRequestInquiryList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentBunqMeFundraiserResult] + :rtype: list[NoteTextRequestInquiry] """ - + return super().value - -class BunqResponseNoteAttachmentBunqMeFundraiserResult(client.BunqResponse): + +class BunqResponseNoteTextRequestInquiry(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentBunqMeFundraiserResult + :rtype: NoteTextRequestInquiry """ - + return super().value - -class BunqResponseNoteTextBunqMeFundraiserResultList(client.BunqResponse): + +class BunqResponseNoteAttachmentRequestResponseList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextBunqMeFundraiserResult] + :rtype: list[NoteAttachmentRequestResponse] """ - + return super().value - -class BunqResponseNoteTextBunqMeFundraiserResult(client.BunqResponse): + +class BunqResponseNoteAttachmentRequestResponse(BunqResponse): @property def value(self): """ - :rtype: NoteTextBunqMeFundraiserResult + :rtype: NoteAttachmentRequestResponse """ - + return super().value - -class BunqResponseNoteAttachmentDraftPaymentList(client.BunqResponse): + +class BunqResponseNoteTextRequestResponseList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentDraftPayment] + :rtype: list[NoteTextRequestResponse] """ - + return super().value - -class BunqResponseNoteAttachmentDraftPayment(client.BunqResponse): + +class BunqResponseNoteTextRequestResponse(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentDraftPayment + :rtype: NoteTextRequestResponse """ - + return super().value - -class BunqResponseNoteTextDraftPaymentList(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleInstanceList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextDraftPayment] + :rtype: list[NoteAttachmentScheduleInstance] """ - + return super().value - -class BunqResponseNoteTextDraftPayment(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleInstance(BunqResponse): @property def value(self): """ - :rtype: NoteTextDraftPayment + :rtype: NoteAttachmentScheduleInstance """ - + return super().value - -class BunqResponseNoteAttachmentIdealMerchantTransactionList( - client.BunqResponse): + +class BunqResponseNoteTextScheduleInstanceList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentIdealMerchantTransaction] + :rtype: list[NoteTextScheduleInstance] """ - + return super().value - -class BunqResponseNoteAttachmentIdealMerchantTransaction(client.BunqResponse): + +class BunqResponseNoteTextScheduleInstance(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentIdealMerchantTransaction + :rtype: NoteTextScheduleInstance """ - + return super().value - -class BunqResponseNoteTextIdealMerchantTransactionList(client.BunqResponse): + +class BunqResponseNoteAttachmentSchedulePaymentBatchList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextIdealMerchantTransaction] + :rtype: list[NoteAttachmentSchedulePaymentBatch] """ - + return super().value - -class BunqResponseNoteTextIdealMerchantTransaction(client.BunqResponse): + +class BunqResponseNoteAttachmentSchedulePaymentBatch(BunqResponse): @property def value(self): """ - :rtype: NoteTextIdealMerchantTransaction + :rtype: NoteAttachmentSchedulePaymentBatch """ - + return super().value - -class BunqResponseNoteAttachmentMasterCardActionList(client.BunqResponse): + +class BunqResponseNoteTextSchedulePaymentBatchList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentMasterCardAction] + :rtype: list[NoteTextSchedulePaymentBatch] """ - + return super().value - -class BunqResponseNoteAttachmentMasterCardAction(client.BunqResponse): + +class BunqResponseNoteTextSchedulePaymentBatch(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentMasterCardAction + :rtype: NoteTextSchedulePaymentBatch """ - + return super().value - -class BunqResponseNoteTextMasterCardActionList(client.BunqResponse): + +class BunqResponseNoteAttachmentSchedulePaymentList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextMasterCardAction] + :rtype: list[NoteAttachmentSchedulePayment] """ - + return super().value - -class BunqResponseNoteTextMasterCardAction(client.BunqResponse): + +class BunqResponseNoteAttachmentSchedulePayment(BunqResponse): @property def value(self): """ - :rtype: NoteTextMasterCardAction + :rtype: NoteAttachmentSchedulePayment """ - + return super().value - -class BunqResponseNoteAttachmentPaymentBatchList(client.BunqResponse): + +class BunqResponseNoteTextSchedulePaymentList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentPaymentBatch] + :rtype: list[NoteTextSchedulePayment] """ - + return super().value - -class BunqResponseNoteAttachmentPaymentBatch(client.BunqResponse): + +class BunqResponseNoteTextSchedulePayment(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentPaymentBatch + :rtype: NoteTextSchedulePayment """ - + return super().value - -class BunqResponseNoteTextPaymentBatchList(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleRequestBatchList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextPaymentBatch] + :rtype: list[NoteAttachmentScheduleRequestBatch] """ - + return super().value - -class BunqResponseNoteTextPaymentBatch(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleRequestBatch(BunqResponse): @property def value(self): """ - :rtype: NoteTextPaymentBatch + :rtype: NoteAttachmentScheduleRequestBatch """ - + return super().value - -class BunqResponseNoteAttachmentPaymentList(client.BunqResponse): + +class BunqResponseNoteTextScheduleRequestBatchList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentPayment] + :rtype: list[NoteTextScheduleRequestBatch] """ - + return super().value - -class BunqResponseNoteAttachmentPayment(client.BunqResponse): + +class BunqResponseNoteTextScheduleRequestBatch(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentPayment + :rtype: NoteTextScheduleRequestBatch """ - + return super().value - -class BunqResponseNoteTextPaymentList(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleRequestList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextPayment] + :rtype: list[NoteAttachmentScheduleRequest] """ - + return super().value - -class BunqResponseNoteTextPayment(client.BunqResponse): + +class BunqResponseNoteAttachmentScheduleRequest(BunqResponse): @property def value(self): """ - :rtype: NoteTextPayment + :rtype: NoteAttachmentScheduleRequest """ - + return super().value - -class BunqResponseNoteAttachmentRequestInquiryBatchList(client.BunqResponse): + +class BunqResponseNoteTextScheduleRequestList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentRequestInquiryBatch] + :rtype: list[NoteTextScheduleRequest] """ - + return super().value - -class BunqResponseNoteAttachmentRequestInquiryBatch(client.BunqResponse): + +class BunqResponseNoteTextScheduleRequest(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentRequestInquiryBatch + :rtype: NoteTextScheduleRequest """ - + return super().value - -class BunqResponseNoteTextRequestInquiryBatchList(client.BunqResponse): + +class BunqResponseNoteAttachmentSofortMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextRequestInquiryBatch] + :rtype: list[NoteAttachmentSofortMerchantTransaction] """ - + return super().value - -class BunqResponseNoteTextRequestInquiryBatch(client.BunqResponse): + +class BunqResponseNoteAttachmentSofortMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: NoteTextRequestInquiryBatch + :rtype: NoteAttachmentSofortMerchantTransaction """ - + return super().value - -class BunqResponseNoteAttachmentRequestInquiryList(client.BunqResponse): + +class BunqResponseNoteTextSofortMerchantTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentRequestInquiry] + :rtype: list[NoteTextSofortMerchantTransaction] """ - + return super().value - -class BunqResponseNoteAttachmentRequestInquiry(client.BunqResponse): + +class BunqResponseNoteTextSofortMerchantTransaction(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentRequestInquiry + :rtype: NoteTextSofortMerchantTransaction """ - + return super().value - -class BunqResponseNoteTextRequestInquiryList(client.BunqResponse): + +class BunqResponseNoteAttachmentWhitelistResultList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextRequestInquiry] + :rtype: list[NoteAttachmentWhitelistResult] """ - + return super().value - -class BunqResponseNoteTextRequestInquiry(client.BunqResponse): + +class BunqResponseNoteAttachmentWhitelistResult(BunqResponse): @property def value(self): """ - :rtype: NoteTextRequestInquiry + :rtype: NoteAttachmentWhitelistResult """ - + return super().value - -class BunqResponseNoteAttachmentRequestResponseList(client.BunqResponse): + +class BunqResponseNoteTextWhitelistResultList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentRequestResponse] + :rtype: list[NoteTextWhitelistResult] """ - + return super().value - -class BunqResponseNoteAttachmentRequestResponse(client.BunqResponse): + +class BunqResponseNoteTextWhitelistResult(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentRequestResponse + :rtype: NoteTextWhitelistResult """ - + return super().value - -class BunqResponseNoteTextRequestResponseList(client.BunqResponse): + +class BunqResponseNotificationFilterEmail(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextRequestResponse] + :rtype: NotificationFilterEmail """ - + return super().value - -class BunqResponseNoteTextRequestResponse(client.BunqResponse): + +class BunqResponseNotificationFilterEmailList(BunqResponse): @property def value(self): """ - :rtype: NoteTextRequestResponse + :rtype: list[NotificationFilterEmail] """ - + return super().value - -class BunqResponseNoteAttachmentScheduleInstanceList(client.BunqResponse): + +class BunqResponseNotificationFilterFailureList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentScheduleInstance] + :rtype: list[NotificationFilterFailure] """ - + return super().value - -class BunqResponseNoteAttachmentScheduleInstance(client.BunqResponse): + +class BunqResponseNotificationFilterPush(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentScheduleInstance + :rtype: NotificationFilterPush """ - + return super().value - -class BunqResponseNoteTextScheduleInstanceList(client.BunqResponse): + +class BunqResponseNotificationFilterPushList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextScheduleInstance] + :rtype: list[NotificationFilterPush] """ - + return super().value - -class BunqResponseNoteTextScheduleInstance(client.BunqResponse): + +class BunqResponseNotificationFilterUrlList(BunqResponse): @property def value(self): """ - :rtype: NoteTextScheduleInstance + :rtype: list[NotificationFilterUrl] """ - + return super().value - -class BunqResponseNoteAttachmentSofortMerchantTransactionList( - client.BunqResponse): + +class BunqResponseNotificationFilterUrlMonetaryAccountList(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentSofortMerchantTransaction] + :rtype: list[NotificationFilterUrlMonetaryAccount] """ - + return super().value - -class BunqResponseNoteAttachmentSofortMerchantTransaction(client.BunqResponse): + +class BunqResponseUser(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentSofortMerchantTransaction + :rtype: User """ - + return super().value - -class BunqResponseNoteTextSofortMerchantTransactionList(client.BunqResponse): + +class BunqResponseUserList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextSofortMerchantTransaction] + :rtype: list[User] """ - + return super().value - -class BunqResponseNoteTextSofortMerchantTransaction(client.BunqResponse): + +class BunqResponseUserPerson(BunqResponse): @property def value(self): """ - :rtype: NoteTextSofortMerchantTransaction + :rtype: UserPerson """ - + return super().value - -class BunqResponseNoteAttachmentWhitelistResultList(client.BunqResponse): + +class BunqResponseUserPaymentServiceProvider(BunqResponse): @property def value(self): """ - :rtype: list[NoteAttachmentWhitelistResult] + :rtype: UserPaymentServiceProvider """ - + return super().value - -class BunqResponseNoteAttachmentWhitelistResult(client.BunqResponse): + +class BunqResponseOauthCallbackUrl(BunqResponse): @property def value(self): """ - :rtype: NoteAttachmentWhitelistResult + :rtype: OauthCallbackUrl """ - + return super().value - -class BunqResponseNoteTextWhitelistResultList(client.BunqResponse): + +class BunqResponseOauthCallbackUrlList(BunqResponse): @property def value(self): """ - :rtype: list[NoteTextWhitelistResult] + :rtype: list[OauthCallbackUrl] """ - + return super().value - -class BunqResponseNoteTextWhitelistResult(client.BunqResponse): + +class BunqResponseOauthClient(BunqResponse): @property def value(self): """ - :rtype: NoteTextWhitelistResult + :rtype: OauthClient """ - + return super().value - -class BunqResponseIdealMerchantTransaction(client.BunqResponse): + +class BunqResponseOauthClientList(BunqResponse): @property def value(self): """ - :rtype: IdealMerchantTransaction + :rtype: list[OauthClient] """ - + return super().value - -class BunqResponseIdealMerchantTransactionList(client.BunqResponse): + +class BunqResponsePaymentAutoAllocateDefinitionList(BunqResponse): @property def value(self): """ - :rtype: list[IdealMerchantTransaction] + :rtype: list[PaymentAutoAllocateDefinition] """ - + return super().value - -class BunqResponseMasterCardAction(client.BunqResponse): + +class BunqResponsePaymentAutoAllocate(BunqResponse): @property def value(self): """ - :rtype: MasterCardAction + :rtype: PaymentAutoAllocate """ - + return super().value - -class BunqResponseMasterCardActionList(client.BunqResponse): + +class BunqResponsePaymentAutoAllocateList(BunqResponse): @property def value(self): """ - :rtype: list[MasterCardAction] + :rtype: list[PaymentAutoAllocate] """ - + return super().value - -class BunqResponseRequestInquiry(client.BunqResponse): + +class BunqResponsePaymentAutoAllocateUserList(BunqResponse): @property def value(self): """ - :rtype: RequestInquiry + :rtype: list[PaymentAutoAllocateUser] """ - + return super().value - -class BunqResponseRequestInquiryList(client.BunqResponse): + +class BunqResponsePaymentServiceProviderCredential(BunqResponse): @property def value(self): """ - :rtype: list[RequestInquiry] + :rtype: PaymentServiceProviderCredential """ - + return super().value - -class BunqResponseRequestResponse(client.BunqResponse): + +class BunqResponsePaymentServiceProviderDraftPaymentList(BunqResponse): @property def value(self): """ - :rtype: RequestResponse + :rtype: list[PaymentServiceProviderDraftPayment] """ - + return super().value - -class BunqResponseRequestResponseList(client.BunqResponse): + +class BunqResponsePaymentServiceProviderDraftPayment(BunqResponse): @property def value(self): """ - :rtype: list[RequestResponse] + :rtype: PaymentServiceProviderDraftPayment """ - + return super().value - -class BunqResponseScheduleInstance(client.BunqResponse): + +class BunqResponsePaymentServiceProviderIssuerTransaction(BunqResponse): @property def value(self): """ - :rtype: ScheduleInstance + :rtype: PaymentServiceProviderIssuerTransaction """ - + return super().value - -class BunqResponseScheduleInstanceList(client.BunqResponse): + +class BunqResponsePaymentServiceProviderIssuerTransactionList(BunqResponse): @property def value(self): """ - :rtype: list[ScheduleInstance] + :rtype: list[PaymentServiceProviderIssuerTransaction] """ - + return super().value - -class BunqResponseTabResultResponse(client.BunqResponse): + +class BunqResponsePermittedIp(BunqResponse): @property def value(self): """ - :rtype: TabResultResponse + :rtype: PermittedIp """ - + return super().value - -class BunqResponseTabResultResponseList(client.BunqResponse): + +class BunqResponsePermittedIpList(BunqResponse): @property def value(self): """ - :rtype: list[TabResultResponse] + :rtype: list[PermittedIp] """ - + return super().value - -class BunqResponseRequestInquiryBatch(client.BunqResponse): + +class BunqResponseSandboxUserCompany(BunqResponse): @property def value(self): """ - :rtype: RequestInquiryBatch + :rtype: SandboxUserCompany """ - + return super().value - -class BunqResponseRequestInquiryBatchList(client.BunqResponse): + +class BunqResponseSandboxUserPerson(BunqResponse): @property def value(self): """ - :rtype: list[RequestInquiryBatch] + :rtype: SandboxUserPerson """ - + return super().value - -class BunqResponseSchedulePayment(client.BunqResponse): + +class BunqResponseScheduleUserList(BunqResponse): @property def value(self): """ - :rtype: SchedulePayment + :rtype: list[ScheduleUser] """ - + return super().value - -class BunqResponseSchedulePaymentList(client.BunqResponse): + +class BunqResponseTokenQrRequestIdeal(BunqResponse): @property def value(self): """ - :rtype: list[SchedulePayment] + :rtype: TokenQrRequestIdeal """ - + return super().value - -class BunqResponseSchedule(client.BunqResponse): + +class BunqResponseTokenQrRequestSofort(BunqResponse): @property def value(self): """ - :rtype: Schedule + :rtype: TokenQrRequestSofort """ - + return super().value - -class BunqResponseScheduleList(client.BunqResponse): + +class BunqResponseTransferwiseAccountQuote(BunqResponse): @property def value(self): """ - :rtype: list[Schedule] + :rtype: TransferwiseAccountQuote """ - + return super().value - -class BunqResponseTabResultInquiry(client.BunqResponse): + +class BunqResponseTransferwiseAccountQuoteList(BunqResponse): @property def value(self): """ - :rtype: TabResultInquiry + :rtype: list[TransferwiseAccountQuote] """ - + return super().value - -class BunqResponseTabResultInquiryList(client.BunqResponse): + +class BunqResponseTransferwiseAccountRequirementList(BunqResponse): @property def value(self): """ - :rtype: list[TabResultInquiry] + :rtype: list[TransferwiseAccountRequirement] """ - + return super().value - -class BunqResponseUser(client.BunqResponse): + +class BunqResponseTransferwiseCurrencyList(BunqResponse): @property def value(self): """ - :rtype: User + :rtype: list[TransferwiseCurrency] """ - + return super().value - -class BunqResponseUserList(client.BunqResponse): + +class BunqResponseTransferwiseQuoteTemporary(BunqResponse): @property def value(self): """ - :rtype: list[User] + :rtype: TransferwiseQuoteTemporary """ - + return super().value - -class BunqResponseUserLight(client.BunqResponse): + +class BunqResponseTransferwiseUserList(BunqResponse): @property def value(self): """ - :rtype: UserLight + :rtype: list[TransferwiseUser] """ - + return super().value - -class BunqResponseUserPerson(client.BunqResponse): + +class BunqResponseTreeProgressList(BunqResponse): @property def value(self): """ - :rtype: UserPerson + :rtype: list[TreeProgress] """ - + return super().value - -class BunqResponseUserCompany(client.BunqResponse): + +class BunqResponseUserCompanyNameList(BunqResponse): @property def value(self): """ - :rtype: UserCompany + :rtype: list[UserCompanyName] """ - + return super().value - -class BunqResponseCustomerList(client.BunqResponse): + +class BunqResponseUserCredentialPasswordIp(BunqResponse): @property def value(self): """ - :rtype: list[Customer] + :rtype: UserCredentialPasswordIp """ - + return super().value - -class BunqResponseCustomer(client.BunqResponse): + +class BunqResponseUserCredentialPasswordIpList(BunqResponse): @property def value(self): """ - :rtype: Customer + :rtype: list[UserCredentialPasswordIp] """ - + return super().value - -class BunqResponseCustomerLimitList(client.BunqResponse): + +class BunqResponseUserLegalNameList(BunqResponse): @property def value(self): """ - :rtype: list[CustomerLimit] + :rtype: list[UserLegalName] """ - + return super().value - -class BunqResponseBillingContractSubscriptionList(client.BunqResponse): + +class BunqResponseWhitelistSddOneOff(BunqResponse): @property def value(self): """ - :rtype: list[BillingContractSubscription] + :rtype: WhitelistSddOneOff """ - + return super().value - -class BunqResponsePermittedIp(client.BunqResponse): + +class BunqResponseWhitelistSddOneOffList(BunqResponse): @property def value(self): """ - :rtype: PermittedIp + :rtype: list[WhitelistSddOneOff] """ - + return super().value - -class BunqResponsePermittedIpList(client.BunqResponse): + +class BunqResponseWhitelistSddRecurring(BunqResponse): @property def value(self): """ - :rtype: list[PermittedIp] + :rtype: WhitelistSddRecurring """ - + return super().value - -class BunqResponseSandboxUser(client.BunqResponse): + +class BunqResponseWhitelistSddRecurringList(BunqResponse): @property def value(self): """ - :rtype: SandboxUser + :rtype: list[WhitelistSddRecurring] """ - + return super().value - -class BunqResponseScheduleUserList(client.BunqResponse): + +class BunqResponseWhitelistSdd(BunqResponse): @property def value(self): """ - :rtype: list[ScheduleUser] + :rtype: WhitelistSdd """ - + return super().value - -class BunqResponseTabItemShopList(client.BunqResponse): + +class BunqResponseWhitelistSddList(BunqResponse): @property def value(self): """ - :rtype: list[TabItemShop] + :rtype: list[WhitelistSdd] """ - + return super().value - -class BunqResponseTabItemShop(client.BunqResponse): + +class BunqResponseWhitelistSddMonetaryAccountPaying(BunqResponse): @property def value(self): """ - :rtype: TabItemShop + :rtype: WhitelistSddMonetaryAccountPaying """ - + return super().value - -class BunqResponseTokenQrRequestIdeal(client.BunqResponse): + +class BunqResponseWhitelistSddMonetaryAccountPayingList(BunqResponse): @property def value(self): """ - :rtype: TokenQrRequestIdeal + :rtype: list[WhitelistSddMonetaryAccountPaying] """ - + return super().value - -class BunqResponseTokenQrRequestSofort(client.BunqResponse): + +class BunqResponseMasterCardPaymentList(BunqResponse): @property def value(self): """ - :rtype: TokenQrRequestSofort + :rtype: list[MasterCardPayment] """ - + return super().value - -class BunqResponseUserCredentialPasswordIp(client.BunqResponse): + +class BunqResponseMasterCardIdentityCheckChallengeRequestUser(BunqResponse): @property def value(self): """ - :rtype: UserCredentialPasswordIp + :rtype: MasterCardIdentityCheckChallengeRequestUser """ - + return super().value - -class BunqResponseUserCredentialPasswordIpList(client.BunqResponse): + +class BunqResponseHealthCheckList(BunqResponse): @property def value(self): """ - :rtype: list[UserCredentialPasswordIp] + :rtype: list[HealthCheck] """ - + return super().value + diff --git a/bunq/sdk/model/generated/object_.py b/bunq/sdk/model/generated/object_.py index 4d1e226..ceb2840 100644 --- a/bunq/sdk/model/generated/object_.py +++ b/bunq/sdk/model/generated/object_.py @@ -1,11 +1,78 @@ # -*- coding: utf-8 -*- -from bunq.sdk import exception +from bunq.sdk.exception.bunq_exception import BunqException from bunq.sdk.json import converter -from bunq.sdk.model import core +from bunq.sdk.model.core.anchor_object_interface import AnchorObjectInterface +from bunq.sdk.model.core.bunq_model import BunqModel from bunq.sdk.model.generated import endpoint -class InvoiceItemGroup(core.BunqModel): +class AmountObject(BunqModel): + """ + :param _value: The amount formatted to two decimal places. + :type _value: str + :param _currency: The currency of the amount. It is an ISO 4217 formatted + currency code. + :type _currency: str + """ + + _value = None + _currency = None + _value_field_for_request = None + _currency_field_for_request = None + + def __init__(self, value=None, currency=None): + """ + :param value: The amount formatted to two decimal places. + :type value: str + :param currency: The currency of the amount. It is an ISO 4217 formatted + currency code. + :type currency: str + """ + + self._value_field_for_request = value + self._currency_field_for_request = currency + + @property + def value(self): + """ + :rtype: str + """ + + return self._value + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._value is not None: + return False + + if self._currency is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AmountObject + """ + + return converter.json_to_class(AmountObject, json_str) + + +class InvoiceItemGroupObject(BunqModel): """ :param _type_: The type of the invoice item group. :type _type_: str @@ -22,7 +89,7 @@ class InvoiceItemGroup(core.BunqModel): :param _product_vat_inclusive: The unit item price including VAT. :type _product_vat_inclusive: Amount :param _item: The invoice items in the group. - :type _item: InvoiceItem + :type _item: list[InvoiceItem] """ _type_ = None @@ -84,7 +151,7 @@ def product_vat_inclusive(self): @property def item(self): """ - :rtype: InvoiceItem + :rtype: list[InvoiceItem] """ return self._item @@ -122,80 +189,16 @@ def from_json(json_str): """ :type json_str: str - :rtype: InvoiceItemGroup - """ - - return converter.json_to_class(InvoiceItemGroup, json_str) - - -class Amount(core.BunqModel): - """ - :param _value: The amount formatted to two decimal places. - :type _value: str - :param _currency: The currency of the amount. It is an ISO 4217 formatted - currency code. - :type _currency: str - """ - - _value = None - _currency = None - _value_field_for_request = None - _currency_field_for_request = None - - def __init__(self, value=None, currency=None): - """ - :param value: The amount formatted to two decimal places. - :type value: str - :param currency: The currency of the amount. It is an ISO 4217 formatted - currency code. - :type currency: str - """ - - self._value_field_for_request = value - self._currency_field_for_request = currency - - @property - def value(self): - """ - :rtype: str - """ - - return self._value - - @property - def currency(self): - """ - :rtype: str - """ - - return self._currency - - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._value is not None: - return False - - if self._currency is not None: - return False - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: Amount + :rtype: InvoiceItemGroupObject """ - return converter.json_to_class(Amount, json_str) + return converter.json_to_class(InvoiceItemGroupObject, json_str) -class InvoiceItem(core.BunqModel): +class InvoiceItemObject(BunqModel): """ + :param _id_: The id of the invoice item. + :type _id_: int :param _billing_date: The billing date of the item. :type _billing_date: str :param _type_description: The price description. @@ -216,6 +219,7 @@ class InvoiceItem(core.BunqModel): :type _total_vat_inclusive: Amount """ + _id_ = None _billing_date = None _type_description = None _type_description_translated = None @@ -226,6 +230,14 @@ class InvoiceItem(core.BunqModel): _total_vat_exclusive = None _total_vat_inclusive = None + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + @property def billing_date(self): """ @@ -303,6 +315,9 @@ def is_all_field_none(self): :rtype: bool """ + if self._id_ is not None: + return False + if self._billing_date is not None: return False @@ -337,13 +352,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: InvoiceItem + :rtype: InvoiceItemObject """ - return converter.json_to_class(InvoiceItem, json_str) + return converter.json_to_class(InvoiceItemObject, json_str) -class LabelMonetaryAccount(core.BunqModel): +class LabelMonetaryAccountObject(BunqModel): """ :param _iban: The IBAN of the monetary account. :type _iban: str @@ -365,6 +380,14 @@ class LabelMonetaryAccount(core.BunqModel): :param _swift_account_number: The account number used for a SWIFT payment. May or may not be an IBAN. :type _swift_account_number: str + :param _transferwise_account_number: The account number used for a + Transferwise payment. May or may not be an IBAN. + :type _transferwise_account_number: str + :param _transferwise_bank_code: The bank code used for a Transferwise + payment. May or may not be a BIC. + :type _transferwise_bank_code: str + :param _merchant_category_code: The merchant category code. + :type _merchant_category_code: str """ _iban = None @@ -376,6 +399,9 @@ class LabelMonetaryAccount(core.BunqModel): _is_light = None _swift_bic = None _swift_account_number = None + _transferwise_account_number = None + _transferwise_bank_code = None + _merchant_category_code = None @property def iban(self): @@ -449,6 +475,30 @@ def swift_account_number(self): return self._swift_account_number + @property + def transferwise_account_number(self): + """ + :rtype: str + """ + + return self._transferwise_account_number + + @property + def transferwise_bank_code(self): + """ + :rtype: str + """ + + return self._transferwise_bank_code + + @property + def merchant_category_code(self): + """ + :rtype: str + """ + + return self._merchant_category_code + def is_all_field_none(self): """ :rtype: bool @@ -481,6 +531,15 @@ def is_all_field_none(self): if self._swift_account_number is not None: return False + if self._transferwise_account_number is not None: + return False + + if self._transferwise_bank_code is not None: + return False + + if self._merchant_category_code is not None: + return False + return True @staticmethod @@ -488,13 +547,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: LabelMonetaryAccount + :rtype: LabelMonetaryAccountObject """ - return converter.json_to_class(LabelMonetaryAccount, json_str) + return converter.json_to_class(LabelMonetaryAccountObject, json_str) -class Avatar(core.BunqModel): +class AvatarObject(BunqModel): """ :param _uuid: The public UUID of the avatar. :type _uuid: str @@ -502,11 +561,14 @@ class Avatar(core.BunqModel): :type _anchor_uuid: str :param _image: The actual image information of this avatar. :type _image: list[Image] + :param _style: The style (if applicable) for this Avatar. + :type _style: str """ _uuid = None _anchor_uuid = None _image = None + _style = None _uuid_field_for_request = None def __init__(self, uuid=None): @@ -541,6 +603,14 @@ def image(self): return self._image + @property + def style(self): + """ + :rtype: str + """ + + return self._style + def is_all_field_none(self): """ :rtype: bool @@ -555,6 +625,9 @@ def is_all_field_none(self): if self._image is not None: return False + if self._style is not None: + return False + return True @staticmethod @@ -562,13 +635,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: Avatar + :rtype: AvatarObject """ - return converter.json_to_class(Avatar, json_str) + return converter.json_to_class(AvatarObject, json_str) -class Image(core.BunqModel): +class ImageObject(BunqModel): """ :param _attachment_public_uuid: The public UUID of the public attachment containing the image. @@ -642,13 +715,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: Image + :rtype: ImageObject """ - return converter.json_to_class(Image, json_str) + return converter.json_to_class(ImageObject, json_str) -class LabelUser(core.BunqModel): +class LabelUserObject(BunqModel): """ :param _uuid: The public UUID of the label-user. :type _uuid: str @@ -754,13 +827,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: LabelUser + :rtype: LabelUserObject """ - return converter.json_to_class(LabelUser, json_str) + return converter.json_to_class(LabelUserObject, json_str) -class Pointer(core.BunqModel): +class PointerObject(BunqModel): """ :param _type_: The alias type, can be: EMAIL|PHONE_NUMBER|IBAN. :type _type_: str @@ -768,6 +841,9 @@ class Pointer(core.BunqModel): :type _value: str :param _name: The alias name. :type _name: str + :param _service: The pointer service. Only required for external + counterparties. + :type _service: str """ _type_ = None @@ -776,8 +852,9 @@ class Pointer(core.BunqModel): _type__field_for_request = None _value_field_for_request = None _name_field_for_request = None + _service_field_for_request = None - def __init__(self, type_=None, value=None, name=None): + def __init__(self, type_=None, value=None, name=None, service=None): """ :param type_: The alias type, can be: EMAIL|PHONE_NUMBER|IBAN. :type type_: str @@ -786,11 +863,15 @@ def __init__(self, type_=None, value=None, name=None): :type value: str :param name: The alias name. Only required for IBANs. :type name: str + :param service: The pointer service. Only required for external + counterparties. + :type service: str """ self._type__field_for_request = type_ self._value_field_for_request = value self._name_field_for_request = name + self._service_field_for_request = service @property def type_(self): @@ -837,13 +918,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: Pointer + :rtype: PointerObject """ - return converter.json_to_class(Pointer, json_str) + return converter.json_to_class(PointerObject, json_str) -class Address(core.BunqModel): +class AddressObject(BunqModel): """ :param _street: The street. :type _street: str @@ -855,10 +936,19 @@ class Address(core.BunqModel): :type _postal_code: str :param _city: The city. :type _city: str - :param _country: The country as an ISO 3166-1 alpha-2 country code.. + :param _country: The country as an ISO 3166-1 alpha-2 country code. :type _country: str + :param _extra: The apartment, building or other extra information for + addresses. + :type _extra: str + :param _mailbox_name: The name on the mailbox (only used for Postal and + Shipping addresses). + :type _mailbox_name: str :param _province: The province according to local standard. :type _province: str + :param _is_user_address_updated: To show whether user created or updated her + address for app event listing. + :type _is_user_address_updated: bool """ _street = None @@ -868,15 +958,19 @@ class Address(core.BunqModel): _city = None _country = None _province = None + _extra = None + _mailbox_name = None + _is_user_address_updated = None _street_field_for_request = None _house_number_field_for_request = None _po_box_field_for_request = None _postal_code_field_for_request = None _city_field_for_request = None _country_field_for_request = None + _extra_field_for_request = None + _mailbox_name_field_for_request = None - def __init__(self, street=None, house_number=None, postal_code=None, - city=None, country=None, po_box=None): + def __init__(self, street=None, house_number=None, postal_code=None, city=None, country=None, po_box=None, extra=None, mailbox_name=None): """ :param street: The street. :type street: str @@ -890,6 +984,12 @@ def __init__(self, street=None, house_number=None, postal_code=None, :type country: str :param po_box: The PO box. :type po_box: str + :param extra: The apartment, building or other extra information for + addresses. + :type extra: str + :param mailbox_name: The name on the mailbox (only used for Postal and + Shipping addresses). + :type mailbox_name: str """ self._street_field_for_request = street @@ -898,6 +998,8 @@ def __init__(self, street=None, house_number=None, postal_code=None, self._city_field_for_request = city self._country_field_for_request = country self._po_box_field_for_request = po_box + self._extra_field_for_request = extra + self._mailbox_name_field_for_request = mailbox_name @property def street(self): @@ -955,6 +1057,30 @@ def province(self): return self._province + @property + def extra(self): + """ + :rtype: str + """ + + return self._extra + + @property + def mailbox_name(self): + """ + :rtype: str + """ + + return self._mailbox_name + + @property + def is_user_address_updated(self): + """ + :rtype: bool + """ + + return self._is_user_address_updated + def is_all_field_none(self): """ :rtype: bool @@ -981,6 +1107,15 @@ def is_all_field_none(self): if self._province is not None: return False + if self._extra is not None: + return False + + if self._mailbox_name is not None: + return False + + if self._is_user_address_updated is not None: + return False + return True @staticmethod @@ -988,13 +1123,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: Address + :rtype: AddressObject """ - return converter.json_to_class(Address, json_str) + return converter.json_to_class(AddressObject, json_str) -class RequestInquiryReference(core.BunqModel): +class RequestInquiryReferenceObject(BunqModel): """ :param _type_: The type of request inquiry. Can be RequestInquiry or RequestInquiryBatch. @@ -1040,22 +1175,25 @@ def from_json(json_str): """ :type json_str: str - :rtype: RequestInquiryReference + :rtype: RequestInquiryReferenceObject """ - return converter.json_to_class(RequestInquiryReference, json_str) + return converter.json_to_class(RequestInquiryReferenceObject, json_str) -class Attachment(core.BunqModel): +class AttachmentObject(BunqModel): """ :param _description: The description of the attachment. :type _description: str :param _content_type: The content type of the attachment's file. :type _content_type: str + :param _urls: The URLs where the file can be downloaded. + :type _urls: list[AttachmentUrl] """ _description = None _content_type = None + _urls = None @property def description(self): @@ -1073,6 +1211,14 @@ def content_type(self): return self._content_type + @property + def urls(self): + """ + :rtype: list[AttachmentUrl] + """ + + return self._urls + def is_all_field_none(self): """ :rtype: bool @@ -1084,6 +1230,9 @@ def is_all_field_none(self): if self._content_type is not None: return False + if self._urls is not None: + return False + return True @staticmethod @@ -1091,48 +1240,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: Attachment + :rtype: AttachmentObject """ - return converter.json_to_class(Attachment, json_str) + return converter.json_to_class(AttachmentObject, json_str) -class BunqMeMerchantAvailable(core.BunqModel): +class AttachmentUrlObject(BunqModel): """ - :param _merchant_type: A merchant type supported by bunq.me. - :type _merchant_type: str - :param _available: Whether or not the merchant is available for the user. - :type _available: bool + :param _type_: The file type of attachment. + :type _type_: str + :param _url: The URL where the attachment can be downloaded. + :type _url: str """ - _merchant_type = None - _available = None + _type_ = None + _url = None @property - def merchant_type(self): + def type_(self): """ :rtype: str """ - return self._merchant_type + return self._type_ @property - def available(self): + def url(self): """ - :rtype: bool + :rtype: str """ - return self._available + return self._url def is_all_field_none(self): """ :rtype: bool """ - if self._merchant_type is not None: + if self._type_ is not None: return False - if self._available is not None: + if self._url is not None: return False return True @@ -1142,58 +1291,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqMeMerchantAvailable + :rtype: AttachmentUrlObject """ - return converter.json_to_class(BunqMeMerchantAvailable, json_str) + return converter.json_to_class(AttachmentUrlObject, json_str) -class AttachmentMonetaryAccountPayment(core.BunqModel): +class PaymentArrivalExpectedObject(BunqModel): """ - :param _id_: The id of the attached Attachment. - :type _id_: int - :param _monetary_account_id: The id of the MonetaryAccount this Attachment - is attached from. - :type _monetary_account_id: int + :param _status: Indicates when we expect the payment to arrive. + :type _status: str + :param _time: The time when the payment is expected to arrive. + :type _time: str """ - _id_ = None - _monetary_account_id = None - _id__field_for_request = None - - def __init__(self, id_): - """ - :param id_: The id of the Attachment to attach to the MonetaryAccount. - :type id_: int - """ - - self._id__field_for_request = id_ + _status = None + _time = None @property - def id_(self): + def status(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._status @property - def monetary_account_id(self): + def time(self): """ - :rtype: int + :rtype: str """ - return self._monetary_account_id + return self._time def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._status is not None: return False - if self._monetary_account_id is not None: + if self._time is not None: return False return True @@ -1203,16 +1342,76 @@ def from_json(json_str): """ :type json_str: str - :rtype: AttachmentMonetaryAccountPayment + :rtype: PaymentArrivalExpectedObject """ - return converter.json_to_class(AttachmentMonetaryAccountPayment, - json_str) + return converter.json_to_class(PaymentArrivalExpectedObject, json_str) -class Geolocation(core.BunqModel): +class AttachmentMonetaryAccountPaymentObject(BunqModel): """ - :param _latitude: The latitude for a geolocation restriction. + :param _id_: The id of the attached Attachment. + :type _id_: int + :param _monetary_account_id: The id of the MonetaryAccount this Attachment + is attached from. + :type _monetary_account_id: int + """ + + _id_ = None + _monetary_account_id = None + _id__field_for_request = None + + def __init__(self, id_): + """ + :param id_: The id of the Attachment to attach to the MonetaryAccount. + :type id_: int + """ + + self._id__field_for_request = id_ + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def monetary_account_id(self): + """ + :rtype: int + """ + + return self._monetary_account_id + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._monetary_account_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AttachmentMonetaryAccountPaymentObject + """ + + return converter.json_to_class(AttachmentMonetaryAccountPaymentObject, json_str) + + +class GeolocationObject(BunqModel): + """ + :param _latitude: The latitude for a geolocation restriction. :type _latitude: float :param _longitude: The longitude for a geolocation restriction. :type _longitude: float @@ -1231,8 +1430,7 @@ class Geolocation(core.BunqModel): _altitude_field_for_request = None _radius_field_for_request = None - def __init__(self, latitude=None, longitude=None, altitude=None, - radius=None): + def __init__(self, latitude=None, longitude=None, altitude=None, radius=None): """ :param latitude: The latitude for a geolocation restriction. :type latitude: str @@ -1305,43 +1503,49 @@ def from_json(json_str): """ :type json_str: str - :rtype: Geolocation + :rtype: GeolocationObject """ - return converter.json_to_class(Geolocation, json_str) + return converter.json_to_class(GeolocationObject, json_str) -class BunqId(core.BunqModel): +class ErrorObject(BunqModel): """ - :param _id_: An integer ID of an object. Unique per object type. - :type _id_: int + :param _error_description: The error description (in English). + :type _error_description: str + :param _error_description_translated: The error description (in the user + language). + :type _error_description_translated: str """ - _id_ = None - _id__field_for_request = None + _error_description = None + _error_description_translated = None - def __init__(self, id_=None): + @property + def error_description(self): """ - :param id_: An integer ID of an object. Unique per object type. - :type id_: int + :rtype: str """ - self._id__field_for_request = id_ + return self._error_description @property - def id_(self): + def error_description_translated(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._error_description_translated def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: + if self._error_description is not None: + return False + + if self._error_description_translated is not None: return False return True @@ -1351,111 +1555,65 @@ def from_json(json_str): """ :type json_str: str - :rtype: BunqId + :rtype: ErrorObject """ - return converter.json_to_class(BunqId, json_str) + return converter.json_to_class(ErrorObject, json_str) -class CardBatchEntry(core.BunqModel): +class PaymentFeeObject(BunqModel): """ - :param _id_: The ID of the card that needs to be updated. - :type _id_: int - :param _activation_code: The activation code required to set status to - ACTIVE initially. Can only set status to ACTIVE using activation code when - order_status is ACCEPTED_FOR_PRODUCTION and status is DEACTIVATED. - :type _activation_code: str - :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, - LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when - order status is - ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Can only be set to DEACTIVATED after initial activation, i.e. order_status - is - DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are - permanent and cannot be changed after. - :type _status: str - :param _limit: DEPRECATED: The limits to define for the card, among - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_ATM, CARD_LIMIT_DIPPING and - CARD_LIMIT_POS_ICC (e.g. 25 EUR for CARD_LIMIT_CONTACTLESS). All the limits - must be provided on update. - :type _limit: list[CardLimit] - :param _card_limit: The limit to define for the card. - :type _card_limit: Amount - :param _mag_stripe_permission: Whether or not it is allowed to use the mag - stripe for the card. - :type _mag_stripe_permission: CardMagStripePermission - :param _country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type _country_permission: list[CardCountryPermission] - :param _monetary_account_id_fallback: ID of the MA to be used as fallback - for this card if insufficient balance. Fallback account is removed if not - supplied. - :type _monetary_account_id_fallback: int + :param _value: The amount formatted to two decimal places. + :type _value: str + :param _currency: The currency of the amount. It is an ISO 4217 formatted + currency code. + :type _currency: str + :param _invoice_id: The id of the invoice related to possible payment fee. + :type _invoice_id: int """ - _id__field_for_request = None - _activation_code_field_for_request = None - _status_field_for_request = None - _limit_field_for_request = None - _card_limit_field_for_request = None - _mag_stripe_permission_field_for_request = None - _country_permission_field_for_request = None - _monetary_account_id_fallback_field_for_request = None + _value = None + _currency = None + _invoice_id = None - def __init__(self, id_, activation_code=None, status=None, limit=None, - card_limit=None, mag_stripe_permission=None, - country_permission=None, monetary_account_id_fallback=None): + @property + def value(self): """ - :param id_: The ID of the card that needs to be updated. - :type id_: int - :param activation_code: The activation code required to set status to ACTIVE - initially. Can only set status to ACTIVE using activation code when - order_status is ACCEPTED_FOR_PRODUCTION and status is DEACTIVATED. - :type activation_code: str - :param status: The status to set for the card. Can be ACTIVE, DEACTIVATED, - LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when - order status is - ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Can only be set to DEACTIVATED after initial activation, i.e. order_status - is - DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. - Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are - permanent and cannot be changed after. - :type status: str - :param limit: DEPRECATED: The limits to define for the card, among - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_ATM, CARD_LIMIT_DIPPING and - CARD_LIMIT_POS_ICC (e.g. 25 EUR for CARD_LIMIT_CONTACTLESS). All the limits - must be provided on update. - :type limit: list[CardLimit] - :param card_limit: The limit to define for the card. - :type card_limit: Amount - :param mag_stripe_permission: Whether or not it is allowed to use the mag - stripe for the card. - :type mag_stripe_permission: CardMagStripePermission - :param country_permission: The countries for which to grant (temporary) - permissions to use the card. - :type country_permission: list[CardCountryPermission] - :param monetary_account_id_fallback: ID of the MA to be used as fallback for - this card if insufficient balance. Fallback account is removed if not - supplied. - :type monetary_account_id_fallback: int + :rtype: str """ - self._id__field_for_request = id_ - self._activation_code_field_for_request = activation_code - self._status_field_for_request = status - self._limit_field_for_request = limit - self._card_limit_field_for_request = card_limit - self._mag_stripe_permission_field_for_request = mag_stripe_permission - self._country_permission_field_for_request = country_permission - self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback + return self._value + + @property + def currency(self): + """ + :rtype: str + """ + + return self._currency + + @property + def invoice_id(self): + """ + :rtype: int + """ + + return self._invoice_id def is_all_field_none(self): """ :rtype: bool """ + if self._value is not None: + return False + + if self._currency is not None: + return False + + if self._invoice_id is not None: + return False + return True @staticmethod @@ -1463,95 +1621,62 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardBatchEntry + :rtype: PaymentFeeObject """ - return converter.json_to_class(CardBatchEntry, json_str) + return converter.json_to_class(PaymentFeeObject, json_str) -class CardLimit(core.BunqModel): +class AttachmentPublicObject(BunqModel): """ - :param _daily_limit: The daily limit amount. - :type _daily_limit: str - :param _currency: Currency for the daily limit. - :type _currency: str - :param _type_: The type of transaction for the limit. Can be CARD_LIMIT_ATM, - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_DIPPING or CARD_LIMIT_POS_ICC. - :type _type_: str - :param _id_: The id of the card limit entry. - :type _id_: int + :param _uuid: The uuid of the attachment. + :type _uuid: str + :param _description: The description of the attachment. + :type _description: str + :param _content_type: The content type of the attachment's file. + :type _content_type: str """ - _id_ = None - _daily_limit = None - _currency = None - _type_ = None - _daily_limit_field_for_request = None - _currency_field_for_request = None - _type__field_for_request = None - - def __init__(self, daily_limit=None, currency=None, type_=None): - """ - :param daily_limit: The daily limit amount. - :type daily_limit: str - :param currency: Currency for the daily limit. - :type currency: str - :param type_: The type of transaction for the limit. Can be CARD_LIMIT_ATM, - CARD_LIMIT_CONTACTLESS, CARD_LIMIT_DIPPING or CARD_LIMIT_POS_ICC. - :type type_: str - """ - - self._daily_limit_field_for_request = daily_limit - self._currency_field_for_request = currency - self._type__field_for_request = type_ - - @property - def id_(self): - """ - :rtype: int - """ - - return self._id_ + _uuid = None + _description = None + _content_type = None @property - def daily_limit(self): + def uuid(self): """ :rtype: str """ - return self._daily_limit + return self._uuid @property - def currency(self): + def description(self): """ :rtype: str """ - return self._currency + return self._description @property - def type_(self): + def content_type(self): """ :rtype: str """ - return self._type_ + return self._content_type def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._daily_limit is not None: + if self._uuid is not None: return False - if self._currency is not None: + if self._description is not None: return False - if self._type_ is not None: + if self._content_type is not None: return False return True @@ -1561,43 +1686,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardLimit + :rtype: AttachmentPublicObject """ - return converter.json_to_class(CardLimit, json_str) + return converter.json_to_class(AttachmentPublicObject, json_str) -class CardMagStripePermission(core.BunqModel): +class BunqMeMerchantAvailableObject(BunqModel): """ - :param _expiry_time: Expiry time of this rule. - :type _expiry_time: str + :param _merchant_type: A merchant type supported by bunq.me. + :type _merchant_type: str + :param _available: Whether or not the merchant is available for the user. + :type _available: bool """ - _expiry_time = None - _expiry_time_field_for_request = None + _merchant_type = None + _available = None - def __init__(self, expiry_time=None): + @property + def merchant_type(self): """ - :param expiry_time: Expiry time of this rule. - :type expiry_time: str + :rtype: str """ - self._expiry_time_field_for_request = expiry_time + return self._merchant_type @property - def expiry_time(self): + def available(self): """ - :rtype: str + :rtype: bool """ - return self._expiry_time + return self._available def is_all_field_none(self): """ :rtype: bool """ - if self._expiry_time is not None: + if self._merchant_type is not None: + return False + + if self._available is not None: return False return True @@ -1607,38 +1737,28 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardMagStripePermission + :rtype: BunqMeMerchantAvailableObject """ - return converter.json_to_class(CardMagStripePermission, json_str) + return converter.json_to_class(BunqMeMerchantAvailableObject, json_str) -class CardCountryPermission(core.BunqModel): +class BunqIdObject(BunqModel): """ - :param _country: The country to allow transactions in (e.g. NL, DE). - :type _country: str - :param _expiry_time: Expiry time of this rule. - :type _expiry_time: str - :param _id_: The id of the card country permission entry. + :param _id_: An integer ID of an object. Unique per object type. :type _id_: int """ _id_ = None - _country = None - _expiry_time = None - _country_field_for_request = None - _expiry_time_field_for_request = None + _id__field_for_request = None - def __init__(self, country=None, expiry_time=None): + def __init__(self, id_=None): """ - :param country: The country to allow transactions in (e.g. NL, DE). - :type country: str - :param expiry_time: Expiry time of this rule. - :type expiry_time: str + :param id_: An integer ID of an object. Unique per object type. + :type id_: int """ - self._country_field_for_request = country - self._expiry_time_field_for_request = expiry_time + self._id__field_for_request = id_ @property def id_(self): @@ -1648,35 +1768,70 @@ def id_(self): return self._id_ - @property - def country(self): + def is_all_field_none(self): """ - :rtype: str + :rtype: bool """ - return self._country + if self._id_ is not None: + return False - @property - def expiry_time(self): + return True + + @staticmethod + def from_json(json_str): """ - :rtype: str + :type json_str: str + + :rtype: BunqIdObject """ - return self._expiry_time + return converter.json_to_class(BunqIdObject, json_str) - def is_all_field_none(self): + +class CardBatchReplaceEntryObject(BunqModel): + """ + :param _id_: The ID of the card that needs to be replaced. + :type _id_: int + :param _name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type _name_on_card: str + :param _pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type _pin_code_assignment: list[CardPinAssignment] + :param _second_line: The second line on the card. + :type _second_line: str + """ + + _id__field_for_request = None + _name_on_card_field_for_request = None + _pin_code_assignment_field_for_request = None + _second_line_field_for_request = None + + def __init__(self, id_, name_on_card=None, pin_code_assignment=None, second_line=None): """ - :rtype: bool + :param id_: The ID of the card that needs to be replaced. + :type id_: int + :param name_on_card: The user's name as it will be on the card. Check + 'card-name' for the available card names for a user. + :type name_on_card: str + :param pin_code_assignment: Array of Types, PINs, account IDs assigned to + the card. + :type pin_code_assignment: list[CardPinAssignment] + :param second_line: The second line on the card. + :type second_line: str """ - if self._id_ is not None: - return False + self._id__field_for_request = id_ + self._name_on_card_field_for_request = name_on_card + self._pin_code_assignment_field_for_request = pin_code_assignment + self._second_line_field_for_request = second_line - if self._country is not None: - return False - if self._expiry_time is not None: - return False + def is_all_field_none(self): + """ + :rtype: bool + """ return True @@ -1685,33 +1840,42 @@ def from_json(json_str): """ :type json_str: str - :rtype: CardCountryPermission + :rtype: CardBatchReplaceEntryObject """ - return converter.json_to_class(CardCountryPermission, json_str) + return converter.json_to_class(CardBatchReplaceEntryObject, json_str) -class CardPinAssignment(core.BunqModel): +class CardPinAssignmentObject(BunqModel): """ :param _type_: PIN type. Can be PRIMARY, SECONDARY or TERTIARY :type _type_: str + :param _routing_type: Routing type. + :type _routing_type: str :param _pin_code: The 4 digit PIN to be assigned to this account. :type _pin_code: str :param _monetary_account_id: The ID of the monetary account to assign to this pin for the card. :type _monetary_account_id: int + :param _status: The status of the card pin assignment. + :type _status: str """ _type_ = None _monetary_account_id = None + _status = None + _routing_type = None _type__field_for_request = None + _routing_type_field_for_request = None _pin_code_field_for_request = None _monetary_account_id_field_for_request = None - def __init__(self, type_=None, pin_code=None, monetary_account_id=None): + def __init__(self, type_=None, routing_type=None, pin_code=None, monetary_account_id=None): """ :param type_: PIN type. Can be PRIMARY, SECONDARY or TERTIARY :type type_: str + :param routing_type: Routing type. Can be MANUAL or AUTOMATIC + :type routing_type: str :param pin_code: The 4 digit PIN to be assigned to this account. :type pin_code: str :param monetary_account_id: The ID of the monetary account to assign to this @@ -1720,6 +1884,7 @@ def __init__(self, type_=None, pin_code=None, monetary_account_id=None): """ self._type__field_for_request = type_ + self._routing_type_field_for_request = routing_type self._pin_code_field_for_request = pin_code self._monetary_account_id_field_for_request = monetary_account_id @@ -1739,118 +1904,37 @@ def monetary_account_id(self): return self._monetary_account_id - def is_all_field_none(self): - """ - :rtype: bool - """ - - if self._type_ is not None: - return False - - if self._monetary_account_id is not None: - return False - - return True - - @staticmethod - def from_json(json_str): - """ - :type json_str: str - - :rtype: CardPinAssignment - """ - - return converter.json_to_class(CardPinAssignment, json_str) - - -class NotificationFilter(core.BunqModel): - """ - :param _notification_delivery_method: The delivery method via which - notifications that match this notification filter will be delivered. - Possible choices are PUSH for delivery via push notification and URL for - delivery via URL callback. - :type _notification_delivery_method: str - :param _notification_target: The target of notifications that match this - notification filter. For URL notification filters this is the URL to which - the callback will be made. For PUSH notifications filters this should always - be null. - :type _notification_target: str - :param _category: The notification category that will match this - notification filter. Possible choices are BILLING, CARD_TRANSACTION_FAILED, - CARD_TRANSACTION_SUCCESSFUL, CHAT, DRAFT_PAYMENT, IDEAL, SOFORT, - MONETARY_ACCOUNT_PROFILE, MUTATION, PAYMENT, PROMOTION, REQUEST, - SCHEDULE_RESULT, SCHEDULE_STATUS, SHARE, SUPPORT, TAB_RESULT, USER_APPROVAL. - :type _category: str - """ - - _notification_delivery_method = None - _notification_target = None - _category = None - _notification_delivery_method_field_for_request = None - _notification_target_field_for_request = None - _category_field_for_request = None - - def __init__(self, notification_delivery_method=None, - notification_target=None, category=None): - """ - :param notification_delivery_method: The delivery method via which - notifications that match this notification filter will be delivered. - Possible choices are PUSH for delivery via push notification and URL for - delivery via URL callback. - :type notification_delivery_method: str - :param notification_target: The target of notifications that match this - notification filter. For URL notification filters this is the URL to which - the callback will be made. For PUSH notifications filters this should always - be null. - :type notification_target: str - :param category: The notification category that will match this notification - filter. Possible choices are BILLING, CARD_TRANSACTION_FAILED, - CARD_TRANSACTION_SUCCESSFUL, CHAT, DRAFT_PAYMENT, IDEAL, SOFORT, - MONETARY_ACCOUNT_PROFILE, MUTATION, PAYMENT, PROMOTION, REQUEST, - SCHEDULE_RESULT, SCHEDULE_STATUS, SHARE, SUPPORT, TAB_RESULT, USER_APPROVAL. - :type category: str - """ - - self._notification_delivery_method_field_for_request = notification_delivery_method - self._notification_target_field_for_request = notification_target - self._category_field_for_request = category - - @property - def notification_delivery_method(self): - """ - :rtype: str - """ - - return self._notification_delivery_method - @property - def notification_target(self): + def status(self): """ :rtype: str """ - return self._notification_target + return self._status @property - def category(self): + def routing_type(self): """ :rtype: str """ - return self._category + return self._routing_type def is_all_field_none(self): """ :rtype: bool """ - if self._notification_delivery_method is not None: + if self._type_ is not None: return False - if self._notification_target is not None: + if self._monetary_account_id is not None: return False - if self._category is not None: + if self._status is not None: + return False + + if self._routing_type is not None: return False return True @@ -1860,63 +1944,86 @@ def from_json(json_str): """ :type json_str: str - :rtype: NotificationFilter + :rtype: CardPinAssignmentObject """ - return converter.json_to_class(NotificationFilter, json_str) + return converter.json_to_class(CardPinAssignmentObject, json_str) -class TabTextWaitingScreen(core.BunqModel): +class CardBatchEntryObject(BunqModel): """ - :param _language: Language of tab text - :type _language: str - :param _description: Tab text - :type _description: str + :param _id_: The ID of the card that needs to be updated. + :type _id_: int + :param _status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when + order status is + ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Can only be set to DEACTIVATED after initial activation, i.e. order_status + is + DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are + permanent and cannot be changed after. + :type _status: str + :param _card_limit: The spending limit for the card. + :type _card_limit: Amount + :param _card_limit_atm: The ATM spending limit for the card. + :type _card_limit_atm: Amount + :param _country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type _country_permission: list[CardCountryPermission] + :param _monetary_account_id_fallback: ID of the MA to be used as fallback + for this card if insufficient balance. Fallback account is removed if not + supplied. + :type _monetary_account_id_fallback: int """ - _language = None - _description = None - _language_field_for_request = None - _description_field_for_request = None - - def __init__(self, language=None, description=None): - """ - :param language: Language of tab text - :type language: str - :param description: Tab text - :type description: str - """ - - self._language_field_for_request = language - self._description_field_for_request = description + _id__field_for_request = None + _status_field_for_request = None + _card_limit_field_for_request = None + _card_limit_atm_field_for_request = None + _country_permission_field_for_request = None + _monetary_account_id_fallback_field_for_request = None - @property - def language(self): + def __init__(self, id_, status=None, card_limit=None, card_limit_atm=None, country_permission=None, monetary_account_id_fallback=None): """ - :rtype: str + :param id_: The ID of the card that needs to be updated. + :type id_: int + :param status: The status to set for the card. Can be ACTIVE, DEACTIVATED, + LOST, STOLEN or CANCELLED, and can only be set to LOST/STOLEN/CANCELLED when + order status is + ACCEPTED_FOR_PRODUCTION/DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Can only be set to DEACTIVATED after initial activation, i.e. order_status + is + DELIVERED_TO_CUSTOMER/CARD_UPDATE_REQUESTED/CARD_UPDATE_SENT/CARD_UPDATE_ACCEPTED. + Mind that all the possible choices (apart from ACTIVE and DEACTIVATED) are + permanent and cannot be changed after. + :type status: str + :param card_limit: The spending limit for the card. + :type card_limit: Amount + :param card_limit_atm: The ATM spending limit for the card. + :type card_limit_atm: Amount + :param country_permission: The countries for which to grant (temporary) + permissions to use the card. + :type country_permission: list[CardCountryPermission] + :param monetary_account_id_fallback: ID of the MA to be used as fallback for + this card if insufficient balance. Fallback account is removed if not + supplied. + :type monetary_account_id_fallback: int """ - return self._language - - @property - def description(self): - """ - :rtype: str - """ + self._id__field_for_request = id_ + self._status_field_for_request = status + self._card_limit_field_for_request = card_limit + self._card_limit_atm_field_for_request = card_limit_atm + self._country_permission_field_for_request = country_permission + self._monetary_account_id_fallback_field_for_request = monetary_account_id_fallback - return self._description def is_all_field_none(self): """ :rtype: bool """ - if self._language is not None: - return False - - if self._description is not None: - return False - return True @staticmethod @@ -1924,89 +2031,63 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabTextWaitingScreen + :rtype: CardBatchEntryObject """ - return converter.json_to_class(TabTextWaitingScreen, json_str) + return converter.json_to_class(CardBatchEntryObject, json_str) -class TabVisibility(core.BunqModel): +class CardCountryPermissionObject(BunqModel): """ - :param _cash_register_qr_code: When true the tab will be linked to the - ACTIVE cash registers QR code. - :type _cash_register_qr_code: bool - :param _tab_qr_code: When true the tab will be visible through its own QR - code. Use ../tab/{tab-id}/qr-code-content to get the raw content of this QR - code - :type _tab_qr_code: bool - :param _location: The location of the Tab in NearPay. - :type _location: Geolocation + :param _country: The country to allow transactions in (e.g. NL, DE). + :type _country: str + :param _expiry_time: Expiry time of this rule. + :type _expiry_time: str + :param _id_: The id of the card country permission entry. + :type _id_: int """ - _cash_register_qr_code = None - _tab_qr_code = None - _location = None - _cash_register_qr_code_field_for_request = None - _tab_qr_code_field_for_request = None - _location_field_for_request = None - - def __init__(self, cash_register_qr_code=None, tab_qr_code=None, - location=None): - """ - :param cash_register_qr_code: When true the Tab will be linked to the ACTIVE - cash registers QR code. If no cash register QR code exists, one will be - created. - :type cash_register_qr_code: bool - :param tab_qr_code: When true the Tab will be visible through its own QR - code. Use ../tab/{tab-id}/qr-code-content to get the raw content of this QR - code - :type tab_qr_code: bool - :param location: The location on which this tab will be made visible in - NearPay. This location must overlap with the location of the CashRegister. - If no location is provided the location of the CashRegister will be used. - :type location: Geolocation - """ - - self._cash_register_qr_code_field_for_request = cash_register_qr_code - self._tab_qr_code_field_for_request = tab_qr_code - self._location_field_for_request = location + _id_ = None + _country = None + _country_field_for_request = None + _expiry_time_field_for_request = None - @property - def cash_register_qr_code(self): + def __init__(self, country=None, expiry_time=None): """ - :rtype: bool + :param country: The country to allow transactions in (e.g. NL, DE). + :type country: str + :param expiry_time: Expiry time of this rule. + :type expiry_time: str """ - return self._cash_register_qr_code + self._country_field_for_request = country + self._expiry_time_field_for_request = expiry_time @property - def tab_qr_code(self): + def id_(self): """ - :rtype: bool + :rtype: int """ - return self._tab_qr_code + return self._id_ @property - def location(self): + def country(self): """ - :rtype: Geolocation + :rtype: str """ - return self._location + return self._country def is_all_field_none(self): """ :rtype: bool """ - if self._cash_register_qr_code is not None: - return False - - if self._tab_qr_code is not None: + if self._id_ is not None: return False - if self._location is not None: + if self._country is not None: return False return True @@ -2016,114 +2097,116 @@ def from_json(json_str): """ :type json_str: str - :rtype: TabVisibility + :rtype: CardCountryPermissionObject """ - return converter.json_to_class(TabVisibility, json_str) + return converter.json_to_class(CardCountryPermissionObject, json_str) -class AttachmentPublic(core.BunqModel): +class CardPrimaryAccountNumberObject(BunqModel): """ - :param _uuid: The uuid of the attachment. - :type _uuid: str - :param _description: The description of the attachment. + :param _id_: The ID for this Virtual PAN. + :type _id_: int + :param _description: The description for this PAN. :type _description: str - :param _content_type: The content type of the attachment's file. - :type _content_type: str + :param _status: The status for this PAN, only for Online Cards. + :type _status: str + :param _monetary_account_id: The ID of the monetary account to assign to + this PAN, only for Online Cards. + :type _monetary_account_id: int + :param _uuid: The UUID for this Virtual PAN. + :type _uuid: str + :param _four_digit: The last four digits of the PAN. + :type _four_digit: str + :param _type_: The type of the PAN. + :type _type_: str """ + _id_ = None _uuid = None _description = None - _content_type = None + _status = None + _monetary_account_id = None + _four_digit = None + _type_ = None + _id__field_for_request = None + _description_field_for_request = None + _status_field_for_request = None + _monetary_account_id_field_for_request = None - @property - def uuid(self): + def __init__(self, id_=None, description=None, status=None, monetary_account_id=None): """ - :rtype: str + :param id_: The ID for this PAN. + :type id_: int + :param description: The description for this PAN. + :type description: str + :param status: The status for this PAN, only for Online Cards. + :type status: str + :param monetary_account_id: The ID of the monetary account to assign to this + PAN, only for Online Cards. + :type monetary_account_id: int """ - return self._uuid + self._id__field_for_request = id_ + self._description_field_for_request = description + self._status_field_for_request = status + self._monetary_account_id_field_for_request = monetary_account_id @property - def description(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._description + return self._id_ @property - def content_type(self): + def uuid(self): """ :rtype: str """ - return self._content_type + return self._uuid - def is_all_field_none(self): + @property + def description(self): """ - :rtype: bool + :rtype: str """ - if self._uuid is not None: - return False - - if self._description is not None: - return False - - if self._content_type is not None: - return False - - return True + return self._description - @staticmethod - def from_json(json_str): + @property + def status(self): """ - :type json_str: str - - :rtype: AttachmentPublic + :rtype: str """ - return converter.json_to_class(AttachmentPublic, json_str) - - -class AttachmentTab(core.BunqModel): - """ - :param _id_: The id of the attachment. - :type _id_: int - :param _description: The description of the attachment. - :type _description: str - :param _content_type: The content type of the attachment's file. - :type _content_type: str - """ - - _id_ = None - _description = None - _content_type = None + return self._status @property - def id_(self): + def monetary_account_id(self): """ :rtype: int """ - return self._id_ + return self._monetary_account_id @property - def description(self): + def four_digit(self): """ :rtype: str """ - return self._description + return self._four_digit @property - def content_type(self): + def type_(self): """ :rtype: str """ - return self._content_type + return self._type_ def is_all_field_none(self): """ @@ -2133,10 +2216,22 @@ def is_all_field_none(self): if self._id_ is not None: return False + if self._uuid is not None: + return False + if self._description is not None: return False - if self._content_type is not None: + if self._status is not None: + return False + + if self._monetary_account_id is not None: + return False + + if self._four_digit is not None: + return False + + if self._type_ is not None: return False return True @@ -2146,13 +2241,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: AttachmentTab + :rtype: CardPrimaryAccountNumberObject """ - return converter.json_to_class(AttachmentTab, json_str) + return converter.json_to_class(CardPrimaryAccountNumberObject, json_str) -class Certificate(core.BunqModel): +class CertificateObject(BunqModel): """ :param _certificate: A single certificate in the chain in .PEM format. :type _certificate: str @@ -2192,48 +2287,81 @@ def from_json(json_str): """ :type json_str: str - :rtype: Certificate + :rtype: CertificateObject """ - return converter.json_to_class(Certificate, json_str) + return converter.json_to_class(CertificateObject, json_str) -class DraftPaymentResponse(core.BunqModel): +class UboObject(BunqModel): """ - :param _status: The status with which was responded. - :type _status: str - :param _user_alias_created: The user that responded to the DraftPayment. - :type _user_alias_created: LabelUser + :param _name: The name of the ultimate beneficiary owner. + :type _name: str + :param _date_of_birth: The date of birth of the ultimate beneficiary owner. + :type _date_of_birth: str + :param _nationality: The nationality of the ultimate beneficiary owner. + :type _nationality: str """ - _status = None - _user_alias_created = None + _name = None + _date_of_birth = None + _nationality = None + _name_field_for_request = None + _date_of_birth_field_for_request = None + _nationality_field_for_request = None + + def __init__(self, name=None, date_of_birth=None, nationality=None): + """ + :param name: The name of the ultimate beneficiary owner. + :type name: str + :param date_of_birth: The date of birth of the ultimate beneficiary owner. + Accepts ISO8601 date formats. + :type date_of_birth: str + :param nationality: The nationality of the ultimate beneficiary owner. + Accepts ISO8601 date formats. + :type nationality: str + """ + + self._name_field_for_request = name + self._date_of_birth_field_for_request = date_of_birth + self._nationality_field_for_request = nationality @property - def status(self): + def name(self): """ :rtype: str """ - return self._status + return self._name @property - def user_alias_created(self): + def date_of_birth(self): """ - :rtype: LabelUser + :rtype: str """ - return self._user_alias_created + return self._date_of_birth + + @property + def nationality(self): + """ + :rtype: str + """ + + return self._nationality def is_all_field_none(self): """ :rtype: bool """ - if self._status is not None: + if self._name is not None: return False - if self._user_alias_created is not None: + if self._date_of_birth is not None: + return False + + if self._nationality is not None: return False return True @@ -2243,141 +2371,181 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftPaymentResponse + :rtype: UboObject """ - return converter.json_to_class(DraftPaymentResponse, json_str) + return converter.json_to_class(UboObject, json_str) -class DraftPaymentEntry(core.BunqModel): +class NotificationFilterObject(BunqModel): """ - :param _amount: The amount of the payment. - :type _amount: Amount - :param _counterparty_alias: The LabelMonetaryAccount containing the public - information of the other (counterparty) side of the DraftPayment. - :type _counterparty_alias: MonetaryAccountReference - :param _description: The description for the DraftPayment. Maximum 140 - characters for DraftPayments to external IBANs, 9000 characters for - DraftPayments to only other bunq MonetaryAccounts. - :type _description: str - :param _merchant_reference: Optional data to be included with the Payment - specific to the merchant. - :type _merchant_reference: str - :param _attachment: The Attachments attached to the DraftPayment. - :type _attachment: list[AttachmentMonetaryAccountPayment] - :param _id_: The id of the draft payment entry. - :type _id_: int - :param _alias: The LabelMonetaryAccount containing the public information of - 'this' (party) side of the DraftPayment. - :type _alias: MonetaryAccountReference - :param _type_: The type of the draft payment entry. - :type _type_: str + :param _notification_delivery_method: The delivery method via which + notifications that match this notification filter will be delivered. + Possible choices are PUSH for delivery via push notification and URL for + delivery via URL callback. + :type _notification_delivery_method: str + :param _notification_target: The target of notifications that match this + notification filter. For URL notification filters this is the URL to which + the callback will be made. For PUSH notifications filters this should always + be null. + :type _notification_target: str + :param _category: The notification category that will match this + notification filter. Possible choices are BILLING, CARD_TRANSACTION_FAILED, + CARD_TRANSACTION_SUCCESSFUL, CHAT, DRAFT_PAYMENT, IDEAL, SOFORT, + MONETARY_ACCOUNT_PROFILE, MUTATION, PAYMENT, PROMOTION, REQUEST, + SCHEDULE_RESULT, SCHEDULE_STATUS, SHARE, SUPPORT, TAB_RESULT, USER_APPROVAL. + :type _category: str """ - _id_ = None - _amount = None - _alias = None - _counterparty_alias = None - _description = None - _merchant_reference = None - _type_ = None - _attachment = None - _amount_field_for_request = None - _counterparty_alias_field_for_request = None - _description_field_for_request = None - _merchant_reference_field_for_request = None - _attachment_field_for_request = None + _notification_delivery_method = None + _notification_target = None + _category = None + _notification_delivery_method_field_for_request = None + _notification_target_field_for_request = None + _category_field_for_request = None - def __init__(self, amount=None, counterparty_alias=None, description=None, - merchant_reference=None, attachment=None): + def __init__(self, notification_delivery_method=None, notification_target=None, category=None): """ - :param amount: The amount of the payment. - :type amount: Amount - :param counterparty_alias: The Alias of the party we are transferring the - money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq - MonetaryAccounts or bunq.to payments) or IBAN (for external bank account). - :type counterparty_alias: Pointer - :param description: The description for the DraftPayment. Maximum 140 - characters for DraftPayments to external IBANs, 9000 characters for - DraftPayments to only other bunq MonetaryAccounts. Field is required but can - be an empty string. - :type description: str - :param merchant_reference: Optional data to be included with the Payment - specific to the merchant. - :type merchant_reference: str - :param attachment: The Attachments to attach to the DraftPayment. - :type attachment: list[AttachmentMonetaryAccountPayment] + :param notification_delivery_method: The delivery method via which + notifications that match this notification filter will be delivered. + Possible choices are PUSH for delivery via push notification and URL for + delivery via URL callback. + :type notification_delivery_method: str + :param notification_target: The target of notifications that match this + notification filter. For URL notification filters this is the URL to which + the callback will be made. For PUSH notifications filters this should always + be null. + :type notification_target: str + :param category: The notification category that will match this notification + filter. Possible choices are BILLING, CARD_TRANSACTION_FAILED, + CARD_TRANSACTION_SUCCESSFUL, CHAT, DRAFT_PAYMENT, IDEAL, SOFORT, + MONETARY_ACCOUNT_PROFILE, MUTATION, PAYMENT, PROMOTION, REQUEST, + SCHEDULE_RESULT, SCHEDULE_STATUS, SHARE, SUPPORT, TAB_RESULT, USER_APPROVAL. + :type category: str """ - self._amount_field_for_request = amount - self._counterparty_alias_field_for_request = counterparty_alias - self._description_field_for_request = description - self._merchant_reference_field_for_request = merchant_reference - self._attachment_field_for_request = attachment + self._notification_delivery_method_field_for_request = notification_delivery_method + self._notification_target_field_for_request = notification_target + self._category_field_for_request = category @property - def id_(self): + def notification_delivery_method(self): """ - :rtype: int + :rtype: str """ - return self._id_ + return self._notification_delivery_method @property - def amount(self): + def notification_target(self): """ - :rtype: Amount + :rtype: str """ - return self._amount + return self._notification_target @property - def alias(self): + def category(self): """ - :rtype: MonetaryAccountReference + :rtype: str """ - return self._alias + return self._category - @property - def counterparty_alias(self): + def is_all_field_none(self): """ - :rtype: MonetaryAccountReference + :rtype: bool """ - return self._counterparty_alias + if self._notification_delivery_method is not None: + return False + + if self._notification_target is not None: + return False + + if self._category is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: NotificationFilterObject + """ + + return converter.json_to_class(NotificationFilterObject, json_str) + + +class TaxResidentObject(BunqModel): + """ + :param _country: The country of the tax number. + :type _country: str + :param _tax_number: The tax number. + :type _tax_number: str + :param _status: The status of the tax number. Either CONFIRMED or + UNCONFIRMED. + :type _status: str + :param _id_: The id of the tax resident. + :type _id_: int + """ + + _id_ = None + _country = None + _tax_number = None + _status = None + _country_field_for_request = None + _tax_number_field_for_request = None + _status_field_for_request = None + + def __init__(self, country=None, tax_number=None, status=None): + """ + :param country: The country of the tax number. + :type country: str + :param tax_number: The tax number. + :type tax_number: str + :param status: The status of the tax number. Either CONFIRMED or + UNCONFIRMED. + :type status: str + """ + + self._country_field_for_request = country + self._tax_number_field_for_request = tax_number + self._status_field_for_request = status @property - def description(self): + def id_(self): """ - :rtype: str + :rtype: int """ - return self._description + return self._id_ @property - def merchant_reference(self): + def country(self): """ :rtype: str """ - return self._merchant_reference + return self._country @property - def type_(self): + def tax_number(self): """ :rtype: str """ - return self._type_ + return self._tax_number @property - def attachment(self): + def status(self): """ - :rtype: list[AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._status def is_all_field_none(self): """ @@ -2387,25 +2555,13 @@ def is_all_field_none(self): if self._id_ is not None: return False - if self._amount is not None: - return False - - if self._alias is not None: - return False - - if self._counterparty_alias is not None: - return False - - if self._description is not None: - return False - - if self._merchant_reference is not None: + if self._country is not None: return False - if self._type_ is not None: + if self._tax_number is not None: return False - if self._attachment is not None: + if self._status is not None: return False return True @@ -2415,65 +2571,79 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftPaymentEntry + :rtype: TaxResidentObject """ - return converter.json_to_class(DraftPaymentEntry, json_str) + return converter.json_to_class(TaxResidentObject, json_str) -class DraftPaymentAnchorObject(core.BunqModel, core.AnchoredObjectInterface): +class CompanyVatNumberObject(BunqModel): """ - :param _Payment: - :type _Payment: endpoint.Payment - :param _PaymentBatch: - :type _PaymentBatch: endpoint.PaymentBatch + :param _type_: The VAT identification number type. + :type _type_: str + :param _country: The country of the VAT identification number. + :type _country: str + :param _value: The VAT identification number number. + :type _value: str """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - - _Payment = None - _PaymentBatch = None + _type_ = None + _country = None + _value = None + _type__field_for_request = None + _country_field_for_request = None + _value_field_for_request = None - @property - def Payment(self): + def __init__(self, country=None, value=None, type_=None): """ - :rtype: endpoint.Payment + :param country: The country of the VAT identification number. + :type country: str + :param value: The VAT identification number number. + :type value: str + :param type_: The VAT identification number type. + :type type_: str """ - return self._Payment + self._country_field_for_request = country + self._value_field_for_request = value + self._type__field_for_request = type_ @property - def PaymentBatch(self): + def type_(self): """ - :rtype: endpoint.PaymentBatch + :rtype: str """ - return self._PaymentBatch + return self._type_ - def get_referenced_object(self): + @property + def country(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: str """ - if self._Payment is not None: - return self._Payment + return self._country - if self._PaymentBatch is not None: - return self._PaymentBatch + @property + def value(self): + """ + :rtype: str + """ - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._value def is_all_field_none(self): """ :rtype: bool """ - if self._Payment is not None: + if self._type_ is not None: return False - if self._PaymentBatch is not None: + if self._country is not None: + return False + + if self._value is not None: return False return True @@ -2483,81 +2653,77 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftPaymentAnchorObject + :rtype: CompanyVatNumberObject """ - return converter.json_to_class(DraftPaymentAnchorObject, json_str) + return converter.json_to_class(CompanyVatNumberObject, json_str) -class DraftShareInviteEntry(core.BunqModel): +class CurrencyCloudBeneficiaryRequirementFieldObject(BunqModel): """ - :param _share_detail: The share details. Only one of these objects is - returned. - :type _share_detail: ShareDetail - :param _start_date: The start date of this share. - :type _start_date: str - :param _end_date: The expiration date of this share. - :type _end_date: str + :param _label: The label to display for the field. + :type _label: str + :param _name: The name of the field. + :type _name: str + :param _validation_expression: The expression to validate field input. + :type _validation_expression: str + :param _input_type: The type of data to input. Determines the keyboard to + display. + :type _input_type: str """ - _share_detail = None - _start_date = None - _end_date = None - _share_detail_field_for_request = None - _start_date_field_for_request = None - _end_date_field_for_request = None + _label = None + _name = None + _validation_expression = None + _input_type = None - def __init__(self, share_detail=None, start_date=None, end_date=None): + @property + def label(self): """ - :param share_detail: The share details. Only one of these objects may be - passed. - :type share_detail: ShareDetail - :param start_date: The start date of this share. - :type start_date: str - :param end_date: The expiration date of this share. - :type end_date: str + :rtype: str """ - self._share_detail_field_for_request = share_detail - self._start_date_field_for_request = start_date - self._end_date_field_for_request = end_date + return self._label @property - def share_detail(self): + def name(self): """ - :rtype: ShareDetail + :rtype: str """ - return self._share_detail + return self._name @property - def start_date(self): + def validation_expression(self): """ :rtype: str """ - return self._start_date + return self._validation_expression @property - def end_date(self): + def input_type(self): """ :rtype: str """ - return self._end_date + return self._input_type def is_all_field_none(self): """ :rtype: bool """ - if self._share_detail is not None: + if self._label is not None: + return False + + if self._name is not None: return False - if self._start_date is not None: + if self._validation_expression is not None: return False - if self._end_date is not None: + if self._input_type is not None: return False return True @@ -2567,87 +2733,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: DraftShareInviteEntry + :rtype: CurrencyCloudBeneficiaryRequirementFieldObject """ - return converter.json_to_class(DraftShareInviteEntry, json_str) + return converter.json_to_class(CurrencyCloudBeneficiaryRequirementFieldObject, json_str) -class ShareDetail(core.BunqModel): +class DraftPaymentResponseObject(BunqModel): """ - :param _payment: The share details for a payment share. In the response - 'payment' is replaced by 'ShareDetailPayment'. - :type _payment: ShareDetailPayment - :param _read_only: The share details for viewing a share. In the response - 'read_only' is replaced by 'ShareDetailReadOnly'. - :type _read_only: ShareDetailReadOnly - :param _draft_payment: The share details for a draft payment share. Remember - to replace 'draft_payment' with 'ShareDetailDraftPayment' before sending a - request. - :type _draft_payment: ShareDetailDraftPayment + :param _status: The status with which was responded. + :type _status: str + :param _user_alias_created: The user that responded to the DraftPayment. + :type _user_alias_created: LabelUser """ - _payment = None - _read_only = None - _draft_payment = None - _payment_field_for_request = None - _read_only_field_for_request = None - _draft_payment_field_for_request = None - - def __init__(self, payment=None, read_only=None, draft_payment=None): - """ - :param payment: The share details for a payment share. Remember to replace - 'payment' with 'ShareDetailPayment' before sending a request. - :type payment: ShareDetailPayment - :param read_only: The share details for viewing a share. Remember to replace - 'read_only' with 'ShareDetailReadOnly' before sending a request. - :type read_only: ShareDetailReadOnly - :param draft_payment: The share details for a draft payment share. Remember - to replace 'draft_payment' with 'ShareDetailDraftPayment' before sending a - request. - :type draft_payment: ShareDetailDraftPayment - """ - - self._payment_field_for_request = payment - self._read_only_field_for_request = read_only - self._draft_payment_field_for_request = draft_payment - - @property - def payment(self): - """ - :rtype: ShareDetailPayment - """ - - return self._payment + _status = None + _user_alias_created = None @property - def read_only(self): + def status(self): """ - :rtype: ShareDetailReadOnly + :rtype: str """ - return self._read_only + return self._status @property - def draft_payment(self): + def user_alias_created(self): """ - :rtype: ShareDetailDraftPayment + :rtype: LabelUser """ - return self._draft_payment + return self._user_alias_created def is_all_field_none(self): """ :rtype: bool """ - if self._payment is not None: - return False - - if self._read_only is not None: + if self._status is not None: return False - if self._draft_payment is not None: + if self._user_alias_created is not None: return False return True @@ -2657,145 +2784,168 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareDetail + :rtype: DraftPaymentResponseObject """ - return converter.json_to_class(ShareDetail, json_str) + return converter.json_to_class(DraftPaymentResponseObject, json_str) -class ShareDetailPayment(core.BunqModel): +class DraftPaymentEntryObject(BunqModel): """ - :param _make_payments: If set to true, the invited user will be able to make - payments from the shared account. - :type _make_payments: bool - :param _make_draft_payments: If set to true, the invited user will be able - to make draft payments from the shared account. - :type _make_draft_payments: bool - :param _view_balance: If set to true, the invited user will be able to view - the account balance. - :type _view_balance: bool - :param _view_old_events: If set to true, the invited user will be able to - view events from before the share was active. - :type _view_old_events: bool - :param _view_new_events: If set to true, the invited user will be able to - view events starting from the time the share became active. - :type _view_new_events: bool - :param _budget: The budget restriction. - :type _budget: BudgetRestriction + :param _amount: The amount of the payment. + :type _amount: Amount + :param _counterparty_alias: The LabelMonetaryAccount containing the public + information of the other (counterparty) side of the DraftPayment. + :type _counterparty_alias: MonetaryAccountReference + :param _description: The description for the DraftPayment. Maximum 140 + characters for DraftPayments to external IBANs, 9000 characters for + DraftPayments to only other bunq MonetaryAccounts. + :type _description: str + :param _merchant_reference: Optional data to be included with the Payment + specific to the merchant. + :type _merchant_reference: str + :param _attachment: The Attachments attached to the DraftPayment. + :type _attachment: list[AttachmentMonetaryAccountPayment] + :param _id_: The id of the draft payment entry. + :type _id_: int + :param _alias: The LabelMonetaryAccount containing the public information of + 'this' (party) side of the DraftPayment. + :type _alias: MonetaryAccountReference + :param _type_: The type of the draft payment entry. + :type _type_: str """ - _make_payments = None - _make_draft_payments = None - _view_balance = None - _view_old_events = None - _view_new_events = None - _budget = None - _make_payments_field_for_request = None - _make_draft_payments_field_for_request = None - _view_balance_field_for_request = None - _view_old_events_field_for_request = None - _view_new_events_field_for_request = None - _budget_field_for_request = None + _id_ = None + _amount = None + _alias = None + _counterparty_alias = None + _description = None + _merchant_reference = None + _type_ = None + _attachment = None + _amount_field_for_request = None + _counterparty_alias_field_for_request = None + _description_field_for_request = None + _merchant_reference_field_for_request = None + _attachment_field_for_request = None - def __init__(self, make_payments=None, view_balance=None, - view_old_events=None, view_new_events=None, - make_draft_payments=None, budget=None): + def __init__(self, amount=None, counterparty_alias=None, description=None, merchant_reference=None, attachment=None): """ - :param make_payments: If set to true, the invited user will be able to make - payments from the shared account. - :type make_payments: bool - :param view_balance: If set to true, the invited user will be able to view - the account balance. - :type view_balance: bool - :param view_old_events: If set to true, the invited user will be able to - view events from before the share was active. - :type view_old_events: bool - :param view_new_events: If set to true, the invited user will be able to - view events starting from the time the share became active. - :type view_new_events: bool - :param make_draft_payments: If set to true, the invited user will be able to - make draft payments from the shared account. - :type make_draft_payments: bool - :param budget: The budget restriction. - :type budget: BudgetRestriction + :param amount: The amount of the payment. + :type amount: Amount + :param counterparty_alias: The Alias of the party we are transferring the + money to. Can be an Alias of type EMAIL or PHONE_NUMBER (for bunq + MonetaryAccounts or bunq.to payments) or IBAN (for external bank account). + :type counterparty_alias: Pointer + :param description: The description for the DraftPayment. Maximum 140 + characters for DraftPayments to external IBANs, 9000 characters for + DraftPayments to only other bunq MonetaryAccounts. Field is required but can + be an empty string. + :type description: str + :param merchant_reference: Optional data to be included with the Payment + specific to the merchant. + :type merchant_reference: str + :param attachment: The Attachments to attach to the DraftPayment. + :type attachment: list[AttachmentMonetaryAccountPayment] """ - self._make_payments_field_for_request = make_payments - self._view_balance_field_for_request = view_balance - self._view_old_events_field_for_request = view_old_events - self._view_new_events_field_for_request = view_new_events - self._make_draft_payments_field_for_request = make_draft_payments - self._budget_field_for_request = budget + self._amount_field_for_request = amount + self._counterparty_alias_field_for_request = counterparty_alias + self._description_field_for_request = description + self._merchant_reference_field_for_request = merchant_reference + self._attachment_field_for_request = attachment @property - def make_payments(self): + def id_(self): """ - :rtype: bool + :rtype: int """ - return self._make_payments + return self._id_ @property - def make_draft_payments(self): + def amount(self): """ - :rtype: bool + :rtype: Amount """ - return self._make_draft_payments + return self._amount @property - def view_balance(self): + def alias(self): """ - :rtype: bool + :rtype: MonetaryAccountReference """ - return self._view_balance + return self._alias @property - def view_old_events(self): + def counterparty_alias(self): """ - :rtype: bool + :rtype: MonetaryAccountReference """ - return self._view_old_events + return self._counterparty_alias @property - def view_new_events(self): + def description(self): """ - :rtype: bool + :rtype: str """ - return self._view_new_events + return self._description + + @property + def merchant_reference(self): + """ + :rtype: str + """ + + return self._merchant_reference + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ @property - def budget(self): + def attachment(self): """ - :rtype: BudgetRestriction + :rtype: list[AttachmentMonetaryAccountPayment] """ - return self._budget + return self._attachment def is_all_field_none(self): """ :rtype: bool """ - if self._make_payments is not None: + if self._id_ is not None: return False - if self._make_draft_payments is not None: + if self._amount is not None: return False - if self._view_balance is not None: + if self._alias is not None: return False - if self._view_old_events is not None: + if self._counterparty_alias is not None: return False - if self._view_new_events is not None: + if self._description is not None: + return False + + if self._merchant_reference is not None: + return False + + if self._type_ is not None: return False - if self._budget is not None: + if self._attachment is not None: return False return True @@ -2805,63 +2955,65 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareDetailPayment + :rtype: DraftPaymentEntryObject """ - return converter.json_to_class(ShareDetailPayment, json_str) + return converter.json_to_class(DraftPaymentEntryObject, json_str) -class BudgetRestriction(core.BunqModel): +class DraftPaymentAnchorObjectObject(BunqModel, AnchorObjectInterface): """ - :param _amount: The amount of the budget given to the invited user. - :type _amount: Amount - :param _frequency: The duration for a budget restriction. Valid values are - DAILY, WEEKLY, MONTHLY, YEARLY. - :type _frequency: str + :param _Payment: + :type _Payment: endpoint.Payment + :param _PaymentBatch: + :type _PaymentBatch: endpoint.PaymentBatch """ - _amount = None - _frequency = None - _amount_field_for_request = None - _frequency_field_for_request = None + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - def __init__(self, amount=None, frequency=None): - """ - :param amount: The amount of the budget given to the invited user. - :type amount: Amount - :param frequency: The duration for a budget restriction. Valid values are - DAILY, WEEKLY, MONTHLY, YEARLY. - :type frequency: str - """ - self._amount_field_for_request = amount - self._frequency_field_for_request = frequency + _Payment = None + _PaymentBatch = None @property - def amount(self): + def Payment(self): """ - :rtype: Amount + :rtype: endpoint.Payment """ - return self._amount + return self._Payment @property - def frequency(self): + def PaymentBatch(self): """ - :rtype: str + :rtype: endpoint.PaymentBatch + """ + + return self._PaymentBatch + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException """ - return self._frequency + if self._Payment is not None: + return self._Payment + + if self._PaymentBatch is not None: + return self._PaymentBatch + + raise BunqException(self._ERROR_NULL_FIELDS) def is_all_field_none(self): """ :rtype: bool """ - if self._amount is not None: + if self._Payment is not None: return False - if self._frequency is not None: + if self._PaymentBatch is not None: return False return True @@ -2871,73 +3023,1555 @@ def from_json(json_str): """ :type json_str: str - :rtype: BudgetRestriction + :rtype: DraftPaymentAnchorObjectObject """ - return converter.json_to_class(BudgetRestriction, json_str) + return converter.json_to_class(DraftPaymentAnchorObjectObject, json_str) -class ShareDetailReadOnly(core.BunqModel): +class ScheduleAnchorObjectObject(BunqModel, AnchorObjectInterface): """ - :param _view_balance: If set to true, the invited user will be able to view - the account balance. - :type _view_balance: bool - :param _view_old_events: If set to true, the invited user will be able to - view events from before the share was active. - :type _view_old_events: bool - :param _view_new_events: If set to true, the invited user will be able to - view events starting from the time the share became active. - :type _view_new_events: bool + :param _Payment: + :type _Payment: endpoint.Payment + :param _PaymentBatch: + :type _PaymentBatch: endpoint.PaymentBatch """ - _view_balance = None - _view_old_events = None - _view_new_events = None - _view_balance_field_for_request = None - _view_old_events_field_for_request = None - _view_new_events_field_for_request = None + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - def __init__(self, view_balance=None, view_old_events=None, - view_new_events=None): - """ - :param view_balance: If set to true, the invited user will be able to view - the account balance. - :type view_balance: bool - :param view_old_events: If set to true, the invited user will be able to - view events from before the share was active. - :type view_old_events: bool - :param view_new_events: If set to true, the invited user will be able to - view events starting from the time the share became active. - :type view_new_events: bool - """ - self._view_balance_field_for_request = view_balance - self._view_old_events_field_for_request = view_old_events - self._view_new_events_field_for_request = view_new_events + _Payment = None + _PaymentBatch = None @property - def view_balance(self): + def Payment(self): """ - :rtype: bool + :rtype: endpoint.Payment """ - return self._view_balance + return self._Payment @property - def view_old_events(self): + def PaymentBatch(self): """ - :rtype: bool + :rtype: endpoint.PaymentBatch """ - return self._view_old_events - - @property - def view_new_events(self): + return self._PaymentBatch + def get_referenced_object(self): """ - :rtype: bool + :rtype: BunqModel + :raise: BunqException """ - return self._view_new_events + if self._Payment is not None: + return self._Payment + + if self._PaymentBatch is not None: + return self._PaymentBatch + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._Payment is not None: + return False + + if self._PaymentBatch is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ScheduleAnchorObjectObject + """ + + return converter.json_to_class(ScheduleAnchorObjectObject, json_str) + + +class EventObjectObject(BunqModel, AnchorObjectInterface): + """ + :param _BunqMeTab: + :type _BunqMeTab: endpoint.BunqMeTab + :param _BunqMeTabResultResponse: + :type _BunqMeTabResultResponse: endpoint.BunqMeTabResultResponse + :param _BunqMeFundraiserResult: + :type _BunqMeFundraiserResult: endpoint.BunqMeFundraiserResult + :param _Card: + :type _Card: endpoint.Card + :param _CardDebit: + :type _CardDebit: endpoint.CardDebit + :param _DraftPayment: + :type _DraftPayment: endpoint.DraftPayment + :param _FeatureAnnouncement: + :type _FeatureAnnouncement: endpoint.FeatureAnnouncement + :param _IdealMerchantTransaction: + :type _IdealMerchantTransaction: endpoint.IdealMerchantTransaction + :param _Invoice: + :type _Invoice: endpoint.Invoice + :param _ScheduledPayment: + :type _ScheduledPayment: endpoint.SchedulePayment + :param _ScheduledPaymentBatch: + :type _ScheduledPaymentBatch: endpoint.SchedulePaymentBatch + :param _ScheduledInstance: + :type _ScheduledInstance: endpoint.ScheduleInstance + :param _MasterCardAction: + :type _MasterCardAction: endpoint.MasterCardAction + :param _BankSwitchServiceNetherlandsIncomingPayment: + :type _BankSwitchServiceNetherlandsIncomingPayment: + endpoint.BankSwitchServiceNetherlandsIncomingPayment + :param _Payment: + :type _Payment: endpoint.Payment + :param _PaymentBatch: + :type _PaymentBatch: endpoint.PaymentBatch + :param _RequestInquiryBatch: + :type _RequestInquiryBatch: endpoint.RequestInquiryBatch + :param _RequestInquiry: + :type _RequestInquiry: endpoint.RequestInquiry + :param _RequestResponse: + :type _RequestResponse: endpoint.RequestResponse + :param _ShareInviteBankInquiry: + :type _ShareInviteBankInquiry: endpoint.ShareInviteMonetaryAccountInquiry + :param _ShareInviteBankResponse: + :type _ShareInviteBankResponse: endpoint.ShareInviteMonetaryAccountResponse + :param _SofortMerchantTransaction: + :type _SofortMerchantTransaction: endpoint.SofortMerchantTransaction + :param _TransferwisePayment: + :type _TransferwisePayment: endpoint.TransferwiseTransfer + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + + _BunqMeTab = None + _BunqMeTabResultResponse = None + _BunqMeFundraiserResult = None + _Card = None + _CardDebit = None + _DraftPayment = None + _FeatureAnnouncement = None + _IdealMerchantTransaction = None + _Invoice = None + _ScheduledPayment = None + _ScheduledPaymentBatch = None + _ScheduledInstance = None + _MasterCardAction = None + _BankSwitchServiceNetherlandsIncomingPayment = None + _Payment = None + _PaymentBatch = None + _RequestInquiryBatch = None + _RequestInquiry = None + _RequestResponse = None + _ShareInviteBankInquiry = None + _ShareInviteBankResponse = None + _SofortMerchantTransaction = None + _TransferwisePayment = None + + @property + def BunqMeTab(self): + """ + :rtype: endpoint.BunqMeTab + """ + + return self._BunqMeTab + + @property + def BunqMeTabResultResponse(self): + """ + :rtype: endpoint.BunqMeTabResultResponse + """ + + return self._BunqMeTabResultResponse + + @property + def BunqMeFundraiserResult(self): + """ + :rtype: endpoint.BunqMeFundraiserResult + """ + + return self._BunqMeFundraiserResult + + @property + def Card(self): + """ + :rtype: endpoint.Card + """ + + return self._Card + + @property + def CardDebit(self): + """ + :rtype: endpoint.CardDebit + """ + + return self._CardDebit + + @property + def DraftPayment(self): + """ + :rtype: endpoint.DraftPayment + """ + + return self._DraftPayment + + @property + def FeatureAnnouncement(self): + """ + :rtype: endpoint.FeatureAnnouncement + """ + + return self._FeatureAnnouncement + + @property + def IdealMerchantTransaction(self): + """ + :rtype: endpoint.IdealMerchantTransaction + """ + + return self._IdealMerchantTransaction + + @property + def Invoice(self): + """ + :rtype: endpoint.Invoice + """ + + return self._Invoice + + @property + def ScheduledPayment(self): + """ + :rtype: endpoint.SchedulePayment + """ + + return self._ScheduledPayment + + @property + def ScheduledPaymentBatch(self): + """ + :rtype: endpoint.SchedulePaymentBatch + """ + + return self._ScheduledPaymentBatch + + @property + def ScheduledInstance(self): + """ + :rtype: endpoint.ScheduleInstance + """ + + return self._ScheduledInstance + + @property + def MasterCardAction(self): + """ + :rtype: endpoint.MasterCardAction + """ + + return self._MasterCardAction + + @property + def BankSwitchServiceNetherlandsIncomingPayment(self): + """ + :rtype: endpoint.BankSwitchServiceNetherlandsIncomingPayment + """ + + return self._BankSwitchServiceNetherlandsIncomingPayment + + @property + def Payment(self): + """ + :rtype: endpoint.Payment + """ + + return self._Payment + + @property + def PaymentBatch(self): + """ + :rtype: endpoint.PaymentBatch + """ + + return self._PaymentBatch + + @property + def RequestInquiryBatch(self): + """ + :rtype: endpoint.RequestInquiryBatch + """ + + return self._RequestInquiryBatch + + @property + def RequestInquiry(self): + """ + :rtype: endpoint.RequestInquiry + """ + + return self._RequestInquiry + + @property + def RequestResponse(self): + """ + :rtype: endpoint.RequestResponse + """ + + return self._RequestResponse + + @property + def ShareInviteBankInquiry(self): + """ + :rtype: endpoint.ShareInviteMonetaryAccountInquiry + """ + + return self._ShareInviteBankInquiry + + @property + def ShareInviteBankResponse(self): + """ + :rtype: endpoint.ShareInviteMonetaryAccountResponse + """ + + return self._ShareInviteBankResponse + + @property + def SofortMerchantTransaction(self): + """ + :rtype: endpoint.SofortMerchantTransaction + """ + + return self._SofortMerchantTransaction + + @property + def TransferwisePayment(self): + """ + :rtype: endpoint.TransferwiseTransfer + """ + + return self._TransferwisePayment + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._BunqMeTab is not None: + return self._BunqMeTab + + if self._BunqMeTabResultResponse is not None: + return self._BunqMeTabResultResponse + + if self._BunqMeFundraiserResult is not None: + return self._BunqMeFundraiserResult + + if self._Card is not None: + return self._Card + + if self._CardDebit is not None: + return self._CardDebit + + if self._DraftPayment is not None: + return self._DraftPayment + + if self._FeatureAnnouncement is not None: + return self._FeatureAnnouncement + + if self._IdealMerchantTransaction is not None: + return self._IdealMerchantTransaction + + if self._Invoice is not None: + return self._Invoice + + if self._ScheduledPayment is not None: + return self._ScheduledPayment + + if self._ScheduledPaymentBatch is not None: + return self._ScheduledPaymentBatch + + if self._ScheduledInstance is not None: + return self._ScheduledInstance + + if self._MasterCardAction is not None: + return self._MasterCardAction + + if self._BankSwitchServiceNetherlandsIncomingPayment is not None: + return self._BankSwitchServiceNetherlandsIncomingPayment + + if self._Payment is not None: + return self._Payment + + if self._PaymentBatch is not None: + return self._PaymentBatch + + if self._RequestInquiryBatch is not None: + return self._RequestInquiryBatch + + if self._RequestInquiry is not None: + return self._RequestInquiry + + if self._RequestResponse is not None: + return self._RequestResponse + + if self._ShareInviteBankInquiry is not None: + return self._ShareInviteBankInquiry + + if self._ShareInviteBankResponse is not None: + return self._ShareInviteBankResponse + + if self._SofortMerchantTransaction is not None: + return self._SofortMerchantTransaction + + if self._TransferwisePayment is not None: + return self._TransferwisePayment + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._BunqMeTab is not None: + return False + + if self._BunqMeTabResultResponse is not None: + return False + + if self._BunqMeFundraiserResult is not None: + return False + + if self._Card is not None: + return False + + if self._CardDebit is not None: + return False + + if self._DraftPayment is not None: + return False + + if self._FeatureAnnouncement is not None: + return False + + if self._IdealMerchantTransaction is not None: + return False + + if self._Invoice is not None: + return False + + if self._ScheduledPayment is not None: + return False + + if self._ScheduledPaymentBatch is not None: + return False + + if self._ScheduledInstance is not None: + return False + + if self._MasterCardAction is not None: + return False + + if self._BankSwitchServiceNetherlandsIncomingPayment is not None: + return False + + if self._Payment is not None: + return False + + if self._PaymentBatch is not None: + return False + + if self._RequestInquiryBatch is not None: + return False + + if self._RequestInquiry is not None: + return False + + if self._RequestResponse is not None: + return False + + if self._ShareInviteBankInquiry is not None: + return False + + if self._ShareInviteBankResponse is not None: + return False + + if self._SofortMerchantTransaction is not None: + return False + + if self._TransferwisePayment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: EventObjectObject + """ + + return converter.json_to_class(EventObjectObject, json_str) + + +class SchedulePaymentEntryObject(BunqModel): + """ + :param _amount: The Amount transferred by the Payment. Will be negative for + outgoing Payments and positive for incoming Payments (relative to the + MonetaryAccount indicated by monetary_account_id). + :type _amount: Amount + :param _counterparty_alias: The LabelMonetaryAccount containing the public + information of the other (counterparty) side of the Payment. + :type _counterparty_alias: MonetaryAccountReference + :param _description: The description for the Payment. Maximum 140 characters + for Payments to external IBANs, 9000 characters for Payments to only other + bunq MonetaryAccounts. + :type _description: str + :param _attachment: The Attachments attached to the Payment. + :type _attachment: list[AttachmentMonetaryAccountPayment] + :param _merchant_reference: Optional data included with the Payment specific + to the merchant. + :type _merchant_reference: str + :param _allow_bunqto: Whether or not sending a bunq.to payment is allowed. + :type _allow_bunqto: bool + :param _alias: The LabelMonetaryAccount containing the public information of + 'this' (party) side of the Payment. + :type _alias: MonetaryAccountReference + """ + + _amount = None + _alias = None + _counterparty_alias = None + _description = None + _attachment = None + _merchant_reference = None + _amount_field_for_request = None + _counterparty_alias_field_for_request = None + _description_field_for_request = None + _attachment_field_for_request = None + _merchant_reference_field_for_request = None + _allow_bunqto_field_for_request = None + + def __init__(self, amount=None, counterparty_alias=None, description=None, attachment=None, merchant_reference=None, allow_bunqto=None): + """ + :param amount: The Amount to transfer with the Payment. Must be bigger 0 and + smaller than the MonetaryAccount's balance. + :type amount: Amount + :param counterparty_alias: The Alias of the party we are transferring the + money to. Can be an Alias of type EMAIL or PHONE (for bunq MonetaryAccounts) + or IBAN (for external bank account). + :type counterparty_alias: Pointer + :param description: The description for the Payment. Maximum 140 characters + for Payments to external IBANs, 9000 characters for Payments to only other + bunq MonetaryAccounts. Field is required but can be an empty string. + :type description: str + :param attachment: The Attachments to attach to the Payment. + :type attachment: list[BunqId] + :param merchant_reference: Optional data to be included with the Payment + specific to the merchant. + :type merchant_reference: str + :param allow_bunqto: Whether or not sending a bunq.to payment is allowed. + :type allow_bunqto: bool + """ + + self._amount_field_for_request = amount + self._counterparty_alias_field_for_request = counterparty_alias + self._description_field_for_request = description + self._attachment_field_for_request = attachment + self._merchant_reference_field_for_request = merchant_reference + self._allow_bunqto_field_for_request = allow_bunqto + + @property + def amount(self): + """ + :rtype: Amount + """ + + return self._amount + + @property + def alias(self): + """ + :rtype: MonetaryAccountReference + """ + + return self._alias + + @property + def counterparty_alias(self): + """ + :rtype: MonetaryAccountReference + """ + + return self._counterparty_alias + + @property + def description(self): + """ + :rtype: str + """ + + return self._description + + @property + def attachment(self): + """ + :rtype: list[AttachmentMonetaryAccountPayment] + """ + + return self._attachment + + @property + def merchant_reference(self): + """ + :rtype: str + """ + + return self._merchant_reference + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._amount is not None: + return False + + if self._alias is not None: + return False + + if self._counterparty_alias is not None: + return False + + if self._description is not None: + return False + + if self._attachment is not None: + return False + + if self._merchant_reference is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: SchedulePaymentEntryObject + """ + + return converter.json_to_class(SchedulePaymentEntryObject, json_str) + + +class ScheduleInstanceAnchorObjectObject(BunqModel, AnchorObjectInterface): + """ + :param _Payment: + :type _Payment: endpoint.Payment + :param _PaymentBatch: + :type _PaymentBatch: endpoint.PaymentBatch + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + + _Payment = None + _PaymentBatch = None + + @property + def Payment(self): + """ + :rtype: endpoint.Payment + """ + + return self._Payment + + @property + def PaymentBatch(self): + """ + :rtype: endpoint.PaymentBatch + """ + + return self._PaymentBatch + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._Payment is not None: + return self._Payment + + if self._PaymentBatch is not None: + return self._PaymentBatch + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._Payment is not None: + return False + + if self._PaymentBatch is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ScheduleInstanceAnchorObjectObject + """ + + return converter.json_to_class(ScheduleInstanceAnchorObjectObject, json_str) + + +class LabelCardObject(BunqModel): + """ + :param _uuid: The public UUID. + :type _uuid: str + :param _type_: The type of the card. + :type _type_: str + :param _second_line: The second line on the card. + :type _second_line: str + :param _expiry_date: The date this card will expire. + :type _expiry_date: str + :param _status: The status of the card. + :type _status: str + :param _label_user: The owner of this card. + :type _label_user: LabelUser + """ + + _uuid = None + _type_ = None + _second_line = None + _expiry_date = None + _status = None + _label_user = None + + @property + def uuid(self): + """ + :rtype: str + """ + + return self._uuid + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def second_line(self): + """ + :rtype: str + """ + + return self._second_line + + @property + def expiry_date(self): + """ + :rtype: str + """ + + return self._expiry_date + + @property + def status(self): + """ + :rtype: str + """ + + return self._status + + @property + def label_user(self): + """ + :rtype: LabelUser + """ + + return self._label_user + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._uuid is not None: + return False + + if self._type_ is not None: + return False + + if self._second_line is not None: + return False + + if self._expiry_date is not None: + return False + + if self._status is not None: + return False + + if self._label_user is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: LabelCardObject + """ + + return converter.json_to_class(LabelCardObject, json_str) + + +class MasterCardActionReferenceObject(BunqModel): + """ + :param _event_id: The id of the event. + :type _event_id: int + """ + + _event_id = None + + @property + def event_id(self): + """ + :rtype: int + """ + + return self._event_id + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._event_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: MasterCardActionReferenceObject + """ + + return converter.json_to_class(MasterCardActionReferenceObject, json_str) + + +class AdditionalInformationObject(BunqModel): + """ + :param _category: The category of the refund, required for chargeback. + :type _category: str + :param _reason: The reason to refund, required for chargeback. + :type _reason: str + :param _comment: Comment about the refund. + :type _comment: str + :param _attachment: The Attachments to attach to the refund request. + :type _attachment: list[AttachmentMasterCardActionRefund] + :param _terms_and_conditions: Proof that the user acknowledged the terms and + conditions for chargebacks. + :type _terms_and_conditions: str + """ + + _category = None + _reason = None + _comment = None + _attachment = None + _terms_and_conditions = None + + @property + def category(self): + """ + :rtype: str + """ + + return self._category + + @property + def reason(self): + """ + :rtype: str + """ + + return self._reason + + @property + def comment(self): + """ + :rtype: str + """ + + return self._comment + + @property + def attachment(self): + """ + :rtype: list[AttachmentMasterCardActionRefund] + """ + + return self._attachment + + @property + def terms_and_conditions(self): + """ + :rtype: str + """ + + return self._terms_and_conditions + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._category is not None: + return False + + if self._reason is not None: + return False + + if self._comment is not None: + return False + + if self._attachment is not None: + return False + + if self._terms_and_conditions is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AdditionalInformationObject + """ + + return converter.json_to_class(AdditionalInformationObject, json_str) + + +class AttachmentMasterCardActionRefundObject(BunqModel): + """ + :param _id_: The id of the attached Attachment. + :type _id_: int + """ + + _id_ = None + _id__field_for_request = None + + def __init__(self, id_=None): + """ + :param id_: The id of the Attachment. + :type id_: int + """ + + self._id__field_for_request = id_ + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: AttachmentMasterCardActionRefundObject + """ + + return converter.json_to_class(AttachmentMasterCardActionRefundObject, json_str) + + +class RequestReferenceSplitTheBillAnchorObjectObject(BunqModel, AnchorObjectInterface): + """ + :param _BillingInvoice: + :type _BillingInvoice: endpoint.Invoice + :param _DraftPayment: + :type _DraftPayment: endpoint.DraftPayment + :param _MasterCardAction: + :type _MasterCardAction: endpoint.MasterCardAction + :param _Payment: + :type _Payment: endpoint.Payment + :param _PaymentBatch: + :type _PaymentBatch: endpoint.PaymentBatch + :param _RequestResponse: + :type _RequestResponse: endpoint.RequestResponse + :param _ScheduleInstance: + :type _ScheduleInstance: endpoint.ScheduleInstance + :param _WhitelistResult: + :type _WhitelistResult: endpoint.WhitelistResult + :param _TransferwisePayment: + :type _TransferwisePayment: endpoint.TransferwiseTransfer + :param _CurrencyConversion: + :type _CurrencyConversion: endpoint.CurrencyConversion + """ + + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + + _BillingInvoice = None + _DraftPayment = None + _MasterCardAction = None + _Payment = None + _PaymentBatch = None + _RequestResponse = None + _ScheduleInstance = None + _WhitelistResult = None + _TransferwisePayment = None + _CurrencyConversion = None + + @property + def BillingInvoice(self): + """ + :rtype: endpoint.Invoice + """ + + return self._BillingInvoice + + @property + def DraftPayment(self): + """ + :rtype: endpoint.DraftPayment + """ + + return self._DraftPayment + + @property + def MasterCardAction(self): + """ + :rtype: endpoint.MasterCardAction + """ + + return self._MasterCardAction + + @property + def Payment(self): + """ + :rtype: endpoint.Payment + """ + + return self._Payment + + @property + def PaymentBatch(self): + """ + :rtype: endpoint.PaymentBatch + """ + + return self._PaymentBatch + + @property + def RequestResponse(self): + """ + :rtype: endpoint.RequestResponse + """ + + return self._RequestResponse + + @property + def ScheduleInstance(self): + """ + :rtype: endpoint.ScheduleInstance + """ + + return self._ScheduleInstance + + @property + def WhitelistResult(self): + """ + :rtype: endpoint.WhitelistResult + """ + + return self._WhitelistResult + + @property + def TransferwisePayment(self): + """ + :rtype: endpoint.TransferwiseTransfer + """ + + return self._TransferwisePayment + + @property + def CurrencyConversion(self): + """ + :rtype: endpoint.CurrencyConversion + """ + + return self._CurrencyConversion + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._BillingInvoice is not None: + return self._BillingInvoice + + if self._DraftPayment is not None: + return self._DraftPayment + + if self._MasterCardAction is not None: + return self._MasterCardAction + + if self._Payment is not None: + return self._Payment + + if self._PaymentBatch is not None: + return self._PaymentBatch + + if self._RequestResponse is not None: + return self._RequestResponse + + if self._ScheduleInstance is not None: + return self._ScheduleInstance + + if self._WhitelistResult is not None: + return self._WhitelistResult + + if self._TransferwisePayment is not None: + return self._TransferwisePayment + + if self._CurrencyConversion is not None: + return self._CurrencyConversion + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._BillingInvoice is not None: + return False + + if self._DraftPayment is not None: + return False + + if self._MasterCardAction is not None: + return False + + if self._Payment is not None: + return False + + if self._PaymentBatch is not None: + return False + + if self._RequestResponse is not None: + return False + + if self._ScheduleInstance is not None: + return False + + if self._WhitelistResult is not None: + return False + + if self._TransferwisePayment is not None: + return False + + if self._CurrencyConversion is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: RequestReferenceSplitTheBillAnchorObjectObject + """ + + return converter.json_to_class(RequestReferenceSplitTheBillAnchorObjectObject, json_str) + + +class WhitelistResultViewAnchoredObjectObject(BunqModel): + """ + :param _id_: The ID of the whitelist entry. + :type _id_: int + :param _requestResponse: The RequestResponse object + :type _requestResponse: endpoint.RequestResponse + :param _draftPayment: The DraftPayment object + :type _draftPayment: endpoint.DraftPayment + """ + + _id_ = None + _requestResponse = None + _draftPayment = None + + @property + def id_(self): + """ + :rtype: int + """ + + return self._id_ + + @property + def requestResponse(self): + """ + :rtype: endpoint.RequestResponse + """ + + return self._requestResponse + + @property + def draftPayment(self): + """ + :rtype: endpoint.DraftPayment + """ + + return self._draftPayment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._id_ is not None: + return False + + if self._requestResponse is not None: + return False + + if self._draftPayment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: WhitelistResultViewAnchoredObjectObject + """ + + return converter.json_to_class(WhitelistResultViewAnchoredObjectObject, json_str) + + +class ShareDetailObject(BunqModel): + """ + :param _payment: The share details for a payment share. In the response + 'payment' is replaced by 'ShareDetailPayment'. + :type _payment: ShareDetailPayment + :param _read_only: The share details for viewing a share. In the response + 'read_only' is replaced by 'ShareDetailReadOnly'. + :type _read_only: ShareDetailReadOnly + :param _draft_payment: The share details for a draft payment share. In the + response 'draft_payment' is replaced by 'ShareDetailDraftPayment'. + :type _draft_payment: ShareDetailDraftPayment + """ + + _payment = None + _read_only = None + _draft_payment = None + _payment_field_for_request = None + _read_only_field_for_request = None + _draft_payment_field_for_request = None + + def __init__(self, payment=None, read_only=None, draft_payment=None): + """ + :param payment: The share details for a payment share. Remember to replace + 'payment' with 'ShareDetailPayment' before sending a request. + :type payment: ShareDetailPayment + :param read_only: The share details for viewing a share. Remember to replace + 'read_only' with 'ShareDetailReadOnly' before sending a request. + :type read_only: ShareDetailReadOnly + :param draft_payment: The share details for a draft payment share. Remember + to replace 'draft_payment' with 'ShareDetailDraftPayment' before sending a + request. + :type draft_payment: ShareDetailDraftPayment + """ + + self._payment_field_for_request = payment + self._read_only_field_for_request = read_only + self._draft_payment_field_for_request = draft_payment + + @property + def payment(self): + """ + :rtype: ShareDetailPayment + """ + + return self._payment + + @property + def read_only(self): + """ + :rtype: ShareDetailReadOnly + """ + + return self._read_only + + @property + def draft_payment(self): + """ + :rtype: ShareDetailDraftPayment + """ + + return self._draft_payment + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._payment is not None: + return False + + if self._read_only is not None: + return False + + if self._draft_payment is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ShareDetailObject + """ + + return converter.json_to_class(ShareDetailObject, json_str) + + +class ShareDetailPaymentObject(BunqModel): + """ + :param _make_payments: If set to true, the invited user will be able to make + payments from the shared account. + :type _make_payments: bool + :param _make_draft_payments: If set to true, the invited user will be able + to make draft payments from the shared account. + :type _make_draft_payments: bool + :param _view_balance: If set to true, the invited user will be able to view + the account balance. + :type _view_balance: bool + :param _view_old_events: If set to true, the invited user will be able to + view events from before the share was active. + :type _view_old_events: bool + :param _view_new_events: If set to true, the invited user will be able to + view events starting from the time the share became active. + :type _view_new_events: bool + """ + + _make_payments = None + _make_draft_payments = None + _view_balance = None + _view_old_events = None + _view_new_events = None + _make_payments_field_for_request = None + _make_draft_payments_field_for_request = None + _view_balance_field_for_request = None + _view_old_events_field_for_request = None + _view_new_events_field_for_request = None + + def __init__(self, make_payments=None, view_balance=None, view_old_events=None, view_new_events=None, make_draft_payments=None): + """ + :param make_payments: If set to true, the invited user will be able to make + payments from the shared account. + :type make_payments: bool + :param view_balance: If set to true, the invited user will be able to view + the account balance. + :type view_balance: bool + :param view_old_events: If set to true, the invited user will be able to + view events from before the share was active. + :type view_old_events: bool + :param view_new_events: If set to true, the invited user will be able to + view events starting from the time the share became active. + :type view_new_events: bool + :param make_draft_payments: If set to true, the invited user will be able to + make draft payments from the shared account. + :type make_draft_payments: bool + """ + + self._make_payments_field_for_request = make_payments + self._view_balance_field_for_request = view_balance + self._view_old_events_field_for_request = view_old_events + self._view_new_events_field_for_request = view_new_events + self._make_draft_payments_field_for_request = make_draft_payments + + @property + def make_payments(self): + """ + :rtype: bool + """ + + return self._make_payments + + @property + def make_draft_payments(self): + """ + :rtype: bool + """ + + return self._make_draft_payments + + @property + def view_balance(self): + """ + :rtype: bool + """ + + return self._view_balance + + @property + def view_old_events(self): + """ + :rtype: bool + """ + + return self._view_old_events + + @property + def view_new_events(self): + """ + :rtype: bool + """ + + return self._view_new_events + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._make_payments is not None: + return False + + if self._make_draft_payments is not None: + return False + + if self._view_balance is not None: + return False + + if self._view_old_events is not None: + return False + + if self._view_new_events is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: ShareDetailPaymentObject + """ + + return converter.json_to_class(ShareDetailPaymentObject, json_str) + + +class ShareDetailReadOnlyObject(BunqModel): + """ + :param _view_balance: If set to true, the invited user will be able to view + the account balance. + :type _view_balance: bool + :param _view_old_events: If set to true, the invited user will be able to + view events from before the share was active. + :type _view_old_events: bool + :param _view_new_events: If set to true, the invited user will be able to + view events starting from the time the share became active. + :type _view_new_events: bool + """ + + _view_balance = None + _view_old_events = None + _view_new_events = None + _view_balance_field_for_request = None + _view_old_events_field_for_request = None + _view_new_events_field_for_request = None + + def __init__(self, view_balance=None, view_old_events=None, view_new_events=None): + """ + :param view_balance: If set to true, the invited user will be able to view + the account balance. + :type view_balance: bool + :param view_old_events: If set to true, the invited user will be able to + view events from before the share was active. + :type view_old_events: bool + :param view_new_events: If set to true, the invited user will be able to + view events starting from the time the share became active. + :type view_new_events: bool + """ + + self._view_balance_field_for_request = view_balance + self._view_old_events_field_for_request = view_old_events + self._view_new_events_field_for_request = view_new_events + + @property + def view_balance(self): + """ + :rtype: bool + """ + + return self._view_balance + + @property + def view_old_events(self): + """ + :rtype: bool + """ + + return self._view_old_events + + @property + def view_new_events(self): + """ + :rtype: bool + """ + + return self._view_new_events def is_all_field_none(self): """ @@ -2960,13 +4594,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareDetailReadOnly + :rtype: ShareDetailReadOnlyObject """ - return converter.json_to_class(ShareDetailReadOnly, json_str) + return converter.json_to_class(ShareDetailReadOnlyObject, json_str) -class ShareDetailDraftPayment(core.BunqModel): +class ShareDetailDraftPaymentObject(BunqModel): """ :param _make_draft_payments: If set to true, the invited user will be able to make draft payments from the shared account. @@ -2991,8 +4625,7 @@ class ShareDetailDraftPayment(core.BunqModel): _view_old_events_field_for_request = None _view_new_events_field_for_request = None - def __init__(self, make_draft_payments=None, view_balance=None, - view_old_events=None, view_new_events=None): + def __init__(self, make_draft_payments=None, view_balance=None, view_old_events=None, view_new_events=None): """ :param make_draft_payments: If set to true, the invited user will be able to make draft payments from the shared account. @@ -3069,13 +4702,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: ShareDetailDraftPayment + :rtype: ShareDetailDraftPaymentObject """ - return converter.json_to_class(ShareDetailDraftPayment, json_str) + return converter.json_to_class(ShareDetailDraftPaymentObject, json_str) -class MonetaryAccountProfileFill(core.BunqModel): +class MonetaryAccountProfileFillObject(BunqModel): """ :param _status: The status of the profile. :type _status: str @@ -3083,9 +4716,6 @@ class MonetaryAccountProfileFill(core.BunqModel): :type _balance_preferred: Amount :param _balance_threshold_low: The low threshold balance. :type _balance_threshold_low: Amount - :param _method_fill: The method used to fill the monetary account. Currently - only iDEAL is supported, and it is the default one. - :type _method_fill: str :param _issuer: The bank the fill is supposed to happen from, with BIC and bank name. :type _issuer: Issuer @@ -3094,16 +4724,13 @@ class MonetaryAccountProfileFill(core.BunqModel): _status = None _balance_preferred = None _balance_threshold_low = None - _method_fill = None _issuer = None _status_field_for_request = None _balance_preferred_field_for_request = None _balance_threshold_low_field_for_request = None - _method_fill_field_for_request = None _issuer_field_for_request = None - def __init__(self, status, balance_preferred, balance_threshold_low, - method_fill, issuer=None): + def __init__(self, status, balance_preferred, balance_threshold_low, issuer=None): """ :param status: The status of the profile. :type status: str @@ -3111,9 +4738,6 @@ def __init__(self, status, balance_preferred, balance_threshold_low, :type balance_preferred: Amount :param balance_threshold_low: The low threshold balance. :type balance_threshold_low: Amount - :param method_fill: The method used to fill the monetary account. Currently - IDEAL and SOFORT is supported. - :type method_fill: str :param issuer: The bank the fill is supposed to happen from, with BIC and bank name. :type issuer: Issuer @@ -3122,7 +4746,6 @@ def __init__(self, status, balance_preferred, balance_threshold_low, self._status_field_for_request = status self._balance_preferred_field_for_request = balance_preferred self._balance_threshold_low_field_for_request = balance_threshold_low - self._method_fill_field_for_request = method_fill self._issuer_field_for_request = issuer @property @@ -3149,14 +4772,6 @@ def balance_threshold_low(self): return self._balance_threshold_low - @property - def method_fill(self): - """ - :rtype: str - """ - - return self._method_fill - @property def issuer(self): """ @@ -3179,9 +4794,6 @@ def is_all_field_none(self): if self._balance_threshold_low is not None: return False - if self._method_fill is not None: - return False - if self._issuer is not None: return False @@ -3192,13 +4804,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountProfileFill + :rtype: MonetaryAccountProfileFillObject """ - return converter.json_to_class(MonetaryAccountProfileFill, json_str) + return converter.json_to_class(MonetaryAccountProfileFillObject, json_str) -class Issuer(core.BunqModel): +class IssuerObject(BunqModel): """ :param _bic: The BIC code. :type _bic: str @@ -3256,13 +4868,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: Issuer + :rtype: IssuerObject """ - return converter.json_to_class(Issuer, json_str) + return converter.json_to_class(IssuerObject, json_str) -class MonetaryAccountProfileDrain(core.BunqModel): +class MonetaryAccountProfileDrainObject(BunqModel): """ :param _status: The status of the profile. :type _status: str @@ -3283,8 +4895,7 @@ class MonetaryAccountProfileDrain(core.BunqModel): _balance_threshold_high_field_for_request = None _savings_account_alias_field_for_request = None - def __init__(self, status, balance_preferred, balance_threshold_high, - savings_account_alias): + def __init__(self, status, balance_preferred, balance_threshold_high, savings_account_alias): """ :param status: The status of the profile. :type status: str @@ -3357,48 +4968,63 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountProfileDrain + :rtype: MonetaryAccountProfileDrainObject """ - return converter.json_to_class(MonetaryAccountProfileDrain, json_str) + return converter.json_to_class(MonetaryAccountProfileDrainObject, json_str) -class MonetaryAccountSetting(core.BunqModel): +class MonetaryAccountSettingObject(BunqModel): """ :param _color: The color chosen for the MonetaryAccount. :type _color: str + :param _icon: The icon chosen for the MonetaryAccount. + :type _icon: str :param _default_avatar_status: The status of the avatar. Can be either AVATAR_DEFAULT, AVATAR_CUSTOM or AVATAR_UNDETERMINED. :type _default_avatar_status: str :param _restriction_chat: The chat restriction. Possible values are ALLOW_INCOMING or BLOCK_INCOMING :type _restriction_chat: str + :param _sdd_expiration_action: The preference for this monetary account on + whether to automatically accept or reject expiring SDDs. + :type _sdd_expiration_action: str """ _color = None + _icon = None _default_avatar_status = None _restriction_chat = None + _sdd_expiration_action = None _color_field_for_request = None + _icon_field_for_request = None _default_avatar_status_field_for_request = None _restriction_chat_field_for_request = None + _sdd_expiration_action_field_for_request = None - def __init__(self, color=None, default_avatar_status=None, - restriction_chat=None): + def __init__(self, color=None, icon=None, default_avatar_status=None, restriction_chat=None, sdd_expiration_action=None): """ :param color: The color chosen for the MonetaryAccount in hexadecimal format. :type color: str + :param icon: The icon chosen for the MonetaryAccount. + :type icon: str :param default_avatar_status: The status of the avatar. Cannot be updated directly. :type default_avatar_status: str :param restriction_chat: The chat restriction. Possible values are ALLOW_INCOMING or BLOCK_INCOMING :type restriction_chat: str + :param sdd_expiration_action: The preference for this monetary account on + whether to automatically accept or reject expiring SDDs. + :type sdd_expiration_action: str """ self._color_field_for_request = color + self._icon_field_for_request = icon self._default_avatar_status_field_for_request = default_avatar_status self._restriction_chat_field_for_request = restriction_chat + self._sdd_expiration_action_field_for_request = sdd_expiration_action @property def color(self): @@ -3408,6 +5034,14 @@ def color(self): return self._color + @property + def icon(self): + """ + :rtype: str + """ + + return self._icon + @property def default_avatar_status(self): """ @@ -3424,6 +5058,14 @@ def restriction_chat(self): return self._restriction_chat + @property + def sdd_expiration_action(self): + """ + :rtype: str + """ + + return self._sdd_expiration_action + def is_all_field_none(self): """ :rtype: bool @@ -3432,12 +5074,18 @@ def is_all_field_none(self): if self._color is not None: return False + if self._icon is not None: + return False + if self._default_avatar_status is not None: return False if self._restriction_chat is not None: return False + if self._sdd_expiration_action is not None: + return False + return True @staticmethod @@ -3445,13 +5093,13 @@ def from_json(json_str): """ :type json_str: str - :rtype: MonetaryAccountSetting + :rtype: MonetaryAccountSettingObject """ - return converter.json_to_class(MonetaryAccountSetting, json_str) + return converter.json_to_class(MonetaryAccountSettingObject, json_str) -class CoOwner(core.BunqModel): +class CoOwnerObject(BunqModel): """ :param _alias: The Alias of the co-owner. :type _alias: LabelUser @@ -3505,76 +5153,61 @@ def from_json(json_str): """ :type json_str: str - :rtype: CoOwner + :rtype: CoOwnerObject """ - return converter.json_to_class(CoOwner, json_str) + return converter.json_to_class(CoOwnerObject, json_str) -class NotificationUrl(core.BunqModel): +class BirdeeInvestmentPortfolioGoalObject(BunqModel): """ - :param _target_url: - :type _target_url: str - :param _category: - :type _category: str - :param _event_type: - :type _event_type: str - :param _object_: - :type _object_: NotificationAnchorObject + :param _amount_target: The investment goal amount. + :type _amount_target: Amount + :param _time_end: The investment goal end time. + :type _time_end: str """ - _target_url = None - _category = None - _event_type = None - _object_ = None + _amount_target = None + _time_end = None + _amount_target_field_for_request = None + _time_end_field_for_request = None - @property - def target_url(self): + def __init__(self, amount_target=None, time_end=None): """ - :rtype: str + :param amount_target: The investment goal amount. + :type amount_target: Amount + :param time_end: The investment goal end time. + :type time_end: str """ - return self._target_url + self._amount_target_field_for_request = amount_target + self._time_end_field_for_request = time_end @property - def category(self): + def amount_target(self): """ - :rtype: str + :rtype: Amount """ - return self._category + return self._amount_target @property - def event_type(self): + def time_end(self): """ :rtype: str """ - return self._event_type - - @property - def object_(self): - """ - :rtype: NotificationAnchorObject - """ - - return self._object_ + return self._time_end def is_all_field_none(self): """ :rtype: bool """ - if self._target_url is not None: - return False - - if self._category is not None: - return False - - if self._event_type is not None: + if self._amount_target is not None: return False - if self._object_ is not None: + if self._time_end is not None: return False return True @@ -3584,405 +5217,335 @@ def from_json(json_str): """ :type json_str: str - :rtype: NotificationUrl + :rtype: BirdeeInvestmentPortfolioGoalObject """ - return converter.json_to_class(NotificationUrl, json_str) + return converter.json_to_class(BirdeeInvestmentPortfolioGoalObject, json_str) -class NotificationAnchorObject(core.BunqModel, core.AnchoredObjectInterface): +class NotificationFilterEmailObject(BunqModel): """ - :param _BunqMeFundraiserResult: - :type _BunqMeFundraiserResult: endpoint.BunqMeFundraiserResult - :param _BunqMeTab: - :type _BunqMeTab: endpoint.BunqMeTab - :param _BunqMeTabResultInquiry: - :type _BunqMeTabResultInquiry: endpoint.BunqMeTabResultInquiry - :param _BunqMeTabResultResponse: - :type _BunqMeTabResultResponse: endpoint.BunqMeTabResultResponse - :param _ChatMessage: - :type _ChatMessage: endpoint.ChatMessage - :param _DraftPayment: - :type _DraftPayment: endpoint.DraftPayment - :param _IdealMerchantTransaction: - :type _IdealMerchantTransaction: endpoint.IdealMerchantTransaction - :param _Invoice: - :type _Invoice: endpoint.Invoice - :param _MasterCardAction: - :type _MasterCardAction: endpoint.MasterCardAction - :param _MonetaryAccount: - :type _MonetaryAccount: endpoint.MonetaryAccount - :param _Payment: - :type _Payment: endpoint.Payment - :param _PaymentBatch: - :type _PaymentBatch: endpoint.PaymentBatch - :param _RequestInquiry: - :type _RequestInquiry: endpoint.RequestInquiry - :param _RequestInquiryBatch: - :type _RequestInquiryBatch: endpoint.RequestInquiryBatch - :param _RequestResponse: - :type _RequestResponse: endpoint.RequestResponse - :param _ShareInviteBankInquiry: - :type _ShareInviteBankInquiry: endpoint.ShareInviteBankInquiry - :param _ShareInviteBankResponse: - :type _ShareInviteBankResponse: endpoint.ShareInviteBankResponse - :param _ScheduledPayment: - :type _ScheduledPayment: endpoint.SchedulePayment - :param _ScheduledInstance: - :type _ScheduledInstance: endpoint.ScheduleInstance - :param _TabResultInquiry: - :type _TabResultInquiry: endpoint.TabResultInquiry - :param _TabResultResponse: - :type _TabResultResponse: endpoint.TabResultResponse - :param _User: - :type _User: endpoint.User + :param _category: The notification category that will match this + notification filter. + :type _category: str + :param _all_user_id: The users this filter pertains to. + :type _all_user_id: list[str] + :param _all_monetary_account_id: The MAs this filter pertains to. + :type _all_monetary_account_id: list[str] """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - - _BunqMeFundraiserResult = None - _BunqMeTab = None - _BunqMeTabResultInquiry = None - _BunqMeTabResultResponse = None - _ChatMessage = None - _DraftPayment = None - _IdealMerchantTransaction = None - _Invoice = None - _MasterCardAction = None - _MonetaryAccount = None - _Payment = None - _PaymentBatch = None - _RequestInquiry = None - _RequestInquiryBatch = None - _RequestResponse = None - _ShareInviteBankInquiry = None - _ShareInviteBankResponse = None - _ScheduledPayment = None - _ScheduledInstance = None - _TabResultInquiry = None - _TabResultResponse = None - _User = None + _category = None + _all_user_id = None + _all_monetary_account_id = None + _category_field_for_request = None + _all_user_id_field_for_request = None + _all_monetary_account_id_field_for_request = None - @property - def BunqMeFundraiserResult(self): + def __init__(self, category, all_user_id=None, all_monetary_account_id=None): """ - :rtype: endpoint.BunqMeFundraiserResult + :param category: The notification category that will match this notification + filter. + :type category: str + :param all_user_id: The users this filter pertains to. OPTIONAL FOR BACKWARD + COMPATIBILITY + :type all_user_id: list[str] + :param all_monetary_account_id: The MAs this filter pertains to. OPTIONAL + FOR BACKWARD COMPATIBILITY + :type all_monetary_account_id: list[str] """ - return self._BunqMeFundraiserResult + self._category_field_for_request = category + self._all_user_id_field_for_request = all_user_id + self._all_monetary_account_id_field_for_request = all_monetary_account_id @property - def BunqMeTab(self): + def category(self): """ - :rtype: endpoint.BunqMeTab + :rtype: str """ - return self._BunqMeTab + return self._category @property - def BunqMeTabResultInquiry(self): + def all_user_id(self): """ - :rtype: endpoint.BunqMeTabResultInquiry + :rtype: list[str] """ - return self._BunqMeTabResultInquiry + return self._all_user_id @property - def BunqMeTabResultResponse(self): + def all_monetary_account_id(self): """ - :rtype: endpoint.BunqMeTabResultResponse + :rtype: list[str] """ - return self._BunqMeTabResultResponse + return self._all_monetary_account_id - @property - def ChatMessage(self): + def is_all_field_none(self): """ - :rtype: endpoint.ChatMessage + :rtype: bool """ - return self._ChatMessage + if self._category is not None: + return False - @property - def DraftPayment(self): + if self._all_user_id is not None: + return False + + if self._all_monetary_account_id is not None: + return False + + return True + + @staticmethod + def from_json(json_str): """ - :rtype: endpoint.DraftPayment + :type json_str: str + + :rtype: NotificationFilterEmailObject """ - return self._DraftPayment + return converter.json_to_class(NotificationFilterEmailObject, json_str) - @property - def IdealMerchantTransaction(self): + +class NotificationFilterPushObject(BunqModel): + """ + :param _category: The notification category that will match this + notification filter. + :type _category: str + :param _all_user_id: The users this filter pertains to. + :type _all_user_id: list[str] + :param _all_monetary_account_id: The MAs this filter pertains to. + :type _all_monetary_account_id: list[str] + """ + + _category = None + _all_user_id = None + _all_monetary_account_id = None + _category_field_for_request = None + _all_user_id_field_for_request = None + _all_monetary_account_id_field_for_request = None + + def __init__(self, category, all_user_id=None, all_monetary_account_id=None): """ - :rtype: endpoint.IdealMerchantTransaction + :param category: The notification category that will match this notification + filter. + :type category: str + :param all_user_id: The users this filter pertains to. OPTIONAL FOR BACKWARD + COMPATIBILITY + :type all_user_id: list[str] + :param all_monetary_account_id: The MAs this filter pertains to. OPTIONAL + FOR BACKWARD COMPATIBILITY + :type all_monetary_account_id: list[str] """ - return self._IdealMerchantTransaction + self._category_field_for_request = category + self._all_user_id_field_for_request = all_user_id + self._all_monetary_account_id_field_for_request = all_monetary_account_id @property - def Invoice(self): + def category(self): """ - :rtype: endpoint.Invoice + :rtype: str """ - return self._Invoice + return self._category @property - def MasterCardAction(self): + def all_user_id(self): """ - :rtype: endpoint.MasterCardAction + :rtype: list[str] """ - return self._MasterCardAction + return self._all_user_id @property - def MonetaryAccount(self): + def all_monetary_account_id(self): """ - :rtype: endpoint.MonetaryAccount + :rtype: list[str] """ - return self._MonetaryAccount + return self._all_monetary_account_id - @property - def Payment(self): + def is_all_field_none(self): """ - :rtype: endpoint.Payment + :rtype: bool """ - return self._Payment + if self._category is not None: + return False - @property - def PaymentBatch(self): - """ - :rtype: endpoint.PaymentBatch - """ + if self._all_user_id is not None: + return False - return self._PaymentBatch + if self._all_monetary_account_id is not None: + return False - @property - def RequestInquiry(self): + return True + + @staticmethod + def from_json(json_str): """ - :rtype: endpoint.RequestInquiry + :type json_str: str + + :rtype: NotificationFilterPushObject """ - return self._RequestInquiry + return converter.json_to_class(NotificationFilterPushObject, json_str) - @property - def RequestInquiryBatch(self): - """ - :rtype: endpoint.RequestInquiryBatch - """ - return self._RequestInquiryBatch +class NotificationFilterUrlObject(BunqModel): + """ + :param _category: The notification category that will match this + notification filter. + :type _category: str + :param _all_user_id: The users this filter pertains to. + :type _all_user_id: list[str] + :param _all_monetary_account_id: The MAs this filter pertains to. + :type _all_monetary_account_id: list[str] + :param _all_verification_type: Type of verification required for the + connection. + :type _all_verification_type: list[str] + :param _notification_target: The URL to which the callback should be made. + :type _notification_target: str + :param _id_: The id of the NotificationFilterUrl. + :type _id_: int + :param _created: The timestamp of the NotificationFilterUrl's creation. + :type _created: str + :param _updated: The timestamp of the NotificationFilterUrl's last update. + :type _updated: str + """ - @property - def RequestResponse(self): + _id_ = None + _created = None + _updated = None + _category = None + _all_user_id = None + _all_monetary_account_id = None + _all_verification_type = None + _notification_target = None + _category_field_for_request = None + _all_user_id_field_for_request = None + _all_monetary_account_id_field_for_request = None + _all_verification_type_field_for_request = None + _notification_target_field_for_request = None + + def __init__(self, category, notification_target=None, all_user_id=None, all_monetary_account_id=None, all_verification_type=None): """ - :rtype: endpoint.RequestResponse + :param category: The notification category that will match this notification + filter. + :type category: str + :param notification_target: The URL to which the callback should be made. + :type notification_target: str + :param all_user_id: The users this filter pertains to. OPTIONAL FOR BACKWARD + COMPATIBILITY + :type all_user_id: list[str] + :param all_monetary_account_id: The MAs this filter pertains to. OPTIONAL + FOR BACKWARD COMPATIBILITY + :type all_monetary_account_id: list[str] + :param all_verification_type: Type of verification required for the + connection. + :type all_verification_type: list[str] """ - return self._RequestResponse + self._category_field_for_request = category + self._notification_target_field_for_request = notification_target + self._all_user_id_field_for_request = all_user_id + self._all_monetary_account_id_field_for_request = all_monetary_account_id + self._all_verification_type_field_for_request = all_verification_type @property - def ShareInviteBankInquiry(self): + def id_(self): """ - :rtype: endpoint.ShareInviteBankInquiry + :rtype: int """ - return self._ShareInviteBankInquiry + return self._id_ @property - def ShareInviteBankResponse(self): + def created(self): """ - :rtype: endpoint.ShareInviteBankResponse + :rtype: str """ - return self._ShareInviteBankResponse + return self._created @property - def ScheduledPayment(self): + def updated(self): """ - :rtype: endpoint.SchedulePayment + :rtype: str """ - return self._ScheduledPayment + return self._updated @property - def ScheduledInstance(self): + def category(self): """ - :rtype: endpoint.ScheduleInstance + :rtype: str """ - return self._ScheduledInstance + return self._category @property - def TabResultInquiry(self): + def all_user_id(self): """ - :rtype: endpoint.TabResultInquiry + :rtype: list[str] """ - return self._TabResultInquiry + return self._all_user_id @property - def TabResultResponse(self): + def all_monetary_account_id(self): """ - :rtype: endpoint.TabResultResponse + :rtype: list[str] """ - return self._TabResultResponse + return self._all_monetary_account_id @property - def User(self): + def all_verification_type(self): """ - :rtype: endpoint.User + :rtype: list[str] """ - return self._User + return self._all_verification_type - def get_referenced_object(self): + @property + def notification_target(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: str """ - if self._BunqMeFundraiserResult is not None: - return self._BunqMeFundraiserResult - - if self._BunqMeTab is not None: - return self._BunqMeTab - - if self._BunqMeTabResultInquiry is not None: - return self._BunqMeTabResultInquiry - - if self._BunqMeTabResultResponse is not None: - return self._BunqMeTabResultResponse - - if self._ChatMessage is not None: - return self._ChatMessage - - if self._DraftPayment is not None: - return self._DraftPayment - - if self._IdealMerchantTransaction is not None: - return self._IdealMerchantTransaction - - if self._Invoice is not None: - return self._Invoice - - if self._MasterCardAction is not None: - return self._MasterCardAction - - if self._MonetaryAccount is not None: - return self._MonetaryAccount - - if self._Payment is not None: - return self._Payment - - if self._PaymentBatch is not None: - return self._PaymentBatch - - if self._RequestInquiry is not None: - return self._RequestInquiry - - if self._RequestInquiryBatch is not None: - return self._RequestInquiryBatch - - if self._RequestResponse is not None: - return self._RequestResponse - - if self._ShareInviteBankInquiry is not None: - return self._ShareInviteBankInquiry - - if self._ShareInviteBankResponse is not None: - return self._ShareInviteBankResponse - - if self._ScheduledPayment is not None: - return self._ScheduledPayment - - if self._ScheduledInstance is not None: - return self._ScheduledInstance - - if self._TabResultInquiry is not None: - return self._TabResultInquiry - - if self._TabResultResponse is not None: - return self._TabResultResponse - - if self._User is not None: - return self._User - - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._notification_target def is_all_field_none(self): """ :rtype: bool """ - if self._BunqMeFundraiserResult is not None: - return False - - if self._BunqMeTab is not None: - return False - - if self._BunqMeTabResultInquiry is not None: - return False - - if self._BunqMeTabResultResponse is not None: - return False - - if self._ChatMessage is not None: - return False - - if self._DraftPayment is not None: - return False - - if self._IdealMerchantTransaction is not None: - return False - - if self._Invoice is not None: - return False - - if self._MasterCardAction is not None: - return False - - if self._MonetaryAccount is not None: - return False - - if self._Payment is not None: - return False - - if self._PaymentBatch is not None: - return False - - if self._RequestInquiry is not None: - return False - - if self._RequestInquiryBatch is not None: - return False - - if self._RequestResponse is not None: + if self._id_ is not None: return False - if self._ShareInviteBankInquiry is not None: + if self._created is not None: return False - if self._ShareInviteBankResponse is not None: + if self._updated is not None: return False - if self._ScheduledPayment is not None: + if self._category is not None: return False - if self._ScheduledInstance is not None: + if self._all_user_id is not None: return False - if self._TabResultInquiry is not None: + if self._all_monetary_account_id is not None: return False - if self._TabResultResponse is not None: + if self._all_verification_type is not None: return False - if self._User is not None: + if self._notification_target is not None: return False return True @@ -3992,104 +5555,76 @@ def from_json(json_str): """ :type json_str: str - :rtype: NotificationAnchorObject + :rtype: NotificationFilterUrlObject """ - return converter.json_to_class(NotificationAnchorObject, json_str) + return converter.json_to_class(NotificationFilterUrlObject, json_str) -class LabelCard(core.BunqModel): +class NotificationUrlObject(BunqModel): """ - :param _uuid: The public UUID. - :type _uuid: str - :param _type_: The type of the card. - :type _type_: str - :param _second_line: The second line on the card. - :type _second_line: str - :param _expiry_date: The date this card will expire. - :type _expiry_date: str - :param _status: The status of the card. - :type _status: str - :param _label_user: The owner of this card. - :type _label_user: LabelUser + :param _target_url: + :type _target_url: str + :param _category: + :type _category: str + :param _event_type: + :type _event_type: str + :param _object_: + :type _object_: NotificationAnchorObject """ - _uuid = None - _type_ = None - _second_line = None - _expiry_date = None - _status = None - _label_user = None - - @property - def uuid(self): - """ - :rtype: str - """ - - return self._uuid - - @property - def type_(self): - """ - :rtype: str - """ - - return self._type_ + _target_url = None + _category = None + _event_type = None + _object_ = None @property - def second_line(self): + def target_url(self): """ :rtype: str """ - return self._second_line + return self._target_url @property - def expiry_date(self): + def category(self): """ :rtype: str """ - return self._expiry_date + return self._category @property - def status(self): + def event_type(self): """ :rtype: str """ - return self._status + return self._event_type @property - def label_user(self): + def object_(self): """ - :rtype: LabelUser + :rtype: NotificationAnchorObject """ - return self._label_user + return self._object_ def is_all_field_none(self): """ :rtype: bool """ - if self._uuid is not None: - return False - - if self._type_ is not None: - return False - - if self._second_line is not None: + if self._target_url is not None: return False - if self._expiry_date is not None: + if self._category is not None: return False - if self._status is not None: + if self._event_type is not None: return False - if self._label_user is not None: + if self._object_ is not None: return False return True @@ -4099,55 +5634,120 @@ def from_json(json_str): """ :type json_str: str - :rtype: LabelCard + :rtype: NotificationUrlObject """ - return converter.json_to_class(LabelCard, json_str) + return converter.json_to_class(NotificationUrlObject, json_str) -class RequestReferenceSplitTheBillAnchorObject(core.BunqModel, - core.AnchoredObjectInterface): +class NotificationAnchorObjectObject(BunqModel, AnchorObjectInterface): """ - :param _BillingInvoice: - :type _BillingInvoice: endpoint.Invoice + :param _BunqMeFundraiserResult: + :type _BunqMeFundraiserResult: endpoint.BunqMeFundraiserResult + :param _BunqMeTab: + :type _BunqMeTab: endpoint.BunqMeTab + :param _BunqMeTabResultInquiry: + :type _BunqMeTabResultInquiry: endpoint.BunqMeTabResultInquiry + :param _BunqMeTabResultResponse: + :type _BunqMeTabResultResponse: endpoint.BunqMeTabResultResponse + :param _ChatMessage: + :type _ChatMessage: endpoint.ChatMessage :param _DraftPayment: :type _DraftPayment: endpoint.DraftPayment + :param _IdealMerchantTransaction: + :type _IdealMerchantTransaction: endpoint.IdealMerchantTransaction + :param _Invoice: + :type _Invoice: endpoint.Invoice :param _MasterCardAction: :type _MasterCardAction: endpoint.MasterCardAction + :param _MonetaryAccount: + :type _MonetaryAccount: endpoint.MonetaryAccount :param _Payment: :type _Payment: endpoint.Payment :param _PaymentBatch: :type _PaymentBatch: endpoint.PaymentBatch + :param _RequestInquiry: + :type _RequestInquiry: endpoint.RequestInquiry + :param _RequestInquiryBatch: + :type _RequestInquiryBatch: endpoint.RequestInquiryBatch :param _RequestResponse: :type _RequestResponse: endpoint.RequestResponse - :param _ScheduleInstance: - :type _ScheduleInstance: endpoint.ScheduleInstance - :param _TabResultResponse: - :type _TabResultResponse: endpoint.TabResultResponse - :param _WhitelistResult: - :type _WhitelistResult: endpoint.WhitelistResult + :param _ShareInviteBankInquiry: + :type _ShareInviteBankInquiry: endpoint.ShareInviteMonetaryAccountInquiry + :param _ShareInviteBankResponse: + :type _ShareInviteBankResponse: endpoint.ShareInviteMonetaryAccountResponse + :param _ScheduledPayment: + :type _ScheduledPayment: endpoint.SchedulePayment + :param _ScheduledInstance: + :type _ScheduledInstance: endpoint.ScheduleInstance + :param _User: + :type _User: endpoint.User """ # Error constants. _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - _BillingInvoice = None + + _BunqMeFundraiserResult = None + _BunqMeTab = None + _BunqMeTabResultInquiry = None + _BunqMeTabResultResponse = None + _ChatMessage = None _DraftPayment = None + _IdealMerchantTransaction = None + _Invoice = None _MasterCardAction = None + _MonetaryAccount = None _Payment = None _PaymentBatch = None + _RequestInquiry = None + _RequestInquiryBatch = None _RequestResponse = None - _ScheduleInstance = None - _TabResultResponse = None - _WhitelistResult = None + _ShareInviteBankInquiry = None + _ShareInviteBankResponse = None + _ScheduledPayment = None + _ScheduledInstance = None + _User = None @property - def BillingInvoice(self): + def BunqMeFundraiserResult(self): """ - :rtype: endpoint.Invoice + :rtype: endpoint.BunqMeFundraiserResult """ - return self._BillingInvoice + return self._BunqMeFundraiserResult + + @property + def BunqMeTab(self): + """ + :rtype: endpoint.BunqMeTab + """ + + return self._BunqMeTab + + @property + def BunqMeTabResultInquiry(self): + """ + :rtype: endpoint.BunqMeTabResultInquiry + """ + + return self._BunqMeTabResultInquiry + + @property + def BunqMeTabResultResponse(self): + """ + :rtype: endpoint.BunqMeTabResultResponse + """ + + return self._BunqMeTabResultResponse + + @property + def ChatMessage(self): + """ + :rtype: endpoint.ChatMessage + """ + + return self._ChatMessage @property def DraftPayment(self): @@ -4157,6 +5757,22 @@ def DraftPayment(self): return self._DraftPayment + @property + def IdealMerchantTransaction(self): + """ + :rtype: endpoint.IdealMerchantTransaction + """ + + return self._IdealMerchantTransaction + + @property + def Invoice(self): + """ + :rtype: endpoint.Invoice + """ + + return self._Invoice + @property def MasterCardAction(self): """ @@ -4165,6 +5781,14 @@ def MasterCardAction(self): return self._MasterCardAction + @property + def MonetaryAccount(self): + """ + :rtype: endpoint.MonetaryAccount + """ + + return self._MonetaryAccount + @property def Payment(self): """ @@ -4181,6 +5805,22 @@ def PaymentBatch(self): return self._PaymentBatch + @property + def RequestInquiry(self): + """ + :rtype: endpoint.RequestInquiry + """ + + return self._RequestInquiry + + @property + def RequestInquiryBatch(self): + """ + :rtype: endpoint.RequestInquiryBatch + """ + + return self._RequestInquiryBatch + @property def RequestResponse(self): """ @@ -4190,94 +5830,175 @@ def RequestResponse(self): return self._RequestResponse @property - def ScheduleInstance(self): + def ShareInviteBankInquiry(self): """ - :rtype: endpoint.ScheduleInstance + :rtype: endpoint.ShareInviteMonetaryAccountInquiry """ - return self._ScheduleInstance + return self._ShareInviteBankInquiry @property - def TabResultResponse(self): + def ShareInviteBankResponse(self): """ - :rtype: endpoint.TabResultResponse + :rtype: endpoint.ShareInviteMonetaryAccountResponse """ - return self._TabResultResponse + return self._ShareInviteBankResponse @property - def WhitelistResult(self): + def ScheduledPayment(self): """ - :rtype: endpoint.WhitelistResult + :rtype: endpoint.SchedulePayment """ - return self._WhitelistResult + return self._ScheduledPayment + + @property + def ScheduledInstance(self): + """ + :rtype: endpoint.ScheduleInstance + """ + + return self._ScheduledInstance + + @property + def User(self): + """ + :rtype: endpoint.User + """ + return self._User def get_referenced_object(self): """ - :rtype: core.BunqModel + :rtype: BunqModel :raise: BunqException """ - if self._BillingInvoice is not None: - return self._BillingInvoice + if self._BunqMeFundraiserResult is not None: + return self._BunqMeFundraiserResult + + if self._BunqMeTab is not None: + return self._BunqMeTab + + if self._BunqMeTabResultInquiry is not None: + return self._BunqMeTabResultInquiry + + if self._BunqMeTabResultResponse is not None: + return self._BunqMeTabResultResponse + + if self._ChatMessage is not None: + return self._ChatMessage if self._DraftPayment is not None: return self._DraftPayment + if self._IdealMerchantTransaction is not None: + return self._IdealMerchantTransaction + + if self._Invoice is not None: + return self._Invoice + if self._MasterCardAction is not None: return self._MasterCardAction + if self._MonetaryAccount is not None: + return self._MonetaryAccount + if self._Payment is not None: return self._Payment if self._PaymentBatch is not None: return self._PaymentBatch + if self._RequestInquiry is not None: + return self._RequestInquiry + + if self._RequestInquiryBatch is not None: + return self._RequestInquiryBatch + if self._RequestResponse is not None: return self._RequestResponse - if self._ScheduleInstance is not None: - return self._ScheduleInstance + if self._ShareInviteBankInquiry is not None: + return self._ShareInviteBankInquiry - if self._TabResultResponse is not None: - return self._TabResultResponse + if self._ShareInviteBankResponse is not None: + return self._ShareInviteBankResponse - if self._WhitelistResult is not None: - return self._WhitelistResult + if self._ScheduledPayment is not None: + return self._ScheduledPayment + + if self._ScheduledInstance is not None: + return self._ScheduledInstance + + if self._User is not None: + return self._User + + raise BunqException(self._ERROR_NULL_FIELDS) + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._BunqMeFundraiserResult is not None: + return False + + if self._BunqMeTab is not None: + return False + + if self._BunqMeTabResultInquiry is not None: + return False + + if self._BunqMeTabResultResponse is not None: + return False - raise exception.BunqException(self._ERROR_NULL_FIELDS) + if self._ChatMessage is not None: + return False - def is_all_field_none(self): - """ - :rtype: bool - """ + if self._DraftPayment is not None: + return False - if self._BillingInvoice is not None: + if self._IdealMerchantTransaction is not None: return False - if self._DraftPayment is not None: + if self._Invoice is not None: return False if self._MasterCardAction is not None: return False + if self._MonetaryAccount is not None: + return False + if self._Payment is not None: return False if self._PaymentBatch is not None: return False + if self._RequestInquiry is not None: + return False + + if self._RequestInquiryBatch is not None: + return False + if self._RequestResponse is not None: return False - if self._ScheduleInstance is not None: + if self._ShareInviteBankInquiry is not None: return False - if self._TabResultResponse is not None: + if self._ShareInviteBankResponse is not None: return False - if self._WhitelistResult is not None: + if self._ScheduledPayment is not None: + return False + + if self._ScheduledInstance is not None: + return False + + if self._User is not None: return False return True @@ -4287,50 +6008,82 @@ def from_json(json_str): """ :type json_str: str - :rtype: RequestReferenceSplitTheBillAnchorObject + :rtype: NotificationAnchorObjectObject """ - return converter.json_to_class(RequestReferenceSplitTheBillAnchorObject, - json_str) + return converter.json_to_class(NotificationAnchorObjectObject, json_str) -class Error(core.BunqModel): +class UserApiKeyAnchoredUserObject(BunqModel, AnchorObjectInterface): """ - :param _error_description: The error description (in English). - :type _error_description: str - :param _error_description_translated: The error description (in the user - language). - :type _error_description_translated: str + :param _UserPerson: + :type _UserPerson: endpoint.UserPerson + :param _UserCompany: + :type _UserCompany: endpoint.UserCompany + :param _UserPaymentServiceProvider: + :type _UserPaymentServiceProvider: endpoint.UserPaymentServiceProvider """ - _error_description = None - _error_description_translated = None + # Error constants. + _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." + + + _UserPerson = None + _UserCompany = None + _UserPaymentServiceProvider = None @property - def error_description(self): + def UserPerson(self): """ - :rtype: str + :rtype: endpoint.UserPerson """ - return self._error_description + return self._UserPerson @property - def error_description_translated(self): + def UserCompany(self): """ - :rtype: str + :rtype: endpoint.UserCompany """ - return self._error_description_translated + return self._UserCompany + + @property + def UserPaymentServiceProvider(self): + """ + :rtype: endpoint.UserPaymentServiceProvider + """ + + return self._UserPaymentServiceProvider + def get_referenced_object(self): + """ + :rtype: BunqModel + :raise: BunqException + """ + + if self._UserPerson is not None: + return self._UserPerson + + if self._UserCompany is not None: + return self._UserCompany + + if self._UserPaymentServiceProvider is not None: + return self._UserPaymentServiceProvider + + raise BunqException(self._ERROR_NULL_FIELDS) def is_all_field_none(self): """ :rtype: bool """ - if self._error_description is not None: + if self._UserPerson is not None: return False - if self._error_description_translated is not None: + if self._UserCompany is not None: + return False + + if self._UserPaymentServiceProvider is not None: return False return True @@ -4340,65 +6093,76 @@ def from_json(json_str): """ :type json_str: str - :rtype: Error + :rtype: UserApiKeyAnchoredUserObject """ - return converter.json_to_class(Error, json_str) + return converter.json_to_class(UserApiKeyAnchoredUserObject, json_str) -class ScheduleAnchorObject(core.BunqModel, core.AnchoredObjectInterface): +class OauthCallbackUrlObject(BunqModel): """ - :param _Payment: - :type _Payment: endpoint.Payment - :param _PaymentBatch: - :type _PaymentBatch: endpoint.PaymentBatch + :param _id_: The id of the callback URL. + :type _id_: int + :param _created: The timestamp of the callback URL's creation. + :type _created: str + :param _updated: The timestamp of the callback URL's last update. + :type _updated: str + :param _url: The Callback URL. + :type _url: str """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - - _Payment = None - _PaymentBatch = None + _id_ = None + _created = None + _updated = None + _url = None @property - def Payment(self): + def id_(self): """ - :rtype: endpoint.Payment + :rtype: int """ - return self._Payment + return self._id_ @property - def PaymentBatch(self): + def created(self): """ - :rtype: endpoint.PaymentBatch + :rtype: str """ - return self._PaymentBatch + return self._created - def get_referenced_object(self): + @property + def updated(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: str """ - if self._Payment is not None: - return self._Payment + return self._updated - if self._PaymentBatch is not None: - return self._PaymentBatch + @property + def url(self): + """ + :rtype: str + """ - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._url def is_all_field_none(self): """ :rtype: bool """ - if self._Payment is not None: + if self._id_ is not None: return False - if self._PaymentBatch is not None: + if self._created is not None: + return False + + if self._updated is not None: + return False + + if self._url is not None: return False return True @@ -4408,66 +6172,49 @@ def from_json(json_str): """ :type json_str: str - :rtype: ScheduleAnchorObject + :rtype: OauthCallbackUrlObject """ - return converter.json_to_class(ScheduleAnchorObject, json_str) + return converter.json_to_class(OauthCallbackUrlObject, json_str) -class ScheduleInstanceAnchorObject(core.BunqModel, - core.AnchoredObjectInterface): +class PermittedDeviceObject(BunqModel): """ - :param _Payment: - :type _Payment: endpoint.Payment - :param _PaymentBatch: - :type _PaymentBatch: endpoint.PaymentBatch + :param _description: The description of the device that may use the + credential. + :type _description: str + :param _ip: The IP address of the device that may use the credential. + :type _ip: str """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - - _Payment = None - _PaymentBatch = None + _description = None + _ip = None @property - def Payment(self): + def description(self): """ - :rtype: endpoint.Payment + :rtype: str """ - return self._Payment + return self._description @property - def PaymentBatch(self): - """ - :rtype: endpoint.PaymentBatch - """ - - return self._PaymentBatch - - def get_referenced_object(self): + def ip(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: str """ - if self._Payment is not None: - return self._Payment - - if self._PaymentBatch is not None: - return self._PaymentBatch - - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._ip def is_all_field_none(self): """ :rtype: bool """ - if self._Payment is not None: + if self._description is not None: return False - if self._PaymentBatch is not None: + if self._ip is not None: return False return True @@ -4477,62 +6224,65 @@ def from_json(json_str): """ :type json_str: str - :rtype: ScheduleInstanceAnchorObject + :rtype: PermittedDeviceObject """ - return converter.json_to_class(ScheduleInstanceAnchorObject, json_str) + return converter.json_to_class(PermittedDeviceObject, json_str) -class WhitelistResultViewAnchoredObject(core.BunqModel): +class TransferwiseRequirementFieldObject(BunqModel): """ - :param _id_: The ID of the whitelist entry. - :type _id_: int - :param _requestResponse: The RequestResponse object - :type _requestResponse: endpoint.RequestResponse - :param _draftPayment: The DraftPayment object - :type _draftPayment: endpoint.DraftPayment + :param _key: The name of the required field. + :type _key: str + :param _value: The value of the required field. + :type _value: str + :param _name: The descriptive label of the field. + :type _name: str + :param _group: The field group. + :type _group: TransferwiseRequirementFieldGroup """ - _id_ = None - _requestResponse = None - _draftPayment = None + _name = None + _group = None + _key_field_for_request = None + _value_field_for_request = None - @property - def id_(self): + def __init__(self, key=None, value=None): """ - :rtype: int + :param key: The name of the required field. + :type key: str + :param value: The value of the required field. + :type value: str """ - return self._id_ + self._key_field_for_request = key + self._value_field_for_request = value @property - def requestResponse(self): + def name(self): """ - :rtype: endpoint.RequestResponse + :rtype: str """ - return self._requestResponse + return self._name @property - def draftPayment(self): + def group(self): """ - :rtype: endpoint.DraftPayment + :rtype: TransferwiseRequirementFieldGroup """ - return self._draftPayment + return self._group def is_all_field_none(self): """ :rtype: bool """ - if self._id_ is not None: - return False - - if self._requestResponse is not None: + if self._name is not None: return False - if self._draftPayment is not None: + if self._group is not None: return False return True @@ -4542,152 +6292,194 @@ def from_json(json_str): """ :type json_str: str - :rtype: WhitelistResultViewAnchoredObject + :rtype: TransferwiseRequirementFieldObject """ - return converter.json_to_class(WhitelistResultViewAnchoredObject, - json_str) + return converter.json_to_class(TransferwiseRequirementFieldObject, json_str) -class SchedulePaymentEntry(core.BunqModel): +class TransferwiseRequirementFieldGroupObject(BunqModel): """ - :param _amount: The Amount transferred by the Payment. Will be negative for - outgoing Payments and positive for incoming Payments (relative to the - MonetaryAccount indicated by monetary_account_id). - :type _amount: Amount - :param _counterparty_alias: The LabelMonetaryAccount containing the public - information of the other (counterparty) side of the Payment. - :type _counterparty_alias: MonetaryAccountReference - :param _description: The description for the Payment. Maximum 140 characters - for Payments to external IBANs, 9000 characters for Payments to only other - bunq MonetaryAccounts. - :type _description: str - :param _attachment: The Attachments attached to the Payment. - :type _attachment: list[AttachmentMonetaryAccountPayment] - :param _merchant_reference: Optional data included with the Payment specific - to the merchant. - :type _merchant_reference: str - :param _allow_bunqto: Whether or not sending a bunq.to payment is allowed. - Mandatory for publicApi. - :type _allow_bunqto: bool - :param _alias: The LabelMonetaryAccount containing the public information of - 'this' (party) side of the Payment. - :type _alias: MonetaryAccountReference + :param _key: The key of the field. This is the value to send as input. + :type _key: str + :param _type_: The field's input type: "text", "select" or "radio". + :type _type_: str + :param _name: The field name. + :type _name: str + :param _refresh_requirements_on_change: Indicates that any changes in this + field affect the requirements, if this field is changed, the requirements + endpoint must be called again to recheck if there are any additional + requirements. + :type _refresh_requirements_on_change: bool + :param _required: Whether or not the field is required. + :type _required: bool + :param _display_format: Formatting mask to guide user input. + :type _display_format: str + :param _example: An example value for this field. + :type _example: str + :param _min_length: The minimum length of the field's value. + :type _min_length: str + :param _max_length: The maximum length of the field's value. + :type _max_length: str + :param _validation_regexp: A regular expression which may be used to + validate the user input. + :type _validation_regexp: str + :param _validation_async: Details of an endpoint which may be used to + validate the user input. + :type _validation_async: TransferwiseRequirementFieldGroupValidationAsync + :param _values_allowed: Shows which values are allowed for fields of type + "select" or "radio". + :type _values_allowed: TransferwiseRequirementFieldGroupValuesAllowed """ - _amount = None - _alias = None - _counterparty_alias = None - _description = None - _attachment = None - _merchant_reference = None - _amount_field_for_request = None - _counterparty_alias_field_for_request = None - _description_field_for_request = None - _attachment_field_for_request = None - _merchant_reference_field_for_request = None - _allow_bunqto_field_for_request = None + _key = None + _type_ = None + _name = None + _refresh_requirements_on_change = None + _required = None + _display_format = None + _example = None + _min_length = None + _max_length = None + _validation_regexp = None + _validation_async = None + _values_allowed = None + + @property + def key(self): + """ + :rtype: str + """ + + return self._key + + @property + def type_(self): + """ + :rtype: str + """ + + return self._type_ + + @property + def name(self): + """ + :rtype: str + """ - def __init__(self, amount=None, counterparty_alias=None, description=None, - attachment=None, merchant_reference=None, allow_bunqto=None): + return self._name + + @property + def refresh_requirements_on_change(self): """ - :param amount: The Amount to transfer with the Payment. Must be bigger 0 and - smaller than the MonetaryAccount's balance. - :type amount: Amount - :param counterparty_alias: The Alias of the party we are transferring the - money to. Can be an Alias of type EMAIL or PHONE (for bunq MonetaryAccounts) - or IBAN (for external bank account). - :type counterparty_alias: Pointer - :param description: The description for the Payment. Maximum 140 characters - for Payments to external IBANs, 9000 characters for Payments to only other - bunq MonetaryAccounts. Field is required but can be an empty string. - :type description: str - :param attachment: The Attachments to attach to the Payment. - :type attachment: list[BunqId] - :param merchant_reference: Optional data to be included with the Payment - specific to the merchant. - :type merchant_reference: str - :param allow_bunqto: Whether or not sending a bunq.to payment is allowed. - Mandatory for publicApi. - :type allow_bunqto: bool + :rtype: bool """ - self._amount_field_for_request = amount - self._counterparty_alias_field_for_request = counterparty_alias - self._description_field_for_request = description - self._attachment_field_for_request = attachment - self._merchant_reference_field_for_request = merchant_reference - self._allow_bunqto_field_for_request = allow_bunqto + return self._refresh_requirements_on_change @property - def amount(self): + def required(self): """ - :rtype: Amount + :rtype: bool """ - return self._amount + return self._required @property - def alias(self): + def display_format(self): """ - :rtype: MonetaryAccountReference + :rtype: str """ - return self._alias + return self._display_format @property - def counterparty_alias(self): + def example(self): """ - :rtype: MonetaryAccountReference + :rtype: str """ - return self._counterparty_alias + return self._example @property - def description(self): + def min_length(self): """ :rtype: str """ - return self._description + return self._min_length @property - def attachment(self): + def max_length(self): """ - :rtype: list[AttachmentMonetaryAccountPayment] + :rtype: str """ - return self._attachment + return self._max_length @property - def merchant_reference(self): + def validation_regexp(self): """ :rtype: str """ - return self._merchant_reference + return self._validation_regexp + + @property + def validation_async(self): + """ + :rtype: TransferwiseRequirementFieldGroupValidationAsync + """ + + return self._validation_async + + @property + def values_allowed(self): + """ + :rtype: TransferwiseRequirementFieldGroupValuesAllowed + """ + + return self._values_allowed def is_all_field_none(self): """ :rtype: bool """ - if self._amount is not None: + if self._key is not None: return False - if self._alias is not None: + if self._type_ is not None: return False - if self._counterparty_alias is not None: + if self._name is not None: return False - if self._description is not None: + if self._refresh_requirements_on_change is not None: return False - if self._attachment is not None: + if self._required is not None: return False - if self._merchant_reference is not None: + if self._display_format is not None: + return False + + if self._example is not None: + return False + + if self._min_length is not None: + return False + + if self._max_length is not None: + return False + + if self._validation_regexp is not None: + return False + + if self._validation_async is not None: + return False + + if self._values_allowed is not None: return False return True @@ -4697,81 +6489,113 @@ def from_json(json_str): """ :type json_str: str - :rtype: SchedulePaymentEntry + :rtype: TransferwiseRequirementFieldGroupObject """ - return converter.json_to_class(SchedulePaymentEntry, json_str) + return converter.json_to_class(TransferwiseRequirementFieldGroupObject, json_str) -class TaxResident(core.BunqModel): +class TransferwiseRequirementFieldGroupValidationAsyncObject(BunqModel): """ - :param _country: The country of the tax number. - :type _country: str - :param _tax_number: The tax number. - :type _tax_number: str - :param _status: The status of the tax number. Either CONFIRMED or - UNCONFIRMED. - :type _status: str + :param _url: The url to be used to validate user input. + :type _url: str + :param _params: The parameters to send when validating user input. + :type _params: TransferwiseRequirementFieldGroupValidationAsyncParams """ - _country = None - _tax_number = None - _status = None - _country_field_for_request = None - _tax_number_field_for_request = None - _status_field_for_request = None + _url = None + _params = None - def __init__(self, country=None, tax_number=None, status=None): + @property + def url(self): """ - :param country: The country of the tax number. - :type country: str - :param tax_number: The tax number. - :type tax_number: str - :param status: The status of the tax number. Either CONFIRMED or - UNCONFIRMED. - :type status: str + :rtype: str """ - self._country_field_for_request = country - self._tax_number_field_for_request = tax_number - self._status_field_for_request = status + return self._url @property - def country(self): + def params(self): """ - :rtype: str + :rtype: TransferwiseRequirementFieldGroupValidationAsyncParams """ - return self._country + return self._params + + def is_all_field_none(self): + """ + :rtype: bool + """ + + if self._url is not None: + return False + + if self._params is not None: + return False + + return True + + @staticmethod + def from_json(json_str): + """ + :type json_str: str + + :rtype: TransferwiseRequirementFieldGroupValidationAsyncObject + """ + + return converter.json_to_class(TransferwiseRequirementFieldGroupValidationAsyncObject, json_str) + + +class TransferwiseRequirementFieldGroupValidationAsyncParamsObject(BunqModel): + """ + :param _key: The parameter key. + :type _key: str + :param _parameter_name: The parameter label. + :type _parameter_name: str + :param _required: Shows whether the parameter is required or not. + :type _required: bool + """ + + _key = None + _parameter_name = None + _required = None @property - def tax_number(self): + def key(self): """ :rtype: str """ - return self._tax_number + return self._key @property - def status(self): + def parameter_name(self): """ :rtype: str """ - return self._status + return self._parameter_name + + @property + def required(self): + """ + :rtype: bool + """ + + return self._required def is_all_field_none(self): """ :rtype: bool """ - if self._country is not None: + if self._key is not None: return False - if self._tax_number is not None: + if self._parameter_name is not None: return False - if self._status is not None: + if self._required is not None: return False return True @@ -4781,81 +6605,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: TaxResident + :rtype: TransferwiseRequirementFieldGroupValidationAsyncParamsObject """ - return converter.json_to_class(TaxResident, json_str) + return converter.json_to_class(TransferwiseRequirementFieldGroupValidationAsyncParamsObject, json_str) -class Ubo(core.BunqModel): +class TransferwiseRequirementFieldGroupValuesAllowedObject(BunqModel): """ - :param _name: The name of the ultimate beneficiary owner. + :param _key: The key. + :type _key: str + :param _name: The label. :type _name: str - :param _date_of_birth: The date of birth of the ultimate beneficiary owner. - :type _date_of_birth: str - :param _nationality: The nationality of the ultimate beneficiary owner. - :type _nationality: str """ + _key = None _name = None - _date_of_birth = None - _nationality = None - _name_field_for_request = None - _date_of_birth_field_for_request = None - _nationality_field_for_request = None - - def __init__(self, name=None, date_of_birth=None, nationality=None): - """ - :param name: The name of the ultimate beneficiary owner. - :type name: str - :param date_of_birth: The date of birth of the ultimate beneficiary owner. - Accepts ISO8601 date formats. - :type date_of_birth: str - :param nationality: The nationality of the ultimate beneficiary owner. - Accepts ISO8601 date formats. - :type nationality: str - """ - - self._name_field_for_request = name - self._date_of_birth_field_for_request = date_of_birth - self._nationality_field_for_request = nationality - - @property - def name(self): - """ - :rtype: str - """ - - return self._name @property - def date_of_birth(self): + def key(self): """ :rtype: str """ - return self._date_of_birth + return self._key @property - def nationality(self): + def name(self): """ :rtype: str """ - return self._nationality + return self._name def is_all_field_none(self): """ :rtype: bool """ - if self._name is not None: - return False - - if self._date_of_birth is not None: + if self._key is not None: return False - if self._nationality is not None: + if self._name is not None: return False return True @@ -4865,65 +6656,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: Ubo + :rtype: TransferwiseRequirementFieldGroupValuesAllowedObject """ - return converter.json_to_class(Ubo, json_str) + return converter.json_to_class(TransferwiseRequirementFieldGroupValuesAllowedObject, json_str) -class UserApiKeyAnchoredUser(core.BunqModel, core.AnchoredObjectInterface): +class HealthCheckResultObject(BunqModel): """ - :param _UserPerson: - :type _UserPerson: endpoint.UserPerson - :param _UserCompany: - :type _UserCompany: endpoint.UserCompany + :param _status: The result status of the health check. + :type _status: str + :param _allEntry: The entries on which the current status is based. + :type _allEntry: list[HealthCheckResultEntry] """ - # Error constants. - _ERROR_NULL_FIELDS = "All fields of an extended model or object are null." - - _UserPerson = None - _UserCompany = None + _status = None + _allEntry = None @property - def UserPerson(self): + def status(self): """ - :rtype: endpoint.UserPerson + :rtype: str """ - return self._UserPerson + return self._status @property - def UserCompany(self): - """ - :rtype: endpoint.UserCompany - """ - - return self._UserCompany - - def get_referenced_object(self): + def allEntry(self): """ - :rtype: core.BunqModel - :raise: BunqException + :rtype: list[HealthCheckResultEntry] """ - if self._UserPerson is not None: - return self._UserPerson - - if self._UserCompany is not None: - return self._UserCompany - - raise exception.BunqException(self._ERROR_NULL_FIELDS) + return self._allEntry def is_all_field_none(self): """ :rtype: bool """ - if self._UserPerson is not None: + if self._status is not None: return False - if self._UserCompany is not None: + if self._allEntry is not None: return False return True @@ -4933,49 +6707,48 @@ def from_json(json_str): """ :type json_str: str - :rtype: UserApiKeyAnchoredUser + :rtype: HealthCheckResultObject """ - return converter.json_to_class(UserApiKeyAnchoredUser, json_str) + return converter.json_to_class(HealthCheckResultObject, json_str) -class PermittedDevice(core.BunqModel): +class HealthCheckResultEntryObject(BunqModel): """ - :param _description: The description of the device that may use the - credential. - :type _description: str - :param _ip: The IP address of the device that may use the credential. - :type _ip: str + :param _type_: The type of HealthCheckResultEntry. + :type _type_: str + :param _status: The status of the HealthCheckResultEntry + :type _status: str """ - _description = None - _ip = None + _type_ = None + _status = None @property - def description(self): + def type_(self): """ :rtype: str """ - return self._description + return self._type_ @property - def ip(self): + def status(self): """ :rtype: str """ - return self._ip + return self._status def is_all_field_none(self): """ :rtype: bool """ - if self._description is not None: + if self._type_ is not None: return False - if self._ip is not None: + if self._status is not None: return False return True @@ -4985,16 +6758,14 @@ def from_json(json_str): """ :type json_str: str - :rtype: PermittedDevice + :rtype: HealthCheckResultEntryObject """ - return converter.json_to_class(PermittedDevice, json_str) - - -class MonetaryAccountReference(core.BunqModel): + return converter.json_to_class(HealthCheckResultEntryObject, json_str) +class MonetaryAccountReference(BunqModel): """ - :type pointer: Pointer - :type label_monetary_account: LabelMonetaryAccount + :type pointer: PointerObject + :type label_monetary_account: LabelMonetaryAccountObject """ # Error constants @@ -5018,12 +6789,12 @@ def __init__(self): @classmethod def create_from_pointer(cls, pointer): """ - :type pointer: Pointer + :type pointer: PointerObject """ instance = cls.__new__(cls) instance.pointer = pointer - instance.label_monetary_account = LabelMonetaryAccount() + instance.label_monetary_account = LabelMonetaryAccountObject() instance.label_monetary_account._iban = pointer.value instance.label_monetary_account._display_name = pointer.name @@ -5032,14 +6803,17 @@ def create_from_pointer(cls, pointer): @classmethod def create_from_label_monetary_account(cls, label_monetary_account): """ - :type label_monetary_account: LabelMonetaryAccount + :type label_monetary_account: LabelMonetaryAccountObject """ instance = cls.__new__(cls) instance.label_monetary_account = label_monetary_account - instance.pointer = Pointer() + instance.pointer = PointerObject() instance.pointer._name = label_monetary_account.display_name instance.pointer._type_ = cls._POINTER_TYPE_IBAN instance.pointer._value = label_monetary_account.iban return instance + + def is_all_field_none(self): + return False diff --git a/bunq/sdk/security/__init__.py b/bunq/sdk/security/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/security.py b/bunq/sdk/security/security.py similarity index 55% rename from bunq/sdk/security.py rename to bunq/sdk/security/security.py index a342cee..c658cb1 100644 --- a/bunq/sdk/security.py +++ b/bunq/sdk/security/security.py @@ -1,8 +1,12 @@ +from __future__ import annotations + import base64 import hmac import re +import typing from base64 import b64encode from hashlib import sha1 +from typing import Dict, List from Cryptodome import Cipher from Cryptodome import Random @@ -10,7 +14,17 @@ from Cryptodome.Cipher import PKCS1_v1_5 as PKCS1_v1_5_Cipher from Cryptodome.Hash import SHA256 from Cryptodome.PublicKey import RSA +from Cryptodome.PublicKey.RSA import RsaKey from Cryptodome.Signature import PKCS1_v1_5 +from requests.structures import CaseInsensitiveDict + +from bunq.sdk.exception.bunq_exception import BunqException + +if typing.TYPE_CHECKING: + from bunq.sdk.context.api_context import ApiContext + +# Error constants. +_ERROR_INVALID_SIGNATURE = 'Could not validate response signature.' # Size of private RSA key to generate _RSA_KEY_SIZE = 2048 @@ -46,21 +60,11 @@ _HEADER_SERVER_SIGNATURE = 'X-Bunq-Server-Signature' -def generate_rsa_private_key(): - """ - :rtype: RSA.RsaKey - """ - +def generate_rsa_private_key() -> RsaKey: return RSA.generate(_RSA_KEY_SIZE) -def public_key_to_string(public_key): - """ - :type public_key: RSA.RsaKey - - :rtype: str - """ - +def public_key_to_string(public_key: RsaKey) -> str: return re.sub( _PATTERN_RSA, _REPLACEMENT_RSA, @@ -68,56 +72,27 @@ def public_key_to_string(public_key): ) -def private_key_to_string(private_key): - """ - :type private_key: RSA.RsaKey - - :rtype: str - """ - +def private_key_to_string(private_key: RsaKey) -> str: return private_key.exportKey(pkcs=_PKCS_NUMBER_PRIVATE_KEY).decode() -def rsa_key_from_string(string): - """ - :type string: str - - :rtype: RSA.RsaKey - """ - +def rsa_key_from_string(string: str) -> RsaKey: return RSA.import_key(string) -def sign_request(private_key, method, endpoint, body_bytes, headers): - """ - :type private_key: RSA.RsaKey - :type method: str - :type endpoint: str - :type body_bytes: bytes - :type headers: dict[str, str] - - :rtype: str - """ - - head_bytes = _generate_request_head_bytes(method, endpoint, headers) - bytes_to_sign = head_bytes + body_bytes +def sign_request(private_key: RsaKey, + body_bytes: bytes) -> str: signer = PKCS1_v1_5.new(private_key) digest = SHA256.new() - digest.update(bytes_to_sign) + digest.update(body_bytes) sign = signer.sign(digest) return b64encode(sign) -def _generate_request_head_bytes(method, endpoint, headers): - """ - :type method: str - :type endpoint: str - :type headers: dict[str, str] - - :rtype: bytes - """ - +def _generate_request_head_bytes(method: str, + endpoint: str, + headers: Dict[str, str]) -> bytes: head_string = _FORMAT_METHOD_AND_ENDPOINT.format(method, endpoint) header_tuples = sorted((k, headers[k]) for k in headers) @@ -128,13 +103,7 @@ def _generate_request_head_bytes(method, endpoint, headers): return (head_string + _DELIMITER_NEWLINE).encode() -def _should_sign_request_header(header_name): - """ - :type header_name: str - - :rtype: bool - """ - +def _should_sign_request_header(header_name: str) -> bool: if header_name in {_HEADER_USER_AGENT, _HEADER_CACHE_CONTROL}: return True @@ -144,15 +113,19 @@ def _should_sign_request_header(header_name): return False -def encrypt(api_context, request_bytes, custom_headers): - """ - :type api_context: bunq.sdk.context.ApiContext - :type request_bytes: bytes - :type custom_headers: dict[str, str] +def generate_signature(string_to_sign: str, key_pair: RsaKey) -> str: + bytes_to_sign = string_to_sign.encode() + signer = PKCS1_v1_5.new(key_pair) + digest = SHA256.new() + digest.update(bytes_to_sign) + sign = signer.sign(digest) + + return b64encode(sign) - :rtype: bytes - """ +def encrypt(api_context: ApiContext, + request_bytes: bytes, + custom_headers: Dict[str, str]) -> bytes: key = Random.get_random_bytes(_AES_KEY_SIZE) iv = Random.get_random_bytes(_BLOCK_SIZE) _add_header_client_encryption_key(api_context, key, custom_headers) @@ -163,15 +136,9 @@ def encrypt(api_context, request_bytes, custom_headers): return request_bytes -def _add_header_client_encryption_key(api_context, key, custom_headers): - """ - :type api_context: bunq.sdk.context.ApiContext - :type key: bytes - :type custom_headers: dict[str, str] - - :rtype: None - """ - +def _add_header_client_encryption_key(api_context: ApiContext, + key: bytes, + custom_headers: Dict[str, str]) -> None: public_key_server = api_context.installation_context.public_key_server key_cipher = PKCS1_v1_5_Cipher.new(public_key_server) key_encrypted = key_cipher.encrypt(key) @@ -179,86 +146,83 @@ def _add_header_client_encryption_key(api_context, key, custom_headers): custom_headers[_HEADER_CLIENT_ENCRYPTION_KEY] = key_encrypted_base64 -def _add_header_client_encryption_iv(iv, custom_headers): - """ - :type iv: bytes - :type custom_headers: dict[str, str] - - :rtype: None - """ - +def _add_header_client_encryption_iv(iv: bytes, + custom_headers: Dict[str, str]) -> None: custom_headers[_HEADER_CLIENT_ENCRYPTION_IV] = base64.b64encode(iv).decode() -def _encrypt_request_bytes(request_bytes, key, iv): - """ - :type request_bytes: bytes - :type key: bytes - :type iv: bytes - - :rtype: bytes - """ - +def _encrypt_request_bytes(request_bytes: bytes, + key: bytes, + iv: bytes) -> bytes: cipher = Cipher.AES.new(key, Cipher.AES.MODE_CBC, iv) request_bytes_padded = _pad_bytes(request_bytes) return cipher.encrypt(request_bytes_padded) -def _pad_bytes(request_bytes): - """ - :type request_bytes: bytes - - :rtype: bytes - """ - +def _pad_bytes(request_bytes: bytes) -> bytes: padding_length = (_BLOCK_SIZE - len(request_bytes) % _BLOCK_SIZE) padding_character = bytes(bytearray([padding_length])) return request_bytes + padding_character * padding_length -def _add_header_client_encryption_hmac(request_bytes, key, iv, custom_headers): - """ - :type request_bytes: bytes - :type key: bytes - :type iv: bytes - :type custom_headers: dict[str, str] - - :rtype: None - """ - +def _add_header_client_encryption_hmac(request_bytes: bytes, + key: bytes, + iv: bytes, + custom_headers: Dict[str, str]) -> None: hashed = hmac.new(key, iv + request_bytes, sha1) hashed_base64 = base64.b64encode(hashed.digest()).decode() custom_headers[_HEADER_CLIENT_ENCRYPTION_HMAC] = hashed_base64 -def validate_response(public_key_server, status_code, body_bytes, headers): - """ - :type public_key_server: RSA.RsaKey - :type status_code: int - :type body_bytes: bytes - :type headers: dict[str, str] +def validate_response(public_key_server: RsaKey, + status_code: int, + body_bytes: bytes, + headers: CaseInsensitiveDict[str, str]) -> None: + if is_valid_response_header_with_body(public_key_server, status_code, body_bytes, headers): + return + elif is_valid_response_body(public_key_server, body_bytes, headers): + return + else: + raise BunqException(_ERROR_INVALID_SIGNATURE) - :rtype: None - """ +def is_valid_response_header_with_body(public_key_server: RsaKey, + status_code: int, + body_bytes: bytes, + headers: CaseInsensitiveDict[str, str]) -> bool: head_bytes = _generate_response_head_bytes(status_code, headers) bytes_signed = head_bytes + body_bytes signer = PKCS1_v1_5.pkcs1_15.new(public_key_server) digest = SHA256.new() digest.update(bytes_signed) - signer.verify(digest, base64.b64decode(headers[_HEADER_SERVER_SIGNATURE])) + try: + signer.verify(digest, base64.b64decode(headers[_HEADER_SERVER_SIGNATURE])) + + return True + except ValueError: + return False + + +def is_valid_response_body(public_key_server: RsaKey, + body_bytes: bytes, + headers: CaseInsensitiveDict[str, str]) -> bool: + signer = PKCS1_v1_5.pkcs1_15.new(public_key_server) + digest = SHA256.new() + digest.update(body_bytes) + + try: + signer.verify(digest, base64.b64decode(headers[_HEADER_SERVER_SIGNATURE])) -def _generate_response_head_bytes(status_code, headers): - """ - :type status_code: int - :type headers: dict[str, str] + return True + except ValueError: + return False - :rtype: bytes - """ +def _generate_response_head_bytes(status_code: int, + headers: CaseInsensitiveDict[str, str]) -> bytes: head_string = str(status_code) + _DELIMITER_NEWLINE header_tuples = sorted((k, headers[k]) for k in headers) @@ -271,12 +235,7 @@ def _generate_response_head_bytes(status_code, headers): return (head_string + _DELIMITER_NEWLINE).encode() -def _get_header_correctly_cased(header_name): - """ - :type header_name: str - :rtype: str - """ - +def _get_header_correctly_cased(header_name: str) -> str: header_name = header_name.capitalize() matches = re.findall(_REGEX_FOR_LOWERCASE_HEADERS, header_name) @@ -287,13 +246,7 @@ def _get_header_correctly_cased(header_name): return header_name -def _should_sign_response_header(header_name): - """ - :type header_name: str - - :rtype: bool - """ - +def _should_sign_response_header(header_name: str) -> bool: if header_name == _HEADER_SERVER_SIGNATURE: return False @@ -301,3 +254,7 @@ def _should_sign_response_header(header_name): return True return False + + +def get_certificate_chain_string(all_chain_certificate: List[str]): + return _DELIMITER_NEWLINE.join(all_chain_certificate) diff --git a/bunq/sdk/util.py b/bunq/sdk/util.py deleted file mode 100644 index 947d0fb..0000000 --- a/bunq/sdk/util.py +++ /dev/null @@ -1,58 +0,0 @@ -import json -import socket - -import requests - -from bunq.sdk.client import ApiClient -from bunq.sdk.context import ApiContext, ApiEnvironmentType -from bunq.sdk.exception import BunqException -from bunq.sdk.model.generated import endpoint - -__UNIQUE_REQUEST_ID = "uniqueness-is-required" -__FIELD_API_KEY = "ApiKey" -__INDEX_FIRST = 0 -__FIELD_RESPONSE = "Response" -__ENDPOINT_SANDBOX_USER = "sandbox-user" - -_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER = "Could not create new sandbox" \ - " user." - - -def automatic_sandbox_install(): - """ - :rtype: ApiContext - """ - - sandbox_user = __generate_new_sandbox_user() - - return ApiContext( - ApiEnvironmentType.SANDBOX, - sandbox_user.api_key, - socket.gethostname() - ) - - -def __generate_new_sandbox_user(): - """ - :rtype: endpoint.SandboxUser - """ - - url = ApiEnvironmentType.SANDBOX.uri_base + __ENDPOINT_SANDBOX_USER - - headers = { - ApiClient.HEADER_REQUEST_ID: __UNIQUE_REQUEST_ID, - ApiClient.HEADER_CACHE_CONTROL: ApiClient._CACHE_CONTROL_NONE, - ApiClient.HEADER_GEOLOCATION: ApiClient._GEOLOCATION_ZERO, - ApiClient.HEADER_LANGUAGE: ApiClient._LANGUAGE_EN_US, - ApiClient.HEADER_REGION: ApiClient._REGION_NL_NL, - } - - response = requests.request(ApiClient._METHOD_POST, url, headers=headers) - - if response.status_code is ApiClient._STATUS_CODE_OK: - response_json = json.loads(response.text) - return endpoint.SandboxUser.from_json( - json.dumps(response_json[__FIELD_RESPONSE][__INDEX_FIRST][ - __FIELD_API_KEY])) - - raise BunqException(_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER) diff --git a/bunq/sdk/util/__init__.py b/bunq/sdk/util/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bunq/sdk/util/type_alias.py b/bunq/sdk/util/type_alias.py new file mode 100644 index 0000000..3e20162 --- /dev/null +++ b/bunq/sdk/util/type_alias.py @@ -0,0 +1,5 @@ +from typing import Union, TypeVar + +JsonValue = Union[int, str, bool, float, bytes, list, dict, object, None] + +T = TypeVar('T') diff --git a/bunq/sdk/util/util.py b/bunq/sdk/util/util.py new file mode 100644 index 0000000..779cb7f --- /dev/null +++ b/bunq/sdk/util/util.py @@ -0,0 +1,48 @@ +from __future__ import annotations + +import json +import socket + +import requests + +from bunq.sdk.context.api_context import ApiContext, ApiEnvironmentType +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.model.generated.endpoint import SandboxUserPersonApiObject + +__UNIQUE_REQUEST_ID = "uniqueness-is-required" +__FIELD_API_KEY = "ApiKey" +__INDEX_FIRST = 0 +__FIELD_RESPONSE = "Response" +__ENDPOINT_SANDBOX_USER_PERSON = "sandbox-user-person" + +# Error constants +_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER = "Could not create new sandbox user." +_ERROR_ALL_FIELD_IS_NULL = 'All fields are null' + + +def automatic_sandbox_install() -> ApiContext: + sandbox_user = __generate_new_sandbox_user() + + return ApiContext.create(ApiEnvironmentType.SANDBOX, sandbox_user.api_key, socket.gethostname()) + + +def __generate_new_sandbox_user() -> SandboxUserPersonApiObject: + url = ApiEnvironmentType.SANDBOX.uri_base + __ENDPOINT_SANDBOX_USER_PERSON + + headers = { + ApiClient.HEADER_REQUEST_ID: __UNIQUE_REQUEST_ID, + ApiClient.HEADER_CACHE_CONTROL: ApiClient.CACHE_CONTROL_NONE, + ApiClient.HEADER_GEOLOCATION: ApiClient.GEOLOCATION_ZERO, + ApiClient.HEADER_LANGUAGE: ApiClient.LANGUAGE_EN_US, + ApiClient.HEADER_REGION: ApiClient.REGION_NL_NL, + } + + response = requests.request(ApiClient.METHOD_POST, url, headers=headers) + + if response.status_code is ApiClient.STATUS_CODE_OK: + response_json = json.loads(response.text) + + return SandboxUserPersonApiObject.from_json(json.dumps(response_json[__FIELD_RESPONSE][__INDEX_FIRST][__FIELD_API_KEY])) + + raise BunqException(_ERROR_COULD_NOT_CREATE_NEW_SANDBOX_USER) diff --git a/examples b/examples index 2182b8b..67f623f 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 2182b8be276fda921657ad22cfe0b8b48a585ccf +Subproject commit 67f623fba4375a3360750821417bb5e9e028ec64 diff --git a/requirements.txt b/requirements.txt index faa2ad6..cc41a8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -aenum==2.0.8 +aenum==2.2.4 chardet==3.0.4 -pycryptodomex==3.4.6 -requests[socks]==2.18.1 -simplejson==3.11.1 -urllib3==1.21.1 +pycryptodomex==3.9.8 +requests[socks]==2.24.0 +simplejson==3.17.2 +urllib3==1.25.10 diff --git a/run.py b/run.py index 7cdc347..820c6a8 100755 --- a/run.py +++ b/run.py @@ -2,8 +2,7 @@ import sys if len(sys.argv) != 2: - print('Invalid argument count. Usage: python3 run.py ' - 'examples/example_name.py') + print('Invalid argument count. Usage: python3 run.py examples/example_name.py') path = sys.argv[1] module_ = path.rstrip('.py').replace('/', '.') diff --git a/setup.py b/setup.py index 0b8ed51..4098e31 100644 --- a/setup.py +++ b/setup.py @@ -6,28 +6,34 @@ https://github.com/pypa/sampleproject """ -# Always prefer setuptools over distutils -from setuptools import setup, find_packages # To use a consistent encoding from codecs import open from os import path +# Always prefer setuptools over distutils +from setuptools import setup, find_packages + here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() +# Get the version from the VERSION file +with open(path.join(here, 'VERSION'), encoding='utf-8') as f: + version = f.read() + setup( name='bunq_sdk', # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.1.0', + version=version, description='bunq Python SDK', long_description=long_description, + long_description_content_type="text/markdown", # The project's main homepage. url='https://github.com/bunq/sdk_python', @@ -56,21 +62,33 @@ # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ], - # Require Python version equal or higher than Python 3.6. - python_requires='>=3.6', + # Require Python version equal or higher than the requested version. + python_requires='>=3.7.0', # Keywords related to the project keywords='open-banking sepa bunq finance api payment', # Packages of the project. "find_packages()" lists all the project packages. - packages=find_packages(exclude=['contrib', 'docs', 'tests', 'examples', - 'assets', '.idea', 'run.py']), + packages=find_packages(exclude=[ + 'contrib', + 'docs', + 'tests', + 'examples', + 'assets', + '.idea', + 'run.py' + ]), # Run-time dependencies of the project. These will be installed by pip. - install_requires=['aenum==2.0.8', 'chardet==3.0.4', 'pycryptodomex==3.4.6', - 'requests==2.18.1', 'simplejson==3.11.1', - 'urllib3==1.21.1'], -) + install_requires=[ + 'aenum>=2.2.4,<3.0.0', + 'chardet>=3.0.4,<4.0.0', + 'pycryptodomex>=3.9.8,<4.0.0', + 'requests>=2.24.0,<3.0.0', + 'simplejson>=3.17.2,<4.0.0', + 'urllib3>=1.25.10,<2.0.0' + ], +) \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index 617ebfd..2a96666 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,64 +1 @@ -# bunq Python SDK - -## Introduction -Hi developers! - - -Welcome to the bunq Python SDK integration tests. Currently we are not -targeting the 100% test coverage, but rather want to be certain that the most -common scenarios can run without any errors. - - -## Scenarios - -These are the scenarios that are currently being tested: -* Create installation, session-server and device server -* Create a new MonetaryAccount -* Create a tab -* Update the tab -* Create attachment and avatar -* Request money from first MA to second MA -* Accept the request -* Make a transaction from first MA to second MA -* Create connect gr code -* Make a payment to another sandbox user -* Send a chat message in a recent payment -* Delete the current session -* Order a card with a second line - -Besides these scenarios, some code of ApiContext, ApiClient and the JSON module -are also tested :thumbs_up:. - -## Configuration - -To run the tests you must first setup the test configuration JSON. The example -of a configuration file is located at [`tests/assets/config.example.json`](./assets/config.example.json). -In order to make use of the configuration file, please copy the example to the -same directory, fill in your sandbox user data and rename the copy to config.json. - -Note: -* `MONETARY_ACCOUNT_ID` and `MONETARY_ACCOUNT_ID2` must be of same user -* `CounterPartyOther` must be of another Sandbox user -* You can create a `CASH_REGISTER_ID` on doc.bunq.com - 1. Add your **Developer Key** to `settings` - 2. Upload an image to the `Attachment Public` endpoint - 3. Create an `Avatar` with the returned UUID - 4. Use the Avatar's UUID to create a `Cash Register` - 5. Copy the Cash Register's ID to the `config.json` - -## Execution - -You can run the tests via command line: - -``` -python -m unittest discover -s tests/model/generated -``` - -or via PyCharm, but first you must configure PyCharm by doing the following: -* Got to preferences --> tools --> Python integrated tools and change default -test runner to `unittests`. -* Configure your Python interpreter to an supported Python version. Python 3 is -recommended. - -Afterwards you can right click on the tests folders and should be able to run -the tests cases form the IDE. +πŸ“š For full API Test documentation, visit [doc.bunq.com](https://doc.bunq.com/getting-started/tools/software-development-kits-sdks/python/tests). diff --git a/tests/assets/NotficationUrlJsons/BunqMeTab.json b/tests/assets/NotificationUrlJsons/BunqMeTab.json similarity index 100% rename from tests/assets/NotficationUrlJsons/BunqMeTab.json rename to tests/assets/NotificationUrlJsons/BunqMeTab.json diff --git a/tests/assets/NotficationUrlJsons/ChatMessageAnnouncement.json b/tests/assets/NotificationUrlJsons/ChatMessageAnnouncement.json similarity index 100% rename from tests/assets/NotficationUrlJsons/ChatMessageAnnouncement.json rename to tests/assets/NotificationUrlJsons/ChatMessageAnnouncement.json diff --git a/tests/assets/NotficationUrlJsons/DraftPayment.json b/tests/assets/NotificationUrlJsons/DraftPayment.json similarity index 100% rename from tests/assets/NotficationUrlJsons/DraftPayment.json rename to tests/assets/NotificationUrlJsons/DraftPayment.json diff --git a/tests/assets/NotficationUrlJsons/MasterCardAction.json b/tests/assets/NotificationUrlJsons/MasterCardAction.json similarity index 100% rename from tests/assets/NotficationUrlJsons/MasterCardAction.json rename to tests/assets/NotificationUrlJsons/MasterCardAction.json diff --git a/tests/assets/NotficationUrlJsons/MonetaryAccountBank.json b/tests/assets/NotificationUrlJsons/MonetaryAccountBank.json similarity index 100% rename from tests/assets/NotficationUrlJsons/MonetaryAccountBank.json rename to tests/assets/NotificationUrlJsons/MonetaryAccountBank.json diff --git a/tests/assets/NotficationUrlJsons/Mutation.json b/tests/assets/NotificationUrlJsons/Mutation.json similarity index 100% rename from tests/assets/NotficationUrlJsons/Mutation.json rename to tests/assets/NotificationUrlJsons/Mutation.json diff --git a/tests/assets/NotficationUrlJsons/PaymentBatch.json b/tests/assets/NotificationUrlJsons/PaymentBatch.json similarity index 100% rename from tests/assets/NotficationUrlJsons/PaymentBatch.json rename to tests/assets/NotificationUrlJsons/PaymentBatch.json diff --git a/tests/assets/NotficationUrlJsons/RequestInquiry.json b/tests/assets/NotificationUrlJsons/RequestInquiry.json similarity index 100% rename from tests/assets/NotficationUrlJsons/RequestInquiry.json rename to tests/assets/NotificationUrlJsons/RequestInquiry.json diff --git a/tests/assets/NotficationUrlJsons/RequestResponse.json b/tests/assets/NotificationUrlJsons/RequestResponse.json similarity index 100% rename from tests/assets/NotficationUrlJsons/RequestResponse.json rename to tests/assets/NotificationUrlJsons/RequestResponse.json diff --git a/tests/assets/NotficationUrlJsons/ScheduledInstance.json b/tests/assets/NotificationUrlJsons/ScheduledInstance.json similarity index 100% rename from tests/assets/NotficationUrlJsons/ScheduledInstance.json rename to tests/assets/NotificationUrlJsons/ScheduledInstance.json diff --git a/tests/assets/NotficationUrlJsons/ScheduledPayment.json b/tests/assets/NotificationUrlJsons/ScheduledPayment.json similarity index 100% rename from tests/assets/NotficationUrlJsons/ScheduledPayment.json rename to tests/assets/NotificationUrlJsons/ScheduledPayment.json diff --git a/tests/assets/NotficationUrlJsons/ShareInviteBankInquiry.json b/tests/assets/NotificationUrlJsons/ShareInviteBankInquiry.json similarity index 100% rename from tests/assets/NotficationUrlJsons/ShareInviteBankInquiry.json rename to tests/assets/NotificationUrlJsons/ShareInviteBankInquiry.json diff --git a/tests/assets/NotficationUrlJsons/ShareInviteBankResponse.json b/tests/assets/NotificationUrlJsons/ShareInviteBankResponse.json similarity index 100% rename from tests/assets/NotficationUrlJsons/ShareInviteBankResponse.json rename to tests/assets/NotificationUrlJsons/ShareInviteBankResponse.json diff --git a/tests/assets/bunq_App_Icon_Square@4x.png b/tests/assets/bunq_App_Icon_Square@4x.png deleted file mode 100644 index 1eebc9a..0000000 Binary files a/tests/assets/bunq_App_Icon_Square@4x.png and /dev/null differ diff --git a/tests/assets/vader.png b/tests/assets/vader.png new file mode 100644 index 0000000..7d4b2d6 Binary files /dev/null and b/tests/assets/vader.png differ diff --git a/tests/bunq_test.py b/tests/bunq_test.py index cdee6ce..d865f2f 100644 --- a/tests/bunq_test.py +++ b/tests/bunq_test.py @@ -1,18 +1,20 @@ import os import time import unittest +from typing import AnyStr + +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.exception.bunq_exception import BunqException +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.model.generated.endpoint import MonetaryAccountBankApiObject, RequestInquiryApiObject, AttachmentPublicApiObject, AvatarApiObject +from bunq.sdk.model.generated.object_ import AmountObject, PointerObject +from bunq.sdk.util import util -from bunq.sdk import context -from bunq.sdk import util -from bunq.sdk.client import ApiClient -from bunq.sdk.exception import BunqException -from bunq.sdk.model.generated import endpoint -from bunq.sdk.model.generated import object_ class BunqSdkTestCase(unittest.TestCase): """ - :type _second_monetary_account: endpoint.MonetaryAccountBank - :type _cash_register: endpoint.CashRegister + :type _second_monetary_account: MonetaryAccountBankApiObject """ # Error constants. @@ -26,7 +28,7 @@ class BunqSdkTestCase(unittest.TestCase): _PATH_ATTACHMENT = 'tests/assets/' _READ_BYTES = "rb" - _ATTACHMENT_PATH_IN = 'bunq_App_Icon_Square@4x.png' + _ATTACHMENT_PATH_IN = 'vader.png' _CONTENT_TYPE = 'image/png' _ATTACHMENT_DESCRIPTION = 'SDK python test' _FIRST_INDEX = 0 @@ -37,115 +39,65 @@ class BunqSdkTestCase(unittest.TestCase): __SPENDING_MONEY_RECIPIENT = 'sugardaddy@bunq.com' __REQUEST_SPENDING_DESCRIPTION = 'sdk python test, thanks daddy <3' - __CASH_REGISTER_STATUS = 'PENDING_APPROVAL' - __CASH_REGISTER_DESCRIPTION = 'python test cash register' - __SECOND_MONETARY_ACCOUNT_DESCRIPTION = 'test account python' _EMAIL_BRAVO = 'bravo@bunq.com' - __TIME_OUT_AUTO_ACCEPT_SPENDING_MONEY = 0.5 + __TIME_OUT_AUTO_ACCEPT_SPENDING_MONEY = 2 _second_monetary_account = None - _cash_register = None @classmethod def setUpClass(cls): - context.BunqContext.load_api_context(cls._get_api_context()) + BunqContext.load_api_context(cls._get_api_context()) def setUp(self): self.__set_second_monetary_account() self.__request_spending_money() time.sleep(self.__TIME_OUT_AUTO_ACCEPT_SPENDING_MONEY) - context.BunqContext.user_context().refresh_user_context() + BunqContext.user_context().refresh_user_context() def __set_second_monetary_account(self): - response = endpoint.MonetaryAccountBank.create( + response = MonetaryAccountBankApiObject.create( self.__CURRENCY_EUR, self.__SECOND_MONETARY_ACCOUNT_DESCRIPTION ) - self._second_monetary_account = endpoint.MonetaryAccountBank.get( + self._second_monetary_account = MonetaryAccountBankApiObject.get( response.value ).value def __request_spending_money(self): - endpoint.RequestInquiry.create( - object_.Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR), - object_.Pointer( - self._POINTER_EMAIL, - self.__SPENDING_MONEY_RECIPIENT - ), + RequestInquiryApiObject.create( + AmountObject(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR), + PointerObject(self._POINTER_EMAIL, self.__SPENDING_MONEY_RECIPIENT), self.__REQUEST_SPENDING_DESCRIPTION, False ) - endpoint.RequestInquiry.create( - object_.Amount(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR), - object_.Pointer( - self._POINTER_EMAIL, - self.__SPENDING_MONEY_RECIPIENT - ), + RequestInquiryApiObject.create( + AmountObject(self.__SPENDING_MONEY_AMOUNT, self.__CURRENCY_EUR), + PointerObject(self._POINTER_EMAIL, self.__SPENDING_MONEY_RECIPIENT), self.__REQUEST_SPENDING_DESCRIPTION, False, self._second_monetary_account.id_ ) - def _get_cash_register_id(self): - if self._cash_register is None: - self._set_cash_register() - - return self._cash_register.id_ - @classmethod - def _get_api_context(cls): - """ - :rtype: context.ApiContext - """ - + def _get_api_context(cls) -> ApiContext: return util.automatic_sandbox_install() - def _get_pointer_bravo(self): - """ - :rtype: object_.Pointer - """ - - return object_.Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO) - - def _get_alias_second_account(self): - """ - :rtype: object_.Pointer - """ + def _get_pointer_bravo(self) -> PointerObject: + return PointerObject(self._POINTER_EMAIL, self._EMAIL_BRAVO) + def _get_alias_second_account(self) -> PointerObject: return self._second_monetary_account.alias[self._FIRST_INDEX] @staticmethod def _get_directory_test_root(): return os.path.dirname(os.path.abspath(__file__)) - def _set_cash_register(self): - attachment_uuid = endpoint.AttachmentPublic.create( - self._attachment_contents, - { - ApiClient.HEADER_CONTENT_TYPE: self._CONTENT_TYPE, - ApiClient.HEADER_ATTACHMENT_DESCRIPTION: - self._ATTACHMENT_DESCRIPTION, - } - ) - avatar_uuid = endpoint.Avatar.create(attachment_uuid.value) - cash_register_id = endpoint.CashRegister.create( - self.__CASH_REGISTER_DESCRIPTION, - self.__CASH_REGISTER_STATUS, - avatar_uuid.value - ) - - self._cash_register = endpoint.CashRegister.get(cash_register_id.value) - @property - def _attachment_contents(self): - """ - :rtype: bytes - """ - + def _attachment_contents(self) -> AnyStr: with open( self._get_directory_test_root() + self._PATH_ATTACHMENT + @@ -155,17 +107,11 @@ def _attachment_contents(self): return file.read() @property - def alias_first(self): - """ - :rtype: Pointer - """ - - if context.BunqContext.user_context().is_only_user_company_set(): - return context.BunqContext.user_context().user_company.alias[ - self._FIRST_INDEX] - - if context.BunqContext.user_context().is_only_user_person_set(): - return context.BunqContext.user_context().user_person.alias[ - self._FIRST_INDEX] + def alias_first(self) -> PointerObject: + if BunqContext.user_context().is_only_user_company_set(): + return BunqContext.user_context().user_company.alias[self._FIRST_INDEX] + + if BunqContext.user_context().is_only_user_person_set(): + return BunqContext.user_context().user_person.alias[self._FIRST_INDEX] raise BunqException(self.__ERROR_COULD_NOT_DETERMINE_USER) diff --git a/tests/config.py b/tests/config.py index bae74e8..753e4aa 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,7 +1,9 @@ import json import os -from bunq.sdk.model.generated import object_ +from typing import List, Any + +from bunq.sdk.model.generated.object_ import Pointer class Config: @@ -15,7 +17,6 @@ class Config: _FIELD_TYPE = "Type" _FIELD_ALIAS = "Alias" _FIELD_TAB_USAGE = "TabUsageSingleTest" - _FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID" _FIELD_MONETARY_ACCOUNT_ID_1 = "MONETARY_ACCOUNT_ID" _FIELD_MONETARY_ACCOUNT_ID_2 = "MONETARY_ACCOUNT_ID2" _FIELD_USER_ID = "USER_ID" @@ -26,105 +27,49 @@ class Config: _FIELD_ATTACHMENT_CONTENT_TYPE = "CONTENT_TYPE" @classmethod - def get_attachment_content_type(cls): - """ - :rtype: str - """ - - return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][ - cls._FIELD_ATTACHMENT_CONTENT_TYPE] + def get_attachment_content_type(cls) -> str: + return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_CONTENT_TYPE] @classmethod - def get_attachment_description(cls): - """ - :rtype: str - """ - - return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][ - cls._FIELD_ATTACHMENT_DESCRIPTION] + def get_attachment_description(cls) -> str: + return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_DESCRIPTION] @classmethod - def get_attachment_path_in(cls): - """ - :rtype: str - """ - - return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][ - cls._FIELD_ATTACHMENT_PATH_IN] + def get_attachment_path_in(cls) -> str: + return cls._get_config_file()[cls._FIELD_ATTACHMENT_PUBLIC][cls._FIELD_ATTACHMENT_PATH_IN] @classmethod - def get_api_key(cls): - """ - :rtype: str - """ - + def get_api_key(cls) -> str: return cls._get_config_file()[cls._FIELD_API_KEY] @classmethod - def get_user_id(cls): - """ - :rtype: int - """ - + def get_user_id(cls) -> int: return int(cls._get_config_file()[cls._FIELD_USER_ID]) @classmethod - def get_monetary_account_id_2(cls): - """ - :rtype: int - """ - + def get_monetary_account_id_2(cls) -> int: return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_2]) @classmethod - def get_monetary_account_id_1(cls): - """ - :rtype: int - """ - + def get_monetary_account_id_1(cls) -> int: return int(cls._get_config_file()[cls._FIELD_MONETARY_ACCOUNT_ID_1]) @classmethod - def get_cash_register_id(cls): - """ - :rtype str - """ + def get_pointer_counter_party_self(cls) -> Pointer: + type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][cls._FIELD_TYPE] + alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][cls._FIELD_ALIAS] - return cls._get_config_file()[cls._FIELD_TAB_USAGE][ - cls._FIELD_CASH_REGISTER_ID] + return Pointer(type_, alias) @classmethod - def get_pointer_counter_party_self(cls): - """ - :rtype: Pointer - """ + def get_pointer_counter_party_other(cls) -> Pointer: + type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][cls._FIELD_TYPE] + alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][cls._FIELD_ALIAS] - type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][ - cls._FIELD_TYPE] - alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_SELF][ - cls._FIELD_ALIAS] - - return object_.Pointer(type_, alias) + return Pointer(type_, alias) @classmethod - def get_pointer_counter_party_other(cls): - """ - :rtype: Pointer - """ - - type_ = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][ - cls._FIELD_TYPE] - alias = cls._get_config_file()[cls._FIELD_COUNTER_PARTY_OTHER][ - cls._FIELD_ALIAS] - - return object_.Pointer(type_, alias) - - @classmethod - def get_permitted_ips(cls): - """ - :rtype: list[str] - """ - + def get_permitted_ips(cls) -> List[str]: permitted_ips_str = cls._get_config_file()[cls._FIELD_PERMITTED_IPS] if not permitted_ips_str: @@ -133,11 +78,7 @@ def get_permitted_ips(cls): return permitted_ips_str.split(cls._DELIMITER_IPS) @classmethod - def _get_config_file(cls): - """ - :rtype: json.load - """ - + def _get_config_file(cls) -> Any: file_path = os.path.dirname(os.path.realpath(__file__)) with open(file_path + "/assets/config.json", "r") as f: return json.load(f) diff --git a/tests/context/__init__.py b/tests/context/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/http/test_api_context.py b/tests/context/test_api_context.py similarity index 82% rename from tests/http/test_api_context.py rename to tests/context/test_api_context.py index 456eeb2..73a69a0 100644 --- a/tests/http/test_api_context.py +++ b/tests/context/test_api_context.py @@ -1,33 +1,31 @@ import json import os -from bunq.sdk.context import ApiContext -from bunq.sdk.context import BunqContext +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.context.bunq_context import BunqContext from bunq.sdk.json import converter from tests.bunq_test import BunqSdkTestCase - class TestApiContext(BunqSdkTestCase): """ Tests: ApiContext """ - _TMP_FILE_PATH = '/context-save-test.conf' + _TMP_FILE_PATH = '/assets/context-save-test.conf' __FIELD_SESSION_CONTEXT = 'session_context' __FIELD_EXPIRE_TIME = 'expiry_time' __TIME_STAMP_IN_PAST = '2000-04-07 19:50:43.839717' @classmethod - def setUpClass(cls): + def setUpClass(cls) -> None: super().setUpClass() cls._FILE_MODE_READ = ApiContext._FILE_MODE_READ - cls._API_CONTEXT = cls._get_api_context() - cls._TMP_FILE_PATH_FULL = (cls._get_directory_test_root() + - cls._TMP_FILE_PATH) + cls._API_CONTEXT: ApiContext = cls._get_api_context() + cls._TMP_FILE_PATH_FULL = (cls._get_directory_test_root() + cls._TMP_FILE_PATH) - def test_api_context_save(self): + def test_api_context_save(self) -> None: """ Converts an ApiContext to JSON data, saves the same ApiContext to a temporary file, and compares whether the JSON data is equal to the @@ -47,7 +45,7 @@ def test_api_context_save(self): self.assertEqual(context_retrieved, context_json) - def test_api_context_restore(self): + def test_api_context_restore(self) -> None: """ Saves an ApiContext to a temporary file, restores an ApiContext from that file, and compares whether the api_keys, tokens, and environment @@ -96,18 +94,15 @@ def test_auto_bunq_context_update(self): Tests the auto update of BunqContext. """ - api_context: ApiContext = BunqContext.api_context() - api_context_json: object = json.loads(api_context.to_json()) + api_context = BunqContext.api_context() + api_context_json = json.loads(api_context.to_json()) - api_context_json[self.__FIELD_SESSION_CONTEXT][ - self.__FIELD_EXPIRE_TIME] = self.__TIME_STAMP_IN_PAST + api_context_json[self.__FIELD_SESSION_CONTEXT][self.__FIELD_EXPIRE_TIME] = self.__TIME_STAMP_IN_PAST expired_api_context = ApiContext.from_json(json.dumps(api_context_json)) - self.assertNotEqual(api_context.session_context.expiry_time, - expired_api_context.session_context.expiry_time) - self.assertEqual(BunqContext.api_context().session_context.expiry_time, - api_context.session_context.expiry_time) + self.assertNotEqual(api_context.session_context.expiry_time, expired_api_context.session_context.expiry_time) + self.assertEqual(BunqContext.api_context().session_context.expiry_time, api_context.session_context.expiry_time) BunqContext.update_api_context(expired_api_context) BunqContext.user_context().refresh_user_context() diff --git a/tests/context/test_psd2_context.py b/tests/context/test_psd2_context.py new file mode 100644 index 0000000..5843750 --- /dev/null +++ b/tests/context/test_psd2_context.py @@ -0,0 +1,112 @@ +import os +import unittest + +from bunq import ApiEnvironmentType +from bunq.sdk.context.api_context import ApiContext +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.json import converter +from bunq.sdk.model.generated.endpoint import OauthClientApiObject +from tests.bunq_test import BunqSdkTestCase + +class TestPsd2Context(unittest.TestCase): + """ + Tests: + Psd2Context + """ + + _FILE_TEST_CONFIGURATION = '/bunq-psd2-test.conf' + _FILE_TEST_OAUTH = '/bunq-oauth-psd2-test.conf' + + _FILE_TEST_CERTIFICATE = '/certificate.pem' + _FILE_TEST_CERTIFICATE_CHAIN = '/certificate.pem' + _FILE_TEST_PRIVATE_KEY = '/key.pem' + + _TEST_DEVICE_DESCRIPTION = 'PSD2TestDevice' + + @classmethod + def setUpClass(cls) -> None: + cls._FILE_MODE_READ = ApiContext._FILE_MODE_READ + cls._FILE_TEST_CONFIGURATION_PATH_FULL = ( + BunqSdkTestCase._get_directory_test_root() + cls._FILE_TEST_CONFIGURATION + ) + cls._FILE_TEST_OAUTH_PATH_FULL = ( + BunqSdkTestCase._get_directory_test_root() + cls._FILE_TEST_OAUTH + ) + cls._FILE_TEST_CERTIFICATE_PATH_FULL = ( + BunqSdkTestCase._get_directory_test_root() + cls._FILE_TEST_CERTIFICATE + ) + cls._FILE_TEST_CERTIFICATE_CHAIN_PATH_FULL = ( + BunqSdkTestCase._get_directory_test_root() + cls._FILE_TEST_CERTIFICATE_CHAIN + ) + cls._FILE_TEST_PRIVATE_KEY_PATH_FULL = ( + BunqSdkTestCase._get_directory_test_root() + cls._FILE_TEST_PRIVATE_KEY + ) + cls.setup_test_data() + + @classmethod + def setup_test_data(cls) -> None: + if not os.path.isfile(cls._FILE_TEST_CONFIGURATION_PATH_FULL): + try: + BunqContext.load_api_context(cls._create_api_context()) + except FileNotFoundError: + return + + api_context = ApiContext.restore(cls._FILE_TEST_CONFIGURATION_PATH_FULL) + BunqContext.load_api_context(api_context) + + def test_create_psd2_context(self) -> None: + if os.path.isfile(self._FILE_TEST_CONFIGURATION_PATH_FULL): + return + + try: + api_context = self._create_api_context() + BunqContext.load_api_context(api_context) + + self.assertTrue(os.path.isfile(self._FILE_TEST_CONFIGURATION_PATH_FULL)) + + except AssertionError: + raise AssertionError + + def test_create_oauth_client(self) -> None: + if os.path.isfile(self._FILE_TEST_OAUTH_PATH_FULL): + return + + try: + client_id = OauthClientApiObject.create().value + oauth_client = OauthClientApiObject.get(client_id).value + + self.assertIsNotNone(oauth_client) + + serialized_client = converter.class_to_json(oauth_client) + + file = open(self._FILE_TEST_OAUTH_PATH_FULL, ApiContext._FILE_MODE_WRITE) + file.write(serialized_client) + file.close() + + self.assertTrue(os.path.isfile(self._FILE_TEST_OAUTH_PATH_FULL)) + + except AssertionError: + raise AssertionError + + @classmethod + def _create_api_context(cls) -> ApiContext: + with open(cls._FILE_TEST_CERTIFICATE_PATH_FULL, cls._FILE_MODE_READ) as file_: + certificate = file_.read() + + with open(cls._FILE_TEST_PRIVATE_KEY_PATH_FULL, cls._FILE_MODE_READ) as file_: + private_key = file_.read() + + with open(cls._FILE_TEST_CERTIFICATE_PATH_FULL, cls._FILE_MODE_READ) as file_: + all_certificate_chain = file_.read() + + api_context = ApiContext.create_for_psd2( + ApiEnvironmentType.SANDBOX, + certificate, + private_key, + [all_certificate_chain], + cls._TEST_DEVICE_DESCRIPTION + ) + + api_context.save(cls._FILE_TEST_CONFIGURATION_PATH_FULL) + + return api_context diff --git a/tests/context/test_user_context.py b/tests/context/test_user_context.py new file mode 100644 index 0000000..c607780 --- /dev/null +++ b/tests/context/test_user_context.py @@ -0,0 +1,23 @@ +from tests.bunq_test import BunqSdkTestCase + +class TestUserContext(BunqSdkTestCase): + """ + Tests: + UserContext + """ + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls._API_CONTEXT = cls._get_api_context() + + def test_build_user_context(self): + from bunq.sdk.context.user_context import UserContext + user_context = UserContext( + self._API_CONTEXT.session_context.user_id, + self._API_CONTEXT.session_context.get_user_reference() + ) + user_context.refresh_user_context() + + self.assertIsNotNone(user_context.user_id) + self.assertIsNotNone(user_context.primary_monetary_account.id_) diff --git a/tests/http/test_bad_request_with_response_id.py b/tests/http/test_bad_request_with_response_id.py index 7fc05b8..0ac482c 100644 --- a/tests/http/test_bad_request_with_response_id.py +++ b/tests/http/test_bad_request_with_response_id.py @@ -1,7 +1,7 @@ -from bunq.sdk.exception import ApiException -from bunq.sdk.model.generated.endpoint import MonetaryAccountBank +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.exception.api_exception import ApiException +from bunq.sdk.model.generated.endpoint import MonetaryAccountBankApiObject from tests.bunq_test import BunqSdkTestCase -from bunq.sdk.context import BunqContext class TestPagination(BunqSdkTestCase): @@ -13,10 +13,8 @@ class TestPagination(BunqSdkTestCase): _INVALID_MONETARY_ACCOUNT_ID = 0 def test_bad_request_with_response_id(self): - """ - """ BunqContext.load_api_context(self._get_api_context()) with self.assertRaises(ApiException) as caught_exception: - MonetaryAccountBank.get(self._INVALID_MONETARY_ACCOUNT_ID) + MonetaryAccountBankApiObject.get(self._INVALID_MONETARY_ACCOUNT_ID) self.assertIsNotNone(caught_exception.exception.response_id) diff --git a/tests/http/test_pagination.py b/tests/http/test_pagination.py index feb86cd..3d51a4b 100644 --- a/tests/http/test_pagination.py +++ b/tests/http/test_pagination.py @@ -1,5 +1,5 @@ -from bunq.sdk import client -from bunq.sdk import exception +from bunq import Pagination +from bunq.sdk.exception.bunq_exception import BunqException from tests.bunq_test import BunqSdkTestCase @@ -17,18 +17,14 @@ class TestPagination(BunqSdkTestCase): def test_get_url_params_count_only(self): pagination = self._create_pagination_with_all_properties_set() url_params_count_only_expected = { - client.Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), + Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), } self.assertEqual(url_params_count_only_expected, pagination.url_params_count_only) - def _create_pagination_with_all_properties_set(self): - """ - :rtype: Pagination - """ - - pagination = client.Pagination() + def _create_pagination_with_all_properties_set(self) -> Pagination: + pagination = Pagination() pagination.older_id = self._PAGINATION_OLDER_ID_CUSTOM pagination.newer_id = self._PAGINATION_NEWER_ID_CUSTOM pagination.future_id = self._PAGINATION_FUTURE_ID_CUSTOM @@ -39,33 +35,28 @@ def _create_pagination_with_all_properties_set(self): def test_get_url_params_previous_page(self): pagination = self._create_pagination_with_all_properties_set() url_params_previous_page_expected = { - client.Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), - client.Pagination.PARAM_OLDER_ID: - str(self._PAGINATION_OLDER_ID_CUSTOM), + Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), + Pagination.PARAM_OLDER_ID: str(self._PAGINATION_OLDER_ID_CUSTOM), } self.assertTrue(pagination.has_previous_page()) - self.assertEqual(url_params_previous_page_expected, - pagination.url_params_previous_page) + self.assertEqual(url_params_previous_page_expected, pagination.url_params_previous_page) def test_get_url_params_previous_page_no_count(self): pagination = self._create_pagination_with_all_properties_set() pagination.count = None url_params_previous_page_expected = { - client.Pagination.PARAM_OLDER_ID: - str(self._PAGINATION_OLDER_ID_CUSTOM), + Pagination.PARAM_OLDER_ID: str(self._PAGINATION_OLDER_ID_CUSTOM), } self.assertTrue(pagination.has_previous_page()) - self.assertEqual(url_params_previous_page_expected, - pagination.url_params_previous_page) + self.assertEqual(url_params_previous_page_expected, pagination.url_params_previous_page) def test_get_url_params_next_page_newer(self): pagination = self._create_pagination_with_all_properties_set() url_params_next_page_expected = { - client.Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), - client.Pagination.PARAM_NEWER_ID: - str(self._PAGINATION_NEWER_ID_CUSTOM), + Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), + Pagination.PARAM_NEWER_ID: str(self._PAGINATION_NEWER_ID_CUSTOM), } self.assertTrue(pagination.has_next_page_assured()) @@ -76,8 +67,7 @@ def test_get_url_params_next_page_newer_no_count(self): pagination = self._create_pagination_with_all_properties_set() pagination.count = None url_params_next_page_expected = { - client.Pagination.PARAM_NEWER_ID: - str(self._PAGINATION_NEWER_ID_CUSTOM), + Pagination.PARAM_NEWER_ID: str(self._PAGINATION_NEWER_ID_CUSTOM), } self.assertTrue(pagination.has_next_page_assured()) @@ -88,9 +78,8 @@ def test_get_url_params_next_page_future(self): pagination = self._create_pagination_with_all_properties_set() pagination.newer_id = None url_params_next_page_expected = { - client.Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), - client.Pagination.PARAM_NEWER_ID: - str(self._PAGINATION_FUTURE_ID_CUSTOM), + Pagination.PARAM_COUNT: str(self._PAGINATION_COUNT_CUSTOM), + Pagination.PARAM_NEWER_ID: str(self._PAGINATION_FUTURE_ID_CUSTOM), } self.assertFalse(pagination.has_next_page_assured()) @@ -102,8 +91,7 @@ def test_get_url_params_next_page_future_no_count(self): pagination.newer_id = None pagination.count = None url_params_next_page_expected = { - client.Pagination.PARAM_NEWER_ID: - str(self._PAGINATION_FUTURE_ID_CUSTOM), + Pagination.PARAM_NEWER_ID: str(self._PAGINATION_FUTURE_ID_CUSTOM), } self.assertFalse(pagination.has_next_page_assured()) @@ -118,7 +106,7 @@ def access_url_params_previous_page(): _ = pagination.url_params_previous_page self.assertFalse(pagination.has_previous_page()) - self.assertRaises(exception.BunqException, + self.assertRaises(BunqException, access_url_params_previous_page) def test_get_url_params_next_page_from_pagination_with_no_next_page(self): @@ -129,4 +117,4 @@ def test_get_url_params_next_page_from_pagination_with_no_next_page(self): def access_url_params_next_page(): _ = pagination.url_params_next_page - self.assertRaises(exception.BunqException, access_url_params_next_page) + self.assertRaises(BunqException, access_url_params_next_page) diff --git a/tests/http/test_pagination_scenario.py b/tests/http/test_pagination_scenario.py index 52d73f1..29b0b5b 100644 --- a/tests/http/test_pagination_scenario.py +++ b/tests/http/test_pagination_scenario.py @@ -1,8 +1,12 @@ -from bunq.sdk import client -from bunq.sdk.context import BunqContext +import time +from typing import List, Dict + +from bunq import Pagination +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.http.bunq_response import BunqResponse from bunq.sdk.json import converter -from bunq.sdk.model.generated import endpoint -from bunq.sdk.model.generated import object_ +from bunq.sdk.model.generated.endpoint import PaymentApiObject +from bunq.sdk.model.generated.object_ import AmountObject from tests.bunq_test import BunqSdkTestCase @@ -12,6 +16,8 @@ class TestPaginationScenario(BunqSdkTestCase): Pagination """ + __TIME_OUT_PREVENT_RATE_LIMIT = 2 + @classmethod def setUpClass(cls): cls._PAYMENT_LISTING_PAGE_SIZE = 2 @@ -26,69 +32,47 @@ def setUpClass(cls): def test_api_scenario_payment_listing_with_pagination(self): self._ensure_enough_payments() payments_expected = self._payments_required() - pagination = client.Pagination() + pagination = Pagination() pagination.count = self._PAYMENT_LISTING_PAGE_SIZE + time.sleep(self.__TIME_OUT_PREVENT_RATE_LIMIT) response_latest = self._list_payments(pagination.url_params_count_only) pagination_latest = response_latest.pagination - response_previous = self._list_payments( - pagination_latest.url_params_previous_page - ) + + time.sleep(self.__TIME_OUT_PREVENT_RATE_LIMIT) + response_previous = self._list_payments(pagination_latest.url_params_previous_page) pagination_previous = response_previous.pagination - response_previous_next = self._list_payments( - pagination_previous.url_params_next_page - ) + + response_previous_next = self._list_payments(pagination_previous.url_params_next_page) payments_previous = response_previous.value payments_previous_next = response_previous_next.value payments_actual = payments_previous_next + payments_previous payments_expected_serialized = converter.serialize(payments_expected) payments_actual_serialized = converter.serialize(payments_actual) - self.assertEqual(payments_expected_serialized, - payments_actual_serialized) - - def _ensure_enough_payments(self): - """ - :rtype: None - """ + self.assertEqual(payments_expected_serialized, payments_actual_serialized) + def _ensure_enough_payments(self) -> None: for _ in range(self._payment_missing_count): self._create_payment() @property - def _payment_missing_count(self): - """ - :rtype: int - """ + def _payment_missing_count(self) -> int: + return self._PAYMENT_REQUIRED_COUNT_MINIMUM - len(self._payments_required()) - return self._PAYMENT_REQUIRED_COUNT_MINIMUM - \ - len(self._payments_required()) - - def _payments_required(self): - """ - :rtype: list[endpoint.Payment] - """ - - pagination = client.Pagination() + def _payments_required(self) -> List[PaymentApiObject]: + pagination = Pagination() pagination.count = self._PAYMENT_REQUIRED_COUNT_MINIMUM return self._list_payments(pagination.url_params_count_only).value - def _list_payments(self, params): - """ - :type params: dict[str, str] - - :rtype BunqResponse[list[Payment]] - """ + @staticmethod + def _list_payments(params: Dict[str, str]) -> BunqResponse[List[PaymentApiObject]]: + return PaymentApiObject.list(params=params) - return endpoint.Payment.list(params=params) - - def _create_payment(self): - """ - :rtype: None - """ - - endpoint.Payment.create(object_.Amount(self._PAYMENT_AMOUNT_EUR, - self._PAYMENT_CURRENCY), - self._get_pointer_bravo(), - self._PAYMENT_DESCRIPTION) + def _create_payment(self) -> None: + PaymentApiObject.create( + AmountObject(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), + self._get_pointer_bravo(), + self._PAYMENT_DESCRIPTION + ) diff --git a/tests/model/core/test_notification_filter.py b/tests/model/core/test_notification_filter.py new file mode 100644 index 0000000..40fe134 --- /dev/null +++ b/tests/model/core/test_notification_filter.py @@ -0,0 +1,67 @@ +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.model.core.notification_filter_push_user_internal import NotificationFilterPushUserInternal +from bunq.sdk.model.core.notification_filter_url_monetary_account_internal import \ + NotificationFilterUrlMonetaryAccountInternal +from bunq.sdk.model.core.notification_filter_url_user_internal import NotificationFilterUrlUserInternal +from bunq.sdk.model.generated.object_ import NotificationFilterUrl, NotificationFilterPush +from tests.bunq_test import BunqSdkTestCase + + +class TestNotificationFilter(BunqSdkTestCase): + _FILTER_CATEGORY_MUTATION = 'MUTATION' + _FILTER_CALLBACK_URL = 'https://test.com/callback' + + def test_notification_filter_url_monetary_account(self): + notification_filter = self.get_notification_filter_url() + all_notification_filter = [notification_filter] + + all_created_notification_filter = NotificationFilterUrlMonetaryAccountInternal.create_with_list_response( + self.get_primary_monetary_account().id_, + all_notification_filter + ).value + + self.assertEqual(1, len(all_created_notification_filter)) + + def test_notification_filter_url_user(self): + notification_filter = self.get_notification_filter_url() + all_notification_filter = [notification_filter] + + all_created_notification_filter = NotificationFilterUrlUserInternal.create_with_list_response( + all_notification_filter + ).value + + self.assertEqual(1, len(all_created_notification_filter)) + + def test_notification_filter_push_user(self): + notification_filter = self.get_notification_filter_push() + all_notification_filter = [notification_filter] + + all_created_notification_filter = NotificationFilterPushUserInternal.create_with_list_response( + all_notification_filter + ).value + + self.assertEqual(1, len(all_created_notification_filter)) + + def test_notification_filter_clear(self): + all_created_notification_filter_push_user = NotificationFilterPushUserInternal.create_with_list_response().value + all_created_notification_filter_url_user = NotificationFilterUrlUserInternal.create_with_list_response().value + all_created_notification_filter_url_monetary_account = \ + NotificationFilterUrlMonetaryAccountInternal.create_with_list_response().value + + self.assertFalse(all_created_notification_filter_push_user) + self.assertFalse(all_created_notification_filter_url_user) + self.assertFalse(all_created_notification_filter_url_monetary_account) + + self.assertEqual(0, len(NotificationFilterPushUserInternal.list().value)) + self.assertEqual(0, len(NotificationFilterUrlUserInternal.list().value)) + self.assertEqual(0, len(NotificationFilterUrlMonetaryAccountInternal.list().value)) + + def get_notification_filter_url(self): + return NotificationFilterUrl(self._FILTER_CATEGORY_MUTATION, self._FILTER_CALLBACK_URL) + + def get_notification_filter_push(self): + return NotificationFilterPush(self._FILTER_CATEGORY_MUTATION) + + @staticmethod + def get_primary_monetary_account(): + return BunqContext.user_context().primary_monetary_account diff --git a/tests/model/core/test_oauth_authorization_uri.py b/tests/model/core/test_oauth_authorization_uri.py new file mode 100644 index 0000000..5bf7ff2 --- /dev/null +++ b/tests/model/core/test_oauth_authorization_uri.py @@ -0,0 +1,26 @@ +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.model.core.oauth_authorization_uri import OauthAuthorizationUri +from bunq.sdk.model.core.oauth_response_type import OauthResponseType +from bunq.sdk.model.generated.endpoint import OauthClient +from tests.bunq_test import BunqSdkTestCase + + +class TestOauthAuthorizationUri(BunqSdkTestCase): + _TEST_EXPECT_URI = 'https://oauth.sandbox.bunq.com/auth?redirect_uri=redirecturi&response_type=code&state=state' + _TEST_REDIRECT_URI = 'redirecturi' + _TEST_STATUS = 'status' + _TEST_STATE = 'state' + + @classmethod + def setUpClass(cls) -> None: + BunqContext.load_api_context(cls._get_api_context()) + + def test_oauth_authorization_uri_create(self) -> None: + uri = OauthAuthorizationUri.create( + OauthResponseType(OauthResponseType.CODE), + self._TEST_REDIRECT_URI, + OauthClient(self._TEST_STATUS), + self._TEST_STATE + ).get_authorization_uri() + + self.assertEqual(self._TEST_EXPECT_URI, uri) diff --git a/tests/model/generated/endpoint/test_attachment_public.py b/tests/model/generated/endpoint/test_attachment_public.py index 263e2c9..c4716a4 100644 --- a/tests/model/generated/endpoint/test_attachment_public.py +++ b/tests/model/generated/endpoint/test_attachment_public.py @@ -1,13 +1,15 @@ -from bunq.sdk.client import ApiClient -from bunq.sdk.model.generated import endpoint +from typing import AnyStr + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.model.generated.endpoint import AttachmentPublicContentApiObject, AttachmentPublicApiObject from tests.bunq_test import BunqSdkTestCase -class TestAttachmentPublic(BunqSdkTestCase): +class TestAttachmentPublicApiObject(BunqSdkTestCase): """ Tests: - AttachmentPublic - AttachmentPublicContent + AttachmentPublicApiObject + AttachmentPublicContentApiObject """ def test_file_upload_and_retrieval(self): @@ -23,22 +25,12 @@ def test_file_upload_and_retrieval(self): self._ATTACHMENT_DESCRIPTION, } - attachment_uuid = endpoint.AttachmentPublic.create( - self.attachment_contents, - custom_headers - ).value - - contents_from_response = endpoint.AttachmentPublicContent.list( - attachment_uuid).value + attachment_uuid = AttachmentPublicApiObject.create(self.attachment_contents, custom_headers).value + contents_from_response = AttachmentPublicContentApiObject.list(attachment_uuid).value self.assertEqual(self.attachment_contents, contents_from_response) @property - def attachment_contents(self): - """ - :rtype: bytes - """ - - with open(self._PATH_ATTACHMENT + self._ATTACHMENT_PATH_IN, - self._READ_BYTES) as f: + def attachment_contents(self) -> AnyStr: + with open(self._PATH_ATTACHMENT + self._ATTACHMENT_PATH_IN, self._READ_BYTES) as f: return f.read() diff --git a/tests/model/generated/endpoint/test_avatar.py b/tests/model/generated/endpoint/test_avatar.py index 4276e53..e9952dc 100644 --- a/tests/model/generated/endpoint/test_avatar.py +++ b/tests/model/generated/endpoint/test_avatar.py @@ -1,22 +1,24 @@ -from bunq.sdk.client import ApiClient -from bunq.sdk.model.generated.endpoint import AttachmentPublic -from bunq.sdk.model.generated.endpoint import AttachmentPublicContent -from bunq.sdk.model.generated.endpoint import Avatar +from typing import AnyStr + +from bunq.sdk.http.api_client import ApiClient +from bunq.sdk.model.generated.endpoint import AttachmentPublicApiObject +from bunq.sdk.model.generated.endpoint import AttachmentPublicContentApiObject +from bunq.sdk.model.generated.endpoint import AvatarApiObject from tests.bunq_test import BunqSdkTestCase class TestAvatar(BunqSdkTestCase): """ Tests: - Avatar - AttachmentPublic - AttachmentPublicContent + AvatarApiObject + AttachmentPublicApiObject + AttachmentPublicContentApiObject """ def test_avatar_creation(self): """ Tests the creation of an avatar by uploading a picture via - AttachmentPublic and setting it as avatar via the uuid + AttachmentPublicApiObject and setting it as avatar via the uuid """ custom_header = { @@ -24,26 +26,14 @@ def test_avatar_creation(self): self._ATTACHMENT_DESCRIPTION, ApiClient.HEADER_CONTENT_TYPE: self._CONTENT_TYPE } - attachment_public_uuid = AttachmentPublic.create( - self.attachment_contents, custom_header).value - - avatar_uuid = Avatar.create(attachment_public_uuid).value - attachment_uuid_after = Avatar.get(avatar_uuid) \ - .value.image[self._FIRST_INDEX].attachment_public_uuid - - file_contents_received = AttachmentPublicContent.list( - attachment_uuid_after).value + attachment_public_uuid = AttachmentPublicApiObject.create(self.attachment_contents, custom_header).value + avatar_uuid = AvatarApiObject.create(attachment_public_uuid).value + attachment_uuid_after = AvatarApiObject.get(avatar_uuid).value.image[self._FIRST_INDEX].attachment_public_uuid + file_contents_received = AttachmentPublicContentApiObject.list(attachment_uuid_after).value self.assertEqual(self.attachment_contents, file_contents_received) @property - def attachment_contents(self): - """ - :rtype: bytes - """ - - with open( - self._PATH_ATTACHMENT + self._ATTACHMENT_PATH_IN, - self._READ_BYTES - ) as file: + def attachment_contents(self) -> AnyStr: + with open(self._PATH_ATTACHMENT + self._ATTACHMENT_PATH_IN, self._READ_BYTES) as file: return file.read() diff --git a/tests/model/generated/endpoint/test_card_debit.py b/tests/model/generated/endpoint/test_card_debit.py index 6d93f04..cb8e22f 100644 --- a/tests/model/generated/endpoint/test_card_debit.py +++ b/tests/model/generated/endpoint/test_card_debit.py @@ -1,29 +1,29 @@ import random import string -from bunq.sdk.context import BunqContext -from bunq.sdk.exception import BunqException -from bunq.sdk.model.generated.endpoint import Card -from bunq.sdk.model.generated.endpoint import CardDebit -from bunq.sdk.model.generated.endpoint import CardName -from bunq.sdk.model.generated.object_ import CardPinAssignment -from bunq.sdk.model.generated.object_ import Pointer +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.model.generated.endpoint import CardApiObject +from bunq.sdk.model.generated.endpoint import CardDebitApiObject +from bunq.sdk.model.generated.endpoint import CardNameApiObject +from bunq.sdk.model.generated.object_ import CardPinAssignmentObject from tests.bunq_test import BunqSdkTestCase class TestCardDebit(BunqSdkTestCase): """ Tests: - Card - CardDebit - CardName + CardApiObject + CardDebitApiObject + CardNameApiObject """ _CARD_PIN_CODE = '4045' _SECOND_LINE_LENGTH_MAXIMUM = 20 _STRING_EMPTY = '' _PIN_CODE_ASSIGNMENT_TYPE_PRIMARY = 'PRIMARY' - _CARD_TYPE_MAESTRO = 'MAESTRO' + _CARD_TYPE_MASTERCARD = 'MASTERCARD' + _PRODUCT_TYPE_MASTERCARD_DEBIT = 'MASTERCARD_DEBIT' + _CARD_ROUTING_TYPE = 'MANUAL' def test_order_debit_card(self): """ @@ -33,38 +33,34 @@ def test_order_debit_card(self): """ second_line = self.second_line_random - - pin_code_assignment = CardPinAssignment( + pin_code_assignment = CardPinAssignmentObject( self._PIN_CODE_ASSIGNMENT_TYPE_PRIMARY, + self._CARD_ROUTING_TYPE, self._CARD_PIN_CODE, BunqContext.user_context().primary_monetary_account.id_ ) - card_debit = CardDebit.create(second_line, self.card_name_allowed, - self.alias_first, self._CARD_TYPE_MAESTRO, - [pin_code_assignment]).value - card = Card.get(card_debit.id_).value + card_debit = CardDebitApiObject.create( + second_line=second_line, + name_on_card=self.card_name_allowed, + type_=self._CARD_TYPE_MASTERCARD, + product_type=self._PRODUCT_TYPE_MASTERCARD_DEBIT, + alias=self.alias_first, + pin_code_assignment=[pin_code_assignment] + ).value + + card = CardApiObject.get(card_debit.id_).value self.assertEqual(self.card_name_allowed, card.name_on_card) self.assertEqual(second_line, card.second_line) self.assertEqual(card_debit.created, card.created) @property - def card_name_allowed(self): - """ - :rtype: str - """ - - return \ - CardName.list().value[self._FIRST_INDEX].possible_card_name_array[ - self._FIRST_INDEX] + def card_name_allowed(self) -> str: + return CardNameApiObject.list().value[self._FIRST_INDEX].possible_card_name_array[self._FIRST_INDEX] @property - def second_line_random(self): - """ - :rtype: str - """ - + def second_line_random(self) -> str: second_line_characters = [] for _ in range(self._SECOND_LINE_LENGTH_MAXIMUM): diff --git a/tests/model/generated/endpoint/test_draft_share_invite_bank.py b/tests/model/generated/endpoint/test_draft_share_invite_bank.py deleted file mode 100644 index 5c04efc..0000000 --- a/tests/model/generated/endpoint/test_draft_share_invite_bank.py +++ /dev/null @@ -1,54 +0,0 @@ -from datetime import datetime -from datetime import timedelta - -from bunq.sdk.context import BunqContext -from bunq.sdk.model.generated.endpoint import DraftShareInviteBank -from bunq.sdk.model.generated.endpoint import DraftShareInviteBankQrCodeContent -from bunq.sdk.model.generated.object_ import DraftShareInviteEntry -from bunq.sdk.model.generated.object_ import ShareDetail -from bunq.sdk.model.generated.object_ import ShareDetailReadOnly -from tests.bunq_test import BunqSdkTestCase - - -class TestDraftShareInvite(BunqSdkTestCase): - """ - Tests: - DraftShareInviteBankEntry - DraftShareInviteBankQrCodeContent - """ - - _OUT_PUT_FILE_PATH = 'connectQr.png' - _WRITE_BYTES = 'wb' - _EXPIRATION_ADDED_TIME = 1 - - def test_draft_share_invite_bank(self): - """ - Tests the creation of a connect and retrieves the QR code bound to - this connect. - - This test has no assertion as of its testing to see if the code runs - without errors - """ - - share_detail = ShareDetail( - read_only=ShareDetailReadOnly(True, True, True) - ) - share_settings = DraftShareInviteEntry(share_detail) - - draft_id = DraftShareInviteBank.create(self.expiration_date, - share_settings).value - - connect_qr = DraftShareInviteBankQrCodeContent.list(draft_id).value - - with open(self._OUT_PUT_FILE_PATH, self._WRITE_BYTES) as f: - f.write(connect_qr) - - @property - def expiration_date(self): - """ - :rtype: str - """ - - date = datetime.utcnow() + timedelta(hours=self._EXPIRATION_ADDED_TIME) - - return date.isoformat() diff --git a/tests/model/generated/endpoint/test_monetary_account_bank.py b/tests/model/generated/endpoint/test_monetary_account_bank.py index a16e1d4..ad91f18 100644 --- a/tests/model/generated/endpoint/test_monetary_account_bank.py +++ b/tests/model/generated/endpoint/test_monetary_account_bank.py @@ -1,7 +1,14 @@ -from secrets import token_hex +try: + from secrets import token_hex +except ImportError: + from os import urandom -from bunq.sdk.context import BunqContext -from bunq.sdk.model.generated.endpoint import MonetaryAccountBank + + def token_hex(): + """ Function to replace import for Python < 3.6. """ + return urandom(16).hex() + +from bunq.sdk.model.generated.endpoint import MonetaryAccountBankApiObject from tests.bunq_test import BunqSdkTestCase @@ -27,12 +34,12 @@ def test_create_new_monetary_account(self): without errors """ - monetary_account_id = MonetaryAccountBank.create( + monetary_account_id = MonetaryAccountBankApiObject.create( self._CURRENCY, self._MONETARY_ACCOUNT_PREFIX + token_hex() ).value - MonetaryAccountBank.update(monetary_account_id, + MonetaryAccountBankApiObject.update(monetary_account_id, status=self._STATUS, sub_status=self._SUB_STATUS, reason=self._REASON, diff --git a/tests/model/generated/endpoint/test_monetary_account_joint.py b/tests/model/generated/endpoint/test_monetary_account_joint.py index c389ebe..ddf65a3 100644 --- a/tests/model/generated/endpoint/test_monetary_account_joint.py +++ b/tests/model/generated/endpoint/test_monetary_account_joint.py @@ -1,13 +1,13 @@ import os -from bunq.sdk.model.generated.endpoint import MonetaryAccountJoint +from bunq.sdk.model.generated.endpoint import MonetaryAccountJointApiObject from tests.bunq_test import BunqSdkTestCase class TestMonetaryAccountJoint(BunqSdkTestCase): """ Tests: - - MonetaryAccountJoint + - MonetaryAccountJointApiObject - CoOwner """ @@ -23,24 +23,17 @@ def setUp(self): pass def test_monetary_account_joint_parser(self): - """ - """ - base_path = os.path.dirname(__file__) file_path = os.path.abspath( - os.path.join(base_path, - self._BASE_PATH_JSON_MODEL + - self._MONETARY_ACCOUNT_JOINT_JSON - ) + os.path.join(base_path, self._BASE_PATH_JSON_MODEL + self._MONETARY_ACCOUNT_JOINT_JSON) ) with open(file_path, self._FILE_MODE_READ) as f: json_string = f.read() - joint_account: MonetaryAccountJoint = MonetaryAccountJoint.from_json( - json_string - ) + joint_account = MonetaryAccountJointApiObject.from_json(json_string) + self.assertIsInstance(joint_account, MonetaryAccountJointApiObject) self.assertIsNotNone(joint_account) self.assertIsNotNone(joint_account.all_co_owner) diff --git a/tests/model/generated/endpoint/test_payment.py b/tests/model/generated/endpoint/test_payment.py index 88661d6..9ce6052 100644 --- a/tests/model/generated/endpoint/test_payment.py +++ b/tests/model/generated/endpoint/test_payment.py @@ -1,14 +1,14 @@ from typing import List -from bunq.sdk.model.generated import endpoint -from bunq.sdk.model.generated import object_ +from bunq.sdk.model.generated.endpoint import PaymentApiObject, PaymentBatchApiObject, BunqResponseInt, BunqResponsePaymentBatch +from bunq.sdk.model.generated.object_ import AmountObject, PointerObject from tests.bunq_test import BunqSdkTestCase class TestPayment(BunqSdkTestCase): """ Tests: - Payment + PaymentApiObject PaymentChat ChatMessageText """ @@ -28,8 +28,8 @@ def test_payment_to_other_user(self): without errors """ - endpoint.Payment.create( - object_.Amount(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), + PaymentApiObject.create( + AmountObject(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), self._get_pointer_bravo(), self._PAYMENT_DESCRIPTION ) @@ -42,46 +42,36 @@ def test_payment_to_other_account(self): without errors """ - endpoint.Payment.create( - object_.Amount(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), + PaymentApiObject.create( + AmountObject(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), self._get_alias_second_account(), self._PAYMENT_DESCRIPTION ) def test_payment_batch(self): - """ - """ - - response_create: endpoint.BunqResponseInt = \ - endpoint.PaymentBatch.create( - self.__create_payment_list() - ) + response_create = PaymentBatchApiObject.create(self.__create_payment_list()) + self.assertIsInstance(response_create, BunqResponseInt) self.assertIsNotNone(response_create) - response_get: endpoint.BunqResponsePaymentBatch = \ - endpoint.PaymentBatch.get(response_create.value) + response_get = PaymentBatchApiObject.get(response_create.value) + self.assertIsInstance(response_get, BunqResponsePaymentBatch) self.assertIsNotNone(response_get) self.assertFalse(response_get.value.is_all_field_none()) - def __create_payment_list(self) -> List[endpoint.Payment]: - """ - :rtype: List[Payment] - """ - - all_payment: List[endpoint.Payment] = [] + def __create_payment_list(self) -> List[PaymentApiObject]: + all_payment = [] while len(all_payment) < self._MAXIMUM_PAYMENT_IN_BATCH: all_payment.append( - endpoint.Payment( - object_.Amount( - self._PAYMENT_AMOUNT_EUR, - self._PAYMENT_CURRENCY - ), - object_.Pointer(self._POINTER_EMAIL, self._EMAIL_BRAVO), + PaymentApiObject( + AmountObject(self._PAYMENT_AMOUNT_EUR, self._PAYMENT_CURRENCY), + PointerObject(self._POINTER_EMAIL, self._EMAIL_BRAVO), self._PAYMENT_DESCRIPTION ) ) + self.assertIsInstance(all_payment, List) + self.assertIsInstance(all_payment[0], PaymentApiObject) return all_payment diff --git a/tests/model/generated/endpoint/test_request_inquiry.py b/tests/model/generated/endpoint/test_request_inquiry.py index 6af6c04..e2c0640 100644 --- a/tests/model/generated/endpoint/test_request_inquiry.py +++ b/tests/model/generated/endpoint/test_request_inquiry.py @@ -1,20 +1,22 @@ -from bunq.sdk.model.generated.endpoint import RequestInquiry -from bunq.sdk.model.generated.endpoint import RequestResponse -from bunq.sdk.model.generated.object_ import Amount +from bunq.sdk.model.generated.endpoint import RequestInquiryApiObject +from bunq.sdk.model.generated.endpoint import RequestResponseApiObject +from bunq.sdk.model.generated.object_ import AmountObject from tests.bunq_test import BunqSdkTestCase class TestRequestEnquiry(BunqSdkTestCase): """ Tests: - RequestInquiry - RequestResponse + RequestInquiryApiObject + RequestResponseApiObject """ _REQUEST_AMOUNT_EUR = '0.01' _REQUEST_CURRENCY = 'EUR' _DESCRIPTION = 'Python unit test request' - _STATUS = 'ACCEPTED' + _FIELD_STATUS = 'status' + _STATUS_ACCEPTED = 'ACCEPTED' + _STATUS_PENDING = 'PENDING' def test_sending_and_accepting_request(self): """ @@ -27,33 +29,26 @@ def test_sending_and_accepting_request(self): self.send_request() - request_response_id = \ - RequestResponse.list(self._second_monetary_account.id_).value[ - self._FIRST_INDEX - ].id_ + url_params_count_only_expected = { + self._FIELD_STATUS: self._STATUS_PENDING + } - self.accept_request(request_response_id) + request_response_id = RequestResponseApiObject.list(self._second_monetary_account.id_, url_params_count_only_expected).value[self._FIRST_INDEX].id_ - def send_request(self): - """ - :rtype: None - """ + self.accept_request(request_response_id) - RequestInquiry.create( - Amount(self._REQUEST_AMOUNT_EUR, self._REQUEST_CURRENCY), + def send_request(self) -> None: + RequestInquiryApiObject.create( + AmountObject(self._REQUEST_AMOUNT_EUR, self._REQUEST_CURRENCY), self._get_alias_second_account(), self._DESCRIPTION, False ) - def accept_request(self, response_id): - """ - :param response_id: - :rtype response_id: int - """ - - RequestResponse.update( + def accept_request(self, response_id: int) -> None: + RequestResponseApiObject.update( response_id, - monetary_account_id=self._second_monetary_account.id_, - status=self._STATUS - ) + self._second_monetary_account.id_, + None, + self._STATUS_ACCEPTED + ) \ No newline at end of file diff --git a/tests/model/generated/endpoint/test_session.py b/tests/model/generated/endpoint/test_session.py index d70da5b..78c3bbe 100644 --- a/tests/model/generated/endpoint/test_session.py +++ b/tests/model/generated/endpoint/test_session.py @@ -1,14 +1,14 @@ import time -from bunq.sdk.context import BunqContext -from bunq.sdk.model.generated.endpoint import Session +from bunq.sdk.context.bunq_context import BunqContext +from bunq.sdk.model.generated.endpoint import SessionApiObject from tests.bunq_test import BunqSdkTestCase class TestSession(BunqSdkTestCase): """ Tests: - Session + SessionApiObject """ _SESSION_ID = 0 @@ -28,7 +28,7 @@ def test_session_delete(self): Session endpoint per second. """ - Session.delete(self._SESSION_ID) + SessionApiObject.delete(self._SESSION_ID) time.sleep(2) BunqContext.api_context().reset_session() BunqContext.api_context().save(self._BUNQ_CONFIG_FILE) diff --git a/tests/model/generated/endpoint/test_tab_usage_single.py b/tests/model/generated/endpoint/test_tab_usage_single.py deleted file mode 100644 index b1c9904..0000000 --- a/tests/model/generated/endpoint/test_tab_usage_single.py +++ /dev/null @@ -1,68 +0,0 @@ -import unittest - -from bunq.sdk.context import BunqContext -from bunq.sdk.model.generated.endpoint import TabItemShop -from bunq.sdk.model.generated.endpoint import TabUsageSingle -from bunq.sdk.model.generated.object_ import Amount -from tests.bunq_test import BunqSdkTestCase - - -class TestTabUsageSingle(BunqSdkTestCase): - """ - Tests: - TabUsageSingle - TabItemShop - """ - - _AMOUNT_EUR = '0.02' - _CURRENCY = 'EUR' - _STATUS_OPEN = 'OPEN' - _STATUS_WAITING = 'WAITING_FOR_PAYMENT' - _TAB_ITEM_DESCRIPTION = 'Super expensive python tea' - _TAB_DESCRIPTION = 'Pay the tab for Python test please.' - _ERROR_ONLY_USER_COMPANY_CAN_CREATE_TAB =\ - 'Only user company can create/use cash registers.' - - def test_create_and_update_tab(self): - """ - Tests the creation of a Tab, adds a tab item to it and updates this tab - - This test has no assertion as of its testing to see if the code runs - without errors - """ - - if BunqContext.user_context().is_only_user_person_set(): - return unittest.skip( - self._ERROR_ONLY_USER_COMPANY_CAN_CREATE_TAB - ) - - tab_uuid = TabUsageSingle.create(self._get_cash_register_id(), - self._TAB_DESCRIPTION, - self._STATUS_OPEN, - Amount(self._AMOUNT_EUR, - self._CURRENCY)).value - - self._add_item_to_tab(tab_uuid) - self._update_tab(tab_uuid) - - def _add_item_to_tab(self, tab_uuid): - """ - :param tab_uuid: - :type tab_uuid: str - """ - - TabItemShop.create( - self._get_cash_register_id(), tab_uuid, - self._TAB_ITEM_DESCRIPTION - ) - - def _update_tab(self, tab_uuid): - """ - :param tab_uuid: - :type tab_uuid: str - """ - - TabUsageSingle.update( - self._get_cash_register_id(), - tab_uuid - ) diff --git a/tests/model/generated/object/test_notification_url.py b/tests/model/generated/object/test_notification_url.py index 8a3f55b..bbc997b 100644 --- a/tests/model/generated/object/test_notification_url.py +++ b/tests/model/generated/object/test_notification_url.py @@ -1,10 +1,14 @@ import json import os +from typing import Optional -from bunq.sdk.json.converter import json_to_class -from bunq.sdk.model import core +from bunq.sdk.model.core.bunq_model import BunqModel from bunq.sdk.model.generated import endpoint from bunq.sdk.model.generated import object_ +from bunq.sdk.model.generated.endpoint import PaymentApiObject, BunqMeTabApiObject, DraftPaymentApiObject, MasterCardActionApiObject, MonetaryAccountApiObject, \ + MonetaryAccountBankApiObject, PaymentBatchApiObject, RequestInquiryApiObject, RequestResponseApiObject, SchedulePaymentApiObject, ScheduleInstanceApiObject, \ + ShareInviteMonetaryAccountInquiryApiObject, ShareInviteMonetaryAccountResponseApiObject +from bunq.sdk.model.generated.object_ import NotificationUrlObject from tests import bunq_test @@ -27,30 +31,20 @@ class TestNotificationUrl(bunq_test.BunqSdkTestCase): _GETTER_SHARE_INVITE_BANK_RESPONSE = 'ShareInviteBankResponse' # Model json paths constants. - BASE_PATH_JSON_MODEL = '../../../assets/NotficationUrlJsons' + BASE_PATH_JSON_MODEL = '../../../assets/NotificationUrlJsons' JSON_PATH_MUTATION_MODEL = BASE_PATH_JSON_MODEL + '/Mutation.json' JSON_PATH_BUNQ_ME_TAB_MODEL = BASE_PATH_JSON_MODEL + '/BunqMeTab.json' - JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL = \ - BASE_PATH_JSON_MODEL + '/ChatMessageAnnouncement.json' + JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL = BASE_PATH_JSON_MODEL + '/ChatMessageAnnouncement.json' JSON_PATH_DRAFT_PAYMENT_MODEL = BASE_PATH_JSON_MODEL + '/DraftPayment.json' - JSON_PATH_MASTER_CARD_ACTION_MODEL = \ - BASE_PATH_JSON_MODEL + '/MasterCardAction.json' - JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL = \ - BASE_PATH_JSON_MODEL + '/MonetaryAccountBank.json' - JSON_PATH_PAYMENT_BATCH_MODEL = \ - BASE_PATH_JSON_MODEL + '/PaymentBatch.json' - JSON_PATH_REQUEST_INQUIRY_MODEL = \ - BASE_PATH_JSON_MODEL + '/RequestInquiry.json' - JSON_PATH_REQUEST_RESPONSE_MODEL = \ - BASE_PATH_JSON_MODEL + '/RequestResponse.json' - JSON_PATH_SCHEDULE_PAYMENT_MODEL = \ - BASE_PATH_JSON_MODEL + '/ScheduledPayment.json' - JSON_PATH_SCHEDULE_INSTANCE_MODEL = \ - BASE_PATH_JSON_MODEL + '/ScheduledInstance.json' - JSON_PATH_SHARE_INVITE_BANK_INQUIRY_MODEL = \ - BASE_PATH_JSON_MODEL + '/ShareInviteBankInquiry.json' - JSON_PATH_SHARE_INVITE_BANK_RESPONSE_MODEL = \ - BASE_PATH_JSON_MODEL + '/ShareInviteBankResponse.json' + JSON_PATH_MASTER_CARD_ACTION_MODEL = BASE_PATH_JSON_MODEL + '/MasterCardAction.json' + JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL = BASE_PATH_JSON_MODEL + '/MonetaryAccountBank.json' + JSON_PATH_PAYMENT_BATCH_MODEL = BASE_PATH_JSON_MODEL + '/PaymentBatch.json' + JSON_PATH_REQUEST_INQUIRY_MODEL = BASE_PATH_JSON_MODEL + '/RequestInquiry.json' + JSON_PATH_REQUEST_RESPONSE_MODEL = BASE_PATH_JSON_MODEL + '/RequestResponse.json' + JSON_PATH_SCHEDULE_PAYMENT_MODEL = BASE_PATH_JSON_MODEL + '/ScheduledPayment.json' + JSON_PATH_SCHEDULE_INSTANCE_MODEL = BASE_PATH_JSON_MODEL + '/ScheduledInstance.json' + JSON_PATH_SHARE_INVITE_BANK_INQUIRY_MODEL = BASE_PATH_JSON_MODEL + '/ShareInviteBankInquiry.json' + JSON_PATH_SHARE_INVITE_BANK_RESPONSE_MODEL = BASE_PATH_JSON_MODEL + '/ShareInviteBankResponse.json' # Model root key. _KEY_NOTIFICATION_URL_MODEL = 'NotificationUrl' @@ -72,21 +66,11 @@ def setUp(self): _FILE_MODE_READ = 'r' def execute_notification_url_test(self, - file_path, - class_name, - getter_name, - sub_class_expected_object_name=None, - sub_class_getter_name=None): - """ - :type sub_class_getter_name: str - :type sub_class_expected_object_name: str - :type file_path: str - :type class_name: str - :type getter_name: str - - :return: None - """ - + file_path: str, + class_name: str, + getter_name: str, + sub_class_expected_object_name: str = None, + sub_class_getter_name: str = None) -> None: notification_url = self.get_notification_url(file_path) self.assertIsNotNone(notification_url) self.assertIsNotNone(notification_url.object_) @@ -96,35 +80,16 @@ def execute_notification_url_test(self, self.assertIsNotNone(expected_model) self.assertIsNotNone(referenced_model) - self.assertTrue( - self.is_model_reference( - referenced_model, - class_name - ) - ) + self.assertTrue(self.is_model_reference(referenced_model, class_name)) if sub_class_expected_object_name is not None: sub_class_model = getattr(referenced_model, sub_class_getter_name) self.assertIsNotNone(sub_class_model) - self.assertTrue( - isinstance( - sub_class_model, - self.get_model_type_or_none( - sub_class_expected_object_name - ) - ) - ) + self.assertTrue(isinstance(sub_class_model, self.get_model_type_or_none(sub_class_expected_object_name))) @classmethod - def is_model_reference(cls, referenced_model, class_name): - """ - :type referenced_model: core.BunqModel - :type class_name: str - - :rtype: bool - """ - + def is_model_reference(cls, referenced_model: BunqModel, class_name: str) -> bool: model_type = cls.get_model_type_or_none(class_name) if model_type is None: @@ -133,124 +98,108 @@ def is_model_reference(cls, referenced_model, class_name): return isinstance(referenced_model, model_type) @classmethod - def get_model_type_or_none(cls, class_name): - """ - :type class_name: str - - :rtype: type|None - """ - + def get_model_type_or_none(cls, class_name: str) -> Optional[type]: for module_ in cls._MODEL_MODULES: if hasattr(module_, class_name): return getattr(module_, class_name) return None - def get_notification_url(self, file_path): - """ - :type file_path: str - - :rtype: object_.NotificationUrl - """ - + def get_notification_url(self, file_path: str) -> NotificationUrlObject: base_path = os.path.dirname(__file__) file_path = os.path.abspath(os.path.join(base_path, file_path)) with open(file_path, self._FILE_MODE_READ) as f: json_string = f.read() json_object = json.loads(json_string) - json_string = json.dumps( - json_object[self._KEY_NOTIFICATION_URL_MODEL] - ) + json_string = json.dumps(json_object[self._KEY_NOTIFICATION_URL_MODEL]) - self.assertTrue( - self._KEY_NOTIFICATION_URL_MODEL in json_object - ) + self.assertTrue(self._KEY_NOTIFICATION_URL_MODEL in json_object) - return object_.NotificationUrl.from_json(json_string) + return NotificationUrlObject.from_json(json_string) def test_mutation_model(self): self.execute_notification_url_test( self.JSON_PATH_MUTATION_MODEL, - endpoint.Payment.__name__, + PaymentApiObject.__name__, self._GETTER_PAYMENT ) def test_bunq_me_tab_model(self): self.execute_notification_url_test( self.JSON_PATH_BUNQ_ME_TAB_MODEL, - endpoint.BunqMeTab.__name__, + BunqMeTabApiObject.__name__, self._GETTER_BUNQ_ME_TAB ) def test_draft_payment_model(self): self.execute_notification_url_test( self.JSON_PATH_DRAFT_PAYMENT_MODEL, - endpoint.DraftPayment.__name__, + DraftPaymentApiObject.__name__, self._GETTER_DRAFT_PAYMENT ) def test_mastercard_action(self): self.execute_notification_url_test( self.JSON_PATH_MASTER_CARD_ACTION_MODEL, - endpoint.MasterCardAction.__name__, + MasterCardActionApiObject.__name__, self._GETTER_MASTER_CARD_ACTION ) def test_monetary_account_bank_model(self): self.execute_notification_url_test( self.JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL, - endpoint.MonetaryAccount.__name__, + MonetaryAccountApiObject.__name__, self._GETTER_MONETARY_ACCOUNT, - endpoint.MonetaryAccountBank.__name__, + MonetaryAccountBankApiObject.__name__, self._GETTER_MONETARY_ACCOUNT_BANK ) def test_payment_batch_model(self): self.execute_notification_url_test( self.JSON_PATH_PAYMENT_BATCH_MODEL, - endpoint.PaymentBatch.__name__, + PaymentBatchApiObject.__name__, self._GETTER_PAYMENT_BATCH ) def test_request_inquiry_model(self): self.execute_notification_url_test( self.JSON_PATH_REQUEST_INQUIRY_MODEL, - endpoint.RequestInquiry.__name__, + RequestInquiryApiObject.__name__, self._GETTER_REQUEST_INQUIRY ) def test_request_response_model(self): self.execute_notification_url_test( self.JSON_PATH_REQUEST_RESPONSE_MODEL, - endpoint.RequestResponse.__name__, + RequestResponseApiObject.__name__, self._GETTER_REQUEST_RESPONSE ) def test_scheduled_payment_model(self): self.execute_notification_url_test( self.JSON_PATH_SCHEDULE_PAYMENT_MODEL, - endpoint.SchedulePayment.__name__, + SchedulePaymentApiObject.__name__, self._GETTER_SCHEDULE_PAYMENT ) def test_scheduled_instance_model(self): self.execute_notification_url_test( self.JSON_PATH_SCHEDULE_INSTANCE_MODEL, - endpoint.ScheduleInstance.__name__, + ScheduleInstanceApiObject.__name__, self._GETTER_SCHEDULE_INSTANCE ) def test_share_invite_bank_inquiry(self): self.execute_notification_url_test( self.JSON_PATH_SHARE_INVITE_BANK_INQUIRY_MODEL, - endpoint.ShareInviteBankInquiry.__name__, + ShareInviteMonetaryAccountInquiryApiObject.__name__, self._GETTER_SHARE_INVITE_BANK_INQUIRY ) def test_share_invite_bank_response(self): self.execute_notification_url_test( self.JSON_PATH_SHARE_INVITE_BANK_RESPONSE_MODEL, - endpoint.ShareInviteBankResponse.__name__, + ShareInviteMonetaryAccountResponseApiObject.__name__, self._GETTER_SHARE_INVITE_BANK_RESPONSE )