Skip to content

Commit

Permalink
Release v0.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jul 26, 2023
1 parent 0d51700 commit ac375be
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mercoa"
version = "v0.2.4"
version = "v0.2.5"
description = ""
readme = "README.md"
authors = []
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
Trigger_All,
Trigger_Amount,
Unauthorized,
UserNotificationPolicyResponse,
VendorNetwork,
bank_lookup,
commons,
Expand Down Expand Up @@ -302,6 +303,7 @@
"Trigger_All",
"Trigger_Amount",
"Unauthorized",
"UserNotificationPolicyResponse",
"VendorNetwork",
"bank_lookup",
"commons",
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
Trigger,
Trigger_All,
Trigger_Amount,
UserNotificationPolicyResponse,
)
from .invoice_types import (
ApprovalRequest,
Expand Down Expand Up @@ -305,6 +306,7 @@
"Trigger_All",
"Trigger_Amount",
"Unauthorized",
"UserNotificationPolicyResponse",
"VendorNetwork",
"bank_lookup",
"commons",
Expand Down
4 changes: 2 additions & 2 deletions src/mercoa/resources/entity/resources/user/__init__.py
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"]
3 changes: 3 additions & 0 deletions src/mercoa/resources/entity/resources/user/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
from ....entity_types.types.entity_user_id import EntityUserId
from ....entity_types.types.entity_user_request import EntityUserRequest
from ....entity_types.types.entity_user_response import EntityUserResponse
from .resources.notification_policy.client import AsyncNotificationPolicyClient, NotificationPolicyClient
from .resources.notifications.client import AsyncNotificationsClient, NotificationsClient


class UserClient:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str):
self._environment = environment
self._token = token
self.notification_policy = NotificationPolicyClient(environment=self._environment, token=self._token)
self.notifications = NotificationsClient(environment=self._environment, token=self._token)

def get_all(self, entity_id: EntityId) -> typing.List[EntityUserResponse]:
Expand Down Expand Up @@ -178,6 +180,7 @@ class AsyncUserClient:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str):
self._environment = environment
self._token = token
self.notification_policy = AsyncNotificationPolicyClient(environment=self._environment, token=self._token)
self.notifications = AsyncNotificationsClient(environment=self._environment, token=self._token)

async def get_all(self, entity_id: EntityId) -> typing.List[EntityUserResponse]:
Expand Down
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"]
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.

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)
2 changes: 2 additions & 0 deletions src/mercoa/resources/entity_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Trigger,
Trigger_All,
Trigger_Amount,
UserNotificationPolicyResponse,
)

__all__ = [
Expand Down Expand Up @@ -96,4 +97,5 @@
"Trigger",
"Trigger_All",
"Trigger_Amount",
"UserNotificationPolicyResponse",
]
2 changes: 2 additions & 0 deletions src/mercoa/resources/entity_types/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .rule import Rule, Rule_Approver
from .tax_id import TaxId
from .trigger import Trigger, Trigger_All, Trigger_Amount
from .user_notification_policy_response import UserNotificationPolicyResponse

__all__ = [
"AccountType",
Expand Down Expand Up @@ -89,4 +90,5 @@
"Trigger",
"Trigger_All",
"Trigger_Amount",
"UserNotificationPolicyResponse",
]
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}
5 changes: 3 additions & 2 deletions src/mercoa/resources/invoice_types/types/invoice_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ...entity_types.types.entity_response import EntityResponse
from ...entity_types.types.entity_user_response import EntityUserResponse
from ...payment_method_types.types.currency_code import CurrencyCode
from ...payment_method_types.types.payment_method_id import PaymentMethodId
from ...payment_method_types.types.payment_method_response import PaymentMethodResponse
from ...transaction.types.transaction_response import TransactionResponse
from .comment_response import CommentResponse
Expand Down Expand Up @@ -42,11 +43,11 @@ class InvoiceResponse(pydantic.BaseModel):
payer_id: typing.Optional[EntityId] = pydantic.Field(alias="payerId")
payer: typing.Optional[EntityResponse]
payment_source: typing.Optional[PaymentMethodResponse] = pydantic.Field(alias="paymentSource")
payment_source_id: typing.Optional[InvoiceId] = pydantic.Field(alias="paymentSourceId")
payment_source_id: typing.Optional[PaymentMethodId] = pydantic.Field(alias="paymentSourceId")
vendor_id: typing.Optional[EntityId] = pydantic.Field(alias="vendorId")
vendor: typing.Optional[EntityResponse]
payment_destination: typing.Optional[PaymentMethodResponse] = pydantic.Field(alias="paymentDestination")
payment_destination_id: typing.Optional[InvoiceId] = pydantic.Field(alias="paymentDestinationId")
payment_destination_id: typing.Optional[PaymentMethodId] = pydantic.Field(alias="paymentDestinationId")
payment_destination_confirmed: bool = pydantic.Field(alias="paymentDestinationConfirmed")
has_documents: bool = pydantic.Field(alias="hasDocuments")
comments: typing.Optional[typing.List[CommentResponse]]
Expand Down
Loading

0 comments on commit ac375be

Please sign in to comment.