-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d51700
commit ac375be
Showing
13 changed files
with
307 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
from .resources import notifications | ||
from .resources import notification_policy, notifications | ||
|
||
__all__ = ["notifications"] | ||
__all__ = ["notification_policy", "notifications"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/mercoa/resources/entity/resources/user/resources/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
from . import notifications | ||
from . import notification_policy, notifications | ||
|
||
__all__ = ["notifications"] | ||
__all__ = ["notification_policy", "notifications"] |
2 changes: 2 additions & 0 deletions
2
src/mercoa/resources/entity/resources/user/resources/notification_policy/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
205 changes: 205 additions & 0 deletions
205
src/mercoa/resources/entity/resources/user/resources/notification_policy/client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
import typing | ||
import urllib.parse | ||
from json.decoder import JSONDecodeError | ||
|
||
import httpx | ||
import pydantic | ||
|
||
from .......core.api_error import ApiError | ||
from .......core.jsonable_encoder import jsonable_encoder | ||
from .......core.remove_none_from_headers import remove_none_from_headers | ||
from .......environment import MercoaEnvironment | ||
from ......commons.errors.auth_header_malformed_error import AuthHeaderMalformedError | ||
from ......commons.errors.auth_header_missing_error import AuthHeaderMissingError | ||
from ......commons.errors.unauthorized import Unauthorized | ||
from ......entity_types.types.entity_id import EntityId | ||
from ......entity_types.types.entity_user_id import EntityUserId | ||
from ......entity_types.types.notification_type import NotificationType | ||
from ......entity_types.types.user_notification_policy_response import UserNotificationPolicyResponse | ||
|
||
|
||
class NotificationPolicyClient: | ||
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str): | ||
self._environment = environment | ||
self._token = token | ||
|
||
def get_all(self, entity_id: EntityId, user_id: EntityUserId) -> typing.List[UserNotificationPolicyResponse]: | ||
_response = httpx.request( | ||
"GET", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", f"entity/{entity_id}/user/{user_id}/notification-policies" | ||
), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(typing.List[UserNotificationPolicyResponse], _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
def get( | ||
self, entity_id: EntityId, user_id: EntityUserId, notification_type: NotificationType | ||
) -> UserNotificationPolicyResponse: | ||
_response = httpx.request( | ||
"GET", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", | ||
f"entity/{entity_id}/user/{user_id}/notification-policy/{notification_type}", | ||
), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(UserNotificationPolicyResponse, _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
def update( | ||
self, entity_id: EntityId, user_id: EntityUserId, notification_type: NotificationType, *, disabled: bool | ||
) -> UserNotificationPolicyResponse: | ||
_response = httpx.request( | ||
"POST", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", | ||
f"entity/{entity_id}/user/{user_id}/notification-policy/{notification_type}", | ||
), | ||
json=jsonable_encoder({"disabled": disabled}), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(UserNotificationPolicyResponse, _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
|
||
class AsyncNotificationPolicyClient: | ||
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str): | ||
self._environment = environment | ||
self._token = token | ||
|
||
async def get_all(self, entity_id: EntityId, user_id: EntityUserId) -> typing.List[UserNotificationPolicyResponse]: | ||
async with httpx.AsyncClient() as _client: | ||
_response = await _client.request( | ||
"GET", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", f"entity/{entity_id}/user/{user_id}/notification-policies" | ||
), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(typing.List[UserNotificationPolicyResponse], _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
async def get( | ||
self, entity_id: EntityId, user_id: EntityUserId, notification_type: NotificationType | ||
) -> UserNotificationPolicyResponse: | ||
async with httpx.AsyncClient() as _client: | ||
_response = await _client.request( | ||
"GET", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", | ||
f"entity/{entity_id}/user/{user_id}/notification-policy/{notification_type}", | ||
), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(UserNotificationPolicyResponse, _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
async def update( | ||
self, entity_id: EntityId, user_id: EntityUserId, notification_type: NotificationType, *, disabled: bool | ||
) -> UserNotificationPolicyResponse: | ||
async with httpx.AsyncClient() as _client: | ||
_response = await _client.request( | ||
"POST", | ||
urllib.parse.urljoin( | ||
f"{self._environment.value}/", | ||
f"entity/{entity_id}/user/{user_id}/notification-policy/{notification_type}", | ||
), | ||
json=jsonable_encoder({"disabled": disabled}), | ||
headers=remove_none_from_headers( | ||
{"Authorization": f"Bearer {self._token}" if self._token is not None else None} | ||
), | ||
timeout=60, | ||
) | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(UserNotificationPolicyResponse, _response_json) # type: ignore | ||
if "errorName" in _response_json: | ||
if _response_json["errorName"] == "AuthHeaderMissingError": | ||
raise AuthHeaderMissingError() | ||
if _response_json["errorName"] == "AuthHeaderMalformedError": | ||
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
if _response_json["errorName"] == "Unauthorized": | ||
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore | ||
raise ApiError(status_code=_response.status_code, body=_response_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/mercoa/resources/entity_types/types/user_notification_policy_response.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
import datetime as dt | ||
import typing | ||
|
||
import pydantic | ||
|
||
from ....core.datetime_utils import serialize_datetime | ||
from .notification_type import NotificationType | ||
|
||
|
||
class UserNotificationPolicyResponse(pydantic.BaseModel): | ||
disabled: bool = pydantic.Field(description=("True if the selected notification type is disabled for this user\n")) | ||
type: NotificationType | ||
|
||
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 | ||
json_encoders = {dt.datetime: serialize_datetime} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.