diff --git a/poetry.lock b/poetry.lock index 397785f..37cbe9b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,14 +1,14 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" -version = "0.6.0" +version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" optional = false python-versions = ">=3.8" files = [ - {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, - {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] [package.dependencies] @@ -368,13 +368,13 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [[package]] name = "pytest-asyncio" -version = "0.23.6" +version = "0.23.7" description = "Pytest support for asyncio" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-asyncio-0.23.6.tar.gz", hash = "sha256:ffe523a89c1c222598c76856e76852b787504ddb72dd5d9b6617ffa8aa2cde5f"}, - {file = "pytest_asyncio-0.23.6-py3-none-any.whl", hash = "sha256:68516fdd1018ac57b846c9846b954f0393b26f094764a28c955eabb0536a4e8a"}, + {file = "pytest_asyncio-0.23.7-py3-none-any.whl", hash = "sha256:009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b"}, + {file = "pytest_asyncio-0.23.7.tar.gz", hash = "sha256:5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index 64188e8..3ae9cb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,35 @@ [tool.poetry] name = "trycourier" -version = "v6.0.5" +version = "v6.1.0" description = "" readme = "README.md" authors = [] +keywords = [] + +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Topic :: Software Development :: Libraries :: Python Modules", + "Typing :: Typed" +] packages = [ { include = "courier", from = "src"} ] +[project.urls] +Repository = 'https://github.com/trycourier/courier-python' + [tool.poetry.dependencies] python = "^3.8" httpx = ">=0.21.2" diff --git a/src/courier/__init__.py b/src/courier/__init__.py index d239ca9..4b6bc96 100644 --- a/src/courier/__init__.py +++ b/src/courier/__init__.py @@ -312,6 +312,7 @@ DefaultPreferences, ListUsersForTenantResponse, SubscriptionTopic, + SubscriptionTopicNew, SubscriptionTopicStatus, TemplateProperty, Tenant, @@ -580,6 +581,7 @@ "SubscribeToListsRequestListObject", "SubscribeToListsResponse", "SubscriptionTopic", + "SubscriptionTopicNew", "SubscriptionTopicStatus", "Tag", "TagData", diff --git a/src/courier/audiences/client.py b/src/courier/audiences/client.py index 3a0c6c0..7f704a8 100644 --- a/src/courier/audiences/client.py +++ b/src/courier/audiences/client.py @@ -9,9 +9,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.audience import Audience from .types.audience_list_response import AudienceListResponse from .types.audience_member_list_response import AudienceMemberListResponse @@ -58,8 +59,10 @@ def get(self, audience_id: str, *, request_options: typing.Optional[RequestOptio url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -76,7 +79,7 @@ def get(self, audience_id: str, *, request_options: typing.Optional[RequestOptio max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Audience, _response.json()) # type: ignore + return typing.cast(Audience, construct_type(type_=Audience, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -146,8 +149,10 @@ def update( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -170,7 +175,7 @@ def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceUpdateResponse, _response.json()) # type: ignore + return typing.cast(AudienceUpdateResponse, construct_type(type_=AudienceUpdateResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -209,9 +214,14 @@ def delete(self, audience_id: str, *, request_options: typing.Optional[RequestOp url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -276,16 +286,18 @@ def list_members( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}/members" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -303,9 +315,11 @@ def list_members( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceMemberListResponse, _response.json()) # type: ignore + return typing.cast(AudienceMemberListResponse, construct_type(type_=AudienceMemberListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -344,16 +358,18 @@ def list_audiences( _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audiences"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -371,9 +387,11 @@ def list_audiences( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceListResponse, _response.json()) # type: ignore + return typing.cast(AudienceListResponse, construct_type(type_=AudienceListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -417,8 +435,10 @@ async def get(self, audience_id: str, *, request_options: typing.Optional[Reques url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -435,7 +455,7 @@ async def get(self, audience_id: str, *, request_options: typing.Optional[Reques max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Audience, _response.json()) # type: ignore + return typing.cast(Audience, construct_type(type_=Audience, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -505,8 +525,10 @@ async def update( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -529,7 +551,7 @@ async def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceUpdateResponse, _response.json()) # type: ignore + return typing.cast(AudienceUpdateResponse, construct_type(type_=AudienceUpdateResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -568,9 +590,14 @@ async def delete(self, audience_id: str, *, request_options: typing.Optional[Req url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -635,16 +662,18 @@ async def list_members( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audiences/{jsonable_encoder(audience_id)}/members" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -662,9 +691,11 @@ async def list_members( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceMemberListResponse, _response.json()) # type: ignore + return typing.cast(AudienceMemberListResponse, construct_type(type_=AudienceMemberListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -703,16 +734,18 @@ async def list_audiences( _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audiences"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -730,9 +763,11 @@ async def list_audiences( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AudienceListResponse, _response.json()) # type: ignore + return typing.cast(AudienceListResponse, construct_type(type_=AudienceListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/audiences/types/audience.py b/src/courier/audiences/types/audience.py index 2e10c58..6f35e97 100644 --- a/src/courier/audiences/types/audience.py +++ b/src/courier/audiences/types/audience.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .filter import Filter -class Audience(pydantic_v1.BaseModel): +class Audience(UncheckedBaseModel): id: str = pydantic_v1.Field() """ A unique identifier representing the audience_id @@ -33,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/audience_list_response.py b/src/courier/audiences/types/audience_list_response.py index 7993d9b..ce25984 100644 --- a/src/courier/audiences/types/audience_list_response.py +++ b/src/courier/audiences/types/audience_list_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audience import Audience -class AudienceListResponse(pydantic_v1.BaseModel): +class AudienceListResponse(UncheckedBaseModel): items: typing.List[Audience] paging: Paging @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/audience_member.py b/src/courier/audiences/types/audience_member.py index 15ef335..9270fa7 100644 --- a/src/courier/audiences/types/audience_member.py +++ b/src/courier/audiences/types/audience_member.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AudienceMember(pydantic_v1.BaseModel): +class AudienceMember(UncheckedBaseModel): added_at: str audience_id: str audience_version: int @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/audience_member_get_response.py b/src/courier/audiences/types/audience_member_get_response.py index fd20086..d0a0ede 100644 --- a/src/courier/audiences/types/audience_member_get_response.py +++ b/src/courier/audiences/types/audience_member_get_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audience_member import AudienceMember -class AudienceMemberGetResponse(pydantic_v1.BaseModel): +class AudienceMemberGetResponse(UncheckedBaseModel): audience_member: AudienceMember = pydantic_v1.Field(alias="audienceMember") def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/audience_member_list_response.py b/src/courier/audiences/types/audience_member_list_response.py index 6a65a06..fcc5156 100644 --- a/src/courier/audiences/types/audience_member_list_response.py +++ b/src/courier/audiences/types/audience_member_list_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audience_member import AudienceMember -class AudienceMemberListResponse(pydantic_v1.BaseModel): +class AudienceMemberListResponse(UncheckedBaseModel): items: typing.List[AudienceMember] paging: Paging @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/audience_update_response.py b/src/courier/audiences/types/audience_update_response.py index d570396..daa12b3 100644 --- a/src/courier/audiences/types/audience_update_response.py +++ b/src/courier/audiences/types/audience_update_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audience import Audience -class AudienceUpdateResponse(pydantic_v1.BaseModel): +class AudienceUpdateResponse(UncheckedBaseModel): audience: Audience def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/base_filter_config.py b/src/courier/audiences/types/base_filter_config.py index f9a1972..da2eb98 100644 --- a/src/courier/audiences/types/base_filter_config.py +++ b/src/courier/audiences/types/base_filter_config.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .operator import Operator -class BaseFilterConfig(pydantic_v1.BaseModel): +class BaseFilterConfig(UncheckedBaseModel): operator: Operator = pydantic_v1.Field() """ The operator to use for filtering @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/nested_filter_config.py b/src/courier/audiences/types/nested_filter_config.py index c569373..51e28d6 100644 --- a/src/courier/audiences/types/nested_filter_config.py +++ b/src/courier/audiences/types/nested_filter_config.py @@ -6,7 +6,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_filter_config import BaseFilterConfig @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audiences/types/single_filter_config.py b/src/courier/audiences/types/single_filter_config.py index 33e1030..12de7fd 100644 --- a/src/courier/audiences/types/single_filter_config.py +++ b/src/courier/audiences/types/single_filter_config.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_filter_config import BaseFilterConfig @@ -28,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/client.py b/src/courier/audit_events/client.py index ada01ac..58efafc 100644 --- a/src/courier/audit_events/client.py +++ b/src/courier/audit_events/client.py @@ -7,9 +7,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.audit_event import AuditEvent from .types.list_audit_events_response import ListAuditEventsResponse @@ -18,7 +19,7 @@ class AuditEventsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> ListAuditEventsResponse: """ @@ -43,23 +44,25 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.audit_events.list( + client.audit_events.list_( cursor="string", ) """ _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audit-events"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -77,7 +80,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAuditEventsResponse, _response.json()) # type: ignore + return typing.cast(ListAuditEventsResponse, construct_type(type_=ListAuditEventsResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -116,8 +119,10 @@ def get(self, audit_event_id: str, *, request_options: typing.Optional[RequestOp url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audit-events/{jsonable_encoder(audit_event_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -134,7 +139,7 @@ def get(self, audit_event_id: str, *, request_options: typing.Optional[RequestOp max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AuditEvent, _response.json()) # type: ignore + return typing.cast(AuditEvent, construct_type(type_=AuditEvent, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -146,7 +151,7 @@ class AsyncAuditEventsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> ListAuditEventsResponse: """ @@ -171,23 +176,25 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.audit_events.list( + await client.audit_events.list_( cursor="string", ) """ _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "audit-events"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -205,7 +212,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListAuditEventsResponse, _response.json()) # type: ignore + return typing.cast(ListAuditEventsResponse, construct_type(type_=ListAuditEventsResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -244,8 +251,10 @@ async def get(self, audit_event_id: str, *, request_options: typing.Optional[Req url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"audit-events/{jsonable_encoder(audit_event_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -262,7 +271,7 @@ async def get(self, audit_event_id: str, *, request_options: typing.Optional[Req max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AuditEvent, _response.json()) # type: ignore + return typing.cast(AuditEvent, construct_type(type_=AuditEvent, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/audit_events/types/actor.py b/src/courier/audit_events/types/actor.py index 4295a54..6ebf3d2 100644 --- a/src/courier/audit_events/types/actor.py +++ b/src/courier/audit_events/types/actor.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Actor(pydantic_v1.BaseModel): +class Actor(UncheckedBaseModel): id: typing.Optional[str] = None email: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/types/audit_event.py b/src/courier/audit_events/types/audit_event.py index f47a07d..53f1531 100644 --- a/src/courier/audit_events/types/audit_event.py +++ b/src/courier/audit_events/types/audit_event.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .actor import Actor from .target import Target -class AuditEvent(pydantic_v1.BaseModel): +class AuditEvent(UncheckedBaseModel): actor: typing.Optional[Actor] = None target: typing.Optional[Target] = None audit_event_id: str = pydantic_v1.Field(alias="auditEventId") @@ -22,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/types/get_audit_event_params.py b/src/courier/audit_events/types/get_audit_event_params.py index 11d8e08..c8577ec 100644 --- a/src/courier/audit_events/types/get_audit_event_params.py +++ b/src/courier/audit_events/types/get_audit_event_params.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class GetAuditEventParams(pydantic_v1.BaseModel): +class GetAuditEventParams(UncheckedBaseModel): audit_event_id: str = pydantic_v1.Field(alias="auditEventId") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/types/list_audit_events_params.py b/src/courier/audit_events/types/list_audit_events_params.py index cd44a5a..fc60dbc 100644 --- a/src/courier/audit_events/types/list_audit_events_params.py +++ b/src/courier/audit_events/types/list_audit_events_params.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListAuditEventsParams(pydantic_v1.BaseModel): +class ListAuditEventsParams(UncheckedBaseModel): cursor: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/types/list_audit_events_response.py b/src/courier/audit_events/types/list_audit_events_response.py index 55543c8..282c15e 100644 --- a/src/courier/audit_events/types/list_audit_events_response.py +++ b/src/courier/audit_events/types/list_audit_events_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audit_event import AuditEvent -class ListAuditEventsResponse(pydantic_v1.BaseModel): +class ListAuditEventsResponse(UncheckedBaseModel): paging: Paging results: typing.List[AuditEvent] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/audit_events/types/target.py b/src/courier/audit_events/types/target.py index 2efc31b..7f881f0 100644 --- a/src/courier/audit_events/types/target.py +++ b/src/courier/audit_events/types/target.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Target(pydantic_v1.BaseModel): +class Target(UncheckedBaseModel): id: typing.Optional[str] = None email: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/auth_tokens/client.py b/src/courier/auth_tokens/client.py index 549e573..c2e9eba 100644 --- a/src/courier/auth_tokens/client.py +++ b/src/courier/auth_tokens/client.py @@ -7,9 +7,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.issue_token_response import IssueTokenResponse # this is used as the default value for optional parameters @@ -65,8 +66,10 @@ def issue_token( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "auth/issue-token"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"scope": scope, "expires_in": expires_in}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -91,7 +94,7 @@ def issue_token( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(IssueTokenResponse, _response.json()) # type: ignore + return typing.cast(IssueTokenResponse, construct_type(type_=IssueTokenResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -148,8 +151,10 @@ async def issue_token( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "auth/issue-token"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"scope": scope, "expires_in": expires_in}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -174,7 +179,7 @@ async def issue_token( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(IssueTokenResponse, _response.json()) # type: ignore + return typing.cast(IssueTokenResponse, construct_type(type_=IssueTokenResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/auth_tokens/types/issue_token_response.py b/src/courier/auth_tokens/types/issue_token_response.py index 8c411dc..7bbba09 100644 --- a/src/courier/auth_tokens/types/issue_token_response.py +++ b/src/courier/auth_tokens/types/issue_token_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class IssueTokenResponse(pydantic_v1.BaseModel): +class IssueTokenResponse(UncheckedBaseModel): token: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/client.py b/src/courier/automations/client.py index c93f081..bbd57eb 100644 --- a/src/courier/automations/client.py +++ b/src/courier/automations/client.py @@ -7,9 +7,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.automation_ad_hoc_invoke_params import AutomationAdHocInvokeParams from .types.automation_invoke_params import AutomationInvokeParams from .types.automation_invoke_response import AutomationInvokeResponse @@ -77,8 +78,10 @@ def invoke_automation_template( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"automations/{jsonable_encoder(template_id)}/invoke" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -103,7 +106,7 @@ def invoke_automation_template( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AutomationInvokeResponse, _response.json()) # type: ignore + return typing.cast(AutomationInvokeResponse, construct_type(type_=AutomationInvokeResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -174,8 +177,10 @@ def invoke_ad_hoc_automation( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "automations/invoke"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -200,7 +205,7 @@ def invoke_ad_hoc_automation( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AutomationInvokeResponse, _response.json()) # type: ignore + return typing.cast(AutomationInvokeResponse, construct_type(type_=AutomationInvokeResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -267,8 +272,10 @@ async def invoke_automation_template( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"automations/{jsonable_encoder(template_id)}/invoke" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -293,7 +300,7 @@ async def invoke_automation_template( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AutomationInvokeResponse, _response.json()) # type: ignore + return typing.cast(AutomationInvokeResponse, construct_type(type_=AutomationInvokeResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -364,8 +371,10 @@ async def invoke_ad_hoc_automation( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "automations/invoke"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -390,7 +399,7 @@ async def invoke_ad_hoc_automation( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(AutomationInvokeResponse, _response.json()) # type: ignore + return typing.cast(AutomationInvokeResponse, construct_type(type_=AutomationInvokeResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/automations/types/accessor_type.py b/src/courier/automations/types/accessor_type.py index d84f104..a63e301 100644 --- a/src/courier/automations/types/accessor_type.py +++ b/src/courier/automations/types/accessor_type.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AccessorType(pydantic_v1.BaseModel): +class AccessorType(UncheckedBaseModel): ref: str = pydantic_v1.Field(alias="$ref") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation.py b/src/courier/automations/types/automation.py index 41b3a54..93ae950 100644 --- a/src/courier/automations/types/automation.py +++ b/src/courier/automations/types/automation.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .automation_step_option import AutomationStepOption -class Automation(pydantic_v1.BaseModel): +class Automation(UncheckedBaseModel): cancelation_token: typing.Optional[str] = None steps: typing.List[AutomationStepOption] @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_ad_hoc_invoke_params.py b/src/courier/automations/types/automation_ad_hoc_invoke_params.py index f385da4..1210f3f 100644 --- a/src/courier/automations/types/automation_ad_hoc_invoke_params.py +++ b/src/courier/automations/types/automation_ad_hoc_invoke_params.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation import Automation from .automation_invoke_params import AutomationInvokeParams @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_add_to_batch_retain.py b/src/courier/automations/types/automation_add_to_batch_retain.py index a4ec80d..03c7ae5 100644 --- a/src/courier/automations/types/automation_add_to_batch_retain.py +++ b/src/courier/automations/types/automation_add_to_batch_retain.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .automation_add_to_batch_retain_type import AutomationAddToBatchRetainType -class AutomationAddToBatchRetain(pydantic_v1.BaseModel): +class AutomationAddToBatchRetain(UncheckedBaseModel): """ Defines what items should be retained and passed along to the next steps when the batch is released @@ -45,8 +46,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_add_to_batch_step.py b/src/courier/automations/types/automation_add_to_batch_step.py index e0746a8..f4ace44 100644 --- a/src/courier/automations/types/automation_add_to_batch_step.py +++ b/src/courier/automations/types/automation_add_to_batch_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_add_to_batch_max_items_type import AutomationAddToBatchMaxItemsType from .automation_add_to_batch_retain import AutomationAddToBatchRetain from .automation_add_to_batch_scope import AutomationAddToBatchScope @@ -70,8 +70,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_add_to_digest_step.py b/src/courier/automations/types/automation_add_to_digest_step.py index 07e2c11..8c83ef6 100644 --- a/src/courier/automations/types/automation_add_to_digest_step.py +++ b/src/courier/automations/types/automation_add_to_digest_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -31,8 +31,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_cancel_step.py b/src/courier/automations/types/automation_cancel_step.py index 80eeb11..257a6c3 100644 --- a/src/courier/automations/types/automation_cancel_step.py +++ b/src/courier/automations/types/automation_cancel_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_delay_step.py b/src/courier/automations/types/automation_delay_step.py index be2df62..7f5c0b1 100644 --- a/src/courier/automations/types/automation_delay_step.py +++ b/src/courier/automations/types/automation_delay_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -25,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_fetch_data_step.py b/src/courier/automations/types/automation_fetch_data_step.py index 197e3dd..0e4ab95 100644 --- a/src/courier/automations/types/automation_fetch_data_step.py +++ b/src/courier/automations/types/automation_fetch_data_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_fetch_data_webhook import AutomationFetchDataWebhook from .automation_step import AutomationStep from .merge_algorithm import MergeAlgorithm @@ -40,8 +40,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_fetch_data_webhook.py b/src/courier/automations/types/automation_fetch_data_webhook.py index 6583b16..23d7267 100644 --- a/src/courier/automations/types/automation_fetch_data_webhook.py +++ b/src/courier/automations/types/automation_fetch_data_webhook.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .automation_fetch_data_webhook_method import AutomationFetchDataWebhookMethod -class AutomationFetchDataWebhook(pydantic_v1.BaseModel): +class AutomationFetchDataWebhook(UncheckedBaseModel): body: typing.Optional[typing.Dict[str, typing.Any]] = None headers: typing.Optional[typing.Dict[str, typing.Any]] = None params: typing.Optional[typing.Dict[str, typing.Any]] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_invoke_params.py b/src/courier/automations/types/automation_invoke_params.py index 6e8653a..1018a17 100644 --- a/src/courier/automations/types/automation_invoke_params.py +++ b/src/courier/automations/types/automation_invoke_params.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .profile import Profile -class AutomationInvokeParams(pydantic_v1.BaseModel): +class AutomationInvokeParams(UncheckedBaseModel): brand: typing.Optional[str] = None data: typing.Optional[typing.Dict[str, typing.Any]] = None profile: typing.Optional[Profile] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_invoke_response.py b/src/courier/automations/types/automation_invoke_response.py index 8372bad..f3e68d0 100644 --- a/src/courier/automations/types/automation_invoke_response.py +++ b/src/courier/automations/types/automation_invoke_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AutomationInvokeResponse(pydantic_v1.BaseModel): +class AutomationInvokeResponse(UncheckedBaseModel): run_id: str = pydantic_v1.Field(alias="runId") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_invoke_step.py b/src/courier/automations/types/automation_invoke_step.py index 428f6fa..dc020d3 100644 --- a/src/courier/automations/types/automation_invoke_step.py +++ b/src/courier/automations/types/automation_invoke_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_invoke_template_params.py b/src/courier/automations/types/automation_invoke_template_params.py index a40ff17..60c7b24 100644 --- a/src/courier/automations/types/automation_invoke_template_params.py +++ b/src/courier/automations/types/automation_invoke_template_params.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_invoke_params import AutomationInvokeParams @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_run_context.py b/src/courier/automations/types/automation_run_context.py index 57a0589..b6e6a15 100644 --- a/src/courier/automations/types/automation_run_context.py +++ b/src/courier/automations/types/automation_run_context.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .profile import Profile -class AutomationRunContext(pydantic_v1.BaseModel): +class AutomationRunContext(UncheckedBaseModel): brand: typing.Optional[str] = None data: typing.Optional[typing.Any] = None profile: typing.Optional[Profile] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_send_list_step.py b/src/courier/automations/types/automation_send_list_step.py index 6001207..c9a3fe3 100644 --- a/src/courier/automations/types/automation_send_list_step.py +++ b/src/courier/automations/types/automation_send_list_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_send_step.py b/src/courier/automations/types/automation_send_step.py index 11fbe96..277487f 100644 --- a/src/courier/automations/types/automation_send_step.py +++ b/src/courier/automations/types/automation_send_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep @@ -22,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_step.py b/src/courier/automations/types/automation_step.py index 18e4367..4eee2e5 100644 --- a/src/courier/automations/types/automation_step.py +++ b/src/courier/automations/types/automation_step.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AutomationStep(pydantic_v1.BaseModel): +class AutomationStep(UncheckedBaseModel): if_: typing.Optional[str] = pydantic_v1.Field(alias="if", default=None) ref: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_throttle_on_throttle.py b/src/courier/automations/types/automation_throttle_on_throttle.py index fbc56f6..fd2c244 100644 --- a/src/courier/automations/types/automation_throttle_on_throttle.py +++ b/src/courier/automations/types/automation_throttle_on_throttle.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AutomationThrottleOnThrottle(pydantic_v1.BaseModel): +class AutomationThrottleOnThrottle(UncheckedBaseModel): node_id: str = pydantic_v1.Field(alias="$node_id") """ The node to go to if the request is throttled @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_throttle_step.py b/src/courier/automations/types/automation_throttle_step.py index 548b4f9..e3c3e18 100644 --- a/src/courier/automations/types/automation_throttle_step.py +++ b/src/courier/automations/types/automation_throttle_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .automation_step import AutomationStep from .automation_throttle_on_throttle import AutomationThrottleOnThrottle from .automation_throttle_scope import AutomationThrottleScope @@ -58,8 +58,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_update_profile_step.py b/src/courier/automations/types/automation_update_profile_step.py index 261790f..5f4e977 100644 --- a/src/courier/automations/types/automation_update_profile_step.py +++ b/src/courier/automations/types/automation_update_profile_step.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .merge_algorithm import MergeAlgorithm from .profile import Profile -class AutomationUpdateProfileStep(pydantic_v1.BaseModel): +class AutomationUpdateProfileStep(UncheckedBaseModel): action: typing.Literal["update-profile"] recipient_id: str profile: Profile @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/automations/types/automation_v_2_send_step.py b/src/courier/automations/types/automation_v_2_send_step.py index 22c03d4..1196b66 100644 --- a/src/courier/automations/types/automation_v_2_send_step.py +++ b/src/courier/automations/types/automation_v_2_send_step.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...send.types.message import Message from .automation_step import AutomationStep @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/client.py b/src/courier/brands/client.py index de86d0b..74d35f3 100644 --- a/src/courier/brands/client.py +++ b/src/courier/brands/client.py @@ -15,9 +15,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.brand import Brand from .types.brand_parameters import BrandParameters from .types.brand_settings import BrandSettings @@ -77,8 +78,10 @@ def create( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "brands"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -103,13 +106,19 @@ def create( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 402: - raise PaymentRequiredError(pydantic_v1.parse_obj_as(PaymentRequired, _response.json())) # type: ignore + raise PaymentRequiredError( + typing.cast(PaymentRequired, construct_type(type_=PaymentRequired, object_=_response.json())) # type: ignore + ) if _response.status_code == 409: - raise AlreadyExistsError(pydantic_v1.parse_obj_as(AlreadyExists, _response.json())) # type: ignore + raise AlreadyExistsError( + typing.cast(AlreadyExists, construct_type(type_=AlreadyExists, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -146,8 +155,10 @@ def get(self, brand_id: str, *, request_options: typing.Optional[RequestOptions] _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -164,14 +175,14 @@ def get(self, brand_id: str, *, request_options: typing.Optional[RequestOptions] max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def list( + def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> BrandsResponse: """ @@ -196,23 +207,25 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.brands.list( + client.brands.list_( cursor="string", ) """ _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "brands"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -230,7 +243,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BrandsResponse, _response.json()) # type: ignore + return typing.cast(BrandsResponse, construct_type(type_=BrandsResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -267,9 +280,14 @@ def delete(self, brand_id: str, *, request_options: typing.Optional[RequestOptio _response = self._client_wrapper.httpx_client.request( method="DELETE", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -287,7 +305,9 @@ def delete(self, brand_id: str, *, request_options: typing.Optional[RequestOptio if 200 <= _response.status_code < 300: return if _response.status_code == 409: - raise ConflictError(pydantic_v1.parse_obj_as(Conflict, _response.json())) # type: ignore + raise ConflictError( + typing.cast(Conflict, construct_type(type_=Conflict, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -366,8 +386,10 @@ def replace( _response = self._client_wrapper.httpx_client.request( method="PUT", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -390,7 +412,7 @@ def replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -447,8 +469,10 @@ async def create( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "brands"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -473,13 +497,19 @@ async def create( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 402: - raise PaymentRequiredError(pydantic_v1.parse_obj_as(PaymentRequired, _response.json())) # type: ignore + raise PaymentRequiredError( + typing.cast(PaymentRequired, construct_type(type_=PaymentRequired, object_=_response.json())) # type: ignore + ) if _response.status_code == 409: - raise AlreadyExistsError(pydantic_v1.parse_obj_as(AlreadyExists, _response.json())) # type: ignore + raise AlreadyExistsError( + typing.cast(AlreadyExists, construct_type(type_=AlreadyExists, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -516,8 +546,10 @@ async def get(self, brand_id: str, *, request_options: typing.Optional[RequestOp _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -534,14 +566,14 @@ async def get(self, brand_id: str, *, request_options: typing.Optional[RequestOp max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def list( + async def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> BrandsResponse: """ @@ -566,23 +598,25 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.brands.list( + await client.brands.list_( cursor="string", ) """ _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "brands"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -600,7 +634,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BrandsResponse, _response.json()) # type: ignore + return typing.cast(BrandsResponse, construct_type(type_=BrandsResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -637,9 +671,14 @@ async def delete(self, brand_id: str, *, request_options: typing.Optional[Reques _response = await self._client_wrapper.httpx_client.request( method="DELETE", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -657,7 +696,9 @@ async def delete(self, brand_id: str, *, request_options: typing.Optional[Reques if 200 <= _response.status_code < 300: return if _response.status_code == 409: - raise ConflictError(pydantic_v1.parse_obj_as(Conflict, _response.json())) # type: ignore + raise ConflictError( + typing.cast(Conflict, construct_type(type_=Conflict, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -736,8 +777,10 @@ async def replace( _response = await self._client_wrapper.httpx_client.request( method="PUT", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"brands/{jsonable_encoder(brand_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -760,7 +803,7 @@ async def replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Brand, _response.json()) # type: ignore + return typing.cast(Brand, construct_type(type_=Brand, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/brands/types/brand.py b/src/courier/brands/types/brand.py index cd6c436..4709f64 100644 --- a/src/courier/brands/types/brand.py +++ b/src/courier/brands/types/brand.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand_settings import BrandSettings from .brand_snippets import BrandSnippets -class Brand(pydantic_v1.BaseModel): +class Brand(UncheckedBaseModel): created: int = pydantic_v1.Field() """ The date/time of when the brand was created. Represented in milliseconds since Unix epoch. @@ -47,8 +48,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_colors.py b/src/courier/brands/types/brand_colors.py index 5beb1aa..0bb3b2e 100644 --- a/src/courier/brands/types/brand_colors.py +++ b/src/courier/brands/types/brand_colors.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BrandColors(pydantic_v1.BaseModel): +class BrandColors(UncheckedBaseModel): primary: typing.Optional[str] = None secondary: typing.Optional[str] = None tertiary: typing.Optional[str] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_get_all_response.py b/src/courier/brands/types/brand_get_all_response.py index 88b1c79..2c30cfa 100644 --- a/src/courier/brands/types/brand_get_all_response.py +++ b/src/courier/brands/types/brand_get_all_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand import Brand -class BrandGetAllResponse(pydantic_v1.BaseModel): +class BrandGetAllResponse(UncheckedBaseModel): paging: Paging results: typing.List[Brand] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_parameters.py b/src/courier/brands/types/brand_parameters.py index 2f89bba..582346b 100644 --- a/src/courier/brands/types/brand_parameters.py +++ b/src/courier/brands/types/brand_parameters.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand_settings import BrandSettings from .brand_snippets import BrandSnippets -class BrandParameters(pydantic_v1.BaseModel): +class BrandParameters(UncheckedBaseModel): id: typing.Optional[str] = None name: str = pydantic_v1.Field() """ @@ -24,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_settings.py b/src/courier/brands/types/brand_settings.py index b8b0ef9..f9e6425 100644 --- a/src/courier/brands/types/brand_settings.py +++ b/src/courier/brands/types/brand_settings.py @@ -5,11 +5,12 @@ from ...commons.types.email import Email from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand_colors import BrandColors -class BrandSettings(pydantic_v1.BaseModel): +class BrandSettings(UncheckedBaseModel): colors: typing.Optional[BrandColors] = None inapp: typing.Optional[typing.Any] = None email: typing.Optional[Email] = None @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_snippet.py b/src/courier/brands/types/brand_snippet.py index 6e46bf8..36f55b5 100644 --- a/src/courier/brands/types/brand_snippet.py +++ b/src/courier/brands/types/brand_snippet.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BrandSnippet(pydantic_v1.BaseModel): +class BrandSnippet(UncheckedBaseModel): format: typing.Literal["handlebars"] name: str value: str @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brand_snippets.py b/src/courier/brands/types/brand_snippets.py index 5a8cb60..c47369d 100644 --- a/src/courier/brands/types/brand_snippets.py +++ b/src/courier/brands/types/brand_snippets.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand_snippet import BrandSnippet -class BrandSnippets(pydantic_v1.BaseModel): +class BrandSnippets(UncheckedBaseModel): items: typing.List[BrandSnippet] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/brands/types/brands_response.py b/src/courier/brands/types/brands_response.py index 99dd6eb..b4f05e3 100644 --- a/src/courier/brands/types/brands_response.py +++ b/src/courier/brands/types/brands_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand import Brand -class BrandsResponse(pydantic_v1.BaseModel): +class BrandsResponse(UncheckedBaseModel): paging: Paging results: typing.List[Brand] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/client.py b/src/courier/bulk/client.py index 960d684..9df33f1 100644 --- a/src/courier/bulk/client.py +++ b/src/courier/bulk/client.py @@ -9,9 +9,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.bulk_create_job_response import BulkCreateJobResponse from .types.bulk_get_job_response import BulkGetJobResponse from .types.bulk_get_job_users_response import BulkGetJobUsersResponse @@ -73,8 +74,10 @@ def create_job( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "bulk"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"message": message}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -99,9 +102,11 @@ def create_job( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkCreateJobResponse, _response.json()) # type: ignore + return typing.cast(BulkCreateJobResponse, construct_type(type_=BulkCreateJobResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -170,8 +175,10 @@ def ingest_users( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -245,8 +252,10 @@ def run_job( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}/run"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -270,7 +279,9 @@ def run_job( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -307,8 +318,10 @@ def get_job(self, job_id: str, *, request_options: typing.Optional[RequestOption _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -325,9 +338,11 @@ def get_job(self, job_id: str, *, request_options: typing.Optional[RequestOption max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkGetJobResponse, _response.json()) # type: ignore + return typing.cast(BulkGetJobResponse, construct_type(type_=BulkGetJobResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -368,8 +383,10 @@ def get_users( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}/users" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -386,9 +403,11 @@ def get_users( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkGetJobUsersResponse, _response.json()) # type: ignore + return typing.cast(BulkGetJobUsersResponse, construct_type(type_=BulkGetJobUsersResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -447,8 +466,10 @@ async def create_job( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "bulk"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"message": message}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -473,9 +494,11 @@ async def create_job( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkCreateJobResponse, _response.json()) # type: ignore + return typing.cast(BulkCreateJobResponse, construct_type(type_=BulkCreateJobResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -544,8 +567,10 @@ async def ingest_users( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -619,8 +644,10 @@ async def run_job( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}/run"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -644,7 +671,9 @@ async def run_job( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -683,8 +712,10 @@ async def get_job( _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -701,9 +732,11 @@ async def get_job( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkGetJobResponse, _response.json()) # type: ignore + return typing.cast(BulkGetJobResponse, construct_type(type_=BulkGetJobResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -744,8 +777,10 @@ async def get_users( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"bulk/{jsonable_encoder(job_id)}/users" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -762,9 +797,11 @@ async def get_users( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(BulkGetJobUsersResponse, _response.json()) # type: ignore + return typing.cast(BulkGetJobUsersResponse, construct_type(type_=BulkGetJobUsersResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/bulk/types/bulk_create_job_response.py b/src/courier/bulk/types/bulk_create_job_response.py index 0ecde0a..676051a 100644 --- a/src/courier/bulk/types/bulk_create_job_response.py +++ b/src/courier/bulk/types/bulk_create_job_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BulkCreateJobResponse(pydantic_v1.BaseModel): +class BulkCreateJobResponse(UncheckedBaseModel): job_id: str = pydantic_v1.Field(alias="jobId") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_get_job_params.py b/src/courier/bulk/types/bulk_get_job_params.py index 5b434ad..4cf8ec8 100644 --- a/src/courier/bulk/types/bulk_get_job_params.py +++ b/src/courier/bulk/types/bulk_get_job_params.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BulkGetJobParams(pydantic_v1.BaseModel): +class BulkGetJobParams(UncheckedBaseModel): job_id: str = pydantic_v1.Field(alias="jobId") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_get_job_response.py b/src/courier/bulk/types/bulk_get_job_response.py index 7228eb2..01b95e9 100644 --- a/src/courier/bulk/types/bulk_get_job_response.py +++ b/src/courier/bulk/types/bulk_get_job_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .job_details import JobDetails -class BulkGetJobResponse(pydantic_v1.BaseModel): +class BulkGetJobResponse(UncheckedBaseModel): job: JobDetails def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_get_job_users_params.py b/src/courier/bulk/types/bulk_get_job_users_params.py index f05091d..7658d55 100644 --- a/src/courier/bulk/types/bulk_get_job_users_params.py +++ b/src/courier/bulk/types/bulk_get_job_users_params.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BulkGetJobUsersParams(pydantic_v1.BaseModel): +class BulkGetJobUsersParams(UncheckedBaseModel): job_id: str = pydantic_v1.Field(alias="jobId") cursor: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_get_job_users_response.py b/src/courier/bulk/types/bulk_get_job_users_response.py index 3dac7df..011efe4 100644 --- a/src/courier/bulk/types/bulk_get_job_users_response.py +++ b/src/courier/bulk/types/bulk_get_job_users_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .bulk_message_user_response import BulkMessageUserResponse -class BulkGetJobUsersResponse(pydantic_v1.BaseModel): +class BulkGetJobUsersResponse(UncheckedBaseModel): items: typing.List[BulkMessageUserResponse] paging: Paging @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_ingest_error.py b/src/courier/bulk/types/bulk_ingest_error.py index 162c029..e3fddec 100644 --- a/src/courier/bulk/types/bulk_ingest_error.py +++ b/src/courier/bulk/types/bulk_ingest_error.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BulkIngestError(pydantic_v1.BaseModel): +class BulkIngestError(UncheckedBaseModel): user: typing.Any error: typing.Any @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_ingest_users_params.py b/src/courier/bulk/types/bulk_ingest_users_params.py index 3ccf861..133e285 100644 --- a/src/courier/bulk/types/bulk_ingest_users_params.py +++ b/src/courier/bulk/types/bulk_ingest_users_params.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .inbound_bulk_message_user import InboundBulkMessageUser -class BulkIngestUsersParams(pydantic_v1.BaseModel): +class BulkIngestUsersParams(UncheckedBaseModel): users: typing.List[InboundBulkMessageUser] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_ingest_users_response.py b/src/courier/bulk/types/bulk_ingest_users_response.py index 3ad5157..7d2a79f 100644 --- a/src/courier/bulk/types/bulk_ingest_users_response.py +++ b/src/courier/bulk/types/bulk_ingest_users_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .bulk_ingest_error import BulkIngestError -class BulkIngestUsersResponse(pydantic_v1.BaseModel): +class BulkIngestUsersResponse(UncheckedBaseModel): total: int errors: typing.Optional[typing.List[BulkIngestError]] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/bulk_message_user_response.py b/src/courier/bulk/types/bulk_message_user_response.py index a13840d..86293eb 100644 --- a/src/courier/bulk/types/bulk_message_user_response.py +++ b/src/courier/bulk/types/bulk_message_user_response.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .bulk_job_user_status import BulkJobUserStatus from .inbound_bulk_message_user import InboundBulkMessageUser @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/inbound_bulk_content_message.py b/src/courier/bulk/types/inbound_bulk_content_message.py index 06c1595..be162f2 100644 --- a/src/courier/bulk/types/inbound_bulk_content_message.py +++ b/src/courier/bulk/types/inbound_bulk_content_message.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...send.types.base_message import BaseMessage from ...send.types.content import Content @@ -26,8 +26,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/inbound_bulk_message.py b/src/courier/bulk/types/inbound_bulk_message.py index d287e52..4f103d1 100644 --- a/src/courier/bulk/types/inbound_bulk_message.py +++ b/src/courier/bulk/types/inbound_bulk_message.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .inbound_bulk_message_v_1 import InboundBulkMessageV1 from .inbound_bulk_message_v_2 import InboundBulkMessageV2 @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/inbound_bulk_message_user.py b/src/courier/bulk/types/inbound_bulk_message_user.py index 2fdfe93..3f45d8d 100644 --- a/src/courier/bulk/types/inbound_bulk_message_user.py +++ b/src/courier/bulk/types/inbound_bulk_message_user.py @@ -5,11 +5,12 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from ...send.types.user_recipient import UserRecipient -class InboundBulkMessageUser(pydantic_v1.BaseModel): +class InboundBulkMessageUser(UncheckedBaseModel): preferences: typing.Optional[RecipientPreferences] = None profile: typing.Optional[typing.Any] = None recipient: typing.Optional[str] = None @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/inbound_bulk_message_v_1.py b/src/courier/bulk/types/inbound_bulk_message_v_1.py index 5872707..3a690e9 100644 --- a/src/courier/bulk/types/inbound_bulk_message_v_1.py +++ b/src/courier/bulk/types/inbound_bulk_message_v_1.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class InboundBulkMessageV1(pydantic_v1.BaseModel): +class InboundBulkMessageV1(UncheckedBaseModel): brand: typing.Optional[str] = pydantic_v1.Field(default=None) """ A unique identifier that represents the brand that should be used @@ -34,8 +35,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/inbound_bulk_template_message.py b/src/courier/bulk/types/inbound_bulk_template_message.py index 6b9a9cd..8682f7b 100644 --- a/src/courier/bulk/types/inbound_bulk_template_message.py +++ b/src/courier/bulk/types/inbound_bulk_template_message.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...send.types.base_message import BaseMessage @@ -20,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/bulk/types/job_details.py b/src/courier/bulk/types/job_details.py index 08f2f8e..babaa23 100644 --- a/src/courier/bulk/types/job_details.py +++ b/src/courier/bulk/types/job_details.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .bulk_job_status import BulkJobStatus from .inbound_bulk_message import InboundBulkMessage -class JobDetails(pydantic_v1.BaseModel): +class JobDetails(UncheckedBaseModel): definition: InboundBulkMessage enqueued: int failures: int @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/client.py b/src/courier/client.py index 69401ca..03befc1 100644 --- a/src/courier/client.py +++ b/src/courier/client.py @@ -16,9 +16,10 @@ from .core.api_error import ApiError from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .core.jsonable_encoder import jsonable_encoder -from .core.pydantic_utilities import pydantic_v1 +from .core.query_encoder import encode_query from .core.remove_none_from_dict import remove_none_from_dict from .core.request_options import RequestOptions +from .core.unchecked_base_model import construct_type from .environment import CourierEnvironment from .lists.client import AsyncListsClient, ListsClient from .messages.client import AsyncMessagesClient, MessagesClient @@ -37,7 +38,7 @@ class Courier: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- @@ -182,8 +183,10 @@ def send( _response = self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "send"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"message": message}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -208,7 +211,7 @@ def send( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SendMessageResponse, _response.json()) # type: ignore + return typing.cast(SendMessageResponse, construct_type(type_=SendMessageResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -218,7 +221,7 @@ def send( class AsyncCourier: """ - Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions. + Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions. Parameters ---------- @@ -363,8 +366,10 @@ async def send( _response = await self._client_wrapper.httpx_client.request( method="POST", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "send"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"message": message}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -389,7 +394,7 @@ async def send( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SendMessageResponse, _response.json()) # type: ignore + return typing.cast(SendMessageResponse, construct_type(type_=SendMessageResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/commons/types/already_exists.py b/src/courier/commons/types/already_exists.py index 262ac78..fdd7506 100644 --- a/src/courier/commons/types/already_exists.py +++ b/src/courier/commons/types/already_exists.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/bad_request.py b/src/courier/commons/types/bad_request.py index e5a1115..376f038 100644 --- a/src/courier/commons/types/bad_request.py +++ b/src/courier/commons/types/bad_request.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/base_error.py b/src/courier/commons/types/base_error.py index 8e7f50a..e2eb4b4 100644 --- a/src/courier/commons/types/base_error.py +++ b/src/courier/commons/types/base_error.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BaseError(pydantic_v1.BaseModel): +class BaseError(UncheckedBaseModel): message: str = pydantic_v1.Field() """ A message describing the error that occurred. @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/channel_preference.py b/src/courier/commons/types/channel_preference.py index 173db68..76b0688 100644 --- a/src/courier/commons/types/channel_preference.py +++ b/src/courier/commons/types/channel_preference.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .channel_classification import ChannelClassification -class ChannelPreference(pydantic_v1.BaseModel): +class ChannelPreference(UncheckedBaseModel): channel: ChannelClassification def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/conflict.py b/src/courier/commons/types/conflict.py index 38bbdcf..8a6d42f 100644 --- a/src/courier/commons/types/conflict.py +++ b/src/courier/commons/types/conflict.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/email.py b/src/courier/commons/types/email.py index a3ce92e..08cad4f 100644 --- a/src/courier/commons/types/email.py +++ b/src/courier/commons/types/email.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Email(pydantic_v1.BaseModel): +class Email(UncheckedBaseModel): footer: typing.Any header: typing.Any @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/message_not_found.py b/src/courier/commons/types/message_not_found.py index 90f0b6b..a08d939 100644 --- a/src/courier/commons/types/message_not_found.py +++ b/src/courier/commons/types/message_not_found.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/not_found.py b/src/courier/commons/types/not_found.py index 7cdd780..7a84221 100644 --- a/src/courier/commons/types/not_found.py +++ b/src/courier/commons/types/not_found.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/notification_preference_details.py b/src/courier/commons/types/notification_preference_details.py index 57839a9..7afb021 100644 --- a/src/courier/commons/types/notification_preference_details.py +++ b/src/courier/commons/types/notification_preference_details.py @@ -4,13 +4,14 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .channel_preference import ChannelPreference from .preference_status import PreferenceStatus from .rule import Rule -class NotificationPreferenceDetails(pydantic_v1.BaseModel): +class NotificationPreferenceDetails(UncheckedBaseModel): status: PreferenceStatus rules: typing.Optional[typing.List[Rule]] = None channel_preferences: typing.Optional[typing.List[ChannelPreference]] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/paging.py b/src/courier/commons/types/paging.py index 39a1f49..532393c 100644 --- a/src/courier/commons/types/paging.py +++ b/src/courier/commons/types/paging.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Paging(pydantic_v1.BaseModel): +class Paging(UncheckedBaseModel): cursor: typing.Optional[str] = None more: bool @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/payment_required.py b/src/courier/commons/types/payment_required.py index 09ce8a6..ee97453 100644 --- a/src/courier/commons/types/payment_required.py +++ b/src/courier/commons/types/payment_required.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_error import BaseError @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/recipient_preferences.py b/src/courier/commons/types/recipient_preferences.py index 5e8a156..64bd718 100644 --- a/src/courier/commons/types/recipient_preferences.py +++ b/src/courier/commons/types/recipient_preferences.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification_preferences import NotificationPreferences -class RecipientPreferences(pydantic_v1.BaseModel): +class RecipientPreferences(UncheckedBaseModel): categories: typing.Optional[NotificationPreferences] = None notifications: typing.Optional[NotificationPreferences] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/rule.py b/src/courier/commons/types/rule.py index fc46562..baa5d9b 100644 --- a/src/courier/commons/types/rule.py +++ b/src/courier/commons/types/rule.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Rule(pydantic_v1.BaseModel): +class Rule(UncheckedBaseModel): start: typing.Optional[str] = None until: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/commons/types/user_tenant_association.py b/src/courier/commons/types/user_tenant_association.py index 8a0f168..5629c09 100644 --- a/src/courier/commons/types/user_tenant_association.py +++ b/src/courier/commons/types/user_tenant_association.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class UserTenantAssociation(pydantic_v1.BaseModel): +class UserTenantAssociation(UncheckedBaseModel): user_id: typing.Optional[str] = pydantic_v1.Field(default=None) """ User ID for the assocation between tenant and user @@ -29,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/core/__init__.py b/src/courier/core/__init__.py index 78a7f80..e4d00ce 100644 --- a/src/courier/core/__init__.py +++ b/src/courier/core/__init__.py @@ -6,9 +6,11 @@ from .file import File, convert_file_dict_to_httpx_tuples from .http_client import AsyncHttpClient, HttpClient from .jsonable_encoder import jsonable_encoder -from .pydantic_utilities import pydantic_v1 +from .pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .query_encoder import encode_query from .remove_none_from_dict import remove_none_from_dict from .request_options import RequestOptions +from .unchecked_base_model import UncheckedBaseModel, UnionMetadata, construct_type __all__ = [ "ApiError", @@ -19,7 +21,12 @@ "HttpClient", "RequestOptions", "SyncClientWrapper", + "UncheckedBaseModel", + "UnionMetadata", + "construct_type", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", + "encode_query", "jsonable_encoder", "pydantic_v1", "remove_none_from_dict", diff --git a/src/courier/core/client_wrapper.py b/src/courier/core/client_wrapper.py index 5c99ebb..20b5453 100644 --- a/src/courier/core/client_wrapper.py +++ b/src/courier/core/client_wrapper.py @@ -23,7 +23,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "trycourier", - "X-Fern-SDK-Version": "v6.0.5", + "X-Fern-SDK-Version": "v6.1.0", } headers["Authorization"] = f"Bearer {self._get_authorization_token()}" return headers diff --git a/src/courier/core/pydantic_utilities.py b/src/courier/core/pydantic_utilities.py index 952b5f2..a72c1a5 100644 --- a/src/courier/core/pydantic_utilities.py +++ b/src/courier/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +import typing + import pydantic IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -9,4 +11,18 @@ else: import pydantic as pydantic_v1 # type: ignore # nopycln: import + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + __all__ = ["pydantic_v1"] diff --git a/src/courier/core/query_encoder.py b/src/courier/core/query_encoder.py new file mode 100644 index 0000000..1f5f766 --- /dev/null +++ b/src/courier/core/query_encoder.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +from collections import ChainMap +from typing import Any, Dict, Optional + +from .pydantic_utilities import pydantic_v1 + + +# Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: + result = {} + for k, v in dict_flat.items(): + key = f"{key_prefix}[{k}]" if key_prefix is not None else k + if isinstance(v, dict): + result.update(traverse_query_dict(v, key)) + else: + result[key] = v + return result + + +def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: + if isinstance(query_value, pydantic_v1.BaseModel) or isinstance(query_value, dict): + if isinstance(query_value, pydantic_v1.BaseModel): + obj_dict = query_value.dict(by_alias=True) + else: + obj_dict = query_value + return traverse_query_dict(obj_dict, query_key) + + return {query_key: query_value} + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: + return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None diff --git a/src/courier/core/unchecked_base_model.py b/src/courier/core/unchecked_base_model.py new file mode 100644 index 0000000..425320d --- /dev/null +++ b/src/courier/core/unchecked_base_model.py @@ -0,0 +1,223 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import inspect +import typing +import uuid + +import typing_extensions + +from .datetime_utils import serialize_datetime +from .pydantic_utilities import IS_PYDANTIC_V2, pydantic_v1 + + +class UnionMetadata: + discriminant: str + + def __init__(self, *, discriminant: str) -> None: + self.discriminant = discriminant + + +Model = typing.TypeVar("Model", bound=pydantic_v1.BaseModel) + + +class UncheckedBaseModel(pydantic_v1.BaseModel): + # Allow extra fields + class Config: + extra = pydantic_v1.Extra.allow + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} + + # Allow construct to not validate model + # Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836 + @classmethod + def construct( + cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + ) -> "Model": + m = cls.__new__(cls) # type: ignore + fields_values = {} + + config = cls.__config__ + + if _fields_set is None: + _fields_set = set(values.keys()) + + for name, field in cls.__fields__.items(): + key = field.alias + if ( + key not in values and config.allow_population_by_field_name + ): # Added this to allow population by field name + key = name + + if key in values: + if ( + values[key] is None and not field.required + ): # Moved this check since None value can be passed for Optional nested field + fields_values[name] = field.get_default() + else: + type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore + fields_values[name] = construct_type(object_=values[key], type_=type_) + _fields_set.add(name) + elif not field.required: + default = field.get_default() + fields_values[name] = default + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(key) + + # Add extras back in + _extra = {} + for key, value in values.items(): + if key not in _fields_set: + _extra[key] = value + # In v2 we'll need to exclude extra fields from fields_values + if not IS_PYDANTIC_V2: + _fields_set.add(key) + fields_values[key] = value + + if IS_PYDANTIC_V2: + object.__setattr__(m, "__pydantic_private__", None) + object.__setattr__(m, "__pydantic_extra__", _extra) + object.__setattr__(m, "__pydantic_fields_set__", _fields_set) + + object.__setattr__(m, "__dict__", fields_values) + object.__setattr__(m, "__fields_set__", _fields_set) + m._init_private_attributes() + return m + + +def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: + inner_types = pydantic_v1.typing.get_args(union_type) + if typing.Any in inner_types: + return object_ + + for inner_type in inner_types: + try: + if inspect.isclass(inner_type) and issubclass(inner_type, pydantic_v1.BaseModel): + # Attempt a validated parse until one works + return pydantic_v1.parse_obj_as(inner_type, object_) + except Exception: + continue + + # If none of the types work, just return the first successful cast + for inner_type in inner_types: + try: + return construct_type(object_=object_, type_=inner_type) + except Exception: + continue + + +def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: + base_type = pydantic_v1.typing.get_origin(type_) or type_ + union_type = type_ + if base_type == typing_extensions.Annotated: + union_type = pydantic_v1.typing.get_args(type_)[0] + annotated_metadata = pydantic_v1.typing.get_args(type_)[1:] + for metadata in annotated_metadata: + if isinstance(metadata, UnionMetadata): + try: + # Cast to the correct type, based on the discriminant + for inner_type in pydantic_v1.typing.get_args(union_type): + if inner_type.__fields__[metadata.discriminant].default == getattr( + object_, metadata.discriminant + ): + return construct_type(object_=object_, type_=inner_type) + except Exception: + # Allow to fall through to our regular union handling + pass + return _convert_undiscriminated_union_type(union_type, object_) + + +def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: + """ + Here we are essentially creating the same `construct` method in spirit as the above, but for all types, not just + Pydantic models. + The idea is to essentially attempt to coerce object_ to type_ (recursively) + """ + base_type = pydantic_v1.typing.get_origin(type_) or type_ + is_annotated = base_type == typing_extensions.Annotated + maybe_annotation_members = pydantic_v1.typing.get_args(type_) + is_annotated_union = is_annotated and pydantic_v1.typing.is_union( + pydantic_v1.typing.get_origin(maybe_annotation_members[0]) + ) + + if base_type == typing.Any: + return object_ + + if base_type == dict: + if not isinstance(object_, typing.Mapping): + return object_ + + key_type, items_type = pydantic_v1.typing.get_args(type_) + d = { + construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type) + for key, item in object_.items() + } + return d + + if base_type == list: + if not isinstance(object_, list): + return object_ + + inner_type = pydantic_v1.typing.get_args(type_)[0] + return [construct_type(object_=entry, type_=inner_type) for entry in object_] + + if base_type == set: + if not isinstance(object_, set) and not isinstance(object_, list): + return object_ + + inner_type = pydantic_v1.typing.get_args(type_)[0] + return {construct_type(object_=entry, type_=inner_type) for entry in object_} + + if pydantic_v1.typing.is_union(base_type) or is_annotated_union: + return _convert_union_type(type_, object_) + + # Cannot do an `issubclass` with a literal type, let's also just confirm we have a class before this call + if ( + object_ is not None + and not pydantic_v1.typing.is_literal_type(type_) + and (inspect.isclass(base_type) and issubclass(base_type, pydantic_v1.BaseModel)) + ): + return type_.construct(**object_) + + if base_type == dt.datetime: + try: + return pydantic_v1.datetime_parse.parse_datetime(object_) + except Exception: + return object_ + + if base_type == dt.date: + try: + return pydantic_v1.datetime_parse.parse_date(object_) + except Exception: + return object_ + + if base_type == uuid.UUID: + try: + return uuid.UUID(object_) + except Exception: + return object_ + + if base_type == int: + try: + return int(object_) + except Exception: + return object_ + + if base_type == bool: + try: + if isinstance(object_, str): + stringified_object = object_.lower() + return stringified_object == "true" or stringified_object == "1" + + return bool(object_) + except Exception: + return object_ + + return object_ diff --git a/src/courier/lists/client.py b/src/courier/lists/client.py index a3585e0..66c7dac 100644 --- a/src/courier/lists/client.py +++ b/src/courier/lists/client.py @@ -12,10 +12,11 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions -from .types.list import List +from ..core.unchecked_base_model import construct_type +from .types.list_ import List from .types.list_get_all_response import ListGetAllResponse from .types.list_get_subscriptions_response import ListGetSubscriptionsResponse from .types.list_put_params import ListPutParams @@ -29,7 +30,7 @@ class ListsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, *, cursor: typing.Optional[str] = None, @@ -61,7 +62,7 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.lists.list( + client.lists.list_( cursor="string", pattern="string", ) @@ -69,17 +70,19 @@ def list( _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "lists"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - "pattern": pattern, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + "pattern": pattern, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -97,9 +100,11 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListGetAllResponse, _response.json()) # type: ignore + return typing.cast(ListGetAllResponse, construct_type(type_=ListGetAllResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -136,8 +141,10 @@ def get(self, list_id: str, *, request_options: typing.Optional[RequestOptions] _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -154,9 +161,11 @@ def get(self, list_id: str, *, request_options: typing.Optional[RequestOptions] max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(List, _response.json()) # type: ignore + return typing.cast(List, construct_type(type_=List, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -241,8 +250,10 @@ def update( _response = self._client_wrapper.httpx_client.request( method="PUT", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -265,7 +276,7 @@ def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(List, _response.json()) # type: ignore + return typing.cast(List, construct_type(type_=List, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -302,9 +313,14 @@ def delete(self, list_id: str, *, request_options: typing.Optional[RequestOption _response = self._client_wrapper.httpx_client.request( method="DELETE", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -359,8 +375,10 @@ def restore(self, list_id: str, *, request_options: typing.Optional[RequestOptio url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/restore" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -429,16 +447,18 @@ def get_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -456,9 +476,11 @@ def get_subscribers( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListGetSubscriptionsResponse, _response.json()) # type: ignore + return typing.cast(ListGetSubscriptionsResponse, construct_type(type_=ListGetSubscriptionsResponse, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -469,7 +491,7 @@ def update_subscribers( self, list_id: str, *, - request: typing.Sequence[PutSubscriptionsRecipient], + recipients: typing.Sequence[PutSubscriptionsRecipient], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -480,7 +502,7 @@ def update_subscribers( list_id : str A unique identifier representing the list you wish to retrieve. - request : typing.Sequence[PutSubscriptionsRecipient] + recipients : typing.Sequence[PutSubscriptionsRecipient] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -505,7 +527,7 @@ def update_subscribers( ) client.lists.update_subscribers( list_id="string", - request=[ + recipients=[ PutSubscriptionsRecipient( recipient_id="string", preferences=RecipientPreferences( @@ -551,13 +573,15 @@ def update_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), - json=jsonable_encoder(request) + json=jsonable_encoder({"recipients": recipients}) if request_options is None or request_options.get("additional_body_parameters") is None else { - **jsonable_encoder(request), + **jsonable_encoder({"recipients": recipients}), **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), }, headers=jsonable_encoder( @@ -577,7 +601,9 @@ def update_subscribers( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -588,7 +614,7 @@ def add_subscribers( self, list_id: str, *, - request: typing.Sequence[PutSubscriptionsRecipient], + recipients: typing.Sequence[PutSubscriptionsRecipient], idempotency_key: typing.Optional[str] = None, idempotency_expiry: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, @@ -601,7 +627,7 @@ def add_subscribers( list_id : str A unique identifier representing the list you wish to retrieve. - request : typing.Sequence[PutSubscriptionsRecipient] + recipients : typing.Sequence[PutSubscriptionsRecipient] idempotency_key : typing.Optional[str] @@ -631,7 +657,7 @@ def add_subscribers( ) client.lists.add_subscribers( list_id="string", - request=[ + recipients=[ PutSubscriptionsRecipient( recipient_id="string", preferences=RecipientPreferences( @@ -677,13 +703,15 @@ def add_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), - json=jsonable_encoder(request) + json=jsonable_encoder({"recipients": recipients}) if request_options is None or request_options.get("additional_body_parameters") is None else { - **jsonable_encoder(request), + **jsonable_encoder({"recipients": recipients}), **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), }, headers=jsonable_encoder( @@ -705,7 +733,9 @@ def add_subscribers( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -801,8 +831,10 @@ def subscribe( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions/{jsonable_encoder(user_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -871,9 +903,14 @@ def unsubscribe( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions/{jsonable_encoder(user_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -891,7 +928,9 @@ def unsubscribe( if 200 <= _response.status_code < 300: return if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -903,7 +942,7 @@ class AsyncListsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, *, cursor: typing.Optional[str] = None, @@ -935,7 +974,7 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.lists.list( + await client.lists.list_( cursor="string", pattern="string", ) @@ -943,17 +982,19 @@ async def list( _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "lists"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - "pattern": pattern, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + "pattern": pattern, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -971,9 +1012,11 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListGetAllResponse, _response.json()) # type: ignore + return typing.cast(ListGetAllResponse, construct_type(type_=ListGetAllResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1010,8 +1053,10 @@ async def get(self, list_id: str, *, request_options: typing.Optional[RequestOpt _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -1028,9 +1073,11 @@ async def get(self, list_id: str, *, request_options: typing.Optional[RequestOpt max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(List, _response.json()) # type: ignore + return typing.cast(List, construct_type(type_=List, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1115,8 +1162,10 @@ async def update( _response = await self._client_wrapper.httpx_client.request( method="PUT", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -1139,7 +1188,7 @@ async def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(List, _response.json()) # type: ignore + return typing.cast(List, construct_type(type_=List, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -1176,9 +1225,14 @@ async def delete(self, list_id: str, *, request_options: typing.Optional[Request _response = await self._client_wrapper.httpx_client.request( method="DELETE", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}"), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -1233,8 +1287,10 @@ async def restore(self, list_id: str, *, request_options: typing.Optional[Reques url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/restore" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -1303,16 +1359,18 @@ async def get_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -1330,9 +1388,11 @@ async def get_subscribers( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListGetSubscriptionsResponse, _response.json()) # type: ignore + return typing.cast(ListGetSubscriptionsResponse, construct_type(type_=ListGetSubscriptionsResponse, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1343,7 +1403,7 @@ async def update_subscribers( self, list_id: str, *, - request: typing.Sequence[PutSubscriptionsRecipient], + recipients: typing.Sequence[PutSubscriptionsRecipient], request_options: typing.Optional[RequestOptions] = None, ) -> None: """ @@ -1354,7 +1414,7 @@ async def update_subscribers( list_id : str A unique identifier representing the list you wish to retrieve. - request : typing.Sequence[PutSubscriptionsRecipient] + recipients : typing.Sequence[PutSubscriptionsRecipient] request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1379,7 +1439,7 @@ async def update_subscribers( ) await client.lists.update_subscribers( list_id="string", - request=[ + recipients=[ PutSubscriptionsRecipient( recipient_id="string", preferences=RecipientPreferences( @@ -1425,13 +1485,15 @@ async def update_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), - json=jsonable_encoder(request) + json=jsonable_encoder({"recipients": recipients}) if request_options is None or request_options.get("additional_body_parameters") is None else { - **jsonable_encoder(request), + **jsonable_encoder({"recipients": recipients}), **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), }, headers=jsonable_encoder( @@ -1451,7 +1513,9 @@ async def update_subscribers( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1462,7 +1526,7 @@ async def add_subscribers( self, list_id: str, *, - request: typing.Sequence[PutSubscriptionsRecipient], + recipients: typing.Sequence[PutSubscriptionsRecipient], idempotency_key: typing.Optional[str] = None, idempotency_expiry: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, @@ -1475,7 +1539,7 @@ async def add_subscribers( list_id : str A unique identifier representing the list you wish to retrieve. - request : typing.Sequence[PutSubscriptionsRecipient] + recipients : typing.Sequence[PutSubscriptionsRecipient] idempotency_key : typing.Optional[str] @@ -1505,7 +1569,7 @@ async def add_subscribers( ) await client.lists.add_subscribers( list_id="string", - request=[ + recipients=[ PutSubscriptionsRecipient( recipient_id="string", preferences=RecipientPreferences( @@ -1551,13 +1615,15 @@ async def add_subscribers( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), - json=jsonable_encoder(request) + json=jsonable_encoder({"recipients": recipients}) if request_options is None or request_options.get("additional_body_parameters") is None else { - **jsonable_encoder(request), + **jsonable_encoder({"recipients": recipients}), **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), }, headers=jsonable_encoder( @@ -1579,7 +1645,9 @@ async def add_subscribers( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1675,8 +1743,10 @@ async def subscribe( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions/{jsonable_encoder(user_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -1745,9 +1815,14 @@ async def unsubscribe( f"{self._client_wrapper.get_base_url()}/", f"lists/{jsonable_encoder(list_id)}/subscriptions/{jsonable_encoder(user_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -1765,7 +1840,9 @@ async def unsubscribe( if 200 <= _response.status_code < 300: return if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/lists/types/__init__.py b/src/courier/lists/types/__init__.py index 073a0c3..ef10c28 100644 --- a/src/courier/lists/types/__init__.py +++ b/src/courier/lists/types/__init__.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from .list import List +from .list_ import List from .list_get_all_response import ListGetAllResponse from .list_get_subscriptions_response import ListGetSubscriptionsResponse from .list_put_params import ListPutParams diff --git a/src/courier/lists/types/list.py b/src/courier/lists/types/list_.py similarity index 56% rename from src/courier/lists/types/list.py rename to src/courier/lists/types/list_.py index 0273bd0..12479fb 100644 --- a/src/courier/lists/types/list.py +++ b/src/courier/lists/types/list_.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class List(pydantic_v1.BaseModel): +class List(UncheckedBaseModel): id: str name: str created: typing.Optional[int] = None @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/lists/types/list_get_all_response.py b/src/courier/lists/types/list_get_all_response.py index f70240f..a88b2f5 100644 --- a/src/courier/lists/types/list_get_all_response.py +++ b/src/courier/lists/types/list_get_all_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 -from .list import List +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel +from .list_ import List -class ListGetAllResponse(pydantic_v1.BaseModel): +class ListGetAllResponse(UncheckedBaseModel): paging: Paging items: typing.List[List] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/lists/types/list_get_subscriptions_response.py b/src/courier/lists/types/list_get_subscriptions_response.py index 9b36ae2..f58f82c 100644 --- a/src/courier/lists/types/list_get_subscriptions_response.py +++ b/src/courier/lists/types/list_get_subscriptions_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .list_subscription_recipient import ListSubscriptionRecipient -class ListGetSubscriptionsResponse(pydantic_v1.BaseModel): +class ListGetSubscriptionsResponse(UncheckedBaseModel): paging: Paging items: typing.List[ListSubscriptionRecipient] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/lists/types/list_put_params.py b/src/courier/lists/types/list_put_params.py index 5be025b..ba67266 100644 --- a/src/courier/lists/types/list_put_params.py +++ b/src/courier/lists/types/list_put_params.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListPutParams(pydantic_v1.BaseModel): +class ListPutParams(UncheckedBaseModel): name: str preferences: typing.Optional[RecipientPreferences] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/lists/types/list_subscription_recipient.py b/src/courier/lists/types/list_subscription_recipient.py index 0983cc9..5187767 100644 --- a/src/courier/lists/types/list_subscription_recipient.py +++ b/src/courier/lists/types/list_subscription_recipient.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListSubscriptionRecipient(pydantic_v1.BaseModel): +class ListSubscriptionRecipient(UncheckedBaseModel): recipient_id: str = pydantic_v1.Field(alias="recipientId") created: typing.Optional[str] = None preferences: typing.Optional[RecipientPreferences] = None @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/lists/types/put_subscriptions_recipient.py b/src/courier/lists/types/put_subscriptions_recipient.py index 5eece30..e0b530f 100644 --- a/src/courier/lists/types/put_subscriptions_recipient.py +++ b/src/courier/lists/types/put_subscriptions_recipient.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class PutSubscriptionsRecipient(pydantic_v1.BaseModel): +class PutSubscriptionsRecipient(UncheckedBaseModel): recipient_id: str = pydantic_v1.Field(alias="recipientId") preferences: typing.Optional[RecipientPreferences] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/client.py b/src/courier/messages/client.py index 016a7db..17eb7c5 100644 --- a/src/courier/messages/client.py +++ b/src/courier/messages/client.py @@ -11,9 +11,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.list_messages_response import ListMessagesResponse from .types.message_details import MessageDetails from .types.message_history_response import MessageHistoryResponse @@ -24,7 +25,7 @@ class MessagesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, *, archived: typing.Optional[bool] = None, @@ -104,7 +105,7 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.messages.list( + client.messages.list_( archived=True, cursor="string", event="string", @@ -124,29 +125,31 @@ def list( _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "messages"), - params=jsonable_encoder( - remove_none_from_dict( - { - "archived": archived, - "cursor": cursor, - "event": event, - "list": list_, - "messageId": message_id, - "notification": notification, - "provider": provider, - "recipient": recipient, - "status": status, - "tag": tag, - "tags": tags, - "tenant_id": tenant_id, - "enqueued_after": enqueued_after, - "traceId": trace_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "archived": archived, + "cursor": cursor, + "event": event, + "list": list_, + "messageId": message_id, + "notification": notification, + "provider": provider, + "recipient": recipient, + "status": status, + "tag": tag, + "tags": tags, + "tenant_id": tenant_id, + "enqueued_after": enqueued_after, + "traceId": trace_id, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -164,7 +167,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListMessagesResponse, _response.json()) # type: ignore + return typing.cast(ListMessagesResponse, construct_type(type_=ListMessagesResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -203,8 +206,10 @@ def get(self, message_id: str, *, request_options: typing.Optional[RequestOption url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -221,11 +226,15 @@ def get(self, message_id: str, *, request_options: typing.Optional[RequestOption max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageDetails, _response.json()) # type: ignore + return typing.cast(MessageDetails, construct_type(type_=MessageDetails, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -276,8 +285,10 @@ def cancel( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/cancel" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -299,7 +310,7 @@ def cancel( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageDetails, _response.json()) # type: ignore + return typing.cast(MessageDetails, construct_type(type_=MessageDetails, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -348,16 +359,18 @@ def get_history( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/history" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "type": type, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -375,11 +388,15 @@ def get_history( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageHistoryResponse, _response.json()) # type: ignore + return typing.cast(MessageHistoryResponse, construct_type(type_=MessageHistoryResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -418,8 +435,10 @@ def get_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/output" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -436,11 +455,15 @@ def get_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(RenderOutputResponse, _response.json()) # type: ignore + return typing.cast(RenderOutputResponse, construct_type(type_=RenderOutputResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -477,8 +500,10 @@ def archive(self, request_id: str, *, request_options: typing.Optional[RequestOp url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"requests/{jsonable_encoder(request_id)}/archive" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -510,7 +535,7 @@ class AsyncMessagesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, *, archived: typing.Optional[bool] = None, @@ -590,7 +615,7 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.messages.list( + await client.messages.list_( archived=True, cursor="string", event="string", @@ -610,29 +635,31 @@ async def list( _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "messages"), - params=jsonable_encoder( - remove_none_from_dict( - { - "archived": archived, - "cursor": cursor, - "event": event, - "list": list_, - "messageId": message_id, - "notification": notification, - "provider": provider, - "recipient": recipient, - "status": status, - "tag": tag, - "tags": tags, - "tenant_id": tenant_id, - "enqueued_after": enqueued_after, - "traceId": trace_id, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "archived": archived, + "cursor": cursor, + "event": event, + "list": list_, + "messageId": message_id, + "notification": notification, + "provider": provider, + "recipient": recipient, + "status": status, + "tag": tag, + "tags": tags, + "tenant_id": tenant_id, + "enqueued_after": enqueued_after, + "traceId": trace_id, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -650,7 +677,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListMessagesResponse, _response.json()) # type: ignore + return typing.cast(ListMessagesResponse, construct_type(type_=ListMessagesResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -689,8 +716,10 @@ async def get(self, message_id: str, *, request_options: typing.Optional[Request url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -707,11 +736,15 @@ async def get(self, message_id: str, *, request_options: typing.Optional[Request max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageDetails, _response.json()) # type: ignore + return typing.cast(MessageDetails, construct_type(type_=MessageDetails, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -762,8 +795,10 @@ async def cancel( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/cancel" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -785,7 +820,7 @@ async def cancel( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageDetails, _response.json()) # type: ignore + return typing.cast(MessageDetails, construct_type(type_=MessageDetails, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -834,16 +869,18 @@ async def get_history( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/history" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "type": type, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "type": type, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -861,11 +898,15 @@ async def get_history( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MessageHistoryResponse, _response.json()) # type: ignore + return typing.cast(MessageHistoryResponse, construct_type(type_=MessageHistoryResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -904,8 +945,10 @@ async def get_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"messages/{jsonable_encoder(message_id)}/output" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -922,11 +965,15 @@ async def get_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(RenderOutputResponse, _response.json()) # type: ignore + return typing.cast(RenderOutputResponse, construct_type(type_=RenderOutputResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) if _response.status_code == 404: - raise MessageNotFoundError(pydantic_v1.parse_obj_as(MessageNotFound, _response.json())) # type: ignore + raise MessageNotFoundError( + typing.cast(MessageNotFound, construct_type(type_=MessageNotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -963,8 +1010,10 @@ async def archive(self, request_id: str, *, request_options: typing.Optional[Req url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"requests/{jsonable_encoder(request_id)}/archive" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None diff --git a/src/courier/messages/types/list_messages_response.py b/src/courier/messages/types/list_messages_response.py index 87e20e1..9e6545d 100644 --- a/src/courier/messages/types/list_messages_response.py +++ b/src/courier/messages/types/list_messages_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_details import MessageDetails -class ListMessagesResponse(pydantic_v1.BaseModel): +class ListMessagesResponse(UncheckedBaseModel): paging: Paging = pydantic_v1.Field() """ Paging information for the result set. @@ -25,8 +26,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/message_details.py b/src/courier/messages/types/message_details.py index bb63da2..26966a4 100644 --- a/src/courier/messages/types/message_details.py +++ b/src/courier/messages/types/message_details.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_status import MessageStatus from .reason import Reason -class MessageDetails(pydantic_v1.BaseModel): +class MessageDetails(UncheckedBaseModel): id: str = pydantic_v1.Field() """ A unique identifier associated with the message you wish to retrieve (results from a send). @@ -75,8 +76,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/message_history_response.py b/src/courier/messages/types/message_history_response.py index a3e1d55..d246b2e 100644 --- a/src/courier/messages/types/message_history_response.py +++ b/src/courier/messages/types/message_history_response.py @@ -4,20 +4,24 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 -from .message_details import MessageDetails +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class MessageHistoryResponse(pydantic_v1.BaseModel): - results: typing.List[MessageDetails] +class MessageHistoryResponse(UncheckedBaseModel): + results: typing.List[typing.Dict[str, typing.Any]] def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/render_output.py b/src/courier/messages/types/render_output.py index 216151b..b3333a0 100644 --- a/src/courier/messages/types/render_output.py +++ b/src/courier/messages/types/render_output.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .rendered_message_content import RenderedMessageContent -class RenderOutput(pydantic_v1.BaseModel): +class RenderOutput(UncheckedBaseModel): channel: str = pydantic_v1.Field() """ The channel used for rendering the message. @@ -29,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/render_output_response.py b/src/courier/messages/types/render_output_response.py index cfc1c4f..4810d30 100644 --- a/src/courier/messages/types/render_output_response.py +++ b/src/courier/messages/types/render_output_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .render_output import RenderOutput -class RenderOutputResponse(pydantic_v1.BaseModel): +class RenderOutputResponse(UncheckedBaseModel): results: typing.List[RenderOutput] = pydantic_v1.Field() """ An array of render output of a previously sent message. @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/rendered_message_block.py b/src/courier/messages/types/rendered_message_block.py index 6e5952d..f80319c 100644 --- a/src/courier/messages/types/rendered_message_block.py +++ b/src/courier/messages/types/rendered_message_block.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class RenderedMessageBlock(pydantic_v1.BaseModel): +class RenderedMessageBlock(UncheckedBaseModel): type: str = pydantic_v1.Field() """ The block type of the rendered message block. @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/messages/types/rendered_message_content.py b/src/courier/messages/types/rendered_message_content.py index 1d72e24..a8849b9 100644 --- a/src/courier/messages/types/rendered_message_content.py +++ b/src/courier/messages/types/rendered_message_content.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .rendered_message_block import RenderedMessageBlock -class RenderedMessageContent(pydantic_v1.BaseModel): +class RenderedMessageContent(UncheckedBaseModel): html: str = pydantic_v1.Field() """ The html content of the rendered message. @@ -44,8 +45,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/client.py b/src/courier/notifications/client.py index fc1c675..b19f72f 100644 --- a/src/courier/notifications/client.py +++ b/src/courier/notifications/client.py @@ -7,9 +7,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.base_check import BaseCheck from .types.notification_block import NotificationBlock from .types.notification_channel import NotificationChannel @@ -26,7 +27,7 @@ class NotificationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> NotificationListResponse: """ @@ -48,23 +49,25 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.notifications.list( + client.notifications.list_( cursor="string", ) """ _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "notifications"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -82,7 +85,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationListResponse, _response.json()) # type: ignore + return typing.cast(NotificationListResponse, construct_type(type_=NotificationListResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -120,8 +123,10 @@ def get_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/content" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -138,7 +143,7 @@ def get_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationGetContentResponse, _response.json()) # type: ignore + return typing.cast(NotificationGetContentResponse, construct_type(type_=NotificationGetContentResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -176,8 +181,10 @@ def get_draft_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/draft/content" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -194,7 +201,7 @@ def get_draft_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationGetContentResponse, _response.json()) # type: ignore + return typing.cast(NotificationGetContentResponse, construct_type(type_=NotificationGetContentResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -271,8 +278,10 @@ def update_variations( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/variations" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -372,8 +381,10 @@ def update_draft_variations( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/draft/variations" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -438,8 +449,10 @@ def get_submission_checks( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -456,7 +469,7 @@ def get_submission_checks( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubmissionChecksGetResponse, _response.json()) # type: ignore + return typing.cast(SubmissionChecksGetResponse, construct_type(type_=SubmissionChecksGetResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -513,8 +526,10 @@ def replace_submission_checks( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"checks": checks}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -537,7 +552,7 @@ def replace_submission_checks( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubmissionChecksReplaceResponse, _response.json()) # type: ignore + return typing.cast(SubmissionChecksReplaceResponse, construct_type(type_=SubmissionChecksReplaceResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -579,9 +594,14 @@ def cancel_submission( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -609,7 +629,7 @@ class AsyncNotificationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> NotificationListResponse: """ @@ -631,23 +651,25 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.notifications.list( + await client.notifications.list_( cursor="string", ) """ _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "notifications"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -665,7 +687,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationListResponse, _response.json()) # type: ignore + return typing.cast(NotificationListResponse, construct_type(type_=NotificationListResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -703,8 +725,10 @@ async def get_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/content" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -721,7 +745,7 @@ async def get_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationGetContentResponse, _response.json()) # type: ignore + return typing.cast(NotificationGetContentResponse, construct_type(type_=NotificationGetContentResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -759,8 +783,10 @@ async def get_draft_content( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/draft/content" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -777,7 +803,7 @@ async def get_draft_content( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(NotificationGetContentResponse, _response.json()) # type: ignore + return typing.cast(NotificationGetContentResponse, construct_type(type_=NotificationGetContentResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -854,8 +880,10 @@ async def update_variations( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/variations" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -955,8 +983,10 @@ async def update_draft_variations( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/draft/variations" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -1021,8 +1051,10 @@ async def get_submission_checks( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -1039,7 +1071,7 @@ async def get_submission_checks( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubmissionChecksGetResponse, _response.json()) # type: ignore + return typing.cast(SubmissionChecksGetResponse, construct_type(type_=SubmissionChecksGetResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -1096,8 +1128,10 @@ async def replace_submission_checks( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"checks": checks}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -1120,7 +1154,7 @@ async def replace_submission_checks( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubmissionChecksReplaceResponse, _response.json()) # type: ignore + return typing.cast(SubmissionChecksReplaceResponse, construct_type(type_=SubmissionChecksReplaceResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -1162,9 +1196,14 @@ async def cancel_submission( f"{self._client_wrapper.get_base_url()}/", f"notifications/{jsonable_encoder(id)}/{jsonable_encoder(submission_id)}/checks", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { diff --git a/src/courier/notifications/types/base_check.py b/src/courier/notifications/types/base_check.py index 4e2fee5..50cacc5 100644 --- a/src/courier/notifications/types/base_check.py +++ b/src/courier/notifications/types/base_check.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .check_status import CheckStatus -class BaseCheck(pydantic_v1.BaseModel): +class BaseCheck(UncheckedBaseModel): id: str status: CheckStatus type: typing.Literal["custom"] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/check.py b/src/courier/notifications/types/check.py index d073c84..b07f849 100644 --- a/src/courier/notifications/types/check.py +++ b/src/courier/notifications/types/check.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_check import BaseCheck @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/message_routing.py b/src/courier/notifications/types/message_routing.py index 928cce5..497d24e 100644 --- a/src/courier/notifications/types/message_routing.py +++ b/src/courier/notifications/types/message_routing.py @@ -6,11 +6,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_routing_method import MessageRoutingMethod -class MessageRouting(pydantic_v1.BaseModel): +class MessageRouting(UncheckedBaseModel): method: MessageRoutingMethod channels: typing.List[MessageRoutingChannel] @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification.py b/src/courier/notifications/types/notification.py index 5230981..21c9ba6 100644 --- a/src/courier/notifications/types/notification.py +++ b/src/courier/notifications/types/notification.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_routing import MessageRouting from .notification_tag import NotificationTag -class Notification(pydantic_v1.BaseModel): +class Notification(UncheckedBaseModel): created_at: int updated_at: int id: str @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_block.py b/src/courier/notifications/types/notification_block.py index 0e1de62..e160ce0 100644 --- a/src/courier/notifications/types/notification_block.py +++ b/src/courier/notifications/types/notification_block.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .block_type import BlockType from .notification_content import NotificationContent -class NotificationBlock(pydantic_v1.BaseModel): +class NotificationBlock(UncheckedBaseModel): alias: typing.Optional[str] = None context: typing.Optional[str] = None id: str @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_channel.py b/src/courier/notifications/types/notification_channel.py index ed757e3..00804e3 100644 --- a/src/courier/notifications/types/notification_channel.py +++ b/src/courier/notifications/types/notification_channel.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification_channel_content import NotificationChannelContent -class NotificationChannel(pydantic_v1.BaseModel): +class NotificationChannel(UncheckedBaseModel): id: str type: typing.Optional[str] = None content: typing.Optional[NotificationChannelContent] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_channel_content.py b/src/courier/notifications/types/notification_channel_content.py index 3751f5d..6462fca 100644 --- a/src/courier/notifications/types/notification_channel_content.py +++ b/src/courier/notifications/types/notification_channel_content.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class NotificationChannelContent(pydantic_v1.BaseModel): +class NotificationChannelContent(UncheckedBaseModel): subject: typing.Optional[str] = None title: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_content_hierarchy.py b/src/courier/notifications/types/notification_content_hierarchy.py index efe4d98..40b7bb3 100644 --- a/src/courier/notifications/types/notification_content_hierarchy.py +++ b/src/courier/notifications/types/notification_content_hierarchy.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class NotificationContentHierarchy(pydantic_v1.BaseModel): +class NotificationContentHierarchy(UncheckedBaseModel): parent: typing.Optional[str] = None children: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_get_content_response.py b/src/courier/notifications/types/notification_get_content_response.py index 6d24456..25ff896 100644 --- a/src/courier/notifications/types/notification_get_content_response.py +++ b/src/courier/notifications/types/notification_get_content_response.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification_block import NotificationBlock from .notification_channel import NotificationChannel -class NotificationGetContentResponse(pydantic_v1.BaseModel): +class NotificationGetContentResponse(UncheckedBaseModel): blocks: typing.Optional[typing.List[NotificationBlock]] = None channels: typing.Optional[typing.List[NotificationChannel]] = None checksum: typing.Optional[str] = None @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_list_response.py b/src/courier/notifications/types/notification_list_response.py index 03b9886..8a74beb 100644 --- a/src/courier/notifications/types/notification_list_response.py +++ b/src/courier/notifications/types/notification_list_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification import Notification -class NotificationListResponse(pydantic_v1.BaseModel): +class NotificationListResponse(UncheckedBaseModel): paging: Paging results: typing.List[Notification] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_tag.py b/src/courier/notifications/types/notification_tag.py index 202410e..a631bba 100644 --- a/src/courier/notifications/types/notification_tag.py +++ b/src/courier/notifications/types/notification_tag.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification_tag_data import NotificationTagData -class NotificationTag(pydantic_v1.BaseModel): +class NotificationTag(UncheckedBaseModel): data: typing.List[NotificationTagData] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/notification_tag_data.py b/src/courier/notifications/types/notification_tag_data.py index 30a75b7..792a973 100644 --- a/src/courier/notifications/types/notification_tag_data.py +++ b/src/courier/notifications/types/notification_tag_data.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class NotificationTagData(pydantic_v1.BaseModel): +class NotificationTagData(UncheckedBaseModel): id: str name: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/submission_checks_get_response.py b/src/courier/notifications/types/submission_checks_get_response.py index 12235bc..8c6a531 100644 --- a/src/courier/notifications/types/submission_checks_get_response.py +++ b/src/courier/notifications/types/submission_checks_get_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .check import Check -class SubmissionChecksGetResponse(pydantic_v1.BaseModel): +class SubmissionChecksGetResponse(UncheckedBaseModel): checks: typing.List[Check] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/notifications/types/submission_checks_replace_response.py b/src/courier/notifications/types/submission_checks_replace_response.py index a0d80df..98ca960 100644 --- a/src/courier/notifications/types/submission_checks_replace_response.py +++ b/src/courier/notifications/types/submission_checks_replace_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .check import Check -class SubmissionChecksReplaceResponse(pydantic_v1.BaseModel): +class SubmissionChecksReplaceResponse(UncheckedBaseModel): checks: typing.List[Check] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/client.py b/src/courier/profiles/client.py index d371461..027daad 100644 --- a/src/courier/profiles/client.py +++ b/src/courier/profiles/client.py @@ -9,9 +9,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.delete_list_subscription_response import DeleteListSubscriptionResponse from .types.get_list_subscriptions_response import GetListSubscriptionsResponse from .types.merge_profile_response import MergeProfileResponse @@ -60,8 +61,10 @@ def get(self, user_id: str, *, request_options: typing.Optional[RequestOptions] url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -78,9 +81,11 @@ def get(self, user_id: str, *, request_options: typing.Optional[RequestOptions] max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ProfileGetResponse, _response.json()) # type: ignore + return typing.cast(ProfileGetResponse, construct_type(type_=ProfileGetResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -135,8 +140,10 @@ def create( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"profile": profile}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -161,9 +168,11 @@ def create( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MergeProfileResponse, _response.json()) # type: ignore + return typing.cast(MergeProfileResponse, construct_type(type_=MergeProfileResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -214,8 +223,10 @@ def replace( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"profile": profile}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -238,9 +249,11 @@ def replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ReplaceProfileResponse, _response.json()) # type: ignore + return typing.cast(ReplaceProfileResponse, construct_type(type_=ReplaceProfileResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -279,9 +292,14 @@ def delete(self, user_id: str, *, request_options: typing.Optional[RequestOption url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -299,7 +317,9 @@ def delete(self, user_id: str, *, request_options: typing.Optional[RequestOption if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -348,16 +368,18 @@ def get_list_subscriptions( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -375,9 +397,11 @@ def get_list_subscriptions( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetListSubscriptionsResponse, _response.json()) # type: ignore + return typing.cast(GetListSubscriptionsResponse, construct_type(type_=GetListSubscriptionsResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -435,8 +459,10 @@ def subscribe_to_lists( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -461,9 +487,11 @@ def subscribe_to_lists( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubscribeToListsResponse, _response.json()) # type: ignore + return typing.cast(SubscribeToListsResponse, construct_type(type_=SubscribeToListsResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -504,9 +532,14 @@ def delete_list_subscription( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -522,9 +555,11 @@ def delete_list_subscription( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteListSubscriptionResponse, _response.json()) # type: ignore + return typing.cast(DeleteListSubscriptionResponse, construct_type(type_=DeleteListSubscriptionResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -568,8 +603,10 @@ async def get(self, user_id: str, *, request_options: typing.Optional[RequestOpt url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -586,9 +623,11 @@ async def get(self, user_id: str, *, request_options: typing.Optional[RequestOpt max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ProfileGetResponse, _response.json()) # type: ignore + return typing.cast(ProfileGetResponse, construct_type(type_=ProfileGetResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -643,8 +682,10 @@ async def create( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"profile": profile}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -669,9 +710,11 @@ async def create( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(MergeProfileResponse, _response.json()) # type: ignore + return typing.cast(MergeProfileResponse, construct_type(type_=MergeProfileResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -722,8 +765,10 @@ async def replace( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"profile": profile}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -746,9 +791,11 @@ async def replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ReplaceProfileResponse, _response.json()) # type: ignore + return typing.cast(ReplaceProfileResponse, construct_type(type_=ReplaceProfileResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -787,9 +834,14 @@ async def delete(self, user_id: str, *, request_options: typing.Optional[Request url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -807,7 +859,9 @@ async def delete(self, user_id: str, *, request_options: typing.Optional[Request if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -856,16 +910,18 @@ async def get_list_subscriptions( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -883,9 +939,11 @@ async def get_list_subscriptions( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetListSubscriptionsResponse, _response.json()) # type: ignore + return typing.cast(GetListSubscriptionsResponse, construct_type(type_=GetListSubscriptionsResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -943,8 +1001,10 @@ async def subscribe_to_lists( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -969,9 +1029,11 @@ async def subscribe_to_lists( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(SubscribeToListsResponse, _response.json()) # type: ignore + return typing.cast(SubscribeToListsResponse, construct_type(type_=SubscribeToListsResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -1012,9 +1074,14 @@ async def delete_list_subscription( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"profiles/{jsonable_encoder(user_id)}/lists" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -1030,9 +1097,11 @@ async def delete_list_subscription( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(DeleteListSubscriptionResponse, _response.json()) # type: ignore + return typing.cast(DeleteListSubscriptionResponse, construct_type(type_=DeleteListSubscriptionResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/profiles/types/address.py b/src/courier/profiles/types/address.py index 557f1f3..278e0fe 100644 --- a/src/courier/profiles/types/address.py +++ b/src/courier/profiles/types/address.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Address(pydantic_v1.BaseModel): +class Address(UncheckedBaseModel): formatted: str street_address: str locality: str @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/airship_profile.py b/src/courier/profiles/types/airship_profile.py index 8aa9d2f..0d4704d 100644 --- a/src/courier/profiles/types/airship_profile.py +++ b/src/courier/profiles/types/airship_profile.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .airship_profile_audience import AirshipProfileAudience from .device_type import DeviceType -class AirshipProfile(pydantic_v1.BaseModel): +class AirshipProfile(UncheckedBaseModel): audience: AirshipProfileAudience device_types: typing.List[DeviceType] @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/airship_profile_audience.py b/src/courier/profiles/types/airship_profile_audience.py index d27b815..0fc941a 100644 --- a/src/courier/profiles/types/airship_profile_audience.py +++ b/src/courier/profiles/types/airship_profile_audience.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AirshipProfileAudience(pydantic_v1.BaseModel): +class AirshipProfileAudience(UncheckedBaseModel): named_user: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/delete_list_subscription_response.py b/src/courier/profiles/types/delete_list_subscription_response.py index 9bc11d5..b62f397 100644 --- a/src/courier/profiles/types/delete_list_subscription_response.py +++ b/src/courier/profiles/types/delete_list_subscription_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class DeleteListSubscriptionResponse(pydantic_v1.BaseModel): +class DeleteListSubscriptionResponse(UncheckedBaseModel): status: typing.Literal["SUCCESS"] def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/get_list_subscriptions_list.py b/src/courier/profiles/types/get_list_subscriptions_list.py index 6f0b7af..08a4198 100644 --- a/src/courier/profiles/types/get_list_subscriptions_list.py +++ b/src/courier/profiles/types/get_list_subscriptions_list.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class GetListSubscriptionsList(pydantic_v1.BaseModel): +class GetListSubscriptionsList(UncheckedBaseModel): id: str name: str = pydantic_v1.Field() """ @@ -32,8 +33,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/get_list_subscriptions_response.py b/src/courier/profiles/types/get_list_subscriptions_response.py index 2d9f9e2..ad7f4cf 100644 --- a/src/courier/profiles/types/get_list_subscriptions_response.py +++ b/src/courier/profiles/types/get_list_subscriptions_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .get_list_subscriptions_list import GetListSubscriptionsList -class GetListSubscriptionsResponse(pydantic_v1.BaseModel): +class GetListSubscriptionsResponse(UncheckedBaseModel): paging: Paging results: typing.List[GetListSubscriptionsList] = pydantic_v1.Field() """ @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/intercom.py b/src/courier/profiles/types/intercom.py index 2841b3a..b2c599f 100644 --- a/src/courier/profiles/types/intercom.py +++ b/src/courier/profiles/types/intercom.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .intercom_recipient import IntercomRecipient -class Intercom(pydantic_v1.BaseModel): +class Intercom(UncheckedBaseModel): from_: str = pydantic_v1.Field(alias="from") to: IntercomRecipient @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/intercom_recipient.py b/src/courier/profiles/types/intercom_recipient.py index 4651303..eb533f0 100644 --- a/src/courier/profiles/types/intercom_recipient.py +++ b/src/courier/profiles/types/intercom_recipient.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class IntercomRecipient(pydantic_v1.BaseModel): +class IntercomRecipient(UncheckedBaseModel): id: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/merge_profile_response.py b/src/courier/profiles/types/merge_profile_response.py index 7b447fd..62cb25c 100644 --- a/src/courier/profiles/types/merge_profile_response.py +++ b/src/courier/profiles/types/merge_profile_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class MergeProfileResponse(pydantic_v1.BaseModel): +class MergeProfileResponse(UncheckedBaseModel): status: typing.Literal["SUCCESS"] def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/ms_teams_base_properties.py b/src/courier/profiles/types/ms_teams_base_properties.py index 3e36a3f..38d8751 100644 --- a/src/courier/profiles/types/ms_teams_base_properties.py +++ b/src/courier/profiles/types/ms_teams_base_properties.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class MsTeamsBaseProperties(pydantic_v1.BaseModel): +class MsTeamsBaseProperties(UncheckedBaseModel): tenant_id: str service_url: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/multiple_tokens.py b/src/courier/profiles/types/multiple_tokens.py index 95b0a01..968b906 100644 --- a/src/courier/profiles/types/multiple_tokens.py +++ b/src/courier/profiles/types/multiple_tokens.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .token import Token -class MultipleTokens(pydantic_v1.BaseModel): +class MultipleTokens(UncheckedBaseModel): tokens: typing.List[Token] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/profile_get_parameters.py b/src/courier/profiles/types/profile_get_parameters.py index 2f66c9e..8b1f859 100644 --- a/src/courier/profiles/types/profile_get_parameters.py +++ b/src/courier/profiles/types/profile_get_parameters.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ProfileGetParameters(pydantic_v1.BaseModel): +class ProfileGetParameters(UncheckedBaseModel): recipient_id: str = pydantic_v1.Field(alias="recipientId") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/profile_get_response.py b/src/courier/profiles/types/profile_get_response.py index dbc3944..095f65d 100644 --- a/src/courier/profiles/types/profile_get_response.py +++ b/src/courier/profiles/types/profile_get_response.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ProfileGetResponse(pydantic_v1.BaseModel): +class ProfileGetResponse(UncheckedBaseModel): profile: typing.Dict[str, typing.Any] preferences: typing.Optional[RecipientPreferences] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/replace_profile_response.py b/src/courier/profiles/types/replace_profile_response.py index c9df0b0..c8ff6b9 100644 --- a/src/courier/profiles/types/replace_profile_response.py +++ b/src/courier/profiles/types/replace_profile_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ReplaceProfileResponse(pydantic_v1.BaseModel): +class ReplaceProfileResponse(UncheckedBaseModel): status: typing.Literal["SUCCESS"] def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_direct_message.py b/src/courier/profiles/types/send_direct_message.py index 24638d0..7ab24f8 100644 --- a/src/courier/profiles/types/send_direct_message.py +++ b/src/courier/profiles/types/send_direct_message.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class SendDirectMessage(pydantic_v1.BaseModel): +class SendDirectMessage(UncheckedBaseModel): user_id: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_channel.py b/src/courier/profiles/types/send_to_channel.py index 181b8c7..f830ce3 100644 --- a/src/courier/profiles/types/send_to_channel.py +++ b/src/courier/profiles/types/send_to_channel.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class SendToChannel(pydantic_v1.BaseModel): +class SendToChannel(UncheckedBaseModel): channel_id: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_ms_teams_channel_id.py b/src/courier/profiles/types/send_to_ms_teams_channel_id.py index 1b97fc3..160b53f 100644 --- a/src/courier/profiles/types/send_to_ms_teams_channel_id.py +++ b/src/courier/profiles/types/send_to_ms_teams_channel_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ms_teams_base_properties import MsTeamsBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_ms_teams_channel_name.py b/src/courier/profiles/types/send_to_ms_teams_channel_name.py index a119a42..e1193f5 100644 --- a/src/courier/profiles/types/send_to_ms_teams_channel_name.py +++ b/src/courier/profiles/types/send_to_ms_teams_channel_name.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ms_teams_base_properties import MsTeamsBaseProperties @@ -17,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_ms_teams_conversation_id.py b/src/courier/profiles/types/send_to_ms_teams_conversation_id.py index 985b537..b7aca00 100644 --- a/src/courier/profiles/types/send_to_ms_teams_conversation_id.py +++ b/src/courier/profiles/types/send_to_ms_teams_conversation_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ms_teams_base_properties import MsTeamsBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_ms_teams_email.py b/src/courier/profiles/types/send_to_ms_teams_email.py index b47e2ca..e71168b 100644 --- a/src/courier/profiles/types/send_to_ms_teams_email.py +++ b/src/courier/profiles/types/send_to_ms_teams_email.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ms_teams_base_properties import MsTeamsBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_ms_teams_user_id.py b/src/courier/profiles/types/send_to_ms_teams_user_id.py index 69fefb9..d34c23f 100644 --- a/src/courier/profiles/types/send_to_ms_teams_user_id.py +++ b/src/courier/profiles/types/send_to_ms_teams_user_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .ms_teams_base_properties import MsTeamsBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_slack_channel.py b/src/courier/profiles/types/send_to_slack_channel.py index 6f7da4c..17c6da9 100644 --- a/src/courier/profiles/types/send_to_slack_channel.py +++ b/src/courier/profiles/types/send_to_slack_channel.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .slack_base_properties import SlackBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_slack_email.py b/src/courier/profiles/types/send_to_slack_email.py index c6f3e37..b03312f 100644 --- a/src/courier/profiles/types/send_to_slack_email.py +++ b/src/courier/profiles/types/send_to_slack_email.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .slack_base_properties import SlackBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/send_to_slack_user_id.py b/src/courier/profiles/types/send_to_slack_user_id.py index d2d7178..e4d23a9 100644 --- a/src/courier/profiles/types/send_to_slack_user_id.py +++ b/src/courier/profiles/types/send_to_slack_user_id.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .slack_base_properties import SlackBaseProperties @@ -16,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/slack_base_properties.py b/src/courier/profiles/types/slack_base_properties.py index 288b933..c932e71 100644 --- a/src/courier/profiles/types/slack_base_properties.py +++ b/src/courier/profiles/types/slack_base_properties.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class SlackBaseProperties(pydantic_v1.BaseModel): +class SlackBaseProperties(UncheckedBaseModel): access_token: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/snooze_rule.py b/src/courier/profiles/types/snooze_rule.py index 8cb5d35..629b940 100644 --- a/src/courier/profiles/types/snooze_rule.py +++ b/src/courier/profiles/types/snooze_rule.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .snooze_rule_type import SnoozeRuleType -class SnoozeRule(pydantic_v1.BaseModel): +class SnoozeRule(UncheckedBaseModel): type: SnoozeRuleType start: str until: str @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/subscribe_to_lists_request.py b/src/courier/profiles/types/subscribe_to_lists_request.py index bbd7fb3..2395cb3 100644 --- a/src/courier/profiles/types/subscribe_to_lists_request.py +++ b/src/courier/profiles/types/subscribe_to_lists_request.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .subscribe_to_lists_request_list_object import SubscribeToListsRequestListObject -class SubscribeToListsRequest(pydantic_v1.BaseModel): +class SubscribeToListsRequest(UncheckedBaseModel): lists: typing.List[SubscribeToListsRequestListObject] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/subscribe_to_lists_request_list_object.py b/src/courier/profiles/types/subscribe_to_lists_request_list_object.py index 7c74aeb..d73a3ce 100644 --- a/src/courier/profiles/types/subscribe_to_lists_request_list_object.py +++ b/src/courier/profiles/types/subscribe_to_lists_request_list_object.py @@ -5,10 +5,11 @@ from ...commons.types.recipient_preferences import RecipientPreferences from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class SubscribeToListsRequestListObject(pydantic_v1.BaseModel): +class SubscribeToListsRequestListObject(UncheckedBaseModel): list_id: str = pydantic_v1.Field(alias="listId") preferences: typing.Optional[RecipientPreferences] = None @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/subscribe_to_lists_response.py b/src/courier/profiles/types/subscribe_to_lists_response.py index c36b4a1..6094ad2 100644 --- a/src/courier/profiles/types/subscribe_to_lists_response.py +++ b/src/courier/profiles/types/subscribe_to_lists_response.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class SubscribeToListsResponse(pydantic_v1.BaseModel): +class SubscribeToListsResponse(UncheckedBaseModel): status: typing.Literal["SUCCESS"] def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/token.py b/src/courier/profiles/types/token.py index 03292e6..8b6d98f 100644 --- a/src/courier/profiles/types/token.py +++ b/src/courier/profiles/types/token.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Token(pydantic_v1.BaseModel): +class Token(UncheckedBaseModel): token: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/profiles/types/user_profile.py b/src/courier/profiles/types/user_profile.py index 63f7539..65979bc 100644 --- a/src/courier/profiles/types/user_profile.py +++ b/src/courier/profiles/types/user_profile.py @@ -4,7 +4,8 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .address import Address from .airship_profile import AirshipProfile from .discord import Discord @@ -14,7 +15,7 @@ from .slack import Slack -class UserProfile(pydantic_v1.BaseModel): +class UserProfile(UncheckedBaseModel): address: Address birthdate: str email: str @@ -56,8 +57,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/audience_filter.py b/src/courier/send/types/audience_filter.py index 5b52550..733922d 100644 --- a/src/courier/send/types/audience_filter.py +++ b/src/courier/send/types/audience_filter.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class AudienceFilter(pydantic_v1.BaseModel): +class AudienceFilter(UncheckedBaseModel): operator: typing.Literal["MEMBER_OF"] = pydantic_v1.Field() """ Send to users only if they are member of the account @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/audience_recipient.py b/src/courier/send/types/audience_recipient.py index 6844ed9..6b0a96e 100644 --- a/src/courier/send/types/audience_recipient.py +++ b/src/courier/send/types/audience_recipient.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .audience_filter import AudienceFilter from .message_data import MessageData -class AudienceRecipient(pydantic_v1.BaseModel): +class AudienceRecipient(UncheckedBaseModel): audience_id: str = pydantic_v1.Field() """ A unique identifier associated with an Audience. A message will be sent to each user in the audience. @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/base_message.py b/src/courier/send/types/base_message.py index 066d0ac..a41a7c1 100644 --- a/src/courier/send/types/base_message.py +++ b/src/courier/send/types/base_message.py @@ -4,7 +4,8 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .delay import Delay from .expiry import Expiry from .message_channels import MessageChannels @@ -16,7 +17,7 @@ from .timeout import Timeout -class BaseMessage(pydantic_v1.BaseModel): +class BaseMessage(UncheckedBaseModel): data: typing.Optional[MessageData] = pydantic_v1.Field(default=None) """ An arbitrary object that includes any data you want to pass to the message. @@ -66,8 +67,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/base_message_send_to.py b/src/courier/send/types/base_message_send_to.py index 4f0c134..467b9fb 100644 --- a/src/courier/send/types/base_message_send_to.py +++ b/src/courier/send/types/base_message_send_to.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_recipient import MessageRecipient -class BaseMessageSendTo(pydantic_v1.BaseModel): +class BaseMessageSendTo(UncheckedBaseModel): to: typing.Optional[MessageRecipient] = pydantic_v1.Field(default=None) """ The recipient or a list of recipients of the message @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/base_social_presence.py b/src/courier/send/types/base_social_presence.py index efd75e8..8e43536 100644 --- a/src/courier/send/types/base_social_presence.py +++ b/src/courier/send/types/base_social_presence.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BaseSocialPresence(pydantic_v1.BaseModel): +class BaseSocialPresence(UncheckedBaseModel): url: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/brand_settings_email.py b/src/courier/send/types/brand_settings_email.py index a2b09b4..7f009bc 100644 --- a/src/courier/send/types/brand_settings_email.py +++ b/src/courier/send/types/brand_settings_email.py @@ -4,14 +4,15 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .brand_template_override import BrandTemplateOverride from .email_footer import EmailFooter from .email_head import EmailHead from .email_header import EmailHeader -class BrandSettingsEmail(pydantic_v1.BaseModel): +class BrandSettingsEmail(UncheckedBaseModel): template_override: typing.Optional[BrandTemplateOverride] = pydantic_v1.Field( alias="templateOverride", default=None ) @@ -24,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/brand_settings_in_app.py b/src/courier/send/types/brand_settings_in_app.py index 137f6a4..fa2878f 100644 --- a/src/courier/send/types/brand_settings_in_app.py +++ b/src/courier/send/types/brand_settings_in_app.py @@ -5,14 +5,15 @@ from ...brands.types.brand_colors import BrandColors from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .icons import Icons from .in_app_placement import InAppPlacement from .preferences import Preferences from .widget_background import WidgetBackground -class BrandSettingsInApp(pydantic_v1.BaseModel): +class BrandSettingsInApp(UncheckedBaseModel): border_radius: typing.Optional[str] = pydantic_v1.Field(alias="borderRadius", default=None) disable_message_icon: typing.Optional[bool] = pydantic_v1.Field(alias="disableMessageIcon", default=None) font_family: typing.Optional[str] = pydantic_v1.Field(alias="fontFamily", default=None) @@ -27,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/brand_settings_social_presence.py b/src/courier/send/types/brand_settings_social_presence.py index 4cf76d0..ed636af 100644 --- a/src/courier/send/types/brand_settings_social_presence.py +++ b/src/courier/send/types/brand_settings_social_presence.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .base_social_presence import BaseSocialPresence -class BrandSettingsSocialPresence(pydantic_v1.BaseModel): +class BrandSettingsSocialPresence(UncheckedBaseModel): inherit_default: typing.Optional[bool] = pydantic_v1.Field(alias="inheritDefault", default=None) facebook: typing.Optional[BaseSocialPresence] = None instagram: typing.Optional[BaseSocialPresence] = None @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/brand_template.py b/src/courier/send/types/brand_template.py index d59b456..8613c3a 100644 --- a/src/courier/send/types/brand_template.py +++ b/src/courier/send/types/brand_template.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class BrandTemplate(pydantic_v1.BaseModel): +class BrandTemplate(UncheckedBaseModel): background_color: typing.Optional[str] = pydantic_v1.Field(alias="backgroundColor", default=None) blocks_background_color: typing.Optional[str] = pydantic_v1.Field(alias="blocksBackgroundColor", default=None) enabled: bool @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/brand_template_override.py b/src/courier/send/types/brand_template_override.py index 9d47bdf..b7fcd92 100644 --- a/src/courier/send/types/brand_template_override.py +++ b/src/courier/send/types/brand_template_override.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .brand_template import BrandTemplate @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/channel.py b/src/courier/send/types/channel.py index 73f01b8..cfc5a3f 100644 --- a/src/courier/send/types/channel.py +++ b/src/courier/send/types/channel.py @@ -4,14 +4,15 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .channel_metadata import ChannelMetadata from .override import Override from .routing_method import RoutingMethod from .timeouts import Timeouts -class Channel(pydantic_v1.BaseModel): +class Channel(UncheckedBaseModel): brand_id: typing.Optional[str] = pydantic_v1.Field(default=None) """ Id of the brand that should be used for rendering the message. @@ -51,8 +52,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/channel_metadata.py b/src/courier/send/types/channel_metadata.py index 87c3346..cd62328 100644 --- a/src/courier/send/types/channel_metadata.py +++ b/src/courier/send/types/channel_metadata.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .utm import Utm -class ChannelMetadata(pydantic_v1.BaseModel): +class ChannelMetadata(UncheckedBaseModel): utm: typing.Optional[Utm] = None def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/content_message.py b/src/courier/send/types/content_message.py index 1265d1f..58b30db 100644 --- a/src/courier/send/types/content_message.py +++ b/src/courier/send/types/content_message.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_message import BaseMessage from .base_message_send_to import BaseMessageSendTo from .content import Content @@ -27,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/delay.py b/src/courier/send/types/delay.py index 48a9ac8..37ed504 100644 --- a/src/courier/send/types/delay.py +++ b/src/courier/send/types/delay.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Delay(pydantic_v1.BaseModel): +class Delay(UncheckedBaseModel): duration: int = pydantic_v1.Field() """ The duration of the delay in milliseconds. @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_action_node.py b/src/courier/send/types/elemental_action_node.py index 2eaae9c..016f1d8 100644 --- a/src/courier/send/types/elemental_action_node.py +++ b/src/courier/send/types/elemental_action_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode from .i_action_button_style import IActionButtonStyle from .i_alignment import IAlignment @@ -56,8 +56,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_base_node.py b/src/courier/send/types/elemental_base_node.py index 5772613..ea4d9d2 100644 --- a/src/courier/send/types/elemental_base_node.py +++ b/src/courier/send/types/elemental_base_node.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ElementalBaseNode(pydantic_v1.BaseModel): +class ElementalBaseNode(UncheckedBaseModel): channels: typing.Optional[typing.List[str]] = None ref: typing.Optional[str] = None if_: typing.Optional[str] = pydantic_v1.Field(alias="if", default=None) @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_channel_node.py b/src/courier/send/types/elemental_channel_node.py index 86ce64a..042fdcf 100644 --- a/src/courier/send/types/elemental_channel_node.py +++ b/src/courier/send/types/elemental_channel_node.py @@ -6,7 +6,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode @@ -45,8 +45,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_content.py b/src/courier/send/types/elemental_content.py index f182253..0ba7da8 100644 --- a/src/courier/send/types/elemental_content.py +++ b/src/courier/send/types/elemental_content.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .elemental_node import ElementalNode -class ElementalContent(pydantic_v1.BaseModel): +class ElementalContent(UncheckedBaseModel): version: str = pydantic_v1.Field() """ For example, "2022-01-01" @@ -22,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_content_sugar.py b/src/courier/send/types/elemental_content_sugar.py index 77d2870..59c8265 100644 --- a/src/courier/send/types/elemental_content_sugar.py +++ b/src/courier/send/types/elemental_content_sugar.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ElementalContentSugar(pydantic_v1.BaseModel): +class ElementalContentSugar(UncheckedBaseModel): """ Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. """ @@ -27,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_divider_node.py b/src/courier/send/types/elemental_divider_node.py index 8e839b3..beec7c6 100644 --- a/src/courier/send/types/elemental_divider_node.py +++ b/src/courier/send/types/elemental_divider_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode @@ -23,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_group_node.py b/src/courier/send/types/elemental_group_node.py index 164ad35..8a73669 100644 --- a/src/courier/send/types/elemental_group_node.py +++ b/src/courier/send/types/elemental_group_node.py @@ -6,7 +6,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode @@ -25,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_image_node.py b/src/courier/send/types/elemental_image_node.py index 0ec0ed0..e83e2b8 100644 --- a/src/courier/send/types/elemental_image_node.py +++ b/src/courier/send/types/elemental_image_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode from .i_alignment import IAlignment @@ -44,8 +44,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_meta_node.py b/src/courier/send/types/elemental_meta_node.py index 286ef0f..0fdbc81 100644 --- a/src/courier/send/types/elemental_meta_node.py +++ b/src/courier/send/types/elemental_meta_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode @@ -25,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_quote_node.py b/src/courier/send/types/elemental_quote_node.py index 866e520..35c2c61 100644 --- a/src/courier/send/types/elemental_quote_node.py +++ b/src/courier/send/types/elemental_quote_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode from .i_alignment import IAlignment from .locales import Locales @@ -42,8 +42,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/elemental_text_node.py b/src/courier/send/types/elemental_text_node.py index 98287a9..052333d 100644 --- a/src/courier/send/types/elemental_text_node.py +++ b/src/courier/send/types/elemental_text_node.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .elemental_base_node import ElementalBaseNode from .locales import Locales from .text_align import TextAlign @@ -69,8 +69,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/email_footer.py b/src/courier/send/types/email_footer.py index 4457515..aaa6f28 100644 --- a/src/courier/send/types/email_footer.py +++ b/src/courier/send/types/email_footer.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class EmailFooter(pydantic_v1.BaseModel): +class EmailFooter(UncheckedBaseModel): content: typing.Optional[typing.Any] = None inherit_default: typing.Optional[bool] = pydantic_v1.Field(alias="inheritDefault", default=None) @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/email_head.py b/src/courier/send/types/email_head.py index 06cdd98..ca6dcaa 100644 --- a/src/courier/send/types/email_head.py +++ b/src/courier/send/types/email_head.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class EmailHead(pydantic_v1.BaseModel): +class EmailHead(UncheckedBaseModel): inherit_default: bool = pydantic_v1.Field(alias="inheritDefault") content: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/email_header.py b/src/courier/send/types/email_header.py index 0f901ec..c9d3dbb 100644 --- a/src/courier/send/types/email_header.py +++ b/src/courier/send/types/email_header.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .logo import Logo -class EmailHeader(pydantic_v1.BaseModel): +class EmailHeader(UncheckedBaseModel): inherit_default: typing.Optional[bool] = pydantic_v1.Field(alias="inheritDefault", default=None) bar_color: typing.Optional[str] = pydantic_v1.Field(alias="barColor", default=None) logo: Logo @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/expiry.py b/src/courier/send/types/expiry.py index 6cb4b22..0bdcccd 100644 --- a/src/courier/send/types/expiry.py +++ b/src/courier/send/types/expiry.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .expires_in_type import ExpiresInType -class Expiry(pydantic_v1.BaseModel): +class Expiry(UncheckedBaseModel): expires_at: typing.Optional[str] = pydantic_v1.Field(default=None) """ An epoch timestamp or ISO8601 timestamp with timezone `(YYYY-MM-DDThh:mm:ss.sTZD)` that describes the time in which a message expires. @@ -24,8 +25,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/i_profile_preferences.py b/src/courier/send/types/i_profile_preferences.py index 96ab804..d834fb4 100644 --- a/src/courier/send/types/i_profile_preferences.py +++ b/src/courier/send/types/i_profile_preferences.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .i_preferences import IPreferences -class IProfilePreferences(pydantic_v1.BaseModel): +class IProfilePreferences(UncheckedBaseModel): categories: typing.Optional[IPreferences] = None notifications: IPreferences template_id: typing.Optional[str] = pydantic_v1.Field(alias="templateId", default=None) @@ -18,8 +19,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/icons.py b/src/courier/send/types/icons.py index 6554555..23ec6ee 100644 --- a/src/courier/send/types/icons.py +++ b/src/courier/send/types/icons.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Icons(pydantic_v1.BaseModel): +class Icons(UncheckedBaseModel): bell: typing.Optional[str] = None message: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/invalid_list_pattern_recipient.py b/src/courier/send/types/invalid_list_pattern_recipient.py index 42c1e62..0b88262 100644 --- a/src/courier/send/types/invalid_list_pattern_recipient.py +++ b/src/courier/send/types/invalid_list_pattern_recipient.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class InvalidListPatternRecipient(pydantic_v1.BaseModel): +class InvalidListPatternRecipient(UncheckedBaseModel): user_id: str list_id: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/invalid_list_recipient.py b/src/courier/send/types/invalid_list_recipient.py index 11bc1be..f61bbe9 100644 --- a/src/courier/send/types/invalid_list_recipient.py +++ b/src/courier/send/types/invalid_list_recipient.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class InvalidListRecipient(pydantic_v1.BaseModel): +class InvalidListRecipient(UncheckedBaseModel): user_id: str list_pattern: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/invalid_user_recipient.py b/src/courier/send/types/invalid_user_recipient.py index 7f1c98a..2f311be 100644 --- a/src/courier/send/types/invalid_user_recipient.py +++ b/src/courier/send/types/invalid_user_recipient.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class InvalidUserRecipient(pydantic_v1.BaseModel): +class InvalidUserRecipient(UncheckedBaseModel): list_id: str list_pattern: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/list_filter.py b/src/courier/send/types/list_filter.py index 0320d6d..c55201a 100644 --- a/src/courier/send/types/list_filter.py +++ b/src/courier/send/types/list_filter.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListFilter(pydantic_v1.BaseModel): +class ListFilter(UncheckedBaseModel): operator: typing.Literal["MEMBER_OF"] = pydantic_v1.Field() """ Send to users only if they are member of the account @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/list_pattern_recipient.py b/src/courier/send/types/list_pattern_recipient.py index 7ec16bd..86f1485 100644 --- a/src/courier/send/types/list_pattern_recipient.py +++ b/src/courier/send/types/list_pattern_recipient.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .list_pattern_recipient_type import ListPatternRecipientType from .message_data import MessageData @@ -18,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/list_pattern_recipient_type.py b/src/courier/send/types/list_pattern_recipient_type.py index 6bf9be1..63d1fc8 100644 --- a/src/courier/send/types/list_pattern_recipient_type.py +++ b/src/courier/send/types/list_pattern_recipient_type.py @@ -4,17 +4,22 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListPatternRecipientType(pydantic_v1.BaseModel): +class ListPatternRecipientType(UncheckedBaseModel): def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/list_recipient.py b/src/courier/send/types/list_recipient.py index d05631b..e09d364 100644 --- a/src/courier/send/types/list_recipient.py +++ b/src/courier/send/types/list_recipient.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .list_filter import ListFilter from .list_recipient_type import ListRecipientType from .message_data import MessageData @@ -20,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/list_recipient_type.py b/src/courier/send/types/list_recipient_type.py index 3fe37fd..1c7db9f 100644 --- a/src/courier/send/types/list_recipient_type.py +++ b/src/courier/send/types/list_recipient_type.py @@ -4,17 +4,22 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListRecipientType(pydantic_v1.BaseModel): +class ListRecipientType(UncheckedBaseModel): def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/locale.py b/src/courier/send/types/locale.py index bdbf4e7..fd701b4 100644 --- a/src/courier/send/types/locale.py +++ b/src/courier/send/types/locale.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Locale(pydantic_v1.BaseModel): +class Locale(UncheckedBaseModel): content: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/logo.py b/src/courier/send/types/logo.py index 53f2fb7..7e8aadc 100644 --- a/src/courier/send/types/logo.py +++ b/src/courier/send/types/logo.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Logo(pydantic_v1.BaseModel): +class Logo(UncheckedBaseModel): href: typing.Optional[str] = None image: typing.Optional[str] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/message_channel_email_override.py b/src/courier/send/types/message_channel_email_override.py index bf849df..6116df6 100644 --- a/src/courier/send/types/message_channel_email_override.py +++ b/src/courier/send/types/message_channel_email_override.py @@ -5,12 +5,13 @@ from ...brands.types.brand import Brand from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .attachment import Attachment from .tracking_override import TrackingOverride -class MessageChannelEmailOverride(pydantic_v1.BaseModel): +class MessageChannelEmailOverride(UncheckedBaseModel): attachments: typing.Optional[typing.List[Attachment]] = None bcc: typing.Optional[str] = None brand: typing.Optional[Brand] = None @@ -27,8 +28,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/message_context.py b/src/courier/send/types/message_context.py index 921b6b4..337155a 100644 --- a/src/courier/send/types/message_context.py +++ b/src/courier/send/types/message_context.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class MessageContext(pydantic_v1.BaseModel): +class MessageContext(UncheckedBaseModel): tenant_id: typing.Optional[str] = pydantic_v1.Field(default=None) """ An id of a tenant, see [tenants api docs](https://www.courier.com/docs/reference/tenants/). @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/message_metadata.py b/src/courier/send/types/message_metadata.py index e57a093..365fb4e 100644 --- a/src/courier/send/types/message_metadata.py +++ b/src/courier/send/types/message_metadata.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .utm import Utm -class MessageMetadata(pydantic_v1.BaseModel): +class MessageMetadata(UncheckedBaseModel): event: typing.Optional[str] = pydantic_v1.Field(default=None) """ An arbitrary string to tracks the event that generated this request (e.g. 'signup'). @@ -34,8 +35,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/message_providers_type.py b/src/courier/send/types/message_providers_type.py index 50f61ec..ec42e85 100644 --- a/src/courier/send/types/message_providers_type.py +++ b/src/courier/send/types/message_providers_type.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .metadata import Metadata -class MessageProvidersType(pydantic_v1.BaseModel): +class MessageProvidersType(UncheckedBaseModel): override: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None) """ Provider specific overrides. @@ -29,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/metadata.py b/src/courier/send/types/metadata.py index 6082657..3b27de6 100644 --- a/src/courier/send/types/metadata.py +++ b/src/courier/send/types/metadata.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .utm import Utm -class Metadata(pydantic_v1.BaseModel): +class Metadata(UncheckedBaseModel): utm: typing.Optional[Utm] = None def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/ms_teams_recipient.py b/src/courier/send/types/ms_teams_recipient.py index 83565a8..3bd79ca 100644 --- a/src/courier/send/types/ms_teams_recipient.py +++ b/src/courier/send/types/ms_teams_recipient.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from ...profiles.types.ms_teams import MsTeams -class MsTeamsRecipient(pydantic_v1.BaseModel): +class MsTeamsRecipient(UncheckedBaseModel): ms_teams: MsTeams def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/preference.py b/src/courier/send/types/preference.py index 4d5e793..730f7ee 100644 --- a/src/courier/send/types/preference.py +++ b/src/courier/send/types/preference.py @@ -7,11 +7,12 @@ from ...commons.types.preference_status import PreferenceStatus from ...commons.types.rule import Rule from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .channel_source import ChannelSource -class Preference(pydantic_v1.BaseModel): +class Preference(UncheckedBaseModel): status: PreferenceStatus rules: typing.Optional[typing.List[Rule]] = None channel_preferences: typing.Optional[typing.List[ChannelPreference]] = None @@ -22,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/preferences.py b/src/courier/send/types/preferences.py index df3225d..993b98e 100644 --- a/src/courier/send/types/preferences.py +++ b/src/courier/send/types/preferences.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Preferences(pydantic_v1.BaseModel): +class Preferences(UncheckedBaseModel): template_ids: typing.List[str] = pydantic_v1.Field(alias="templateIds") def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/routing.py b/src/courier/send/types/routing.py index 2c9d69f..44ac6da 100644 --- a/src/courier/send/types/routing.py +++ b/src/courier/send/types/routing.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .routing_channel import RoutingChannel from .routing_method import RoutingMethod -class Routing(pydantic_v1.BaseModel): +class Routing(UncheckedBaseModel): """ Allows you to customize which channel(s) Courier will potentially deliver the message. If no routing key is specified, Courier will use the default routing configuration or @@ -29,8 +30,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/routing_strategy_channel.py b/src/courier/send/types/routing_strategy_channel.py index 3e09652..40c2565 100644 --- a/src/courier/send/types/routing_strategy_channel.py +++ b/src/courier/send/types/routing_strategy_channel.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .message_providers import MessageProviders from .routing_method import RoutingMethod -class RoutingStrategyChannel(pydantic_v1.BaseModel): +class RoutingStrategyChannel(UncheckedBaseModel): channel: str config: typing.Optional[typing.Dict[str, typing.Any]] = None method: typing.Optional[RoutingMethod] = None @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/routing_strategy_provider.py b/src/courier/send/types/routing_strategy_provider.py index 6ccc065..9b61ade 100644 --- a/src/courier/send/types/routing_strategy_provider.py +++ b/src/courier/send/types/routing_strategy_provider.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .metadata import Metadata -class RoutingStrategyProvider(pydantic_v1.BaseModel): +class RoutingStrategyProvider(UncheckedBaseModel): name: str config: typing.Optional[typing.Dict[str, typing.Any]] = None if_: typing.Optional[str] = pydantic_v1.Field(alias="if", default=None) @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/slack_recipient.py b/src/courier/send/types/slack_recipient.py index 1640ea9..ffab397 100644 --- a/src/courier/send/types/slack_recipient.py +++ b/src/courier/send/types/slack_recipient.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from ...profiles.types.slack import Slack -class SlackRecipient(pydantic_v1.BaseModel): +class SlackRecipient(UncheckedBaseModel): slack: Slack def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/template_message.py b/src/courier/send/types/template_message.py index 4dee1e7..c811519 100644 --- a/src/courier/send/types/template_message.py +++ b/src/courier/send/types/template_message.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .base_message import BaseMessage from .base_message_send_to import BaseMessageSendTo @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/timeout.py b/src/courier/send/types/timeout.py index 780b6b8..b1ccf90 100644 --- a/src/courier/send/types/timeout.py +++ b/src/courier/send/types/timeout.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .criteria import Criteria -class Timeout(pydantic_v1.BaseModel): +class Timeout(UncheckedBaseModel): provider: typing.Optional[typing.Dict[str, int]] = None channel: typing.Optional[typing.Dict[str, int]] = None message: typing.Optional[int] = None @@ -20,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/timeouts.py b/src/courier/send/types/timeouts.py index 048d1ef..9d81781 100644 --- a/src/courier/send/types/timeouts.py +++ b/src/courier/send/types/timeouts.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Timeouts(pydantic_v1.BaseModel): +class Timeouts(UncheckedBaseModel): provider: typing.Optional[int] = None channel: typing.Optional[int] = None @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/tracking_override.py b/src/courier/send/types/tracking_override.py index 2584a2e..a54b241 100644 --- a/src/courier/send/types/tracking_override.py +++ b/src/courier/send/types/tracking_override.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class TrackingOverride(pydantic_v1.BaseModel): +class TrackingOverride(UncheckedBaseModel): open: bool def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/user_recipient.py b/src/courier/send/types/user_recipient.py index c7e11cd..1050ad0 100644 --- a/src/courier/send/types/user_recipient.py +++ b/src/courier/send/types/user_recipient.py @@ -4,7 +4,7 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .i_profile_preferences import IProfilePreferences from .message_context import MessageContext from .message_data import MessageData @@ -43,8 +43,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/user_recipient_type.py b/src/courier/send/types/user_recipient_type.py index 4ae02b0..e04ab57 100644 --- a/src/courier/send/types/user_recipient_type.py +++ b/src/courier/send/types/user_recipient_type.py @@ -4,17 +4,22 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class UserRecipientType(pydantic_v1.BaseModel): +class UserRecipientType(UncheckedBaseModel): def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/utm.py b/src/courier/send/types/utm.py index b429cd7..e0097d8 100644 --- a/src/courier/send/types/utm.py +++ b/src/courier/send/types/utm.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class Utm(pydantic_v1.BaseModel): +class Utm(UncheckedBaseModel): source: typing.Optional[str] = None medium: typing.Optional[str] = None campaign: typing.Optional[str] = None @@ -19,8 +20,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/send/types/widget_background.py b/src/courier/send/types/widget_background.py index 93136a7..48e48c6 100644 --- a/src/courier/send/types/widget_background.py +++ b/src/courier/send/types/widget_background.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class WidgetBackground(pydantic_v1.BaseModel): +class WidgetBackground(UncheckedBaseModel): top_color: typing.Optional[str] = pydantic_v1.Field(alias="topColor", default=None) bottom_color: typing.Optional[str] = pydantic_v1.Field(alias="bottomColor", default=None) @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/templates/client.py b/src/courier/templates/client.py index cb451e3..de39d93 100644 --- a/src/courier/templates/client.py +++ b/src/courier/templates/client.py @@ -7,9 +7,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.list_templates_response import ListTemplatesResponse @@ -17,7 +18,7 @@ class TemplatesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> ListTemplatesResponse: """ @@ -42,23 +43,25 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.templates.list( + client.templates.list_( cursor="string", ) """ _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "notifications"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -76,7 +79,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListTemplatesResponse, _response.json()) # type: ignore + return typing.cast(ListTemplatesResponse, construct_type(type_=ListTemplatesResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -88,7 +91,7 @@ class AsyncTemplatesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, *, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None ) -> ListTemplatesResponse: """ @@ -113,23 +116,25 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.templates.list( + await client.templates.list_( cursor="string", ) """ _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "notifications"), - params=jsonable_encoder( - remove_none_from_dict( - { - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -147,7 +152,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListTemplatesResponse, _response.json()) # type: ignore + return typing.cast(ListTemplatesResponse, construct_type(type_=ListTemplatesResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/templates/types/list_templates_response.py b/src/courier/templates/types/list_templates_response.py index 131aff2..c820a73 100644 --- a/src/courier/templates/types/list_templates_response.py +++ b/src/courier/templates/types/list_templates_response.py @@ -5,11 +5,12 @@ from ...commons.types.paging import Paging from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .notification_templates import NotificationTemplates -class ListTemplatesResponse(pydantic_v1.BaseModel): +class ListTemplatesResponse(UncheckedBaseModel): paging: Paging results: typing.List[NotificationTemplates] = pydantic_v1.Field() """ @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/templates/types/notification_templates.py b/src/courier/templates/types/notification_templates.py index c7ca539..5f6d37d 100644 --- a/src/courier/templates/types/notification_templates.py +++ b/src/courier/templates/types/notification_templates.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .routing_strategy import RoutingStrategy from .tag import Tag -class NotificationTemplates(pydantic_v1.BaseModel): +class NotificationTemplates(UncheckedBaseModel): created_at: int = pydantic_v1.Field() """ A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). @@ -45,8 +46,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/templates/types/routing_strategy.py b/src/courier/templates/types/routing_strategy.py index ddeb085..76f10f7 100644 --- a/src/courier/templates/types/routing_strategy.py +++ b/src/courier/templates/types/routing_strategy.py @@ -4,12 +4,13 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .channel_identifier import ChannelIdentifier from .routing_strategy_method import RoutingStrategyMethod -class RoutingStrategy(pydantic_v1.BaseModel): +class RoutingStrategy(UncheckedBaseModel): method: RoutingStrategyMethod = pydantic_v1.Field() """ The method for selecting channels to send the message with. Value can be either 'single' or 'all'. If not provided will default to 'single' @@ -25,8 +26,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/templates/types/tag.py b/src/courier/templates/types/tag.py index f57616f..b1b2b1f 100644 --- a/src/courier/templates/types/tag.py +++ b/src/courier/templates/types/tag.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .tag_data import TagData -class Tag(pydantic_v1.BaseModel): +class Tag(UncheckedBaseModel): data: typing.List[TagData] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/templates/types/tag_data.py b/src/courier/templates/types/tag_data.py index baf9273..1fecb6e 100644 --- a/src/courier/templates/types/tag_data.py +++ b/src/courier/templates/types/tag_data.py @@ -4,10 +4,11 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class TagData(pydantic_v1.BaseModel): +class TagData(UncheckedBaseModel): id: str = pydantic_v1.Field() """ A unique identifier of the tag. @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/tenants/__init__.py b/src/courier/tenants/__init__.py index 8f4a33a..b3b08e1 100644 --- a/src/courier/tenants/__init__.py +++ b/src/courier/tenants/__init__.py @@ -4,6 +4,7 @@ DefaultPreferences, ListUsersForTenantResponse, SubscriptionTopic, + SubscriptionTopicNew, SubscriptionTopicStatus, TemplateProperty, Tenant, @@ -14,6 +15,7 @@ "DefaultPreferences", "ListUsersForTenantResponse", "SubscriptionTopic", + "SubscriptionTopicNew", "SubscriptionTopicStatus", "TemplateProperty", "Tenant", diff --git a/src/courier/tenants/client.py b/src/courier/tenants/client.py index 483b138..44eeddf 100644 --- a/src/courier/tenants/client.py +++ b/src/courier/tenants/client.py @@ -9,11 +9,13 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type from .types.default_preferences import DefaultPreferences from .types.list_users_for_tenant_response import ListUsersForTenantResponse +from .types.subscription_topic_new import SubscriptionTopicNew from .types.tenant import Tenant from .types.tenant_list_response import TenantListResponse @@ -104,8 +106,10 @@ def create_or_replace( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -128,9 +132,11 @@ def create_or_replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Tenant, _response.json()) # type: ignore + return typing.cast(Tenant, construct_type(type_=Tenant, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -167,8 +173,10 @@ def get(self, tenant_id: str, *, request_options: typing.Optional[RequestOptions url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -185,18 +193,21 @@ def get(self, tenant_id: str, *, request_options: typing.Optional[RequestOptions max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Tenant, _response.json()) # type: ignore + return typing.cast(Tenant, construct_type(type_=Tenant, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def list( + def list_( self, *, + parent_tenant_id: typing.Optional[str] = None, limit: typing.Optional[int] = None, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, @@ -204,8 +215,11 @@ def list( """ Parameters ---------- + parent_tenant_id : typing.Optional[str] + Filter the list of tenants by parent_id + limit : typing.Optional[int] - The number of accousnts to return + The number of tenants to return (defaults to 20, maximum value of 100) cursor : typing.Optional[str] @@ -225,7 +239,8 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.tenants.list( + client.tenants.list_( + parent_tenant_id="string", limit=1, cursor="string", ) @@ -233,17 +248,20 @@ def list( _response = self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "tenants"), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "parent_tenant_id": parent_tenant_id, + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -261,7 +279,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(TenantListResponse, _response.json()) # type: ignore + return typing.cast(TenantListResponse, construct_type(type_=TenantListResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -298,9 +316,14 @@ def delete(self, tenant_id: str, *, request_options: typing.Optional[RequestOpti url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -369,19 +392,108 @@ def get_users_by_tenant( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}/users" ), - params=jsonable_encoder( + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( remove_none_from_dict( { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), } ) ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return typing.cast(ListUsersForTenantResponse, construct_type(type_=ListUsersForTenantResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def create_or_replace_default_preferences_for_topic( + self, + tenant_id: str, + topic_id: str, + *, + request: SubscriptionTopicNew, + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Parameters + ---------- + tenant_id : str + Id of the tenant to update the default preferences for. + + topic_id : str + Id fo the susbcription topic you want to have a default preference for. + + request : SubscriptionTopicNew + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from courier import SubscriptionTopicNew + from courier.client import Courier + + client = Courier( + authorization_token="YOUR_AUTHORIZATION_TOKEN", + ) + client.tenants.create_or_replace_default_preferences_for_topic( + tenant_id="tenantABC", + topic_id="HB529N49MD4D5PMX9WR5P4JH78NA", + request=SubscriptionTopicNew( + status="OPTED_IN", + has_custom_routing=True, + custom_routing=["inbox"], + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + method="PUT", + url=urllib.parse.urljoin( + f"{self._client_wrapper.get_base_url()}/", + f"tenants/{jsonable_encoder(tenant_id)}/default_preferences/items/{jsonable_encoder(topic_id)}", + ), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, headers=jsonable_encoder( remove_none_from_dict( { @@ -397,9 +509,74 @@ def get_users_by_tenant( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListUsersForTenantResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + return + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def remove_default_preferences_for_topic( + self, tenant_id: str, topic_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Parameters + ---------- + tenant_id : str + Id of the tenant to update the default preferences for. + + topic_id : str + Id fo the susbcription topic you want to have a default preference for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from courier.client import Courier + + client = Courier( + authorization_token="YOUR_AUTHORIZATION_TOKEN", + ) + client.tenants.remove_default_preferences_for_topic( + tenant_id="string", + topic_id="string", + ) + """ + _response = self._client_wrapper.httpx_client.request( + method="DELETE", + url=urllib.parse.urljoin( + f"{self._client_wrapper.get_base_url()}/", + f"tenants/{jsonable_encoder(tenant_id)}/default_preferences/items/{jsonable_encoder(topic_id)}", + ), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return try: _response_json = _response.json() except JSONDecodeError: @@ -490,8 +667,10 @@ async def create_or_replace( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -514,9 +693,11 @@ async def create_or_replace( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Tenant, _response.json()) # type: ignore + return typing.cast(Tenant, construct_type(type_=Tenant, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -553,8 +734,10 @@ async def get(self, tenant_id: str, *, request_options: typing.Optional[RequestO url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -571,18 +754,21 @@ async def get(self, tenant_id: str, *, request_options: typing.Optional[RequestO max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(Tenant, _response.json()) # type: ignore + return typing.cast(Tenant, construct_type(type_=Tenant, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def list( + async def list_( self, *, + parent_tenant_id: typing.Optional[str] = None, limit: typing.Optional[int] = None, cursor: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, @@ -590,8 +776,11 @@ async def list( """ Parameters ---------- + parent_tenant_id : typing.Optional[str] + Filter the list of tenants by parent_id + limit : typing.Optional[int] - The number of accousnts to return + The number of tenants to return (defaults to 20, maximum value of 100) cursor : typing.Optional[str] @@ -611,7 +800,8 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.tenants.list( + await client.tenants.list_( + parent_tenant_id="string", limit=1, cursor="string", ) @@ -619,17 +809,20 @@ async def list( _response = await self._client_wrapper.httpx_client.request( method="GET", url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "tenants"), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "parent_tenant_id": parent_tenant_id, + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -647,7 +840,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(TenantListResponse, _response.json()) # type: ignore + return typing.cast(TenantListResponse, construct_type(type_=TenantListResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -684,9 +877,14 @@ async def delete(self, tenant_id: str, *, request_options: typing.Optional[Reque url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -755,19 +953,108 @@ async def get_users_by_tenant( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"tenants/{jsonable_encoder(tenant_id)}/users" ), - params=jsonable_encoder( + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( remove_none_from_dict( { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), } ) ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return typing.cast(ListUsersForTenantResponse, construct_type(type_=ListUsersForTenantResponse, object_=_response.json())) # type: ignore + if _response.status_code == 400: + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def create_or_replace_default_preferences_for_topic( + self, + tenant_id: str, + topic_id: str, + *, + request: SubscriptionTopicNew, + request_options: typing.Optional[RequestOptions] = None, + ) -> None: + """ + Parameters + ---------- + tenant_id : str + Id of the tenant to update the default preferences for. + + topic_id : str + Id fo the susbcription topic you want to have a default preference for. + + request : SubscriptionTopicNew + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from courier import SubscriptionTopicNew + from courier.client import AsyncCourier + + client = AsyncCourier( + authorization_token="YOUR_AUTHORIZATION_TOKEN", + ) + await client.tenants.create_or_replace_default_preferences_for_topic( + tenant_id="tenantABC", + topic_id="HB529N49MD4D5PMX9WR5P4JH78NA", + request=SubscriptionTopicNew( + status="OPTED_IN", + has_custom_routing=True, + custom_routing=["inbox"], + ), + ) + """ + _response = await self._client_wrapper.httpx_client.request( + method="PUT", + url=urllib.parse.urljoin( + f"{self._client_wrapper.get_base_url()}/", + f"tenants/{jsonable_encoder(tenant_id)}/default_preferences/items/{jsonable_encoder(topic_id)}", + ), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, headers=jsonable_encoder( remove_none_from_dict( { @@ -783,9 +1070,74 @@ async def get_users_by_tenant( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListUsersForTenantResponse, _response.json()) # type: ignore - if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + return + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def remove_default_preferences_for_topic( + self, tenant_id: str, topic_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Parameters + ---------- + tenant_id : str + Id of the tenant to update the default preferences for. + + topic_id : str + Id fo the susbcription topic you want to have a default preference for. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from courier.client import AsyncCourier + + client = AsyncCourier( + authorization_token="YOUR_AUTHORIZATION_TOKEN", + ) + await client.tenants.remove_default_preferences_for_topic( + tenant_id="string", + topic_id="string", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + method="DELETE", + url=urllib.parse.urljoin( + f"{self._client_wrapper.get_base_url()}/", + f"tenants/{jsonable_encoder(tenant_id)}/default_preferences/items/{jsonable_encoder(topic_id)}", + ), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/tenants/types/__init__.py b/src/courier/tenants/types/__init__.py index 174381e..f56cfd3 100644 --- a/src/courier/tenants/types/__init__.py +++ b/src/courier/tenants/types/__init__.py @@ -3,6 +3,7 @@ from .default_preferences import DefaultPreferences from .list_users_for_tenant_response import ListUsersForTenantResponse from .subscription_topic import SubscriptionTopic +from .subscription_topic_new import SubscriptionTopicNew from .subscription_topic_status import SubscriptionTopicStatus from .template_property import TemplateProperty from .tenant import Tenant @@ -12,6 +13,7 @@ "DefaultPreferences", "ListUsersForTenantResponse", "SubscriptionTopic", + "SubscriptionTopicNew", "SubscriptionTopicStatus", "TemplateProperty", "Tenant", diff --git a/src/courier/tenants/types/default_preferences.py b/src/courier/tenants/types/default_preferences.py index b851a4b..bac7da9 100644 --- a/src/courier/tenants/types/default_preferences.py +++ b/src/courier/tenants/types/default_preferences.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .subscription_topic import SubscriptionTopic -class DefaultPreferences(pydantic_v1.BaseModel): +class DefaultPreferences(UncheckedBaseModel): items: typing.Optional[typing.List[SubscriptionTopic]] = None def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/tenants/types/list_users_for_tenant_response.py b/src/courier/tenants/types/list_users_for_tenant_response.py index c968e8e..2ff74b9 100644 --- a/src/courier/tenants/types/list_users_for_tenant_response.py +++ b/src/courier/tenants/types/list_users_for_tenant_response.py @@ -5,10 +5,11 @@ from ...commons.types.user_tenant_association import UserTenantAssociation from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel -class ListUsersForTenantResponse(pydantic_v1.BaseModel): +class ListUsersForTenantResponse(UncheckedBaseModel): items: typing.Optional[typing.List[UserTenantAssociation]] = None has_more: bool = pydantic_v1.Field() """ @@ -42,8 +43,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/tenants/types/subscription_topic.py b/src/courier/tenants/types/subscription_topic.py index 5291c57..3d6d5c4 100644 --- a/src/courier/tenants/types/subscription_topic.py +++ b/src/courier/tenants/types/subscription_topic.py @@ -4,28 +4,32 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 -from .subscription_topic_status import SubscriptionTopicStatus +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .subscription_topic_new import SubscriptionTopicNew -class SubscriptionTopic(pydantic_v1.BaseModel): +class SubscriptionTopic(SubscriptionTopicNew): id: str = pydantic_v1.Field() """ Topic ID """ - status: SubscriptionTopicStatus - def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True smart_union = True + allow_population_by_field_name = True + populate_by_name = True extra = pydantic_v1.Extra.allow json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/courier/tenants/types/subscription_topic_new.py b/src/courier/tenants/types/subscription_topic_new.py new file mode 100644 index 0000000..eb5a091 --- /dev/null +++ b/src/courier/tenants/types/subscription_topic_new.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...commons.types.channel_classification import ChannelClassification +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel +from .subscription_topic_status import SubscriptionTopicStatus + + +class SubscriptionTopicNew(UncheckedBaseModel): + status: SubscriptionTopicStatus + has_custom_routing: typing.Optional[bool] = pydantic_v1.Field(default=None) + """ + Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences + """ + + custom_routing: typing.Optional[typing.List[ChannelClassification]] = pydantic_v1.Field(default=None) + """ + The default channels to send to this tenant when has_custom_routing is enabled + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/courier/tenants/types/tenant.py b/src/courier/tenants/types/tenant.py index 9cff10c..f39aed2 100644 --- a/src/courier/tenants/types/tenant.py +++ b/src/courier/tenants/types/tenant.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .default_preferences import DefaultPreferences -class Tenant(pydantic_v1.BaseModel): +class Tenant(UncheckedBaseModel): id: str = pydantic_v1.Field() """ Id of the tenant. @@ -49,8 +50,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/tenants/types/tenant_list_response.py b/src/courier/tenants/types/tenant_list_response.py index a52e719..4e66d90 100644 --- a/src/courier/tenants/types/tenant_list_response.py +++ b/src/courier/tenants/types/tenant_list_response.py @@ -4,11 +4,12 @@ import typing from ...core.datetime_utils import serialize_datetime -from ...core.pydantic_utilities import pydantic_v1 +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...core.unchecked_base_model import UncheckedBaseModel from .tenant import Tenant -class TenantListResponse(pydantic_v1.BaseModel): +class TenantListResponse(UncheckedBaseModel): cursor: typing.Optional[str] = pydantic_v1.Field(default=None) """ A pointer to the next page of results. Defined only when has_more is set to true. @@ -45,8 +46,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/translations/client.py b/src/courier/translations/client.py index f799bc1..ca89ef4 100644 --- a/src/courier/translations/client.py +++ b/src/courier/translations/client.py @@ -9,9 +9,10 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.jsonable_encoder import jsonable_encoder -from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query from ..core.remove_none_from_dict import remove_none_from_dict from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -59,8 +60,10 @@ def get(self, domain: str, locale: str, *, request_options: typing.Optional[Requ f"{self._client_wrapper.get_base_url()}/", f"translations/{jsonable_encoder(domain)}/{jsonable_encoder(locale)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -77,9 +80,11 @@ def get(self, domain: str, locale: str, *, request_options: typing.Optional[Requ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(str, _response.json()) # type: ignore + return typing.cast(str, construct_type(type_=str, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -128,8 +133,10 @@ def update( f"{self._client_wrapper.get_base_url()}/", f"translations/{jsonable_encoder(domain)}/{jsonable_encoder(locale)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request), headers=jsonable_encoder( @@ -149,7 +156,9 @@ def update( if 200 <= _response.status_code < 300: return if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -199,8 +208,10 @@ async def get(self, domain: str, locale: str, *, request_options: typing.Optiona f"{self._client_wrapper.get_base_url()}/", f"translations/{jsonable_encoder(domain)}/{jsonable_encoder(locale)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -217,9 +228,11 @@ async def get(self, domain: str, locale: str, *, request_options: typing.Optiona max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(str, _response.json()) # type: ignore + return typing.cast(str, construct_type(type_=str, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -268,8 +281,10 @@ async def update( f"{self._client_wrapper.get_base_url()}/", f"translations/{jsonable_encoder(domain)}/{jsonable_encoder(locale)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request), headers=jsonable_encoder( @@ -289,7 +304,9 @@ async def update( if 200 <= _response.status_code < 300: return if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/types/send_message_response.py b/src/courier/types/send_message_response.py index 47f33ce..f39a279 100644 --- a/src/courier/types/send_message_response.py +++ b/src/courier/types/send_message_response.py @@ -4,10 +4,11 @@ import typing from ..core.datetime_utils import serialize_datetime -from ..core.pydantic_utilities import pydantic_v1 +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ..core.unchecked_base_model import UncheckedBaseModel -class SendMessageResponse(pydantic_v1.BaseModel): +class SendMessageResponse(UncheckedBaseModel): request_id: str = pydantic_v1.Field(alias="requestId") """ A successful call to `POST /send` returns a `202` status code along with a `requestId` in the response body. @@ -22,8 +23,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/preferences/client.py b/src/courier/users/preferences/client.py index 4f9d1fb..43bb616 100644 --- a/src/courier/users/preferences/client.py +++ b/src/courier/users/preferences/client.py @@ -11,9 +11,10 @@ from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import pydantic_v1 +from ...core.query_encoder import encode_query from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type from .types.topic_preference_update import TopicPreferenceUpdate from .types.user_preferences_get_response import UserPreferencesGetResponse from .types.user_preferences_list_response import UserPreferencesListResponse @@ -27,7 +28,7 @@ class PreferencesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def list( + def list_( self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> UserPreferencesListResponse: """ @@ -52,7 +53,7 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.users.preferences.list( + client.users.preferences.list_( user_id="string", ) """ @@ -61,8 +62,10 @@ def list( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -79,9 +82,11 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesListResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesListResponse, construct_type(type_=UserPreferencesListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -127,8 +132,10 @@ def get( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences/{jsonable_encoder(topic_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -145,9 +152,11 @@ def get( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesGetResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesGetResponse, construct_type(type_=UserPreferencesGetResponse, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -206,8 +215,10 @@ def update( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences/{jsonable_encoder(topic_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"topic": topic}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -230,9 +241,11 @@ def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesUpdateResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesUpdateResponse, construct_type(type_=UserPreferencesUpdateResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -244,7 +257,7 @@ class AsyncPreferencesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def list( + async def list_( self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> UserPreferencesListResponse: """ @@ -269,7 +282,7 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.users.preferences.list( + await client.users.preferences.list_( user_id="string", ) """ @@ -278,8 +291,10 @@ async def list( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -296,9 +311,11 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesListResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesListResponse, construct_type(type_=UserPreferencesListResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -344,8 +361,10 @@ async def get( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences/{jsonable_encoder(topic_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -362,9 +381,11 @@ async def get( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesGetResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesGetResponse, construct_type(type_=UserPreferencesGetResponse, object_=_response.json())) # type: ignore if _response.status_code == 404: - raise NotFoundError(pydantic_v1.parse_obj_as(NotFound, _response.json())) # type: ignore + raise NotFoundError( + typing.cast(NotFound, construct_type(type_=NotFound, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -423,8 +444,10 @@ async def update( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/preferences/{jsonable_encoder(topic_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"topic": topic}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -447,9 +470,11 @@ async def update( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(UserPreferencesUpdateResponse, _response.json()) # type: ignore + return typing.cast(UserPreferencesUpdateResponse, construct_type(type_=UserPreferencesUpdateResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/users/preferences/types/topic_preference.py b/src/courier/users/preferences/types/topic_preference.py index b08d878..7c1f03c 100644 --- a/src/courier/users/preferences/types/topic_preference.py +++ b/src/courier/users/preferences/types/topic_preference.py @@ -6,10 +6,11 @@ from ....commons.types.channel_classification import ChannelClassification from ....commons.types.preference_status import PreferenceStatus from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class TopicPreference(pydantic_v1.BaseModel): +class TopicPreference(UncheckedBaseModel): custom_routing: typing.Optional[typing.List[ChannelClassification]] = pydantic_v1.Field(default=None) """ The Channels a user has chosen to receive notifications through for this topic @@ -26,8 +27,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/preferences/types/topic_preference_update.py b/src/courier/users/preferences/types/topic_preference_update.py index b26b425..fefc410 100644 --- a/src/courier/users/preferences/types/topic_preference_update.py +++ b/src/courier/users/preferences/types/topic_preference_update.py @@ -6,10 +6,11 @@ from ....commons.types.channel_classification import ChannelClassification from ....commons.types.preference_status import PreferenceStatus from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class TopicPreferenceUpdate(pydantic_v1.BaseModel): +class TopicPreferenceUpdate(UncheckedBaseModel): status: PreferenceStatus custom_routing: typing.Optional[typing.List[ChannelClassification]] = pydantic_v1.Field(default=None) """ @@ -23,8 +24,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/preferences/types/user_preferences_get_response.py b/src/courier/users/preferences/types/user_preferences_get_response.py index c478e98..5482595 100644 --- a/src/courier/users/preferences/types/user_preferences_get_response.py +++ b/src/courier/users/preferences/types/user_preferences_get_response.py @@ -4,11 +4,12 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .topic_preference import TopicPreference -class UserPreferencesGetResponse(pydantic_v1.BaseModel): +class UserPreferencesGetResponse(UncheckedBaseModel): topic: TopicPreference def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/preferences/types/user_preferences_list_response.py b/src/courier/users/preferences/types/user_preferences_list_response.py index 07d213f..6bef2bf 100644 --- a/src/courier/users/preferences/types/user_preferences_list_response.py +++ b/src/courier/users/preferences/types/user_preferences_list_response.py @@ -5,11 +5,12 @@ from ....commons.types.paging import Paging from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .topic_preference import TopicPreference -class UserPreferencesListResponse(pydantic_v1.BaseModel): +class UserPreferencesListResponse(UncheckedBaseModel): paging: Paging items: typing.List[TopicPreference] = pydantic_v1.Field() """ @@ -21,8 +22,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/preferences/types/user_preferences_update_response.py b/src/courier/users/preferences/types/user_preferences_update_response.py index 028d47b..fad6600 100644 --- a/src/courier/users/preferences/types/user_preferences_update_response.py +++ b/src/courier/users/preferences/types/user_preferences_update_response.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class UserPreferencesUpdateResponse(pydantic_v1.BaseModel): +class UserPreferencesUpdateResponse(UncheckedBaseModel): message: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tenants/client.py b/src/courier/users/tenants/client.py index 996a485..6ae318c 100644 --- a/src/courier/users/tenants/client.py +++ b/src/courier/users/tenants/client.py @@ -8,9 +8,10 @@ from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import pydantic_v1 +from ...core.query_encoder import encode_query from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type from .types.list_tenants_for_user_response import ListTenantsForUserResponse # this is used as the default value for optional parameters @@ -74,8 +75,10 @@ def add_multple( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"tenants": tenants}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -159,8 +162,10 @@ def add( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants/{jsonable_encoder(tenant_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -222,9 +227,14 @@ def remove_all(self, user_id: str, *, request_options: typing.Optional[RequestOp url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -284,9 +294,14 @@ def remove(self, user_id: str, tenant_id: str, *, request_options: typing.Option f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants/{jsonable_encoder(tenant_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -309,7 +324,7 @@ def remove(self, user_id: str, tenant_id: str, *, request_options: typing.Option raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def list( + def list_( self, user_id: str, *, @@ -346,7 +361,7 @@ def list( client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.users.tenants.list( + client.users.tenants.list_( user_id="string", limit=1, cursor="string", @@ -357,17 +372,19 @@ def list( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -385,7 +402,7 @@ def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListTenantsForUserResponse, _response.json()) # type: ignore + return typing.cast(ListTenantsForUserResponse, construct_type(type_=ListTenantsForUserResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: @@ -450,8 +467,10 @@ async def add_multple( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder({"tenants": tenants}) if request_options is None or request_options.get("additional_body_parameters") is None @@ -535,8 +554,10 @@ async def add( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants/{jsonable_encoder(tenant_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(_request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -598,9 +619,14 @@ async def remove_all(self, user_id: str, *, request_options: typing.Optional[Req url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -662,9 +688,14 @@ async def remove( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants/{jsonable_encoder(tenant_id)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), + json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) + if request_options is not None + else None, headers=jsonable_encoder( remove_none_from_dict( { @@ -687,7 +718,7 @@ async def remove( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def list( + async def list_( self, user_id: str, *, @@ -724,7 +755,7 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.users.tenants.list( + await client.users.tenants.list_( user_id="string", limit=1, cursor="string", @@ -735,17 +766,19 @@ async def list( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tenants" ), - params=jsonable_encoder( - remove_none_from_dict( - { - "limit": limit, - "cursor": cursor, - **( - request_options.get("additional_query_parameters", {}) - if request_options is not None - else {} - ), - } + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "limit": limit, + "cursor": cursor, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) ) ), headers=jsonable_encoder( @@ -763,7 +796,7 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(ListTenantsForUserResponse, _response.json()) # type: ignore + return typing.cast(ListTenantsForUserResponse, construct_type(type_=ListTenantsForUserResponse, object_=_response.json())) # type: ignore try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/users/tenants/types/add_user_to_single_tenants_params_profile.py b/src/courier/users/tenants/types/add_user_to_single_tenants_params_profile.py index d1458f4..b0ab640 100644 --- a/src/courier/users/tenants/types/add_user_to_single_tenants_params_profile.py +++ b/src/courier/users/tenants/types/add_user_to_single_tenants_params_profile.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class AddUserToSingleTenantsParamsProfile(pydantic_v1.BaseModel): +class AddUserToSingleTenantsParamsProfile(UncheckedBaseModel): """ AddUserToSingleTenantsParamsProfile is no longer used for Add a User to a Single Tenant """ @@ -38,8 +39,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tenants/types/list_tenants_for_user_response.py b/src/courier/users/tenants/types/list_tenants_for_user_response.py index bfafe66..3ffc161 100644 --- a/src/courier/users/tenants/types/list_tenants_for_user_response.py +++ b/src/courier/users/tenants/types/list_tenants_for_user_response.py @@ -5,10 +5,11 @@ from ....commons.types.user_tenant_association import UserTenantAssociation from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class ListTenantsForUserResponse(pydantic_v1.BaseModel): +class ListTenantsForUserResponse(UncheckedBaseModel): items: typing.Optional[typing.List[UserTenantAssociation]] = None has_more: bool = pydantic_v1.Field() """ @@ -42,8 +43,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/client.py b/src/courier/users/tokens/client.py index 97230a6..8527592 100644 --- a/src/courier/users/tokens/client.py +++ b/src/courier/users/tokens/client.py @@ -9,9 +9,10 @@ from ...core.api_error import ApiError from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.jsonable_encoder import jsonable_encoder -from ...core.pydantic_utilities import pydantic_v1 +from ...core.query_encoder import encode_query from ...core.remove_none_from_dict import remove_none_from_dict from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type from .types.get_all_tokens_response import GetAllTokensResponse from .types.get_user_token_response import GetUserTokenResponse from .types.patch_user_token_opts import PatchUserTokenOpts @@ -57,8 +58,10 @@ def add_multiple(self, user_id: str, *, request_options: typing.Optional[Request url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -80,7 +83,9 @@ def add_multiple(self, user_id: str, *, request_options: typing.Optional[Request if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -149,8 +154,10 @@ def add( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -175,7 +182,9 @@ def add( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -232,8 +241,10 @@ def update( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -258,7 +269,9 @@ def update( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -304,8 +317,10 @@ def get( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -322,16 +337,18 @@ def get( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetUserTokenResponse, _response.json()) # type: ignore + return typing.cast(GetUserTokenResponse, construct_type(type_=GetUserTokenResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def list(self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetAllTokensResponse: + def list_(self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetAllTokensResponse: """ Gets all tokens available for a :user_id @@ -354,7 +371,7 @@ def list(self, user_id: str, *, request_options: typing.Optional[RequestOptions] client = Courier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - client.users.tokens.list( + client.users.tokens.list_( user_id="string", ) """ @@ -363,8 +380,10 @@ def list(self, user_id: str, *, request_options: typing.Optional[RequestOptions] url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -381,9 +400,11 @@ def list(self, user_id: str, *, request_options: typing.Optional[RequestOptions] max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetAllTokensResponse, _response.json()) # type: ignore + return typing.cast(GetAllTokensResponse, construct_type(type_=GetAllTokensResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -427,8 +448,10 @@ async def add_multiple(self, user_id: str, *, request_options: typing.Optional[R url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {}))) if request_options is not None @@ -450,7 +473,9 @@ async def add_multiple(self, user_id: str, *, request_options: typing.Optional[R if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -519,8 +544,10 @@ async def add( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -545,7 +572,9 @@ async def add( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -602,8 +631,10 @@ async def update( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), json=jsonable_encoder(request) if request_options is None or request_options.get("additional_body_parameters") is None @@ -628,7 +659,9 @@ async def update( if 200 <= _response.status_code < 300: return if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: @@ -674,8 +707,10 @@ async def get( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens/{jsonable_encoder(token)}", ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -692,16 +727,18 @@ async def get( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetUserTokenResponse, _response.json()) # type: ignore + return typing.cast(GetUserTokenResponse, construct_type(type_=GetUserTokenResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def list( + async def list_( self, user_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetAllTokensResponse: """ @@ -726,7 +763,7 @@ async def list( client = AsyncCourier( authorization_token="YOUR_AUTHORIZATION_TOKEN", ) - await client.users.tokens.list( + await client.users.tokens.list_( user_id="string", ) """ @@ -735,8 +772,10 @@ async def list( url=urllib.parse.urljoin( f"{self._client_wrapper.get_base_url()}/", f"users/{jsonable_encoder(user_id)}/tokens" ), - params=jsonable_encoder( - request_options.get("additional_query_parameters") if request_options is not None else None + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) ), headers=jsonable_encoder( remove_none_from_dict( @@ -753,9 +792,11 @@ async def list( max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore ) if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(GetAllTokensResponse, _response.json()) # type: ignore + return typing.cast(GetAllTokensResponse, construct_type(type_=GetAllTokensResponse, object_=_response.json())) # type: ignore if _response.status_code == 400: - raise BadRequestError(pydantic_v1.parse_obj_as(BadRequest, _response.json())) # type: ignore + raise BadRequestError( + typing.cast(BadRequest, construct_type(type_=BadRequest, object_=_response.json())) # type: ignore + ) try: _response_json = _response.json() except JSONDecodeError: diff --git a/src/courier/users/tokens/types/delete_user_token_opts.py b/src/courier/users/tokens/types/delete_user_token_opts.py index 0fec948..9b5cb6e 100644 --- a/src/courier/users/tokens/types/delete_user_token_opts.py +++ b/src/courier/users/tokens/types/delete_user_token_opts.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class DeleteUserTokenOpts(pydantic_v1.BaseModel): +class DeleteUserTokenOpts(UncheckedBaseModel): user_id: str token: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/device.py b/src/courier/users/tokens/types/device.py index ee64493..766ec09 100644 --- a/src/courier/users/tokens/types/device.py +++ b/src/courier/users/tokens/types/device.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class Device(pydantic_v1.BaseModel): +class Device(UncheckedBaseModel): app_id: typing.Optional[str] = pydantic_v1.Field(default=None) """ Id of the application the token is used for @@ -43,8 +44,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/get_user_token_opts.py b/src/courier/users/tokens/types/get_user_token_opts.py index 848dbb4..e9b1e52 100644 --- a/src/courier/users/tokens/types/get_user_token_opts.py +++ b/src/courier/users/tokens/types/get_user_token_opts.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class GetUserTokenOpts(pydantic_v1.BaseModel): +class GetUserTokenOpts(UncheckedBaseModel): user_id: str token: str @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/get_user_token_response.py b/src/courier/users/tokens/types/get_user_token_response.py index c0d325c..14be13c 100644 --- a/src/courier/users/tokens/types/get_user_token_response.py +++ b/src/courier/users/tokens/types/get_user_token_response.py @@ -4,7 +4,7 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .token_status import TokenStatus from .user_token import UserToken @@ -21,8 +21,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/get_user_tokens_opts.py b/src/courier/users/tokens/types/get_user_tokens_opts.py index c7c88bd..3443c43 100644 --- a/src/courier/users/tokens/types/get_user_tokens_opts.py +++ b/src/courier/users/tokens/types/get_user_tokens_opts.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class GetUserTokensOpts(pydantic_v1.BaseModel): +class GetUserTokensOpts(UncheckedBaseModel): user_id: str def json(self, **kwargs: typing.Any) -> str: @@ -15,8 +16,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/patch_operation.py b/src/courier/users/tokens/types/patch_operation.py index 803df68..f294852 100644 --- a/src/courier/users/tokens/types/patch_operation.py +++ b/src/courier/users/tokens/types/patch_operation.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class PatchOperation(pydantic_v1.BaseModel): +class PatchOperation(UncheckedBaseModel): op: str = pydantic_v1.Field() """ The operation to perform. @@ -28,8 +29,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/patch_user_token_opts.py b/src/courier/users/tokens/types/patch_user_token_opts.py index d03babe..721c8c7 100644 --- a/src/courier/users/tokens/types/patch_user_token_opts.py +++ b/src/courier/users/tokens/types/patch_user_token_opts.py @@ -4,11 +4,12 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .patch_operation import PatchOperation -class PatchUserTokenOpts(pydantic_v1.BaseModel): +class PatchUserTokenOpts(UncheckedBaseModel): patch: typing.List[PatchOperation] def json(self, **kwargs: typing.Any) -> str: @@ -16,8 +17,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/put_user_token_opts.py b/src/courier/users/tokens/types/put_user_token_opts.py index 4a381e5..fbc7d11 100644 --- a/src/courier/users/tokens/types/put_user_token_opts.py +++ b/src/courier/users/tokens/types/put_user_token_opts.py @@ -4,11 +4,12 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .user_token import UserToken -class PutUserTokenOpts(pydantic_v1.BaseModel): +class PutUserTokenOpts(UncheckedBaseModel): user_id: str token: UserToken @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/put_user_tokens_opts.py b/src/courier/users/tokens/types/put_user_tokens_opts.py index 55dbaa6..471214c 100644 --- a/src/courier/users/tokens/types/put_user_tokens_opts.py +++ b/src/courier/users/tokens/types/put_user_tokens_opts.py @@ -4,11 +4,12 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .user_token import UserToken -class PutUserTokensOpts(pydantic_v1.BaseModel): +class PutUserTokensOpts(UncheckedBaseModel): user_id: str tokens: typing.List[UserToken] @@ -17,8 +18,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/tracking.py b/src/courier/users/tokens/types/tracking.py index 7a374bf..c79f3d1 100644 --- a/src/courier/users/tokens/types/tracking.py +++ b/src/courier/users/tokens/types/tracking.py @@ -4,10 +4,11 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel -class Tracking(pydantic_v1.BaseModel): +class Tracking(UncheckedBaseModel): os_version: typing.Optional[str] = pydantic_v1.Field(default=None) """ The operating system version @@ -33,8 +34,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True diff --git a/src/courier/users/tokens/types/user_token.py b/src/courier/users/tokens/types/user_token.py index 3226ba9..18c57ad 100644 --- a/src/courier/users/tokens/types/user_token.py +++ b/src/courier/users/tokens/types/user_token.py @@ -4,14 +4,15 @@ import typing from ....core.datetime_utils import serialize_datetime -from ....core.pydantic_utilities import pydantic_v1 +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ....core.unchecked_base_model import UncheckedBaseModel from .device import Device from .expiry_date import ExpiryDate from .provider_key import ProviderKey from .tracking import Tracking -class UserToken(pydantic_v1.BaseModel): +class UserToken(UncheckedBaseModel): token: typing.Optional[str] = pydantic_v1.Field(default=None) """ Full body of the token. Must match token in URL. @@ -43,8 +44,12 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) class Config: frozen = True