From 48ffb09f1a76a37e6cc0ff025a3ccd89eaa468f2 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 1 Mar 2023 15:34:04 +0000 Subject: [PATCH 1/2] ci: regenerated with OpenAPI Doc 2.1.0, Speakeay CLI 1.7.0 --- bankfeeds/README.md | 65 ++ bankfeeds/RELEASES.md | 9 + bankfeeds/USAGE.md | 35 + bankfeeds/files.gen | 19 + bankfeeds/gen.yaml | 9 +- bankfeeds/setup.py | 36 + bankfeeds/src/codat/__init__.py | 1 + .../src/codat/bank_account_transactions.py | 108 +++ bankfeeds/src/codat/bank_feed_accounts.py | 105 +++ bankfeeds/src/codat/models/__init__.py | 0 .../src/codat/models/operations/__init__.py | 8 + .../get_bank_account_push_options.py | 229 ++++++ .../codat/models/operations/get_bank_feeds.py | 58 ++ .../list_all_bank_transactionscount.py | 154 ++++ .../operations/post_bank_transactions.py | 235 ++++++ .../codat/models/operations/put_bank_feeds.py | 59 ++ .../models/operations/update_bank_feed.py | 60 ++ bankfeeds/src/codat/models/shared/__init__.py | 3 + bankfeeds/src/codat/models/shared/security.py | 9 + bankfeeds/src/codat/sdk.py | 75 ++ bankfeeds/src/codat/utils/__init__.py | 2 + bankfeeds/src/codat/utils/retries.py | 116 +++ bankfeeds/src/codat/utils/utils.py | 700 ++++++++++++++++++ 23 files changed, 2094 insertions(+), 1 deletion(-) create mode 100755 bankfeeds/README.md create mode 100644 bankfeeds/RELEASES.md create mode 100755 bankfeeds/USAGE.md create mode 100755 bankfeeds/files.gen create mode 100755 bankfeeds/setup.py create mode 100755 bankfeeds/src/codat/__init__.py create mode 100755 bankfeeds/src/codat/bank_account_transactions.py create mode 100755 bankfeeds/src/codat/bank_feed_accounts.py create mode 100755 bankfeeds/src/codat/models/__init__.py create mode 100755 bankfeeds/src/codat/models/operations/__init__.py create mode 100755 bankfeeds/src/codat/models/operations/get_bank_account_push_options.py create mode 100755 bankfeeds/src/codat/models/operations/get_bank_feeds.py create mode 100755 bankfeeds/src/codat/models/operations/list_all_bank_transactionscount.py create mode 100755 bankfeeds/src/codat/models/operations/post_bank_transactions.py create mode 100755 bankfeeds/src/codat/models/operations/put_bank_feeds.py create mode 100755 bankfeeds/src/codat/models/operations/update_bank_feed.py create mode 100755 bankfeeds/src/codat/models/shared/__init__.py create mode 100755 bankfeeds/src/codat/models/shared/security.py create mode 100755 bankfeeds/src/codat/sdk.py create mode 100755 bankfeeds/src/codat/utils/__init__.py create mode 100755 bankfeeds/src/codat/utils/retries.py create mode 100755 bankfeeds/src/codat/utils/utils.py diff --git a/bankfeeds/README.md b/bankfeeds/README.md new file mode 100755 index 000000000..f3430b843 --- /dev/null +++ b/bankfeeds/README.md @@ -0,0 +1,65 @@ +# codat-bankfeeds + + +## SDK Installation + +```bash +pip install codat-bankfeeds +``` + + +## SDK Example Usage + +```python +import codat +from codat.models import operations, shared + +s = codat.Codat() +s.config_security( + security=shared.Security( + api_key="YOUR_API_KEY_HERE", + ) +) + +req = operations.GetBankAccountPushOptionsRequest( + security=operations.GetBankAccountPushOptionsSecurity( + api_key="YOUR_API_KEY_HERE", + ), + path_params=operations.GetBankAccountPushOptionsPathParams( + account_id="unde", + company_id="deserunt", + connection_id="porro", + ), + query_params=operations.GetBankAccountPushOptionsQueryParams( + order_by="nulla", + page=6027.63, + page_size=8579.46, + query="perspiciatis", + ), +) + +res = s.bank_account_transactions.get_bank_account_push_options(req) + +if res.push_option is not None: + # handle response +``` + + + +## SDK Available Operations + + +### bank_account_transactions + +* `get_bank_account_push_options` - List push options for bank account bank transactions +* `list_all_bank_transactionscount` - List bank transactions for bank account +* `post_bank_transactions` - Create bank transactions + +### bank_feed_accounts + +* `get_bank_feeds` - List bank feed bank accounts +* `put_bank_feeds` - Update bank feed bank accounts +* `update_bank_feed` - Update bank feed bank account + + +### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks) diff --git a/bankfeeds/RELEASES.md b/bankfeeds/RELEASES.md new file mode 100644 index 000000000..888b52e83 --- /dev/null +++ b/bankfeeds/RELEASES.md @@ -0,0 +1,9 @@ + + +## 2023-03-01 15:34:00 +### Changes +Based on: +- OpenAPI Doc 2.1.0 https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Bank-Feeds.yaml +- Speakeasy CLI 1.7.0 https://github.com/speakeasy-api/speakeasy +### Releases +- [PyPI v0.1.0] https://pypi.org/project/codat-bankfeeds/0.1.0 - bankfeeds \ No newline at end of file diff --git a/bankfeeds/USAGE.md b/bankfeeds/USAGE.md new file mode 100755 index 000000000..c802447be --- /dev/null +++ b/bankfeeds/USAGE.md @@ -0,0 +1,35 @@ + +```python +import codat +from codat.models import operations, shared + +s = codat.Codat() +s.config_security( + security=shared.Security( + api_key="YOUR_API_KEY_HERE", + ) +) + +req = operations.GetBankAccountPushOptionsRequest( + security=operations.GetBankAccountPushOptionsSecurity( + api_key="YOUR_API_KEY_HERE", + ), + path_params=operations.GetBankAccountPushOptionsPathParams( + account_id="unde", + company_id="deserunt", + connection_id="porro", + ), + query_params=operations.GetBankAccountPushOptionsQueryParams( + order_by="nulla", + page=6027.63, + page_size=8579.46, + query="perspiciatis", + ), +) + +res = s.bank_account_transactions.get_bank_account_push_options(req) + +if res.push_option is not None: + # handle response +``` + \ No newline at end of file diff --git a/bankfeeds/files.gen b/bankfeeds/files.gen new file mode 100755 index 000000000..fc0f39a39 --- /dev/null +++ b/bankfeeds/files.gen @@ -0,0 +1,19 @@ +src/codat/bank_account_transactions.py +src/codat/bank_feed_accounts.py +src/codat/sdk.py +setup.py +src/codat/__init__.py +src/codat/models/__init__.py +src/codat/utils/__init__.py +src/codat/utils/retries.py +src/codat/utils/utils.py +src/codat/models/operations/get_bank_account_push_options.py +src/codat/models/operations/list_all_bank_transactionscount.py +src/codat/models/operations/post_bank_transactions.py +src/codat/models/operations/get_bank_feeds.py +src/codat/models/operations/put_bank_feeds.py +src/codat/models/operations/update_bank_feed.py +src/codat/models/operations/__init__.py +src/codat/models/shared/security.py +src/codat/models/shared/__init__.py +USAGE.md \ No newline at end of file diff --git a/bankfeeds/gen.yaml b/bankfeeds/gen.yaml index b13ab5be3..2fe252a6d 100644 --- a/bankfeeds/gen.yaml +++ b/bankfeeds/gen.yaml @@ -1,7 +1,14 @@ configVersion: 1.0.0 +management: + docChecksum: 2850b50909854a03af955e915ac1f608 + docVersion: 2.1.0 + speakeasyVersion: 1.7.0 generation: + telemetryEnabled: false sdkClassName: codat sdkFlattening: true python: - version: 0.0.1 + version: 0.1.0 + author: Speakeasy + description: Python Client SDK Generated by Speakeasy packageName: codat-bankfeeds diff --git a/bankfeeds/setup.py b/bankfeeds/setup.py new file mode 100755 index 000000000..b98e889c7 --- /dev/null +++ b/bankfeeds/setup.py @@ -0,0 +1,36 @@ +import setuptools + +try: + with open("README.md", "r") as fh: + long_description = fh.read() +except FileNotFoundError: + long_description = "" + +setuptools.setup( + name="codat-bankfeeds", + version="0.1.0", + author="Speakeasy", + description="Python Client SDK Generated by Speakeasy", + long_description=long_description, + long_description_content_type="text/markdown", + packages=setuptools.find_packages(where="src"), + install_requires=[ + "certifi==2022.12.07", + "charset-normalizer==2.1.1", + "dataclasses-json-speakeasy==0.5.8", + "idna==3.3", + "marshmallow==3.17.1", + "marshmallow-enum==1.5.1", + "mypy-extensions==0.4.3", + "packaging==21.3", + "pyparsing==3.0.9", + "python-dateutil==2.8.2", + "requests==2.28.1", + "six==1.16.0", + "typing-inspect==0.8.0", + "typing_extensions==4.3.0", + "urllib3==1.26.12", + ], + package_dir={'': 'src'}, + python_requires='>=3.9' +) diff --git a/bankfeeds/src/codat/__init__.py b/bankfeeds/src/codat/__init__.py new file mode 100755 index 000000000..8d74a7d2f --- /dev/null +++ b/bankfeeds/src/codat/__init__.py @@ -0,0 +1 @@ +from .sdk import * \ No newline at end of file diff --git a/bankfeeds/src/codat/bank_account_transactions.py b/bankfeeds/src/codat/bank_account_transactions.py new file mode 100755 index 000000000..c37da07f2 --- /dev/null +++ b/bankfeeds/src/codat/bank_account_transactions.py @@ -0,0 +1,108 @@ +import requests +from . import utils +from codat.models import operations +from typing import Optional + +class BankAccountTransactions: + _client: requests.Session + _security_client: requests.Session + _server_url: str + _language: str + _sdk_version: str + _gen_version: str + + def __init__(self, client: requests.Session, security_client: requests.Session, server_url: str, language: str, sdk_version: str, gen_version: str) -> None: + self._client = client + self._security_client = security_client + self._server_url = server_url + self._language = language + self._sdk_version = sdk_version + self._gen_version = gen_version + + + def get_bank_account_push_options(self, request: operations.GetBankAccountPushOptionsRequest) -> operations.GetBankAccountPushOptionsResponse: + r"""List push options for bank account bank transactions + Gets the options of pushing bank account transactions. + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/options/bankAccounts/{accountId}/bankTransactions", request.path_params) + + query_params = utils.get_query_params(request.query_params) + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("GET", url, params=query_params) + content_type = r.headers.get("Content-Type") + + res = operations.GetBankAccountPushOptionsResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[operations.GetBankAccountPushOptionsPushOption]) + res.push_option = out + + return res + + + def list_all_bank_transactionscount(self, request: operations.ListAllBankTransactionscountRequest) -> operations.ListAllBankTransactionscountResponse: + r"""List bank transactions for bank account + Gets bank transactions for a given bank account ID + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/data/bankAccounts/{accountId}/bankTransactions", request.path_params) + + query_params = utils.get_query_params(request.query_params) + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("GET", url, params=query_params) + content_type = r.headers.get("Content-Type") + + res = operations.ListAllBankTransactionscountResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[operations.ListAllBankTransactionscountLinks]) + res.links = out + + return res + + + def post_bank_transactions(self, request: operations.PostBankTransactionsRequest) -> operations.PostBankTransactionsResponse: + r"""Create bank transactions + Posts bank transactions to the accounting package for a given company. + + > **Supported Integrations** + > + > Check out our [Knowledge UI](https://knowledge.codat.io/supported-features/accounting?view=tab-by-data-type&dataType=bankTransactions) for integrations that support POST methods. + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/push/bankAccounts/{accountId}}/bankTransactions", request.path_params) + + headers = {} + req_content_type, data, form = utils.serialize_request_body(request) + if req_content_type != "multipart/form-data" and req_content_type != "multipart/mixed": + headers["content-type"] = req_content_type + query_params = utils.get_query_params(request.query_params) + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("POST", url, params=query_params, data=data, files=form, headers=headers) + content_type = r.headers.get("Content-Type") + + res = operations.PostBankTransactionsResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[operations.PostBankTransactions200ApplicationJSON]) + res.post_bank_transactions_200_application_json_object = out + + return res + + \ No newline at end of file diff --git a/bankfeeds/src/codat/bank_feed_accounts.py b/bankfeeds/src/codat/bank_feed_accounts.py new file mode 100755 index 000000000..10e23659a --- /dev/null +++ b/bankfeeds/src/codat/bank_feed_accounts.py @@ -0,0 +1,105 @@ +import requests +from . import utils +from codat.models import operations +from typing import Optional + +class BankFeedAccounts: + _client: requests.Session + _security_client: requests.Session + _server_url: str + _language: str + _sdk_version: str + _gen_version: str + + def __init__(self, client: requests.Session, security_client: requests.Session, server_url: str, language: str, sdk_version: str, gen_version: str) -> None: + self._client = client + self._security_client = security_client + self._server_url = server_url + self._language = language + self._sdk_version = sdk_version + self._gen_version = gen_version + + + def get_bank_feeds(self, request: operations.GetBankFeedsRequest) -> operations.GetBankFeedsResponse: + r"""List bank feed bank accounts + Get BankFeed BankAccounts for a single data source connected to a single company. + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/connectionInfo/bankFeedAccounts", request.path_params) + + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("GET", url) + content_type = r.headers.get("Content-Type") + + res = operations.GetBankFeedsResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[list[operations.GetBankFeedsBankFeedBankAccount]]) + res.bank_feed_bank_accounts = out + + return res + + + def put_bank_feeds(self, request: operations.PutBankFeedsRequest) -> operations.PutBankFeedsResponse: + r"""Update bank feed bank accounts + Put BankFeed BankAccounts for a single data source connected to a single company. + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/connectionInfo/bankFeedAccounts", request.path_params) + + headers = {} + req_content_type, data, form = utils.serialize_request_body(request) + if req_content_type != "multipart/form-data" and req_content_type != "multipart/mixed": + headers["content-type"] = req_content_type + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("PUT", url, data=data, files=form, headers=headers) + content_type = r.headers.get("Content-Type") + + res = operations.PutBankFeedsResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[list[operations.PutBankFeedsBankFeedBankAccount]]) + res.bank_feed_bank_accounts = out + + return res + + + def update_bank_feed(self, request: operations.UpdateBankFeedRequest) -> operations.UpdateBankFeedResponse: + r"""Update bank feed bank account + Update a single BankFeed BankAccount for a single data source connected to a single company. + """ + + base_url = self._server_url + + url = utils.generate_url(base_url, "/companies/{companyId}/connections/{connectionId}/connectionInfo/bankFeedAccounts/{bankAccountId}", request.path_params) + + headers = {} + req_content_type, data, form = utils.serialize_request_body(request) + if req_content_type != "multipart/form-data" and req_content_type != "multipart/mixed": + headers["content-type"] = req_content_type + + client = utils.configure_security_client(self._client, request.security) + + r = client.request("PATCH", url, data=data, files=form, headers=headers) + content_type = r.headers.get("Content-Type") + + res = operations.UpdateBankFeedResponse(status_code=r.status_code, content_type=content_type) + + if r.status_code == 200: + if utils.match_content_type(content_type, "application/json"): + out = utils.unmarshal_json(r.text, Optional[operations.UpdateBankFeedBankFeedBankAccount]) + res.bank_feed_bank_account = out + + return res + + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/__init__.py b/bankfeeds/src/codat/models/__init__.py new file mode 100755 index 000000000..e69de29bb diff --git a/bankfeeds/src/codat/models/operations/__init__.py b/bankfeeds/src/codat/models/operations/__init__.py new file mode 100755 index 000000000..79c97921b --- /dev/null +++ b/bankfeeds/src/codat/models/operations/__init__.py @@ -0,0 +1,8 @@ +from .get_bank_account_push_options import * +from .get_bank_feeds import * +from .list_all_bank_transactionscount import * +from .post_bank_transactions import * +from .put_bank_feeds import * +from .update_bank_feed import * + +__all__ = ["GetBankAccountPushOptionsPathParams","GetBankAccountPushOptionsPushOption","GetBankAccountPushOptionsPushOptionOptionTypeEnum","GetBankAccountPushOptionsPushOptionPushOptionChoice","GetBankAccountPushOptionsPushOptionPushOptionChoiceOptionTypeEnum","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoice","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoiceOptionTypeEnum","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoice","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoice","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfo","GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation","GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfo","GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfoPushFieldValidation","GetBankAccountPushOptionsPushOptionPushValidationInfo","GetBankAccountPushOptionsPushOptionPushValidationInfoPushFieldValidation","GetBankAccountPushOptionsQueryParams","GetBankAccountPushOptionsRequest","GetBankAccountPushOptionsResponse","GetBankAccountPushOptionsSecurity","GetBankFeedsBankFeedBankAccount","GetBankFeedsBankFeedBankAccountAccountTypeEnum","GetBankFeedsPathParams","GetBankFeedsRequest","GetBankFeedsResponse","GetBankFeedsSecurity","ListAllBankTransactionscountLinks","ListAllBankTransactionscountLinksLinks","ListAllBankTransactionscountLinksLinksCurrent","ListAllBankTransactionscountLinksLinksNext","ListAllBankTransactionscountLinksLinksPrevious","ListAllBankTransactionscountLinksLinksSelf","ListAllBankTransactionscountLinksResults","ListAllBankTransactionscountLinksResultsTransactions","ListAllBankTransactionscountLinksResultsTransactionsTransactionTypeEnum","ListAllBankTransactionscountPathParams","ListAllBankTransactionscountQueryParams","ListAllBankTransactionscountRequest","ListAllBankTransactionscountResponse","ListAllBankTransactionscountSecurity","PostBankTransactions200ApplicationJSON","PostBankTransactions200ApplicationJSONChanges","PostBankTransactions200ApplicationJSONChangesPushOperationRecordRef","PostBankTransactions200ApplicationJSONChangesTypeEnum","PostBankTransactions200ApplicationJSONData","PostBankTransactions200ApplicationJSONDataTransactions","PostBankTransactions200ApplicationJSONDataTransactionsTransactionTypeEnum","PostBankTransactions200ApplicationJSONStatusEnum","PostBankTransactions200ApplicationJSONValidation","PostBankTransactions200ApplicationJSONValidationValidationItem","PostBankTransactionsPathParams","PostBankTransactionsQueryParams","PostBankTransactionsRequest","PostBankTransactionsRequestBody","PostBankTransactionsRequestBodyTransactions","PostBankTransactionsRequestBodyTransactionsTransactionTypeEnum","PostBankTransactionsResponse","PostBankTransactionsSecurity","PutBankFeedsBankFeedBankAccount","PutBankFeedsBankFeedBankAccountAccountTypeEnum","PutBankFeedsPathParams","PutBankFeedsRequest","PutBankFeedsResponse","PutBankFeedsSecurity","UpdateBankFeedBankFeedBankAccount","UpdateBankFeedBankFeedBankAccountAccountTypeEnum","UpdateBankFeedPathParams","UpdateBankFeedRequest","UpdateBankFeedResponse","UpdateBankFeedSecurity"] \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/get_bank_account_push_options.py b/bankfeeds/src/codat/models/operations/get_bank_account_push_options.py new file mode 100755 index 000000000..1f6b7d5e8 --- /dev/null +++ b/bankfeeds/src/codat/models/operations/get_bank_account_push_options.py @@ -0,0 +1,229 @@ +from __future__ import annotations +import dataclasses +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from enum import Enum +from typing import Optional + + +@dataclasses.dataclass +class GetBankAccountPushOptionsPathParams: + account_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'accountId', 'style': 'simple', 'explode': False }}) + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + + +@dataclasses.dataclass +class GetBankAccountPushOptionsQueryParams: + page: float = dataclasses.field(metadata={'query_param': { 'field_name': 'page', 'style': 'form', 'explode': True }}) + order_by: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'orderBy', 'style': 'form', 'explode': True }}) + page_size: Optional[float] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'pageSize', 'style': 'form', 'explode': True }}) + query: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'query', 'style': 'form', 'explode': True }}) + + +@dataclasses.dataclass +class GetBankAccountPushOptionsSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class GetBankAccountPushOptionsRequest: + path_params: GetBankAccountPushOptionsPathParams = dataclasses.field() + query_params: GetBankAccountPushOptionsQueryParams = dataclasses.field() + security: GetBankAccountPushOptionsSecurity = dataclasses.field() + +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum(str, Enum): + ARRAY = "Array" + OBJECT = "Object" + STRING = "String" + NUMBER = "Number" + BOOLEAN = "Boolean" + DATE_TIME = "DateTime" + FILE = "File" + MULTI_PART = "MultiPart" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation: + details: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('details') }}) + field: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('field') }}) + ref: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('ref'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo: + information: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('information'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoice: + description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('description') }}) + display_name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('displayName') }}) + required: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('required') }}) + type: GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('type') }}) + value: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('value') }}) + rel: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('rel'), 'exclude': lambda f: f is None }}) + validation: Optional[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum(str, Enum): + ARRAY = "Array" + OBJECT = "Object" + STRING = "String" + NUMBER = "Number" + BOOLEAN = "Boolean" + DATE_TIME = "DateTime" + FILE = "File" + MULTI_PART = "MultiPart" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation: + details: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('details') }}) + field: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('field') }}) + ref: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('ref'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo: + information: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('information'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoice: + description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('description') }}) + display_name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('displayName') }}) + required: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('required') }}) + type: GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoiceOptionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('type') }}) + value: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('value') }}) + options: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushOptionChoice]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('options'), 'exclude': lambda f: f is None }}) + rel: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('rel'), 'exclude': lambda f: f is None }}) + validation: Optional[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoicePushValidationInfo] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoiceOptionTypeEnum(str, Enum): + ARRAY = "Array" + OBJECT = "Object" + STRING = "String" + NUMBER = "Number" + BOOLEAN = "Boolean" + DATE_TIME = "DateTime" + FILE = "File" + MULTI_PART = "MultiPart" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation: + details: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('details') }}) + field: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('field') }}) + ref: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('ref'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfo: + information: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('information'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoice: + description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('description') }}) + display_name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('displayName') }}) + required: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('required') }}) + type: GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoiceOptionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('type') }}) + value: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('value') }}) + options: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushOptionChoice]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('options'), 'exclude': lambda f: f is None }}) + rel: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('rel'), 'exclude': lambda f: f is None }}) + validation: Optional[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoicePushValidationInfo] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + +class GetBankAccountPushOptionsPushOptionPushOptionChoiceOptionTypeEnum(str, Enum): + ARRAY = "Array" + OBJECT = "Object" + STRING = "String" + NUMBER = "Number" + BOOLEAN = "Boolean" + DATE_TIME = "DateTime" + FILE = "File" + MULTI_PART = "MultiPart" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfoPushFieldValidation: + details: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('details') }}) + field: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('field') }}) + ref: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('ref'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfo: + information: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('information'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushOptionChoice: + description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('description') }}) + display_name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('displayName') }}) + required: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('required') }}) + type: GetBankAccountPushOptionsPushOptionPushOptionChoiceOptionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('type') }}) + value: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('value') }}) + options: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoicePushOptionChoice]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('options'), 'exclude': lambda f: f is None }}) + rel: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('rel'), 'exclude': lambda f: f is None }}) + validation: Optional[GetBankAccountPushOptionsPushOptionPushOptionChoicePushValidationInfo] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + +class GetBankAccountPushOptionsPushOptionOptionTypeEnum(str, Enum): + ARRAY = "Array" + OBJECT = "Object" + STRING = "String" + NUMBER = "Number" + BOOLEAN = "Boolean" + DATE_TIME = "DateTime" + FILE = "File" + MULTI_PART = "MultiPart" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushValidationInfoPushFieldValidation: + details: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('details') }}) + field: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('field') }}) + ref: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('ref'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOptionPushValidationInfo: + information: Optional[list[GetBankAccountPushOptionsPushOptionPushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('information'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[GetBankAccountPushOptionsPushOptionPushValidationInfoPushFieldValidation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankAccountPushOptionsPushOption: + description: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('description') }}) + display_name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('displayName') }}) + required: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('required') }}) + type: GetBankAccountPushOptionsPushOptionOptionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('type') }}) + options: Optional[list[GetBankAccountPushOptionsPushOptionPushOptionChoice]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('options'), 'exclude': lambda f: f is None }}) + rel: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('rel'), 'exclude': lambda f: f is None }}) + validation: Optional[GetBankAccountPushOptionsPushOptionPushValidationInfo] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class GetBankAccountPushOptionsResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + push_option: Optional[GetBankAccountPushOptionsPushOption] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/get_bank_feeds.py b/bankfeeds/src/codat/models/operations/get_bank_feeds.py new file mode 100755 index 000000000..3cec64489 --- /dev/null +++ b/bankfeeds/src/codat/models/operations/get_bank_feeds.py @@ -0,0 +1,58 @@ +from __future__ import annotations +import dataclasses +import dateutil.parser +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from enum import Enum +from marshmallow import fields +from typing import Optional + + +@dataclasses.dataclass +class GetBankFeedsPathParams: + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + + +@dataclasses.dataclass +class GetBankFeedsSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class GetBankFeedsRequest: + path_params: GetBankFeedsPathParams = dataclasses.field() + security: GetBankFeedsSecurity = dataclasses.field() + +class GetBankFeedsBankFeedBankAccountAccountTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class GetBankFeedsBankFeedBankAccount: + r"""GetBankFeedsBankFeedBankAccount + The target bank account in a supported accounting package for ingestion into a bank feed. + """ + + id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('id') }}) + account_name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountName'), 'exclude': lambda f: f is None }}) + account_number: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountNumber'), 'exclude': lambda f: f is None }}) + account_type: Optional[GetBankFeedsBankFeedBankAccountAccountTypeEnum] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountType'), 'exclude': lambda f: f is None }}) + balance: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance'), 'exclude': lambda f: f is None }}) + currency: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('currency'), 'exclude': lambda f: f is None }}) + feed_start_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('feedStartDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + sort_code: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sortCode'), 'exclude': lambda f: f is None }}) + status: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('status'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class GetBankFeedsResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + bank_feed_bank_accounts: Optional[list[GetBankFeedsBankFeedBankAccount]] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/list_all_bank_transactionscount.py b/bankfeeds/src/codat/models/operations/list_all_bank_transactionscount.py new file mode 100755 index 000000000..f22cf3eb0 --- /dev/null +++ b/bankfeeds/src/codat/models/operations/list_all_bank_transactionscount.py @@ -0,0 +1,154 @@ +from __future__ import annotations +import dataclasses +import dateutil.parser +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from enum import Enum +from marshmallow import fields +from typing import Optional + + +@dataclasses.dataclass +class ListAllBankTransactionscountPathParams: + account_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'accountId', 'style': 'simple', 'explode': False }}) + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + + +@dataclasses.dataclass +class ListAllBankTransactionscountQueryParams: + page: float = dataclasses.field(metadata={'query_param': { 'field_name': 'page', 'style': 'form', 'explode': True }}) + order_by: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'orderBy', 'style': 'form', 'explode': True }}) + page_size: Optional[float] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'pageSize', 'style': 'form', 'explode': True }}) + query: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'query', 'style': 'form', 'explode': True }}) + + +@dataclasses.dataclass +class ListAllBankTransactionscountSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class ListAllBankTransactionscountRequest: + path_params: ListAllBankTransactionscountPathParams = dataclasses.field() + query_params: ListAllBankTransactionscountQueryParams = dataclasses.field() + security: ListAllBankTransactionscountSecurity = dataclasses.field() + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksLinksCurrent: + href: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('href') }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksLinksNext: + href: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('href'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksLinksPrevious: + href: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('href'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksLinksSelf: + href: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('href') }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksLinks: + current: ListAllBankTransactionscountLinksLinksCurrent = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('current') }}) + self: ListAllBankTransactionscountLinksLinksSelf = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('self') }}) + next: Optional[ListAllBankTransactionscountLinksLinksNext] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('next'), 'exclude': lambda f: f is None }}) + previous: Optional[ListAllBankTransactionscountLinksLinksPrevious] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('previous'), 'exclude': lambda f: f is None }}) + +class ListAllBankTransactionscountLinksResultsTransactionsTransactionTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + INT = "Int" + DIV = "Div" + FEE = "Fee" + SER_CHG = "SerChg" + DEP = "Dep" + ATM = "Atm" + POS = "Pos" + XFER = "Xfer" + CHECK = "Check" + PAYMENT = "Payment" + CASH = "Cash" + DIRECT_DEP = "DirectDep" + DIRECT_DEBIT = "DirectDebit" + REPEAT_PMT = "RepeatPmt" + OTHER = "Other" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksResultsTransactions: + amount: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('amount') }}) + balance: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance') }}) + date_: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('date'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso') }}) + reconciled: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('reconciled') }}) + transaction_type: ListAllBankTransactionscountLinksResultsTransactionsTransactionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactionType') }}) + counterparty: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('counterparty'), 'exclude': lambda f: f is None }}) + description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('description'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('id'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + reference: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('reference'), 'exclude': lambda f: f is None }}) + source_modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sourceModifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinksResults: + r"""ListAllBankTransactionscountLinksResults + > **Accessing Bank Accounts through Banking API** + > + > This datatype was originally used for accessing bank account data both in accounting integrations and open banking aggregators. + > + > To view bank account data through the Banking API, please refer to the new datatype [here](https://docs.codat.io/banking-api#/operations/list-all-banking-transactions) + + > View the coverage for bank transactions in the Data coverage explorer. + + ## Overview + + Transactional banking data for a specific company and account. + + Bank transactions include the: + * Amount of the transaction. + * Current account balance. + * Transaction type, for example, credit, debit, or transfer. + """ + + account_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountId'), 'exclude': lambda f: f is None }}) + contract_version: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('contractVersion'), 'exclude': lambda f: f is None }}) + transactions: Optional[list[ListAllBankTransactionscountLinksResultsTransactions]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactions'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ListAllBankTransactionscountLinks: + r"""ListAllBankTransactionscountLinks + Codat's Paging Model + """ + + links: ListAllBankTransactionscountLinksLinks = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('_links') }}) + page_number: int = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('pageNumber') }}) + page_size: int = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('pageSize') }}) + total_results: int = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('totalResults') }}) + results: Optional[list[ListAllBankTransactionscountLinksResults]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('results'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class ListAllBankTransactionscountResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + links: Optional[ListAllBankTransactionscountLinks] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/post_bank_transactions.py b/bankfeeds/src/codat/models/operations/post_bank_transactions.py new file mode 100755 index 000000000..6577ecd0f --- /dev/null +++ b/bankfeeds/src/codat/models/operations/post_bank_transactions.py @@ -0,0 +1,235 @@ +from __future__ import annotations +import dataclasses +import dateutil.parser +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from enum import Enum +from marshmallow import fields +from typing import Optional + + +@dataclasses.dataclass +class PostBankTransactionsPathParams: + account_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'accountId', 'style': 'simple', 'explode': False }}) + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + + +@dataclasses.dataclass +class PostBankTransactionsQueryParams: + allow_sync_on_push_complete: Optional[bool] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'allowSyncOnPushComplete', 'style': 'form', 'explode': True }}) + timeout_in_minutes: Optional[int] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'timeoutInMinutes', 'style': 'form', 'explode': True }}) + +class PostBankTransactionsRequestBodyTransactionsTransactionTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + INT = "Int" + DIV = "Div" + FEE = "Fee" + SER_CHG = "SerChg" + DEP = "Dep" + ATM = "Atm" + POS = "Pos" + XFER = "Xfer" + CHECK = "Check" + PAYMENT = "Payment" + CASH = "Cash" + DIRECT_DEP = "DirectDep" + DIRECT_DEBIT = "DirectDebit" + REPEAT_PMT = "RepeatPmt" + OTHER = "Other" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactionsRequestBodyTransactions: + amount: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('amount') }}) + balance: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance') }}) + date_: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('date'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso') }}) + reconciled: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('reconciled') }}) + transaction_type: PostBankTransactionsRequestBodyTransactionsTransactionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactionType') }}) + counterparty: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('counterparty'), 'exclude': lambda f: f is None }}) + description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('description'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('id'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + reference: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('reference'), 'exclude': lambda f: f is None }}) + source_modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sourceModifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactionsRequestBody: + r"""PostBankTransactionsRequestBody + > **Accessing Bank Accounts through Banking API** + > + > This datatype was originally used for accessing bank account data both in accounting integrations and open banking aggregators. + > + > To view bank account data through the Banking API, please refer to the new datatype [here](https://docs.codat.io/banking-api#/operations/list-all-banking-transactions) + + > View the coverage for bank transactions in the Data coverage explorer. + + ## Overview + + Transactional banking data for a specific company and account. + + Bank transactions include the: + * Amount of the transaction. + * Current account balance. + * Transaction type, for example, credit, debit, or transfer. + """ + + account_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountId'), 'exclude': lambda f: f is None }}) + contract_version: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('contractVersion'), 'exclude': lambda f: f is None }}) + transactions: Optional[list[PostBankTransactionsRequestBodyTransactions]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactions'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class PostBankTransactionsSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class PostBankTransactionsRequest: + path_params: PostBankTransactionsPathParams = dataclasses.field() + query_params: PostBankTransactionsQueryParams = dataclasses.field() + security: PostBankTransactionsSecurity = dataclasses.field() + request: Optional[PostBankTransactionsRequestBody] = dataclasses.field(default=None, metadata={'request': { 'media_type': 'application/json' }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONChangesPushOperationRecordRef: + data_type: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('dataType'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('id'), 'exclude': lambda f: f is None }}) + +class PostBankTransactions200ApplicationJSONChangesTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREATED = "Created" + MODIFIED = "Modified" + DELETED = "Deleted" + ATTACHMENT_UPLOADED = "AttachmentUploaded" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONChanges: + attachment_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('attachmentId'), 'exclude': lambda f: f is None }}) + record_ref: Optional[PostBankTransactions200ApplicationJSONChangesPushOperationRecordRef] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('recordRef'), 'exclude': lambda f: f is None }}) + type: Optional[PostBankTransactions200ApplicationJSONChangesTypeEnum] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('type'), 'exclude': lambda f: f is None }}) + +class PostBankTransactions200ApplicationJSONDataTransactionsTransactionTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + INT = "Int" + DIV = "Div" + FEE = "Fee" + SER_CHG = "SerChg" + DEP = "Dep" + ATM = "Atm" + POS = "Pos" + XFER = "Xfer" + CHECK = "Check" + PAYMENT = "Payment" + CASH = "Cash" + DIRECT_DEP = "DirectDep" + DIRECT_DEBIT = "DirectDebit" + REPEAT_PMT = "RepeatPmt" + OTHER = "Other" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONDataTransactions: + amount: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('amount') }}) + balance: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance') }}) + date_: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('date'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso') }}) + reconciled: bool = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('reconciled') }}) + transaction_type: PostBankTransactions200ApplicationJSONDataTransactionsTransactionTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactionType') }}) + counterparty: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('counterparty'), 'exclude': lambda f: f is None }}) + description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('description'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('id'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + reference: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('reference'), 'exclude': lambda f: f is None }}) + source_modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sourceModifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONData: + r"""PostBankTransactions200ApplicationJSONData + > **Accessing Bank Accounts through Banking API** + > + > This datatype was originally used for accessing bank account data both in accounting integrations and open banking aggregators. + > + > To view bank account data through the Banking API, please refer to the new datatype [here](https://docs.codat.io/banking-api#/operations/list-all-banking-transactions) + + > View the coverage for bank transactions in the Data coverage explorer. + + ## Overview + + Transactional banking data for a specific company and account. + + Bank transactions include the: + * Amount of the transaction. + * Current account balance. + * Transaction type, for example, credit, debit, or transfer. + """ + + account_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountId'), 'exclude': lambda f: f is None }}) + contract_version: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('contractVersion'), 'exclude': lambda f: f is None }}) + transactions: Optional[list[PostBankTransactions200ApplicationJSONDataTransactions]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('transactions'), 'exclude': lambda f: f is None }}) + +class PostBankTransactions200ApplicationJSONStatusEnum(str, Enum): + PENDING = "Pending" + FAILED = "Failed" + SUCCESS = "Success" + TIMED_OUT = "TimedOut" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONValidationValidationItem: + item_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('itemId'), 'exclude': lambda f: f is None }}) + message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('message'), 'exclude': lambda f: f is None }}) + validator_name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validatorName'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSONValidation: + r"""PostBankTransactions200ApplicationJSONValidation + A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. + """ + + errors: Optional[list[PostBankTransactions200ApplicationJSONValidationValidationItem]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('errors'), 'exclude': lambda f: f is None }}) + warnings: Optional[list[PostBankTransactions200ApplicationJSONValidationValidationItem]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('warnings'), 'exclude': lambda f: f is None }}) + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PostBankTransactions200ApplicationJSON: + company_id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('companyId') }}) + data_connection_key: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('dataConnectionKey') }}) + push_operation_key: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('pushOperationKey') }}) + requested_on_utc: datetime = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('requestedOnUtc'), 'encoder': utils.datetimeisoformat(False), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso') }}) + status: PostBankTransactions200ApplicationJSONStatusEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('status') }}) + status_code: int = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('statusCode') }}) + changes: Optional[list[PostBankTransactions200ApplicationJSONChanges]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('changes'), 'exclude': lambda f: f is None }}) + completed_on_utc: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('completedOnUtc'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + data: Optional[PostBankTransactions200ApplicationJSONData] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('data'), 'exclude': lambda f: f is None }}) + data_type: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('dataType'), 'exclude': lambda f: f is None }}) + error_message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('errorMessage'), 'exclude': lambda f: f is None }}) + timeout_in_minutes: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('timeoutInMinutes'), 'exclude': lambda f: f is None }}) + timeout_in_seconds: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('timeoutInSeconds'), 'exclude': lambda f: f is None }}) + validation: Optional[PostBankTransactions200ApplicationJSONValidation] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('validation'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class PostBankTransactionsResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + post_bank_transactions_200_application_json_object: Optional[PostBankTransactions200ApplicationJSON] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/put_bank_feeds.py b/bankfeeds/src/codat/models/operations/put_bank_feeds.py new file mode 100755 index 000000000..ca7676e72 --- /dev/null +++ b/bankfeeds/src/codat/models/operations/put_bank_feeds.py @@ -0,0 +1,59 @@ +from __future__ import annotations +import dataclasses +import dateutil.parser +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from enum import Enum +from marshmallow import fields +from typing import Optional + + +@dataclasses.dataclass +class PutBankFeedsPathParams: + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + +class PutBankFeedsBankFeedBankAccountAccountTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class PutBankFeedsBankFeedBankAccount: + r"""PutBankFeedsBankFeedBankAccount + The target bank account in a supported accounting package for ingestion into a bank feed. + """ + + id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('id') }}) + account_name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountName'), 'exclude': lambda f: f is None }}) + account_number: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountNumber'), 'exclude': lambda f: f is None }}) + account_type: Optional[PutBankFeedsBankFeedBankAccountAccountTypeEnum] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountType'), 'exclude': lambda f: f is None }}) + balance: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance'), 'exclude': lambda f: f is None }}) + currency: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('currency'), 'exclude': lambda f: f is None }}) + feed_start_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('feedStartDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + sort_code: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sortCode'), 'exclude': lambda f: f is None }}) + status: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('status'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class PutBankFeedsSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class PutBankFeedsRequest: + path_params: PutBankFeedsPathParams = dataclasses.field() + security: PutBankFeedsSecurity = dataclasses.field() + request: Optional[list[PutBankFeedsBankFeedBankAccount]] = dataclasses.field(default=None, metadata={'request': { 'media_type': 'application/json' }}) + + +@dataclasses.dataclass +class PutBankFeedsResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + bank_feed_bank_accounts: Optional[list[PutBankFeedsBankFeedBankAccount]] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/operations/update_bank_feed.py b/bankfeeds/src/codat/models/operations/update_bank_feed.py new file mode 100755 index 000000000..9e95637b0 --- /dev/null +++ b/bankfeeds/src/codat/models/operations/update_bank_feed.py @@ -0,0 +1,60 @@ +from __future__ import annotations +import dataclasses +import dateutil.parser +from codat import utils +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from enum import Enum +from marshmallow import fields +from typing import Optional + + +@dataclasses.dataclass +class UpdateBankFeedPathParams: + bank_account_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'bankAccountId', 'style': 'simple', 'explode': False }}) + company_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'companyId', 'style': 'simple', 'explode': False }}) + connection_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'connectionId', 'style': 'simple', 'explode': False }}) + +class UpdateBankFeedBankFeedBankAccountAccountTypeEnum(str, Enum): + UNKNOWN = "Unknown" + CREDIT = "Credit" + DEBIT = "Debit" + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class UpdateBankFeedBankFeedBankAccount: + r"""UpdateBankFeedBankFeedBankAccount + The target bank account in a supported accounting package for ingestion into a bank feed. + """ + + id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.field_name('id') }}) + account_name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountName'), 'exclude': lambda f: f is None }}) + account_number: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountNumber'), 'exclude': lambda f: f is None }}) + account_type: Optional[UpdateBankFeedBankFeedBankAccountAccountTypeEnum] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('accountType'), 'exclude': lambda f: f is None }}) + balance: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('balance'), 'exclude': lambda f: f is None }}) + currency: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('currency'), 'exclude': lambda f: f is None }}) + feed_start_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('feedStartDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + modified_date: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('modifiedDate'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }}) + sort_code: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('sortCode'), 'exclude': lambda f: f is None }}) + status: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.field_name('status'), 'exclude': lambda f: f is None }}) + + +@dataclasses.dataclass +class UpdateBankFeedSecurity: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + + +@dataclasses.dataclass +class UpdateBankFeedRequest: + path_params: UpdateBankFeedPathParams = dataclasses.field() + security: UpdateBankFeedSecurity = dataclasses.field() + request: Optional[UpdateBankFeedBankFeedBankAccount] = dataclasses.field(default=None, metadata={'request': { 'media_type': 'application/json' }}) + + +@dataclasses.dataclass +class UpdateBankFeedResponse: + content_type: str = dataclasses.field() + status_code: int = dataclasses.field() + bank_feed_bank_account: Optional[UpdateBankFeedBankFeedBankAccount] = dataclasses.field(default=None) + \ No newline at end of file diff --git a/bankfeeds/src/codat/models/shared/__init__.py b/bankfeeds/src/codat/models/shared/__init__.py new file mode 100755 index 000000000..b6972b92a --- /dev/null +++ b/bankfeeds/src/codat/models/shared/__init__.py @@ -0,0 +1,3 @@ +from .security import * + +__all__ = ["Security"] \ No newline at end of file diff --git a/bankfeeds/src/codat/models/shared/security.py b/bankfeeds/src/codat/models/shared/security.py new file mode 100755 index 000000000..7fe4a9463 --- /dev/null +++ b/bankfeeds/src/codat/models/shared/security.py @@ -0,0 +1,9 @@ +from __future__ import annotations +import dataclasses + + + +@dataclasses.dataclass +class Security: + api_key: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'apiKey', 'sub_type': 'header', 'field_name': 'Authorization' }}) + \ No newline at end of file diff --git a/bankfeeds/src/codat/sdk.py b/bankfeeds/src/codat/sdk.py new file mode 100755 index 000000000..82ce67ff5 --- /dev/null +++ b/bankfeeds/src/codat/sdk.py @@ -0,0 +1,75 @@ + +import requests +from . import utils +from .bank_account_transactions import BankAccountTransactions +from .bank_feed_accounts import BankFeedAccounts +from codat.models import shared + +SERVERS = [ + "https://api.codat.io", +] + + +class Codat: + + bank_account_transactions: BankAccountTransactions + bank_feed_accounts: BankFeedAccounts + + _client: requests.Session + _security_client: requests.Session + _security: shared.Security + _server_url: str = SERVERS[0] + _language: str = "python" + _sdk_version: str = "0.1.0" + _gen_version: str = "1.7.0" + + def __init__(self) -> None: + self._client = requests.Session() + self._security_client = requests.Session() + self._init_sdks() + + + def config_server_url(self, server_url: str, params: dict[str, str]): + if params is not None: + self._server_url = utils.replace_parameters(server_url, params) + else: + self._server_url = server_url + + self._init_sdks() + + + def config_client(self, client: requests.Session): + self._client = client + + if self._security is not None: + self._security_client = utils.configure_security_client(self._client, self._security) + self._init_sdks() + + + def config_security(self, security: shared.Security): + self._security = security + self._security_client = utils.configure_security_client(self._client, security) + self._init_sdks() + + + def _init_sdks(self): + + self.bank_account_transactions = BankAccountTransactions( + self._client, + self._security_client, + self._server_url, + self._language, + self._sdk_version, + self._gen_version + ) + + self.bank_feed_accounts = BankFeedAccounts( + self._client, + self._security_client, + self._server_url, + self._language, + self._sdk_version, + self._gen_version + ) + + \ No newline at end of file diff --git a/bankfeeds/src/codat/utils/__init__.py b/bankfeeds/src/codat/utils/__init__.py new file mode 100755 index 000000000..2f39e5450 --- /dev/null +++ b/bankfeeds/src/codat/utils/__init__.py @@ -0,0 +1,2 @@ +from .retries import * +from .utils import * diff --git a/bankfeeds/src/codat/utils/retries.py b/bankfeeds/src/codat/utils/retries.py new file mode 100755 index 000000000..983d0d462 --- /dev/null +++ b/bankfeeds/src/codat/utils/retries.py @@ -0,0 +1,116 @@ +import random +import time + +import requests + + +class BackoffStrategy: + initial_interval: int + max_interval: int + exponent: float + max_elapsed_time: int + + def __init__(self, initial_interval: int, max_interval: int, exponent: float, max_elapsed_time: int): + self.initial_interval = initial_interval + self.max_interval = max_interval + self.exponent = exponent + self.max_elapsed_time = max_elapsed_time + + +class RetryConfig: + strategy: str + backoff: BackoffStrategy + retry_connection_errors: bool + + def __init__(self, strategy: str, retry_connection_errors: bool): + self.strategy = strategy + self.retry_connection_errors = retry_connection_errors + + +class Retries: + config: RetryConfig + status_codes: list[str] + + def __init__(self, config: RetryConfig, status_codes: list[str]): + self.config = config + self.status_codes = status_codes + + +class TemporaryError(Exception): + response: requests.Response + + def __init__(self, response: requests.Response): + self.response = response + + +class PermanentError(Exception): + inner: Exception + + def __init__(self, inner: Exception): + self.inner = inner + + +def retry(fn, retries: Retries): + if retries.config.strategy == 'backoff': + def do_request(): + res: requests.Response + try: + res = fn() + + for code in retries.status_codes: + if "X" in code.upper(): + codeRange = int(code[0]) + + s = res.status_code / 100 + + if s >= codeRange and s < codeRange + 1: + raise TemporaryError(res) + else: + parsed_code = int(code) + + if res.status_code == parsed_code: + raise TemporaryError(res) + except requests.exceptions.ConnectionError as e: + if not retries.config.config.retry_connection_errors: + raise + else: + raise PermanentError(e) + except requests.exceptions.Timeout as e: + if not retries.config.config.retry_connection_errors: + raise + else: + raise PermanentError(e) + except TemporaryError: + raise + except Exception as e: + raise PermanentError(e) + + return res + + return retry_with_backoff(do_request, retries.config.backoff.initial_interval, retries.config.backoff.max_interval, retries.config.backoff.exponent, retries.config.backoff.max_elapsed_time) + else: + fn() + + +def retry_with_backoff(fn, initial_interval=500, max_interval=60000, exponent=1.5, max_elapsed_time=3600000): + start = round(time.time()*1000) + x = 0 + + while True: + try: + return fn() + except PermanentError as e: + raise e.inner + except Exception as e: + now = round(time.time()*1000) + if now - start > max_elapsed_time: + if isinstance(e, TemporaryError): + return e.response + else: + raise + sleep = ((initial_interval/1000) * + exponent**x + random.uniform(0, 1)) + if sleep > max_interval/1000: + sleep = max_interval/1000 + time.sleep(sleep) + x += 1 diff --git a/bankfeeds/src/codat/utils/utils.py b/bankfeeds/src/codat/utils/utils.py new file mode 100755 index 000000000..e9bf17b97 --- /dev/null +++ b/bankfeeds/src/codat/utils/utils.py @@ -0,0 +1,700 @@ +import base64 +import json +import re +from dataclasses import Field, dataclass, fields, is_dataclass, make_dataclass +from datetime import date, datetime +from email.message import Message +from enum import Enum +from typing import Callable, Optional, Tuple, Union, get_args, get_origin +from xmlrpc.client import boolean + +import dateutil.parser +import requests +from dataclasses_json import DataClassJsonMixin + + +class SecurityClient: + client: requests.Session + query_params: dict[str, str] = {} + + def __init__(self, client: requests.Session): + self.client = client + + def request(self, method, url, **kwargs): + params = kwargs.get('params', {}) + kwargs["params"] = self.query_params | params + + return self.client.request(method, url, **kwargs) + + +def configure_security_client(client: requests.Session, security: dataclass): + client = SecurityClient(client) + + sec_fields: Tuple[Field, ...] = fields(security) + for sec_field in sec_fields: + value = getattr(security, sec_field.name) + if value is None: + continue + + metadata = sec_field.metadata.get('security') + if metadata is None: + continue + if metadata.get('option'): + _parse_security_option(client, value) + return client + elif metadata.get('scheme'): + # Special case for basic auth which could be a flattened struct + if metadata.get("sub_type") == "basic" and not is_dataclass(value): + _parse_security_scheme(client, metadata, security) + else: + _parse_security_scheme(client, metadata, value) + + return client + + +def _parse_security_option(client: SecurityClient, option: dataclass): + opt_fields: Tuple[Field, ...] = fields(option) + for opt_field in opt_fields: + metadata = opt_field.metadata.get('security') + if metadata is None or metadata.get('scheme') is None: + continue + _parse_security_scheme( + client, metadata, getattr(option, opt_field.name)) + + +def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme: any): + scheme_type = scheme_metadata.get('type') + sub_type = scheme_metadata.get('sub_type') + + if is_dataclass(scheme): + if scheme_type == 'http' and sub_type == 'basic': + _parse_basic_auth_scheme(client, scheme) + return + + scheme_fields: Tuple[Field, ...] = fields(scheme) + for scheme_field in scheme_fields: + metadata = scheme_field.metadata.get('security') + if metadata is None or metadata.get('field_name') is None: + continue + + value = getattr(scheme, scheme_field.name) + + _parse_security_scheme_value( + client, scheme_metadata, metadata, value) + else: + _parse_security_scheme_value( + client, scheme_metadata, scheme_metadata, scheme) + + +def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: dict, security_metadata: dict, value: any): + scheme_type = scheme_metadata.get('type') + sub_type = scheme_metadata.get('sub_type') + + header_name = security_metadata.get('field_name') + + if scheme_type == "apiKey": + if sub_type == 'header': + client.client.headers[header_name] = value + elif sub_type == 'query': + client.query_params[header_name] = value + elif sub_type == 'cookie': + client.client.cookies[header_name] = value + else: + raise Exception('not supported') + elif scheme_type == "openIdConnect": + client.client.headers[header_name] = value + elif scheme_type == 'oauth2': + client.client.headers[header_name] = value + elif scheme_type == 'http': + if sub_type == 'bearer': + client.client.headers[header_name] = value + else: + raise Exception('not supported') + else: + raise Exception('not supported') + + +def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass): + username = "" + password = "" + + scheme_fields: Tuple[Field, ...] = fields(scheme) + for scheme_field in scheme_fields: + metadata = scheme_field.metadata.get('security') + if metadata is None or metadata.get('field_name') is None: + continue + + field_name = metadata.get('field_name') + value = getattr(scheme, scheme_field.name) + + if field_name == 'username': + username = value + if field_name == 'password': + password = value + + data = f'{username}:{password}'.encode() + client.client.headers['Authorization'] = f'Basic {base64.b64encode(data).decode()}' + + +def generate_url(server_url: str, path: str, path_params: dataclass) -> str: + path_param_fields: Tuple[Field, ...] = fields(path_params) + for f in path_param_fields: + param_metadata = f.metadata.get('path_param') + if param_metadata is None: + continue + if param_metadata.get('style', 'simple') == 'simple': + param = getattr(path_params, f.name) + if param is None: + continue + + if type(param) is list: + pp_vals: list[str] = [] + for pp_val in param: + if pp_val is None: + continue + pp_vals.append(val_to_string(pp_val)) + path = path.replace( + '{' + param_metadata.get('field_name', f.name) + '}', ",".join(pp_vals), 1) + elif type(param) is dict: + pp_vals: list[str] = [] + for pp_key in param: + if param[pp_key] is None: + continue + if param_metadata.get('explode'): + pp_vals.append( + f"{pp_key}={val_to_string(param[pp_key])}") + else: + pp_vals.append( + f"{pp_key},{val_to_string(param[pp_key])}") + path = path.replace( + '{' + param_metadata.get('field_name', f.name) + '}', ",".join(pp_vals), 1) + elif not isinstance(param, (str, int, float, complex, bool)): + pp_vals: list[str] = [] + param_fields: Tuple[Field, ...] = fields(param) + for field in param_fields: + param_value_metadata = field.metadata.get('path_param') + if not param_value_metadata: + continue + + parm_name = param_value_metadata.get('field_name', f.name) + + param_field_val = getattr(param, field.name) + if param_field_val is None: + continue + elif param_metadata.get('explode'): + pp_vals.append( + f"{parm_name}={val_to_string(param_field_val)}") + else: + pp_vals.append( + f"{parm_name},{val_to_string(param_field_val)}") + path = path.replace( + '{' + param_metadata.get('field_name', f.name) + '}', ",".join(pp_vals), 1) + else: + path = path.replace( + '{' + param_metadata.get('field_name', f.name) + '}', val_to_string(param), 1) + + return server_url.removesuffix("/") + path + + +def is_optional(field): + return get_origin(field) is Union and type(None) in get_args(field) + + +def replace_parameters(string_with_params: str, params: dict[str, str]) -> str: + for key, value in params.items(): + string_with_params = string_with_params.replace( + '{' + key + '}', value) + + return string_with_params + + +def get_query_params(query_params: dataclass) -> dict[str, list[str]]: + if query_params is None: + return {} + + params: dict[str, list[str]] = {} + + param_fields: Tuple[Field, ...] = fields(query_params) + for f in param_fields: + metadata = f.metadata.get('query_param') + if not metadata: + continue + + param_name = f.name + f_name = metadata.get("field_name") + serialization = metadata.get('serialization', '') + if serialization != '': + params = params | _get_serialized_query_params( + metadata, f_name, getattr(query_params, param_name)) + else: + style = metadata.get('style', 'form') + if style == 'deepObject': + params = params | _get_deep_object_query_params( + metadata, f_name, getattr(query_params, param_name)) + elif style == 'form': + params = params | _get_form_query_params( + metadata, f_name, getattr(query_params, param_name)) + else: + raise Exception('not yet implemented') + return params + + +def get_headers(headers_params: dataclass) -> dict[str, str]: + if headers_params is None: + return {} + + headers: dict[str, str] = {} + + param_fields: Tuple[Field, ...] = fields(headers_params) + for f in param_fields: + metadata = f.metadata.get('header') + if not metadata: + continue + + value = _serialize_header(metadata.get( + 'explode', False), getattr(headers_params, f.name)) + + if value != '': + headers[metadata.get('field_name', f.name)] = value + + return headers + + +def _get_serialized_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: + params: dict[str, list[str]] = {} + + serialization = metadata.get('serialization', '') + if serialization == 'json': + params[metadata.get("field_name", field_name)] = marshal_json(obj) + + return params + + +def _get_deep_object_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: + params: dict[str, list[str]] = {} + + if obj is None: + return params + + if is_dataclass(obj): + obj_fields: Tuple[Field, ...] = fields(obj) + for obj_field in obj_fields: + obj_param_metadata = obj_field.metadata.get('query_param') + if not obj_param_metadata: + continue + + val = getattr(obj, obj_field.name) + if val is None: + continue + + if isinstance(val, list): + for v in val: + if v is None: + continue + + if params.get(f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]') is None: + params[f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ + ] + + params[ + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'].append(val_to_string(v)) + else: + params[ + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ + val_to_string(val)] + elif isinstance(obj, dict): + for key, value in obj.items(): + if value is None: + continue + + if isinstance(value, list): + for val in value: + if val is None: + continue + + if params.get(f'{metadata.get("field_name", field_name)}[{key}]') is None: + params[f'{metadata.get("field_name", field_name)}[{key}]'] = [ + ] + + params[ + f'{metadata.get("field_name", field_name)}[{key}]'].append(val_to_string(val)) + else: + params[f'{metadata.get("field_name", field_name)}[{key}]'] = [ + val_to_string(value)] + return params + + +def _get_query_param_field_name(obj_field: Field) -> str: + obj_param_metadata = obj_field.metadata.get('query_param') + + if not obj_param_metadata: + return "" + + return obj_param_metadata.get("field_name", obj_field.name) + + +def _get_form_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: + return _populate_form(field_name, metadata.get("explode", True), obj, _get_query_param_field_name) + + +def serialize_request_body(request: dataclass) -> Tuple[str, any, any]: + if request is None: + return None, None, None, None + + request_val = getattr(request, "request") + if request_val is None: + raise Exception("request body not found") + + request_fields: Tuple[Field, ...] = fields(request) + request_metadata = None + + for f in request_fields: + if f.name == "request": + request_metadata = f.metadata.get('request') + break + + if request_metadata is not None: + # single request + return serialize_content_type('request', request_metadata.get('media_type', 'application/octet-stream'), request_val) + + request_fields: Tuple[Field, ...] = fields(request_val) + for f in request_fields: + req = getattr(request_val, f.name) + if req is None: + continue + + request_metadata = f.metadata.get('request') + if request_metadata is None: + raise Exception( + f'missing request tag on request body field {f.name}') + + return serialize_content_type(f.name, request_metadata.get('media_type', 'application/octet-stream'), req) + + +def serialize_content_type(field_name: str, media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: + if re.match(r'(application|text)\/.*?\+*json.*', media_type) != None: + return media_type, marshal_json(request), None + if re.match(r'multipart\/.*', media_type) != None: + return serialize_multipart_form(media_type, request) + if re.match(r'application\/x-www-form-urlencoded.*', media_type) != None: + return media_type, serialize_form_data(field_name, request), None + if isinstance(request, (bytes, bytearray)): + return media_type, request, None + if isinstance(request, str): + return media_type, request, None + + raise Exception( + f"invalid request body type {type(request)} for mediaType {media_type}") + + +def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: + form: list[list[any]] = [] + request_fields = fields(request) + + for field in request_fields: + val = getattr(request, field.name) + if val is None: + continue + + field_metadata = field.metadata.get('multipart_form') + if not field_metadata: + continue + + if field_metadata.get("file") is True: + file_fields = fields(val) + + file_name = "" + field_name = "" + content = bytes() + + for file_field in file_fields: + file_metadata = file_field.metadata.get('multipart_form') + if file_metadata is None: + continue + + if file_metadata.get("content") is True: + content = getattr(val, file_field.name) + else: + field_name = file_metadata.get( + "field_name", file_field.name) + file_name = getattr(val, file_field.name) + if field_name == "" or file_name == "" or content == bytes(): + raise Exception('invalid multipart/form-data file') + + form.append([field_name, [file_name, content]]) + elif field_metadata.get("json") is True: + to_append = [field_metadata.get("field_name", field.name), [ + None, marshal_json(val), "application/json"]] + form.append(to_append) + else: + field_name = field_metadata.get( + "field_name", field.name) + if isinstance(val, list): + for value in val: + if value is None: + continue + form.append( + [field_name + "[]", [None, val_to_string(value)]]) + else: + form.append([field_name, [None, val_to_string(val)]]) + return media_type, None, form + + +def serialize_dict(original: dict, explode: bool, field_name, existing: Optional[dict[str, list[str]]]) -> dict[ + str, list[str]]: + if existing is None: + existing = [] + + if explode is True: + for k, v in original.items(): + if k not in existing: + existing[k] = [] + existing[k].append(v) + else: + temp = [] + for k, v in original.items(): + temp.append(str(k)) + temp.append(str(v)) + if field_name not in existing: + existing[field_name] = [] + existing[field_name].append(",".join(temp)) + return existing + + +def serialize_form_data(field_name: str, data: dataclass) -> dict[str, any]: + form: dict[str, list[str]] = {} + + if is_dataclass(data): + for field in fields(data): + val = getattr(data, field.name) + if val is None: + continue + + metadata = field.metadata.get('form') + if metadata is None: + continue + + field_name = metadata.get('field_name', field.name) + + if metadata.get('json'): + form[field_name] = [marshal_json(val)] + else: + if metadata.get('style', 'form') == 'form': + form = form | _populate_form( + field_name, metadata.get('explode', True), val, _get_form_field_name) + else: + raise Exception( + f'Invalid form style for field {field.name}') + elif isinstance(data, dict): + for key, value in data.items(): + form[key] = [val_to_string(value)] + else: + raise Exception(f'Invalid request body type for field {field_name}') + + return form + + +def _get_form_field_name(obj_field: Field) -> str: + obj_param_metadata = obj_field.metadata.get('form') + + if not obj_param_metadata: + return "" + + return obj_param_metadata.get("field_name", obj_field.name) + + +def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_func: Callable) -> dict[str, list[str]]: + params: dict[str, str | list[str]] = {} + + if obj is None: + return params + + if is_dataclass(obj): + items = [] + + obj_fields: Tuple[Field, ...] = fields(obj) + for obj_field in obj_fields: + obj_field_name = get_field_name_func(obj_field) + if obj_field_name == '': + continue + + val = getattr(obj, obj_field.name) + if val is None: + continue + + if explode: + params[obj_field_name] = [val_to_string(val)] + else: + items.append( + f'{obj_field_name},{val_to_string(val)}') + + if len(items) > 0: + params[field_name] = [','.join(items)] + elif isinstance(obj, dict): + items = [] + for key, value in obj.items(): + if value is None: + continue + + if explode: + params[key] = val_to_string(value) + else: + items.append(f'{key},{val_to_string(value)}') + + if len(items) > 0: + params[field_name] = [','.join(items)] + elif isinstance(obj, list): + items = [] + + for value in obj: + if value is None: + continue + + if explode: + if not field_name in params: + params[field_name] = [] + params[field_name].append(val_to_string(value)) + else: + items.append(val_to_string(value)) + + if len(items) > 0: + params[field_name] = [','.join([str(item) for item in items])] + else: + params[field_name] = val_to_string(obj) + + return params + + +def _serialize_header(explode: boolean, obj: any) -> str: + if obj is None: + return '' + + if is_dataclass(obj): + items = [] + obj_fields: Tuple[Field, ...] = fields(obj) + for obj_field in obj_fields: + obj_param_metadata = obj_field.metadata.get('header') + + if not obj_param_metadata: + continue + + obj_field_name = obj_param_metadata.get( + 'field_name', obj_field.name) + if obj_field_name == '': + continue + + val = getattr(obj, obj_field.name) + if val is None: + continue + + if explode: + items.append( + f'{obj_field_name}={val_to_string(val)}') + else: + items.append(obj_field_name) + items.append(val_to_string(val)) + + if len(items) > 0: + return ','.join(items) + elif isinstance(obj, dict): + items = [] + + for key, value in obj.items(): + if value is None: + continue + + if explode: + items.append(f'{key}={val_to_string(value)}') + else: + items.append(key) + items.append(val_to_string(value)) + + if len(items) > 0: + return ','.join([str(item) for item in items]) + elif isinstance(obj, list): + items = [] + + for value in obj: + if value is None: + continue + + items.append(val_to_string(value)) + + return ','.join(items) + else: + return f'{val_to_string(obj)}' + + +def unmarshal_json(data, t): + Unmarhsal = make_dataclass('Unmarhsal', [('res', t)], + bases=(DataClassJsonMixin,)) + d = json.loads(data) + out = Unmarhsal.from_dict({"res": d}) + return out.res + + +def marshal_json(c): + Marshal = make_dataclass('Marshal', [('res', type(c))], + bases=(DataClassJsonMixin,)) + m = Marshal(res=c) + d = m.to_dict() + return json.dumps(d["res"]) + + +def match_content_type(content_type: str, pattern: str) -> boolean: + if content_type == pattern or pattern == "*" or pattern == "*/*": + return True + + m = Message() + m['content-type'] = content_type + media_type = m.get_content_type() + + if media_type == pattern: + return True + + parts = media_type.split("/") + if len(parts) == 2: + if f'{parts[0]}/*' == pattern or f'*/{parts[1]}' == pattern: + return True + + return False + + +def datetimeisoformat(optional: bool): + def isoformatoptional(v): + if optional and v is None: + return None + return val_to_string(v) + + return isoformatoptional + + +def dateisoformat(optional: bool): + def isoformatoptional(v): + if optional and v is None: + return None + return date.isoformat(v) + + return isoformatoptional + + +def datefromisoformat(date: str): + return dateutil.parser.parse(date).date() + + +def field_name(name): + def override(_, _field_name=name): + return _field_name + + return override + + +def val_to_string(val): + if isinstance(val, bool): + return str(val).lower() + elif isinstance(val, datetime): + return val.isoformat().replace('+00:00', 'Z') + elif isinstance(val, Enum): + return val.value + + return str(val) From 7a27ac666bdf49558dde2c0971dee9ddc04b169e Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 2 Mar 2023 00:19:56 +0000 Subject: [PATCH 2/2] ci: regenerated with OpenAPI Doc 2.1.0, Speakeay CLI 1.7.1 --- bankfeeds/RELEASES.md | 10 +++++++++- bankfeeds/gen.yaml | 4 ++-- bankfeeds/setup.py | 2 +- bankfeeds/src/codat/sdk.py | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bankfeeds/RELEASES.md b/bankfeeds/RELEASES.md index 888b52e83..7095d08de 100644 --- a/bankfeeds/RELEASES.md +++ b/bankfeeds/RELEASES.md @@ -6,4 +6,12 @@ Based on: - OpenAPI Doc 2.1.0 https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Bank-Feeds.yaml - Speakeasy CLI 1.7.0 https://github.com/speakeasy-api/speakeasy ### Releases -- [PyPI v0.1.0] https://pypi.org/project/codat-bankfeeds/0.1.0 - bankfeeds \ No newline at end of file +- [PyPI v0.1.0] https://pypi.org/project/codat-bankfeeds/0.1.0 - bankfeeds + +## 2023-03-02 00:19:50 +### Changes +Based on: +- OpenAPI Doc 2.1.0 https://raw.githubusercontent.com/codatio/oas/main/yaml/Codat-Bank-Feeds.yaml +- Speakeasy CLI 1.7.1 https://github.com/speakeasy-api/speakeasy +### Releases +- [PyPI v0.1.1] https://pypi.org/project/codat-bankfeeds/0.1.1 - bankfeeds \ No newline at end of file diff --git a/bankfeeds/gen.yaml b/bankfeeds/gen.yaml index 2fe252a6d..1a715dfde 100644 --- a/bankfeeds/gen.yaml +++ b/bankfeeds/gen.yaml @@ -2,13 +2,13 @@ configVersion: 1.0.0 management: docChecksum: 2850b50909854a03af955e915ac1f608 docVersion: 2.1.0 - speakeasyVersion: 1.7.0 + speakeasyVersion: 1.7.1 generation: telemetryEnabled: false sdkClassName: codat sdkFlattening: true python: - version: 0.1.0 + version: 0.1.1 author: Speakeasy description: Python Client SDK Generated by Speakeasy packageName: codat-bankfeeds diff --git a/bankfeeds/setup.py b/bankfeeds/setup.py index b98e889c7..518a207f8 100755 --- a/bankfeeds/setup.py +++ b/bankfeeds/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="codat-bankfeeds", - version="0.1.0", + version="0.1.1", author="Speakeasy", description="Python Client SDK Generated by Speakeasy", long_description=long_description, diff --git a/bankfeeds/src/codat/sdk.py b/bankfeeds/src/codat/sdk.py index 82ce67ff5..a71d2b7ec 100755 --- a/bankfeeds/src/codat/sdk.py +++ b/bankfeeds/src/codat/sdk.py @@ -20,8 +20,8 @@ class Codat: _security: shared.Security _server_url: str = SERVERS[0] _language: str = "python" - _sdk_version: str = "0.1.0" - _gen_version: str = "1.7.0" + _sdk_version: str = "0.1.1" + _gen_version: str = "1.7.1" def __init__(self) -> None: self._client = requests.Session()