From a2414a630cfb11091c87a637c9c8cf6bdbbabcd1 Mon Sep 17 00:00:00 2001 From: moneykitt Date: Thu, 2 May 2024 16:58:42 +0000 Subject: [PATCH] Update with latest OpenAPI changes --- .openapi-generator/FILES | 7 +- moneykit/__init__.py | 6 +- moneykit/api/account_numbers_api.py | 20 +- moneykit/api/accounts_api.py | 20 +- moneykit/api_client.py | 2 +- moneykit/configuration.py | 2 +- moneykit/models/__init__.py | 4 +- .../models/response401_get_account_numbers.py | 189 ++++++++++++++++++ pyproject.toml | 2 +- test/test_response401_get_account_numbers.py | 56 ++++++ 10 files changed, 273 insertions(+), 35 deletions(-) create mode 100644 moneykit/models/response401_get_account_numbers.py create mode 100644 test/test_response401_get_account_numbers.py diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 9d4e792..f0bdf19 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -99,7 +99,7 @@ moneykit/models/requested_link_permission.py moneykit/models/response401_disconnect_links_id_delete.py moneykit/models/response401_exchange_token_link_session_exchange_token_post.py moneykit/models/response401_get_account_links_id_accounts_account_id_get.py -moneykit/models/response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get.py +moneykit/models/response401_get_account_numbers.py moneykit/models/response401_get_accounts_links_id_accounts_get.py moneykit/models/response401_get_holdings_links_id_investments_holdings_get.py moneykit/models/response401_get_identities_links_id_identity_get.py @@ -138,7 +138,4 @@ moneykit/py.typed moneykit/rest.py pyproject.toml test/__init__.py -test/test_account_numbers_legacy20230218.py -test/test_account_with_account_numbers_legacy20230218.py -test/test_get_account_numbers_response_legacy20230218.py -test/test_response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get.py +test/test_response401_get_account_numbers.py diff --git a/moneykit/__init__.py b/moneykit/__init__.py index 6b4c3d6..ea4562a 100644 --- a/moneykit/__init__.py +++ b/moneykit/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "0.1.13" +__version__ = "0.1.14" # import apis into sdk package from moneykit.api.access_token_api import AccessTokenApi @@ -156,9 +156,7 @@ from moneykit.models.response401_get_account_links_id_accounts_account_id_get import ( Response401GetAccountLinksIdAccountsAccountIdGet, ) -from moneykit.models.response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get import ( - Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet, -) +from moneykit.models.response401_get_account_numbers import Response401GetAccountNumbers from moneykit.models.response401_get_accounts_links_id_accounts_get import ( Response401GetAccountsLinksIdAccountsGet, ) diff --git a/moneykit/api/account_numbers_api.py b/moneykit/api/account_numbers_api.py index 3a3f397..b7b5610 100644 --- a/moneykit/api/account_numbers_api.py +++ b/moneykit/api/account_numbers_api.py @@ -47,7 +47,7 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client @validate_call - def get_account_numbers_legacy20230218( + def get_account_numbers( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -90,7 +90,7 @@ def get_account_numbers_legacy20230218( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -100,7 +100,7 @@ def get_account_numbers_legacy20230218( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -117,7 +117,7 @@ def get_account_numbers_legacy20230218( ).data @validate_call - def get_account_numbers_legacy20230218_with_http_info( + def get_account_numbers_with_http_info( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -160,7 +160,7 @@ def get_account_numbers_legacy20230218_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -170,7 +170,7 @@ def get_account_numbers_legacy20230218_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -187,7 +187,7 @@ def get_account_numbers_legacy20230218_with_http_info( ) @validate_call - def get_account_numbers_legacy20230218_without_preload_content( + def get_account_numbers_without_preload_content( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -230,7 +230,7 @@ def get_account_numbers_legacy20230218_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -240,7 +240,7 @@ def get_account_numbers_legacy20230218_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -252,7 +252,7 @@ def get_account_numbers_legacy20230218_without_preload_content( ) return response_data.response - def _get_account_numbers_legacy20230218_serialize( + def _get_account_numbers_serialize( self, id, _request_auth, diff --git a/moneykit/api/accounts_api.py b/moneykit/api/accounts_api.py index 405948b..61c1fd0 100644 --- a/moneykit/api/accounts_api.py +++ b/moneykit/api/accounts_api.py @@ -323,7 +323,7 @@ def _get_account_serialize( ) @validate_call - def get_account_numbers_legacy20230218( + def get_account_numbers( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -366,7 +366,7 @@ def get_account_numbers_legacy20230218( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -376,7 +376,7 @@ def get_account_numbers_legacy20230218( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -393,7 +393,7 @@ def get_account_numbers_legacy20230218( ).data @validate_call - def get_account_numbers_legacy20230218_with_http_info( + def get_account_numbers_with_http_info( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -436,7 +436,7 @@ def get_account_numbers_legacy20230218_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -446,7 +446,7 @@ def get_account_numbers_legacy20230218_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -463,7 +463,7 @@ def get_account_numbers_legacy20230218_with_http_info( ) @validate_call - def get_account_numbers_legacy20230218_without_preload_content( + def get_account_numbers_without_preload_content( self, id: Annotated[StrictStr, Field(description="The unique ID for this link.")], _request_timeout: Union[ @@ -506,7 +506,7 @@ def get_account_numbers_legacy20230218_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._get_account_numbers_legacy20230218_serialize( + _param = self._get_account_numbers_serialize( id=id, _request_auth=_request_auth, _content_type=_content_type, @@ -516,7 +516,7 @@ def get_account_numbers_legacy20230218_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "GetAccountNumbersResponseLegacy20230218", - "401": "Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet", + "401": "Response401GetAccountNumbers", "429": "APIErrorRateLimitExceededResponse", "404": "LinkErrorNotFoundResponse", "403": "LinkErrorForbiddenActionResponse", @@ -528,7 +528,7 @@ def get_account_numbers_legacy20230218_without_preload_content( ) return response_data.response - def _get_account_numbers_legacy20230218_serialize( + def _get_account_numbers_serialize( self, id, _request_auth, diff --git a/moneykit/api_client.py b/moneykit/api_client.py index 6e3f38c..e118c09 100644 --- a/moneykit/api_client.py +++ b/moneykit/api_client.py @@ -81,7 +81,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/0.1.13/python" + self.user_agent = "OpenAPI-Generator/0.1.14/python" self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/moneykit/configuration.py b/moneykit/configuration.py index d1ffb01..000f5a8 100644 --- a/moneykit/configuration.py +++ b/moneykit/configuration.py @@ -406,7 +406,7 @@ def to_debug_report(self): "OS: {env}\n" "Python Version: {pyversion}\n" "Version of the API: 2023-02-18\n" - "SDK Package Version: 0.1.13".format( + "SDK Package Version: 0.1.14".format( env=sys.platform, pyversion=sys.version ) ) diff --git a/moneykit/models/__init__.py b/moneykit/models/__init__.py index e627066..95f8b34 100644 --- a/moneykit/models/__init__.py +++ b/moneykit/models/__init__.py @@ -128,9 +128,7 @@ from moneykit.models.response401_get_account_links_id_accounts_account_id_get import ( Response401GetAccountLinksIdAccountsAccountIdGet, ) -from moneykit.models.response401_get_account_numbers_legacy20230218_links_id_accounts_numbers_get import ( - Response401GetAccountNumbersLegacy20230218LinksIdAccountsNumbersGet, -) +from moneykit.models.response401_get_account_numbers import Response401GetAccountNumbers from moneykit.models.response401_get_accounts_links_id_accounts_get import ( Response401GetAccountsLinksIdAccountsGet, ) diff --git a/moneykit/models/response401_get_account_numbers.py b/moneykit/models/response401_get_account_numbers.py new file mode 100644 index 0000000..23f1921 --- /dev/null +++ b/moneykit/models/response401_get_account_numbers.py @@ -0,0 +1,189 @@ +# coding: utf-8 + +""" + MoneyKit API + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 2023-02-18 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +import pprint +import re # noqa: F401 + +from typing import Optional +from pydantic import BaseModel, ValidationError, field_validator +from moneykit.models.api_error_auth_expired_access_token_response import ( + APIErrorAuthExpiredAccessTokenResponse, +) +from moneykit.models.api_error_auth_unauthorized_response import ( + APIErrorAuthUnauthorizedResponse, +) +from moneykit.models.link_error_unauthorized_access_response import ( + LinkErrorUnauthorizedAccessResponse, +) +from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict +from typing_extensions import Literal + +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +RESPONSE401GETACCOUNTNUMBERS_ANY_OF_SCHEMAS = [ + "APIErrorAuthExpiredAccessTokenResponse", + "APIErrorAuthUnauthorizedResponse", + "LinkErrorUnauthorizedAccessResponse", +] + + +class Response401GetAccountNumbers(BaseModel): + """ + Response401GetAccountNumbers + """ + + # data type: APIErrorAuthExpiredAccessTokenResponse + anyof_schema_1_validator: Optional[APIErrorAuthExpiredAccessTokenResponse] = None + # data type: APIErrorAuthUnauthorizedResponse + anyof_schema_2_validator: Optional[APIErrorAuthUnauthorizedResponse] = None + # data type: LinkErrorUnauthorizedAccessResponse + anyof_schema_3_validator: Optional[LinkErrorUnauthorizedAccessResponse] = None + if TYPE_CHECKING: + actual_instance: Optional[ + Union[ + APIErrorAuthExpiredAccessTokenResponse, + APIErrorAuthUnauthorizedResponse, + LinkErrorUnauthorizedAccessResponse, + ] + ] = None + else: + actual_instance: Any = None + any_of_schemas: List[str] = Literal[RESPONSE401GETACCOUNTNUMBERS_ANY_OF_SCHEMAS] + + model_config = {"validate_assignment": True} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError( + "If a position argument is used, only 1 is allowed to set `actual_instance`" + ) + if kwargs: + raise ValueError( + "If a position argument is used, keyword arguments cannot be used." + ) + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_anyof(cls, v): + instance = Response401GetAccountNumbers.model_construct() + error_messages = [] + # validate data type: APIErrorAuthExpiredAccessTokenResponse + if not isinstance(v, APIErrorAuthExpiredAccessTokenResponse): + error_messages.append( + f"Error! Input type `{type(v)}` is not `APIErrorAuthExpiredAccessTokenResponse`" + ) + else: + return v + + # validate data type: APIErrorAuthUnauthorizedResponse + if not isinstance(v, APIErrorAuthUnauthorizedResponse): + error_messages.append( + f"Error! Input type `{type(v)}` is not `APIErrorAuthUnauthorizedResponse`" + ) + else: + return v + + # validate data type: LinkErrorUnauthorizedAccessResponse + if not isinstance(v, LinkErrorUnauthorizedAccessResponse): + error_messages.append( + f"Error! Input type `{type(v)}` is not `LinkErrorUnauthorizedAccessResponse`" + ) + else: + return v + + if error_messages: + # no match + raise ValueError( + "No match found when setting the actual_instance in Response401GetAccountNumbers with anyOf schemas: APIErrorAuthExpiredAccessTokenResponse, APIErrorAuthUnauthorizedResponse, LinkErrorUnauthorizedAccessResponse. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + # anyof_schema_1_validator: Optional[APIErrorAuthExpiredAccessTokenResponse] = None + try: + instance.actual_instance = APIErrorAuthExpiredAccessTokenResponse.from_json( + json_str + ) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # anyof_schema_2_validator: Optional[APIErrorAuthUnauthorizedResponse] = None + try: + instance.actual_instance = APIErrorAuthUnauthorizedResponse.from_json( + json_str + ) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # anyof_schema_3_validator: Optional[LinkErrorUnauthorizedAccessResponse] = None + try: + instance.actual_instance = LinkErrorUnauthorizedAccessResponse.from_json( + json_str + ) + return instance + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if error_messages: + # no match + raise ValueError( + "No match found when deserializing the JSON string into Response401GetAccountNumbers with anyOf schemas: APIErrorAuthExpiredAccessTokenResponse, APIErrorAuthUnauthorizedResponse, LinkErrorUnauthorizedAccessResponse. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_dict() + else: + return json.dumps(self.actual_instance) + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/pyproject.toml b/pyproject.toml index 3e4314b..3b9cb5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "moneykit" -version = "0.1.13" +version = "0.1.14" description = "MoneyKit API" authors = ["OpenAPI Generator Community "] license = "NoLicense" diff --git a/test/test_response401_get_account_numbers.py b/test/test_response401_get_account_numbers.py new file mode 100644 index 0000000..8bfd9ef --- /dev/null +++ b/test/test_response401_get_account_numbers.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + MoneyKit API + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + The version of the OpenAPI document: 2023-02-18 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from moneykit.models.response401_get_account_numbers import Response401GetAccountNumbers + + +class TestResponse401GetAccountNumbers(unittest.TestCase): + """Response401GetAccountNumbers unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Response401GetAccountNumbers: + """Test Response401GetAccountNumbers + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `Response401GetAccountNumbers` + """ + model = Response401GetAccountNumbers() + if include_optional: + return Response401GetAccountNumbers( + error_code = link_error.unauthorized_access, + error_message = None, + documentation_url = None + ) + else: + return Response401GetAccountNumbers( + error_message = None, + ) + """ + + def testResponse401GetAccountNumbers(self): + """Test Response401GetAccountNumbers""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main()