diff --git a/poetry.lock b/poetry.lock index 9b6cbce..afc2abd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -60,13 +60,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.0" +version = "1.2.1" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, - {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, + {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, + {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, ] [package.extras] @@ -132,13 +132,13 @@ socks = ["socksio (==1.*)"] [[package]] name = "idna" -version = "3.6" +version = "3.7" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ - {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, - {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, + {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, + {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 5788e7a..153d184 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "revert-api" -version = "0.0.834" +version = "0.0.852" description = "" readme = "README.md" authors = [] diff --git a/src/revert/__init__.py b/src/revert/__init__.py index eab4aad..462fbb6 100644 --- a/src/revert/__init__.py +++ b/src/revert/__init__.py @@ -26,12 +26,14 @@ ImportConnectionsRequestBody, ImportConnectionsResponse, MappableFieldType, + TriggerSyncResponse, chat, common, connection, crm, field_mapping, metadata, + sync, ticket, ) from .environment import RevertEnvironment @@ -63,11 +65,13 @@ "ImportConnectionsResponse", "MappableFieldType", "RevertEnvironment", + "TriggerSyncResponse", "chat", "common", "connection", "crm", "field_mapping", "metadata", + "sync", "ticket", ] diff --git a/src/revert/client.py b/src/revert/client.py index 80882ce..ecc57ea 100644 --- a/src/revert/client.py +++ b/src/revert/client.py @@ -11,6 +11,7 @@ from .resources.crm.client import AsyncCrmClient, CrmClient from .resources.field_mapping.client import AsyncFieldMappingClient, FieldMappingClient from .resources.metadata.client import AsyncMetadataClient, MetadataClient +from .resources.sync.client import AsyncSyncClient, SyncClient from .resources.ticket.client import AsyncTicketClient, TicketClient @@ -32,6 +33,7 @@ def __init__( self.crm = CrmClient(client_wrapper=self._client_wrapper) self.field_mapping = FieldMappingClient(client_wrapper=self._client_wrapper) self.metadata = MetadataClient(client_wrapper=self._client_wrapper) + self.sync = SyncClient(client_wrapper=self._client_wrapper) self.ticket = TicketClient(client_wrapper=self._client_wrapper) @@ -53,6 +55,7 @@ def __init__( self.crm = AsyncCrmClient(client_wrapper=self._client_wrapper) self.field_mapping = AsyncFieldMappingClient(client_wrapper=self._client_wrapper) self.metadata = AsyncMetadataClient(client_wrapper=self._client_wrapper) + self.sync = AsyncSyncClient(client_wrapper=self._client_wrapper) self.ticket = AsyncTicketClient(client_wrapper=self._client_wrapper) diff --git a/src/revert/core/client_wrapper.py b/src/revert/core/client_wrapper.py index 7bf34a1..cb7cfac 100644 --- a/src/revert/core/client_wrapper.py +++ b/src/revert/core/client_wrapper.py @@ -13,7 +13,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "revert-api", - "X-Fern-SDK-Version": "0.0.834", + "X-Fern-SDK-Version": "0.0.852", } return headers diff --git a/src/revert/resources/__init__.py b/src/revert/resources/__init__.py index 82c62af..841aae7 100644 --- a/src/revert/resources/__init__.py +++ b/src/revert/resources/__init__.py @@ -1,6 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from . import chat, common, connection, crm, field_mapping, metadata, ticket +from . import chat, common, connection, crm, field_mapping, metadata, sync, ticket from .connection import ( ConnectionImport, ConnectionStatus, @@ -28,6 +28,7 @@ MappableFieldType, ) from .metadata import CrmMetadata, CrmMetadataResponse, CrmStatus +from .sync import TriggerSyncResponse __all__ = [ "ConnectionImport", @@ -55,11 +56,13 @@ "ImportConnectionsRequestBody", "ImportConnectionsResponse", "MappableFieldType", + "TriggerSyncResponse", "chat", "common", "connection", "crm", "field_mapping", "metadata", + "sync", "ticket", ] diff --git a/src/revert/resources/common/__init__.py b/src/revert/resources/common/__init__.py index 81a59f3..3cb482c 100644 --- a/src/revert/resources/common/__init__.py +++ b/src/revert/resources/common/__init__.py @@ -32,6 +32,7 @@ LeadWrite, Message, NotFoundError, + NotImplementedError, Note, NoteRead, NoteWrite, @@ -89,6 +90,7 @@ "LeadWrite", "Message", "NotFoundError", + "NotImplementedError", "Note", "NoteRead", "NoteWrite", diff --git a/src/revert/resources/common/resources/__init__.py b/src/revert/resources/common/resources/__init__.py index 8da5e48..25338f8 100644 --- a/src/revert/resources/common/resources/__init__.py +++ b/src/revert/resources/common/resources/__init__.py @@ -12,7 +12,14 @@ TicketStatus, Tpid, ) -from .errors import BadRequestError, BaseError, InternalServerError, NotFoundError, UnAuthorizedError +from .errors import ( + BadRequestError, + BaseError, + InternalServerError, + NotFoundError, + NotImplementedError, + UnAuthorizedError, +) from . import associations, errors, types, unified from .associations import ( CompanyAssociation, @@ -86,6 +93,7 @@ "LeadWrite", "Message", "NotFoundError", + "NotImplementedError", "Note", "NoteRead", "NoteWrite", diff --git a/src/revert/resources/common/resources/errors/__init__.py b/src/revert/resources/common/resources/errors/__init__.py index d7f6ffb..e7e4a7a 100644 --- a/src/revert/resources/common/resources/errors/__init__.py +++ b/src/revert/resources/common/resources/errors/__init__.py @@ -1,6 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from .types import BaseError -from .errors import BadRequestError, InternalServerError, NotFoundError, UnAuthorizedError +from .errors import BadRequestError, InternalServerError, NotFoundError, NotImplementedError, UnAuthorizedError -__all__ = ["BadRequestError", "BaseError", "InternalServerError", "NotFoundError", "UnAuthorizedError"] +__all__ = [ + "BadRequestError", + "BaseError", + "InternalServerError", + "NotFoundError", + "NotImplementedError", + "UnAuthorizedError", +] diff --git a/src/revert/resources/common/resources/errors/errors/__init__.py b/src/revert/resources/common/resources/errors/errors/__init__.py index e0d1610..e83f3b2 100644 --- a/src/revert/resources/common/resources/errors/errors/__init__.py +++ b/src/revert/resources/common/resources/errors/errors/__init__.py @@ -3,6 +3,7 @@ from .bad_request_error import BadRequestError from .internal_server_error import InternalServerError from .not_found_error import NotFoundError +from .not_implemented_error import NotImplementedError from .un_authorized_error import UnAuthorizedError -__all__ = ["BadRequestError", "InternalServerError", "NotFoundError", "UnAuthorizedError"] +__all__ = ["BadRequestError", "InternalServerError", "NotFoundError", "NotImplementedError", "UnAuthorizedError"] diff --git a/src/revert/resources/common/resources/errors/errors/not_implemented_error.py b/src/revert/resources/common/resources/errors/errors/not_implemented_error.py new file mode 100644 index 0000000..2622f2a --- /dev/null +++ b/src/revert/resources/common/resources/errors/errors/not_implemented_error.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +from ......core.api_error import ApiError +from ..types.base_error import BaseError + + +class NotImplementedError(ApiError): + def __init__(self, body: BaseError): + super().__init__(status_code=500, body=body) diff --git a/src/revert/resources/sync/__init__.py b/src/revert/resources/sync/__init__.py new file mode 100644 index 0000000..6481d7a --- /dev/null +++ b/src/revert/resources/sync/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import TriggerSyncResponse + +__all__ = ["TriggerSyncResponse"] diff --git a/src/revert/resources/sync/client.py b/src/revert/resources/sync/client.py new file mode 100644 index 0000000..785726a --- /dev/null +++ b/src/revert/resources/sync/client.py @@ -0,0 +1,114 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import urllib.parse +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.remove_none_from_dict import remove_none_from_dict +from ..common.resources.errors.errors.internal_server_error import InternalServerError +from ..common.resources.errors.errors.not_found_error import NotFoundError +from ..common.resources.errors.errors.not_implemented_error import NotImplementedError +from ..common.resources.errors.errors.un_authorized_error import UnAuthorizedError +from ..common.resources.errors.types.base_error import BaseError +from .types.trigger_sync_response import TriggerSyncResponse + +try: + import pydantic.v1 as pydantic # type: ignore +except ImportError: + import pydantic # type: ignore + + +class SyncClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def trigger_sync( + self, *, x_revert_api_token: str, x_revert_t_id: str, x_connection_api_key: typing.Optional[str] = None + ) -> TriggerSyncResponse: + """ + Trigger sync for a specific tenant + + Parameters: + - x_revert_api_token: str. Your official API key for accessing revert apis. + + - x_revert_t_id: str. The unique customer id used when the customer linked their account. + + - x_connection_api_key: typing.Optional[str]. API key for third party provider + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "sync"), + headers=remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + "x-revert-api-token": x_revert_api_token, + "x-revert-t-id": x_revert_t_id, + "x-connection-api-key": x_connection_api_key, + } + ), + timeout=None, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(TriggerSyncResponse, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnAuthorizedError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 500: + raise NotImplementedError(pydantic.parse_obj_as(BaseError, _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) + + +class AsyncSyncClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def trigger_sync( + self, *, x_revert_api_token: str, x_revert_t_id: str, x_connection_api_key: typing.Optional[str] = None + ) -> TriggerSyncResponse: + """ + Trigger sync for a specific tenant + + Parameters: + - x_revert_api_token: str. Your official API key for accessing revert apis. + + - x_revert_t_id: str. The unique customer id used when the customer linked their account. + + - x_connection_api_key: typing.Optional[str]. API key for third party provider + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "sync"), + headers=remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + "x-revert-api-token": x_revert_api_token, + "x-revert-t-id": x_revert_t_id, + "x-connection-api-key": x_connection_api_key, + } + ), + timeout=None, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(TriggerSyncResponse, _response.json()) # type: ignore + if _response.status_code == 401: + raise UnAuthorizedError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic.parse_obj_as(BaseError, _response.json())) # type: ignore + if _response.status_code == 500: + raise NotImplementedError(pydantic.parse_obj_as(BaseError, _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) diff --git a/src/revert/resources/sync/types/__init__.py b/src/revert/resources/sync/types/__init__.py new file mode 100644 index 0000000..7a66c54 --- /dev/null +++ b/src/revert/resources/sync/types/__init__.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +from .trigger_sync_response import TriggerSyncResponse + +__all__ = ["TriggerSyncResponse"] diff --git a/src/revert/resources/sync/types/trigger_sync_response.py b/src/revert/resources/sync/types/trigger_sync_response.py new file mode 100644 index 0000000..091414c --- /dev/null +++ b/src/revert/resources/sync/types/trigger_sync_response.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ...common.resources.types.types.response_status import ResponseStatus + +try: + import pydantic.v1 as pydantic # type: ignore +except ImportError: + import pydantic # type: ignore + + +class TriggerSyncResponse(pydantic.BaseModel): + status: ResponseStatus + + 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) + + class Config: + frozen = True + smart_union = True + json_encoders = {dt.datetime: serialize_datetime}