Skip to content

Commit

Permalink
Release v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jul 15, 2023
1 parent 926f0cc commit 2c77039
Show file tree
Hide file tree
Showing 29 changed files with 811 additions and 28 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mercoa"
version = "v0.2.1"
version = "v0.2.2"
description = ""
readme = "README.md"
authors = []
Expand All @@ -10,8 +10,8 @@ packages = [

[tool.poetry.dependencies]
python = "^3.7"
pydantic = "^1.9.2"
httpx = "0.23.3"
pydantic = "^1.9.2"

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
16 changes: 16 additions & 0 deletions src/mercoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
EntityUserRequest,
EntityUserResponse,
FindCounterpartiesResponse,
FindEntityResponse,
FindInvoiceResponse,
FindNotificationResponse,
FullName,
IdentifierList,
IdentifierList_RolesList,
Expand All @@ -86,6 +89,11 @@
InvoiceResponse,
InvoiceStatus,
Itin,
NotificationId,
NotificationPolicyRequest,
NotificationPolicyResponse,
NotificationResponse,
NotificationType,
OcrResponse,
OrderDirection,
OrganizationId,
Expand Down Expand Up @@ -217,6 +225,9 @@
"EntityUserRequest",
"EntityUserResponse",
"FindCounterpartiesResponse",
"FindEntityResponse",
"FindInvoiceResponse",
"FindNotificationResponse",
"FullName",
"IdentifierList",
"IdentifierList_RolesList",
Expand All @@ -235,6 +246,11 @@
"InvoiceStatus",
"Itin",
"MercoaEnvironment",
"NotificationId",
"NotificationPolicyRequest",
"NotificationPolicyResponse",
"NotificationResponse",
"NotificationType",
"OcrResponse",
"OrderDirection",
"OrganizationId",
Expand Down
16 changes: 16 additions & 0 deletions src/mercoa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,18 @@
EntityUserRequest,
EntityUserResponse,
FindCounterpartiesResponse,
FindEntityResponse,
FindNotificationResponse,
IdentifierList,
IdentifierList_RolesList,
IdentifierList_UserList,
IndividualProfileRequest,
IndividualProfileResponse,
NotificationId,
NotificationPolicyRequest,
NotificationPolicyResponse,
NotificationResponse,
NotificationType,
ProfileRequest,
ProfileResponse,
RepresentativeId,
Expand All @@ -77,6 +84,7 @@
CommentRequest,
CommentResponse,
DocumentResponse,
FindInvoiceResponse,
InvoiceApproverResponse,
InvoiceId,
InvoiceLineItemRequest,
Expand Down Expand Up @@ -221,6 +229,9 @@
"EntityUserRequest",
"EntityUserResponse",
"FindCounterpartiesResponse",
"FindEntityResponse",
"FindInvoiceResponse",
"FindNotificationResponse",
"FullName",
"IdentifierList",
"IdentifierList_RolesList",
Expand All @@ -238,6 +249,11 @@
"InvoiceResponse",
"InvoiceStatus",
"Itin",
"NotificationId",
"NotificationPolicyRequest",
"NotificationPolicyResponse",
"NotificationResponse",
"NotificationType",
"OcrResponse",
"OrderDirection",
"OrganizationId",
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/resources/entity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
approval_policy,
counterparty,
invoice,
notification_policy,
payment_method,
representative,
user,
Expand All @@ -17,6 +18,7 @@
"approval_policy",
"counterparty",
"invoice",
"notification_policy",
"payment_method",
"representative",
"user",
Expand Down
113 changes: 99 additions & 14 deletions src/mercoa/resources/entity/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
from ..entity_types.types.entity_response import EntityResponse
from ..entity_types.types.entity_status import EntityStatus
from ..entity_types.types.entity_update_request import EntityUpdateRequest
from ..entity_types.types.find_entity_response import FindEntityResponse
from .resources.approval_policy.client import ApprovalPolicyClient, AsyncApprovalPolicyClient
from .resources.counterparty.client import AsyncCounterpartyClient, CounterpartyClient
from .resources.invoice.client import AsyncInvoiceClient, InvoiceClient
from .resources.notification_policy.client import AsyncNotificationPolicyClient, NotificationPolicyClient
from .resources.payment_method.client import AsyncPaymentMethodClient, PaymentMethodClient
from .resources.representative.client import AsyncRepresentativeClient, RepresentativeClient
from .resources.user.client import AsyncUserClient, UserClient
Expand All @@ -32,12 +34,13 @@ class EntityClient:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str):
self._environment = environment
self._token = token
self.user = UserClient(environment=self._environment, token=self._token)
self.approval_policy = ApprovalPolicyClient(environment=self._environment, token=self._token)
self.counterparty = CounterpartyClient(environment=self._environment, token=self._token)
self.invoice = InvoiceClient(environment=self._environment, token=self._token)
self.notification_policy = NotificationPolicyClient(environment=self._environment, token=self._token)
self.payment_method = PaymentMethodClient(environment=self._environment, token=self._token)
self.representative = RepresentativeClient(environment=self._environment, token=self._token)
self.user = UserClient(environment=self._environment, token=self._token)

def get_all(
self, *, is_payee: typing.Optional[bool] = None, is_payor: typing.Optional[bool] = None
Expand Down Expand Up @@ -67,12 +70,28 @@ def get_all(
raise ApiError(status_code=_response.status_code, body=_response_json)

def find(
self, *, foreign_id: typing.Optional[str] = None, status: typing.Optional[EntityStatus] = None
) -> typing.List[EntityResponse]:
self,
*,
foreign_id: typing.Union[typing.Optional[str], typing.List[str]],
status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]],
is_payee: typing.Optional[bool] = None,
is_payor: typing.Optional[bool] = None,
name: typing.Optional[str] = None,
limit: typing.Optional[int] = None,
starting_after: typing.Optional[EntityId] = None,
) -> FindEntityResponse:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment.value}/", "entity"),
params={"foreignId": foreign_id, "status": status},
params={
"foreignId": foreign_id,
"status": status,
"isPayee": is_payee,
"isPayor": is_payor,
"name": name,
"limit": limit,
"startingAfter": starting_after,
},
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
Expand All @@ -83,7 +102,7 @@ def find(
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[EntityResponse], _response_json) # type: ignore
return pydantic.parse_obj_as(FindEntityResponse, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
Expand Down Expand Up @@ -191,7 +210,7 @@ def delete(self, entity_id: EntityId) -> None:
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def accept_terms_of_service(self, entity_id: EntityId) -> str:
def accept_terms_of_service(self, entity_id: EntityId) -> None:
_response = httpx.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/accept-tos"),
Expand All @@ -200,12 +219,36 @@ def accept_terms_of_service(self, entity_id: EntityId) -> str:
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
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 initiate_kyb(self, entity_id: EntityId) -> None:
_response = httpx.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/request-kyb"),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(str, _response_json) # type: ignore
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
Expand Down Expand Up @@ -317,12 +360,13 @@ class AsyncEntityClient:
def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: str):
self._environment = environment
self._token = token
self.user = AsyncUserClient(environment=self._environment, token=self._token)
self.approval_policy = AsyncApprovalPolicyClient(environment=self._environment, token=self._token)
self.counterparty = AsyncCounterpartyClient(environment=self._environment, token=self._token)
self.invoice = AsyncInvoiceClient(environment=self._environment, token=self._token)
self.notification_policy = AsyncNotificationPolicyClient(environment=self._environment, token=self._token)
self.payment_method = AsyncPaymentMethodClient(environment=self._environment, token=self._token)
self.representative = AsyncRepresentativeClient(environment=self._environment, token=self._token)
self.user = AsyncUserClient(environment=self._environment, token=self._token)

async def get_all(
self, *, is_payee: typing.Optional[bool] = None, is_payor: typing.Optional[bool] = None
Expand Down Expand Up @@ -353,13 +397,29 @@ async def get_all(
raise ApiError(status_code=_response.status_code, body=_response_json)

async def find(
self, *, foreign_id: typing.Optional[str] = None, status: typing.Optional[EntityStatus] = None
) -> typing.List[EntityResponse]:
self,
*,
foreign_id: typing.Union[typing.Optional[str], typing.List[str]],
status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]],
is_payee: typing.Optional[bool] = None,
is_payor: typing.Optional[bool] = None,
name: typing.Optional[str] = None,
limit: typing.Optional[int] = None,
starting_after: typing.Optional[EntityId] = None,
) -> FindEntityResponse:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"GET",
urllib.parse.urljoin(f"{self._environment.value}/", "entity"),
params={"foreignId": foreign_id, "status": status},
params={
"foreignId": foreign_id,
"status": status,
"isPayee": is_payee,
"isPayor": is_payor,
"name": name,
"limit": limit,
"startingAfter": starting_after,
},
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
Expand All @@ -370,7 +430,7 @@ async def find(
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[EntityResponse], _response_json) # type: ignore
return pydantic.parse_obj_as(FindEntityResponse, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
Expand Down Expand Up @@ -482,7 +542,7 @@ async def delete(self, entity_id: EntityId) -> None:
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def accept_terms_of_service(self, entity_id: EntityId) -> str:
async def accept_terms_of_service(self, entity_id: EntityId) -> None:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"POST",
Expand All @@ -492,12 +552,37 @@ async def accept_terms_of_service(self, entity_id: EntityId) -> str:
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
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 initiate_kyb(self, entity_id: EntityId) -> None:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/request-kyb"),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(str, _response_json) # type: ignore
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
Expand Down
3 changes: 2 additions & 1 deletion src/mercoa/resources/entity/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from . import approval_policy, counterparty, invoice, payment_method, representative, user
from . import approval_policy, counterparty, invoice, notification_policy, payment_method, representative, user
from .approval_policy import NumApproverLessThanOneError, NumApproversUserListMismatchError

__all__ = [
Expand All @@ -9,6 +9,7 @@
"approval_policy",
"counterparty",
"invoice",
"notification_policy",
"payment_method",
"representative",
"user",
Expand Down
Loading

0 comments on commit 2c77039

Please sign in to comment.