diff --git a/pyproject.toml b/pyproject.toml index df1d364..f3513a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mercoa" -version = "v0.2.10" +version = "v0.2.11" description = "" readme = "README.md" authors = [] diff --git a/src/mercoa/__init__.py b/src/mercoa/__init__.py index 0891dcf..904abd2 100644 --- a/src/mercoa/__init__.py +++ b/src/mercoa/__init__.py @@ -25,6 +25,7 @@ BankStatus, BankType, BirthDate, + BusinessOnboardingOptions, BusinessProfileRequest, BusinessProfileResponse, BusinessType, @@ -53,7 +54,10 @@ EmailSenderRequest, EmailSenderResponse, EntityAddPayeesRequest, + EntityArchivePayeesRequest, + EntityForeignIdAlreadyExists, EntityId, + EntityOnboardingLinkType, EntityRequest, EntityResponse, EntityStatus, @@ -70,10 +74,12 @@ IdentifierList_RolesList, IdentifierList_UserList, IndividualGovernmentId, + IndividualOnboardingOptions, IndividualProfileRequest, IndividualProfileResponse, InvalidPostalCode, InvalidStateOrProvince, + InvalidTaxId, InvoiceFailureType, InvoiceId, InvoiceLineItemRequest, @@ -96,6 +102,9 @@ NotificationResponse, NotificationType, OcrResponse, + OnboardingOption, + OnboardingOptionsRequest, + OnboardingOptionsResponse, OrderDirection, OrganizationId, OrganizationRequest, @@ -195,6 +204,7 @@ "BankStatus", "BankType", "BirthDate", + "BusinessOnboardingOptions", "BusinessProfileRequest", "BusinessProfileResponse", "BusinessType", @@ -223,7 +233,10 @@ "EmailSenderRequest", "EmailSenderResponse", "EntityAddPayeesRequest", + "EntityArchivePayeesRequest", + "EntityForeignIdAlreadyExists", "EntityId", + "EntityOnboardingLinkType", "EntityRequest", "EntityResponse", "EntityStatus", @@ -240,10 +253,12 @@ "IdentifierList_RolesList", "IdentifierList_UserList", "IndividualGovernmentId", + "IndividualOnboardingOptions", "IndividualProfileRequest", "IndividualProfileResponse", "InvalidPostalCode", "InvalidStateOrProvince", + "InvalidTaxId", "InvoiceFailureType", "InvoiceId", "InvoiceLineItemRequest", @@ -267,6 +282,9 @@ "NotificationResponse", "NotificationType", "OcrResponse", + "OnboardingOption", + "OnboardingOptionsRequest", + "OnboardingOptionsResponse", "OrderDirection", "OrganizationId", "OrganizationRequest", diff --git a/src/mercoa/resources/__init__.py b/src/mercoa/resources/__init__.py index fd41198..03fcef6 100644 --- a/src/mercoa/resources/__init__.py +++ b/src/mercoa/resources/__init__.py @@ -44,7 +44,10 @@ CounterpartyResponse, Ein, EntityAddPayeesRequest, + EntityArchivePayeesRequest, + EntityForeignIdAlreadyExists, EntityId, + EntityOnboardingLinkType, EntityRequest, EntityResponse, EntityStatus, @@ -60,6 +63,7 @@ IdentifierList_UserList, IndividualProfileRequest, IndividualProfileResponse, + InvalidTaxId, NotificationId, NotificationPolicyRequest, NotificationPolicyResponse, @@ -109,6 +113,7 @@ ) from .ocr import OcrResponse from .organization_types import ( + BusinessOnboardingOptions, ColorSchemeRequest, ColorSchemeResponse, EmailLogResponse, @@ -117,12 +122,16 @@ EmailSenderProvider, EmailSenderRequest, EmailSenderResponse, + IndividualOnboardingOptions, InvoiceNotificationConfigurationRequest, InvoiceNotificationConfigurationResponse, NotificationConfigurationRequest, NotificationConfigurationRequest_Invoice, NotificationConfigurationResponse, NotificationConfigurationResponse_Invoice, + OnboardingOption, + OnboardingOptionsRequest, + OnboardingOptionsResponse, OrganizationId, OrganizationRequest, OrganizationResponse, @@ -200,6 +209,7 @@ "BankStatus", "BankType", "BirthDate", + "BusinessOnboardingOptions", "BusinessProfileRequest", "BusinessProfileResponse", "BusinessType", @@ -228,7 +238,10 @@ "EmailSenderRequest", "EmailSenderResponse", "EntityAddPayeesRequest", + "EntityArchivePayeesRequest", + "EntityForeignIdAlreadyExists", "EntityId", + "EntityOnboardingLinkType", "EntityRequest", "EntityResponse", "EntityStatus", @@ -245,10 +258,12 @@ "IdentifierList_RolesList", "IdentifierList_UserList", "IndividualGovernmentId", + "IndividualOnboardingOptions", "IndividualProfileRequest", "IndividualProfileResponse", "InvalidPostalCode", "InvalidStateOrProvince", + "InvalidTaxId", "InvoiceFailureType", "InvoiceId", "InvoiceLineItemRequest", @@ -271,6 +286,9 @@ "NotificationResponse", "NotificationType", "OcrResponse", + "OnboardingOption", + "OnboardingOptionsRequest", + "OnboardingOptionsResponse", "OrderDirection", "OrganizationId", "OrganizationRequest", diff --git a/src/mercoa/resources/bank_lookup/client.py b/src/mercoa/resources/bank_lookup/client.py index 2017864..080475b 100644 --- a/src/mercoa/resources/bank_lookup/client.py +++ b/src/mercoa/resources/bank_lookup/client.py @@ -14,7 +14,8 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from .types.bank_lookup_response import BankLookupResponse @@ -52,6 +53,10 @@ def find(self, *, routing_number: str) -> BankLookupResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -90,4 +95,8 @@ async def find(self, *, routing_number: str) -> BankLookupResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/__init__.py b/src/mercoa/resources/entity/__init__.py index 5be7edc..6641645 100644 --- a/src/mercoa/resources/entity/__init__.py +++ b/src/mercoa/resources/entity/__init__.py @@ -1,6 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .errors import InvalidTaxId from .resources import ( NumApproverLessThanOneError, NumApproversUserListMismatchError, @@ -14,7 +13,6 @@ ) __all__ = [ - "InvalidTaxId", "NumApproverLessThanOneError", "NumApproversUserListMismatchError", "approval_policy", diff --git a/src/mercoa/resources/entity/client.py b/src/mercoa/resources/entity/client.py index a15c5af..ea93bc0 100644 --- a/src/mercoa/resources/entity/client.py +++ b/src/mercoa/resources/entity/client.py @@ -16,15 +16,18 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..entity_types.types.entity_add_payees_request import EntityAddPayeesRequest +from ..entity_types.types.entity_archive_payees_request import EntityArchivePayeesRequest from ..entity_types.types.entity_id import EntityId +from ..entity_types.types.entity_onboarding_link_type import EntityOnboardingLinkType from ..entity_types.types.entity_request import EntityRequest 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 ..entity_types.types.token_generation_options import TokenGenerationOptions -from .errors.invalid_tax_id import InvalidTaxId from .resources.approval_policy.client import ApprovalPolicyClient, AsyncApprovalPolicyClient from .resources.counterparty.client import AsyncCounterpartyClient, CounterpartyClient from .resources.invoice.client import AsyncInvoiceClient, InvoiceClient @@ -77,6 +80,10 @@ def get_all( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def find( @@ -126,6 +133,10 @@ def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, *, request: EntityRequest) -> EntityResponse: @@ -157,6 +168,10 @@ def create(self, *, request: EntityRequest) -> EntityResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> EntityResponse: @@ -187,6 +202,10 @@ def get(self, entity_id: EntityId) -> EntityResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, *, request: EntityUpdateRequest) -> EntityResponse: @@ -218,6 +237,10 @@ def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> Entity raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, entity_id: EntityId) -> None: @@ -248,6 +271,10 @@ def delete(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> None: @@ -278,6 +305,10 @@ def accept_terms_of_service(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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: @@ -308,6 +339,10 @@ def initiate_kyb(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get_raw_token(self, entity_id: EntityId) -> str: @@ -338,6 +373,10 @@ def get_raw_token(self, entity_id: EntityId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get_token(self, entity_id: EntityId, *, request: TokenGenerationOptions) -> str: @@ -369,6 +408,10 @@ def get_token(self, entity_id: EntityId, *, request: TokenGenerationOptions) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def plaid_link_token(self, entity_id: EntityId) -> str: @@ -399,12 +442,93 @@ def plaid_link_token(self, entity_id: EntityId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) - def oatfi_preapproval(self, entity_id: EntityId) -> bool: + def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesRequest) -> None: + _response = httpx.request( + "POST", + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/addPayees"), + json=jsonable_encoder(request), + 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 + 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 + if _response_json["errorName"] == "InvalidPostalCode": + raise InvalidPostalCode(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidStateOrProvince": + raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidTaxId": + raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def archive_payees(self, entity_id: EntityId, *, request: EntityArchivePayeesRequest) -> None: + _response = httpx.request( + "POST", + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/archivePayees"), + json=jsonable_encoder(request), + 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 + 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 + if _response_json["errorName"] == "InvalidPostalCode": + raise InvalidPostalCode(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidStateOrProvince": + raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidTaxId": + raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get_onboarding_link( + self, + entity_id: EntityId, + *, + type: EntityOnboardingLinkType, + connected_entity_id: typing.Optional[EntityId] = None, + ) -> str: _response = httpx.request( "GET", - urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/oatfiPreapproval"), + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/onboarding"), + params={"type": type, "connectedEntityId": connected_entity_id}, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} ), @@ -415,7 +539,7 @@ def oatfi_preapproval(self, entity_id: EntityId) -> bool: except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(bool, _response_json) # type: ignore + return pydantic.parse_obj_as(str, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() @@ -429,13 +553,23 @@ def oatfi_preapproval(self, entity_id: EntityId) -> bool: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) - def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesRequest) -> None: + def send_onboarding_link( + self, + entity_id: EntityId, + *, + type: EntityOnboardingLinkType, + connected_entity_id: typing.Optional[EntityId] = None, + ) -> None: _response = httpx.request( "POST", - urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/addPayees"), - json=jsonable_encoder(request), + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/onboarding"), + params={"type": type, "connectedEntityId": connected_entity_id}, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} ), @@ -460,6 +594,10 @@ def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesRequest) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -507,6 +645,10 @@ async def get_all( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def find( @@ -557,6 +699,10 @@ async def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, *, request: EntityRequest) -> EntityResponse: @@ -589,6 +735,10 @@ async def create(self, *, request: EntityRequest) -> EntityResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> EntityResponse: @@ -620,6 +770,10 @@ async def get(self, entity_id: EntityId) -> EntityResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, *, request: EntityUpdateRequest) -> EntityResponse: @@ -652,6 +806,10 @@ async def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, entity_id: EntityId) -> None: @@ -683,6 +841,10 @@ async def delete(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> None: @@ -714,6 +876,10 @@ async def accept_terms_of_service(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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: @@ -745,6 +911,10 @@ async def initiate_kyb(self, entity_id: EntityId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_raw_token(self, entity_id: EntityId) -> str: @@ -776,6 +946,10 @@ async def get_raw_token(self, entity_id: EntityId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_token(self, entity_id: EntityId, *, request: TokenGenerationOptions) -> str: @@ -808,6 +982,10 @@ async def get_token(self, entity_id: EntityId, *, request: TokenGenerationOption raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def plaid_link_token(self, entity_id: EntityId) -> str: @@ -839,13 +1017,96 @@ async def plaid_link_token(self, entity_id: EntityId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesRequest) -> None: + async with httpx.AsyncClient() as _client: + _response = await _client.request( + "POST", + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/addPayees"), + json=jsonable_encoder(request), + 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 + 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 + if _response_json["errorName"] == "InvalidPostalCode": + raise InvalidPostalCode(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidStateOrProvince": + raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidTaxId": + raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) - async def oatfi_preapproval(self, entity_id: EntityId) -> bool: + async def archive_payees(self, entity_id: EntityId, *, request: EntityArchivePayeesRequest) -> None: + async with httpx.AsyncClient() as _client: + _response = await _client.request( + "POST", + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/archivePayees"), + json=jsonable_encoder(request), + 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 + 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 + if _response_json["errorName"] == "InvalidPostalCode": + raise InvalidPostalCode(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidStateOrProvince": + raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "InvalidTaxId": + raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get_onboarding_link( + self, + entity_id: EntityId, + *, + type: EntityOnboardingLinkType, + connected_entity_id: typing.Optional[EntityId] = None, + ) -> str: async with httpx.AsyncClient() as _client: _response = await _client.request( "GET", - urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/oatfiPreapproval"), + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/onboarding"), + params={"type": type, "connectedEntityId": connected_entity_id}, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} ), @@ -856,7 +1117,7 @@ async def oatfi_preapproval(self, entity_id: EntityId) -> bool: except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(bool, _response_json) # type: ignore + return pydantic.parse_obj_as(str, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() @@ -870,14 +1131,24 @@ async def oatfi_preapproval(self, entity_id: EntityId) -> bool: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) - async def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesRequest) -> None: + async def send_onboarding_link( + self, + entity_id: EntityId, + *, + type: EntityOnboardingLinkType, + connected_entity_id: typing.Optional[EntityId] = None, + ) -> None: async with httpx.AsyncClient() as _client: _response = await _client.request( "POST", - urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/addPayees"), - json=jsonable_encoder(request), + urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/onboarding"), + params={"type": type, "connectedEntityId": connected_entity_id}, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} ), @@ -902,4 +1173,8 @@ async def add_payees(self, entity_id: EntityId, *, request: EntityAddPayeesReque raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/errors/__init__.py b/src/mercoa/resources/entity/errors/__init__.py deleted file mode 100644 index 1aab154..0000000 --- a/src/mercoa/resources/entity/errors/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .invalid_tax_id import InvalidTaxId - -__all__ = ["InvalidTaxId"] diff --git a/src/mercoa/resources/entity/resources/approval_policy/client.py b/src/mercoa/resources/entity/resources/approval_policy/client.py index 9b9ff23..7f195fc 100644 --- a/src/mercoa/resources/entity/resources/approval_policy/client.py +++ b/src/mercoa/resources/entity/resources/approval_policy/client.py @@ -16,12 +16,13 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.approval_policy_id import ApprovalPolicyId from ....entity_types.types.approval_policy_request import ApprovalPolicyRequest from ....entity_types.types.approval_policy_response import ApprovalPolicyResponse from ....entity_types.types.approval_policy_update_request import ApprovalPolicyUpdateRequest from ....entity_types.types.entity_id import EntityId -from ...errors.invalid_tax_id import InvalidTaxId from .errors.num_approver_less_than_one_error import NumApproverLessThanOneError from .errors.num_approvers_user_list_mismatch_error import NumApproversUserListMismatchError @@ -59,6 +60,10 @@ def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> ApprovalPolicyResponse: @@ -96,6 +101,10 @@ def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> Appr raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, policy_id: ApprovalPolicyId) -> ApprovalPolicyResponse: @@ -126,6 +135,10 @@ def get(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> ApprovalPolic raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -165,6 +178,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> None: @@ -195,6 +212,10 @@ def delete(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -232,6 +253,10 @@ async def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyRespon raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> ApprovalPolicyResponse: @@ -270,6 +295,10 @@ async def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) - raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, policy_id: ApprovalPolicyId) -> ApprovalPolicyResponse: @@ -301,6 +330,10 @@ async def get(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> Approva raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -341,6 +374,10 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> None: @@ -372,4 +409,8 @@ async def delete(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> None raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/counterparty/client.py b/src/mercoa/resources/entity/resources/counterparty/client.py index 5e9b200..7c06ace 100644 --- a/src/mercoa/resources/entity/resources/counterparty/client.py +++ b/src/mercoa/resources/entity/resources/counterparty/client.py @@ -15,9 +15,10 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId from ....entity_types.types.find_counterparties_response import FindCounterpartiesResponse -from ...errors.invalid_tax_id import InvalidTaxId class CounterpartyClient: @@ -54,6 +55,10 @@ def find(self, entity_id: EntityId, *, payment_methods: typing.Optional[bool] = raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -94,4 +99,8 @@ async def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/invoice/client.py b/src/mercoa/resources/entity/resources/invoice/client.py index 866e402..511ba79 100644 --- a/src/mercoa/resources/entity/resources/invoice/client.py +++ b/src/mercoa/resources/entity/resources/invoice/client.py @@ -18,6 +18,8 @@ from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized from ....commons.types.order_direction import OrderDirection +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId from ....entity_types.types.entity_user_id import EntityUserId from ....invoice_types.types.find_invoice_response import FindInvoiceResponse @@ -26,7 +28,6 @@ from ....invoice_types.types.invoice_order_by_field import InvoiceOrderByField from ....invoice_types.types.invoice_status import InvoiceStatus from ....payment_method_types.types.currency_code import CurrencyCode -from ...errors.invalid_tax_id import InvalidTaxId class InvoiceClient: @@ -47,6 +48,7 @@ def find( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], ) -> FindInvoiceResponse: _response = httpx.request( @@ -62,6 +64,7 @@ def find( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, }, headers=remove_none_from_headers( @@ -88,6 +91,10 @@ def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def metrics( @@ -97,6 +104,7 @@ def metrics( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], due_date_start: typing.Optional[dt.datetime] = None, due_date_end: typing.Optional[dt.datetime] = None, @@ -111,6 +119,7 @@ def metrics( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, @@ -142,6 +151,10 @@ def metrics( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -163,6 +176,7 @@ async def find( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], ) -> FindInvoiceResponse: async with httpx.AsyncClient() as _client: @@ -179,6 +193,7 @@ async def find( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, }, headers=remove_none_from_headers( @@ -205,6 +220,10 @@ async def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def metrics( @@ -214,6 +233,7 @@ async def metrics( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], due_date_start: typing.Optional[dt.datetime] = None, due_date_end: typing.Optional[dt.datetime] = None, @@ -229,6 +249,7 @@ async def metrics( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, "dueDateStart": serialize_datetime(due_date_start) if due_date_start is not None else None, "dueDateEnd": serialize_datetime(due_date_end) if due_date_end is not None else None, @@ -262,4 +283,8 @@ async def metrics( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/notification_policy/client.py b/src/mercoa/resources/entity/resources/notification_policy/client.py index eb01382..a8e7124 100644 --- a/src/mercoa/resources/entity/resources/notification_policy/client.py +++ b/src/mercoa/resources/entity/resources/notification_policy/client.py @@ -16,11 +16,12 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId from ....entity_types.types.notification_policy_request import NotificationPolicyRequest from ....entity_types.types.notification_policy_response import NotificationPolicyResponse from ....entity_types.types.notification_type import NotificationType -from ...errors.invalid_tax_id import InvalidTaxId class NotificationPolicyClient: @@ -56,6 +57,10 @@ def get_all(self, entity_id: EntityId) -> typing.List[NotificationPolicyResponse raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, notification_type: NotificationType) -> NotificationPolicyResponse: @@ -88,6 +93,10 @@ def get(self, entity_id: EntityId, notification_type: NotificationType) -> Notif raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -123,6 +132,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -160,6 +173,10 @@ async def get_all(self, entity_id: EntityId) -> typing.List[NotificationPolicyRe raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, notification_type: NotificationType) -> NotificationPolicyResponse: @@ -193,6 +210,10 @@ async def get(self, entity_id: EntityId, notification_type: NotificationType) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -229,4 +250,8 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/payment_method/client.py b/src/mercoa/resources/entity/resources/payment_method/client.py index d518f58..38b2662 100644 --- a/src/mercoa/resources/entity/resources/payment_method/client.py +++ b/src/mercoa/resources/entity/resources/payment_method/client.py @@ -16,13 +16,14 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId from ....payment_method_types.types.payment_method_id import PaymentMethodId from ....payment_method_types.types.payment_method_request import PaymentMethodRequest from ....payment_method_types.types.payment_method_response import PaymentMethodResponse from ....payment_method_types.types.payment_method_type import PaymentMethodType from ....payment_method_types.types.payment_method_update_request import PaymentMethodUpdateRequest -from ...errors.invalid_tax_id import InvalidTaxId class PaymentMethodClient: @@ -64,6 +65,10 @@ def get_all( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> PaymentMethodResponse: @@ -95,6 +100,10 @@ def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> Payme raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, payment_method_id: PaymentMethodId) -> PaymentMethodResponse: @@ -127,6 +136,10 @@ def get(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> Paymen raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -162,6 +175,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: @@ -194,6 +211,10 @@ def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> Non raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: @@ -226,6 +247,10 @@ def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: Paymen raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def complete_micro_deposits( @@ -261,6 +286,10 @@ def complete_micro_deposits( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -304,6 +333,10 @@ async def get_all( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> PaymentMethodResponse: @@ -336,6 +369,10 @@ async def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, payment_method_id: PaymentMethodId) -> PaymentMethodResponse: @@ -369,6 +406,10 @@ async def get(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -405,6 +446,10 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: @@ -438,6 +483,10 @@ async def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: @@ -472,6 +521,10 @@ async def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def complete_micro_deposits( @@ -509,4 +562,8 @@ async def complete_micro_deposits( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/representative/client.py b/src/mercoa/resources/entity/resources/representative/client.py index 0375346..7eddeaf 100644 --- a/src/mercoa/resources/entity/resources/representative/client.py +++ b/src/mercoa/resources/entity/resources/representative/client.py @@ -16,11 +16,12 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId from ....entity_types.types.representative_id import RepresentativeId from ....entity_types.types.representative_request import RepresentativeRequest from ....entity_types.types.representative_response import RepresentativeResponse -from ...errors.invalid_tax_id import InvalidTaxId class RepresentativeClient: @@ -56,6 +57,10 @@ def get_all(self, entity_id: EntityId) -> typing.List[RepresentativeResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> RepresentativeResponse: @@ -87,6 +92,10 @@ def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> Repr raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, representative_id: RepresentativeId) -> RepresentativeResponse: @@ -119,6 +128,10 @@ def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> Repre raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, entity_id: EntityId, representative_id: RepresentativeId) -> None: @@ -151,6 +164,10 @@ def delete(self, entity_id: EntityId, representative_id: RepresentativeId) -> No raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -188,6 +205,10 @@ async def get_all(self, entity_id: EntityId) -> typing.List[RepresentativeRespon raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> RepresentativeResponse: @@ -220,6 +241,10 @@ async def create(self, entity_id: EntityId, *, request: RepresentativeRequest) - raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, representative_id: RepresentativeId) -> RepresentativeResponse: @@ -253,6 +278,10 @@ async def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, entity_id: EntityId, representative_id: RepresentativeId) -> None: @@ -286,4 +315,8 @@ async def delete(self, entity_id: EntityId, representative_id: RepresentativeId) raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/user/client.py b/src/mercoa/resources/entity/resources/user/client.py index 0bd7c30..a662e13 100644 --- a/src/mercoa/resources/entity/resources/user/client.py +++ b/src/mercoa/resources/entity/resources/user/client.py @@ -16,12 +16,13 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.entity_id import EntityId 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 ....entity_types.types.token_generation_options import TokenGenerationOptions -from ...errors.invalid_tax_id import InvalidTaxId from .resources.notification_policy.client import AsyncNotificationPolicyClient, NotificationPolicyClient from .resources.notifications.client import AsyncNotificationsClient, NotificationsClient @@ -61,6 +62,10 @@ def get_all(self, entity_id: EntityId) -> typing.List[EntityUserResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, entity_id: EntityId, *, request: EntityUserRequest) -> EntityUserResponse: @@ -92,6 +97,10 @@ def create(self, entity_id: EntityId, *, request: EntityUserRequest) -> EntityUs raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> EntityUserResponse: @@ -122,6 +131,10 @@ def get(self, entity_id: EntityId, user_id: EntityUserId) -> EntityUserResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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, *, request: EntityUserRequest) -> EntityUserResponse: @@ -153,6 +166,10 @@ def update(self, entity_id: EntityId, user_id: EntityUserId, *, request: EntityU raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: @@ -183,6 +200,10 @@ def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get_raw_token(self, entity_id: EntityId, user_id: EntityUserId) -> str: @@ -213,6 +234,10 @@ def get_raw_token(self, entity_id: EntityId, user_id: EntityUserId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get_token(self, entity_id: EntityId, user_id: EntityUserId, *, request: TokenGenerationOptions) -> str: @@ -244,6 +269,10 @@ def get_token(self, entity_id: EntityId, user_id: EntityUserId, *, request: Toke raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -283,6 +312,10 @@ async def get_all(self, entity_id: EntityId) -> typing.List[EntityUserResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, entity_id: EntityId, *, request: EntityUserRequest) -> EntityUserResponse: @@ -315,6 +348,10 @@ async def create(self, entity_id: EntityId, *, request: EntityUserRequest) -> En raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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) -> EntityUserResponse: @@ -346,6 +383,10 @@ async def get(self, entity_id: EntityId, user_id: EntityUserId) -> EntityUserRes raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -380,6 +421,10 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: @@ -411,6 +456,10 @@ async def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_raw_token(self, entity_id: EntityId, user_id: EntityUserId) -> str: @@ -442,6 +491,10 @@ async def get_raw_token(self, entity_id: EntityId, user_id: EntityUserId) -> str raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_token(self, entity_id: EntityId, user_id: EntityUserId, *, request: TokenGenerationOptions) -> str: @@ -474,4 +527,8 @@ async def get_token(self, entity_id: EntityId, user_id: EntityUserId, *, request raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/user/resources/notification_policy/client.py b/src/mercoa/resources/entity/resources/user/resources/notification_policy/client.py index 2a7c17e..e30d931 100644 --- a/src/mercoa/resources/entity/resources/user/resources/notification_policy/client.py +++ b/src/mercoa/resources/entity/resources/user/resources/notification_policy/client.py @@ -16,11 +16,12 @@ from ......commons.errors.invalid_postal_code import InvalidPostalCode from ......commons.errors.invalid_state_or_province import InvalidStateOrProvince from ......commons.errors.unauthorized import Unauthorized +from ......entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ......entity_types.errors.invalid_tax_id import InvalidTaxId 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 -from .....errors.invalid_tax_id import InvalidTaxId class NotificationPolicyClient: @@ -58,6 +59,10 @@ def get_all(self, entity_id: EntityId, user_id: EntityUserId) -> typing.List[Use raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get( @@ -93,6 +98,10 @@ def get( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -129,6 +138,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -168,6 +181,10 @@ async def get_all(self, entity_id: EntityId, user_id: EntityUserId) -> typing.Li raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get( @@ -204,6 +221,10 @@ async def get( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -241,4 +262,8 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity/resources/user/resources/notifications/client.py b/src/mercoa/resources/entity/resources/user/resources/notifications/client.py index b588672..6718363 100644 --- a/src/mercoa/resources/entity/resources/user/resources/notifications/client.py +++ b/src/mercoa/resources/entity/resources/user/resources/notifications/client.py @@ -18,12 +18,14 @@ from ......commons.errors.invalid_state_or_province import InvalidStateOrProvince from ......commons.errors.unauthorized import Unauthorized from ......commons.types.order_direction import OrderDirection +from ......entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ......entity_types.errors.invalid_tax_id import InvalidTaxId from ......entity_types.types.entity_id import EntityId from ......entity_types.types.entity_user_id import EntityUserId from ......entity_types.types.find_notification_response import FindNotificationResponse from ......entity_types.types.notification_id import NotificationId from ......entity_types.types.notification_response import NotificationResponse -from .....errors.invalid_tax_id import InvalidTaxId +from ......entity_types.types.notification_type import NotificationType class NotificationsClient: @@ -41,6 +43,7 @@ def find( order_direction: typing.Optional[OrderDirection] = None, limit: typing.Optional[int] = None, starting_after: typing.Optional[NotificationId] = None, + notification_type: typing.Union[typing.Optional[NotificationType], typing.List[NotificationType]], ) -> FindNotificationResponse: _response = httpx.request( "GET", @@ -51,6 +54,7 @@ def find( "orderDirection": order_direction, "limit": limit, "startingAfter": starting_after, + "notificationType": notification_type, }, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} @@ -76,6 +80,10 @@ def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + 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_id: NotificationId) -> NotificationResponse: @@ -108,6 +116,10 @@ def get(self, entity_id: EntityId, user_id: EntityUserId, notification_id: Notif raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -126,6 +138,7 @@ async def find( order_direction: typing.Optional[OrderDirection] = None, limit: typing.Optional[int] = None, starting_after: typing.Optional[NotificationId] = None, + notification_type: typing.Union[typing.Optional[NotificationType], typing.List[NotificationType]], ) -> FindNotificationResponse: async with httpx.AsyncClient() as _client: _response = await _client.request( @@ -137,6 +150,7 @@ async def find( "orderDirection": order_direction, "limit": limit, "startingAfter": starting_after, + "notificationType": notification_type, }, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} @@ -162,6 +176,10 @@ async def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get( @@ -197,4 +215,8 @@ async def get( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/entity_types/__init__.py b/src/mercoa/resources/entity_types/__init__.py index b537e39..74cacd4 100644 --- a/src/mercoa/resources/entity_types/__init__.py +++ b/src/mercoa/resources/entity_types/__init__.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +from .errors import EntityForeignIdAlreadyExists, InvalidTaxId from .types import ( AccountType, AmountTrigger, @@ -14,7 +15,9 @@ CounterpartyResponse, Ein, EntityAddPayeesRequest, + EntityArchivePayeesRequest, EntityId, + EntityOnboardingLinkType, EntityRequest, EntityResponse, EntityStatus, @@ -70,7 +73,10 @@ "CounterpartyResponse", "Ein", "EntityAddPayeesRequest", + "EntityArchivePayeesRequest", + "EntityForeignIdAlreadyExists", "EntityId", + "EntityOnboardingLinkType", "EntityRequest", "EntityResponse", "EntityStatus", @@ -86,6 +92,7 @@ "IdentifierList_UserList", "IndividualProfileRequest", "IndividualProfileResponse", + "InvalidTaxId", "NotificationId", "NotificationPolicyRequest", "NotificationPolicyResponse", diff --git a/src/mercoa/resources/entity_types/errors/__init__.py b/src/mercoa/resources/entity_types/errors/__init__.py new file mode 100644 index 0000000..79c9dcd --- /dev/null +++ b/src/mercoa/resources/entity_types/errors/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from .invalid_tax_id import InvalidTaxId + +__all__ = ["EntityForeignIdAlreadyExists", "InvalidTaxId"] diff --git a/src/mercoa/resources/entity_types/errors/entity_foreign_id_already_exists.py b/src/mercoa/resources/entity_types/errors/entity_foreign_id_already_exists.py new file mode 100644 index 0000000..2b4bbfe --- /dev/null +++ b/src/mercoa/resources/entity_types/errors/entity_foreign_id_already_exists.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError + + +class EntityForeignIdAlreadyExists(ApiError): + def __init__(self, body: str): + super().__init__(status_code=400, body=body) diff --git a/src/mercoa/resources/entity/errors/invalid_tax_id.py b/src/mercoa/resources/entity_types/errors/invalid_tax_id.py similarity index 100% rename from src/mercoa/resources/entity/errors/invalid_tax_id.py rename to src/mercoa/resources/entity_types/errors/invalid_tax_id.py diff --git a/src/mercoa/resources/entity_types/types/__init__.py b/src/mercoa/resources/entity_types/types/__init__.py index 707ede3..d9b094b 100644 --- a/src/mercoa/resources/entity_types/types/__init__.py +++ b/src/mercoa/resources/entity_types/types/__init__.py @@ -13,7 +13,9 @@ from .counterparty_response import CounterpartyResponse from .ein import Ein from .entity_add_payees_request import EntityAddPayeesRequest +from .entity_archive_payees_request import EntityArchivePayeesRequest from .entity_id import EntityId +from .entity_onboarding_link_type import EntityOnboardingLinkType from .entity_request import EntityRequest from .entity_response import EntityResponse from .entity_status import EntityStatus @@ -63,7 +65,9 @@ "CounterpartyResponse", "Ein", "EntityAddPayeesRequest", + "EntityArchivePayeesRequest", "EntityId", + "EntityOnboardingLinkType", "EntityRequest", "EntityResponse", "EntityStatus", diff --git a/src/mercoa/resources/entity_types/types/entity_archive_payees_request.py b/src/mercoa/resources/entity_types/types/entity_archive_payees_request.py new file mode 100644 index 0000000..e90c5a7 --- /dev/null +++ b/src/mercoa/resources/entity_types/types/entity_archive_payees_request.py @@ -0,0 +1,25 @@ +# 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 .entity_id import EntityId + + +class EntityArchivePayeesRequest(pydantic.BaseModel): + payees: typing.List[EntityId] = pydantic.Field(description=("List of payee entity IDs to archive\n")) + + 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} diff --git a/src/mercoa/resources/entity_types/types/entity_onboarding_link_type.py b/src/mercoa/resources/entity_types/types/entity_onboarding_link_type.py new file mode 100644 index 0000000..fdf6a9f --- /dev/null +++ b/src/mercoa/resources/entity_types/types/entity_onboarding_link_type.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class EntityOnboardingLinkType(str, enum.Enum): + PAYEE = "PAYEE" + PAYOR = "PAYOR" + + def visit(self, payee: typing.Callable[[], T_Result], payor: typing.Callable[[], T_Result]) -> T_Result: + if self is EntityOnboardingLinkType.PAYEE: + return payee() + if self is EntityOnboardingLinkType.PAYOR: + return payor() diff --git a/src/mercoa/resources/entity_types/types/notification_response.py b/src/mercoa/resources/entity_types/types/notification_response.py index 1268b96..8186654 100644 --- a/src/mercoa/resources/entity_types/types/notification_response.py +++ b/src/mercoa/resources/entity_types/types/notification_response.py @@ -13,7 +13,12 @@ class NotificationResponse(pydantic.BaseModel): id: NotificationId - invoice_id: typing.Optional[InvoiceId] = pydantic.Field(alias="invoiceId") + invoice_id: typing.Optional[InvoiceId] = pydantic.Field( + alias="invoiceId", + description=( + "The invoice ID that this notification is related to. This field is only present for notifications related to invoices.\n" + ), + ) type: NotificationType created_at: dt.datetime = pydantic.Field(alias="createdAt") diff --git a/src/mercoa/resources/invoice/client.py b/src/mercoa/resources/invoice/client.py index 3ded6b7..b3cae15 100644 --- a/src/mercoa/resources/invoice/client.py +++ b/src/mercoa/resources/invoice/client.py @@ -19,7 +19,8 @@ from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized from ..commons.types.order_direction import OrderDirection -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..entity_types.types.entity_id import EntityId from ..entity_types.types.entity_user_id import EntityUserId from ..invoice_types.types.find_invoice_response import FindInvoiceResponse @@ -54,6 +55,7 @@ def find( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], ) -> FindInvoiceResponse: _response = httpx.request( @@ -70,6 +72,7 @@ def find( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, }, headers=remove_none_from_headers( @@ -96,6 +99,10 @@ def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, *, request: InvoiceRequest) -> InvoiceResponse: @@ -127,6 +134,10 @@ def create(self, *, request: InvoiceRequest) -> InvoiceResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get(self, invoice_id: InvoiceId) -> InvoiceResponse: @@ -157,6 +168,10 @@ def get(self, invoice_id: InvoiceId) -> InvoiceResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceResponse: @@ -188,6 +203,10 @@ def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceRe raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, invoice_id: InvoiceId) -> None: @@ -218,6 +237,10 @@ def delete(self, invoice_id: InvoiceId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get_vendor_link(self, invoice_id: InvoiceId) -> str: @@ -248,6 +271,10 @@ def get_vendor_link(self, invoice_id: InvoiceId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -272,6 +299,7 @@ async def find( search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]], + invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]], status: typing.Union[typing.Optional[InvoiceStatus], typing.List[InvoiceStatus]], ) -> FindInvoiceResponse: async with httpx.AsyncClient() as _client: @@ -289,6 +317,7 @@ async def find( "search": search, "vendorId": vendor_id, "approverId": approver_id, + "invoiceId": invoice_id, "status": status, }, headers=remove_none_from_headers( @@ -315,6 +344,10 @@ async def find( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, *, request: InvoiceRequest) -> InvoiceResponse: @@ -347,6 +380,10 @@ async def create(self, *, request: InvoiceRequest) -> InvoiceResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get(self, invoice_id: InvoiceId) -> InvoiceResponse: @@ -378,6 +415,10 @@ async def get(self, invoice_id: InvoiceId) -> InvoiceResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceResponse: @@ -410,6 +451,10 @@ async def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> Inv raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, invoice_id: InvoiceId) -> None: @@ -441,6 +486,10 @@ async def delete(self, invoice_id: InvoiceId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get_vendor_link(self, invoice_id: InvoiceId) -> str: @@ -472,4 +521,8 @@ async def get_vendor_link(self, invoice_id: InvoiceId) -> str: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/invoice/resources/approval/client.py b/src/mercoa/resources/invoice/resources/approval/client.py index 3d0adc6..1d84b7e 100644 --- a/src/mercoa/resources/invoice/resources/approval/client.py +++ b/src/mercoa/resources/invoice/resources/approval/client.py @@ -15,7 +15,8 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized -from ....entity.errors.invalid_tax_id import InvalidTaxId +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....invoice_types.types.approval_request import ApprovalRequest from ....invoice_types.types.invoice_id import InvoiceId @@ -54,6 +55,10 @@ def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: @@ -85,6 +90,10 @@ def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -123,6 +132,10 @@ async def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> N raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: @@ -155,4 +168,8 @@ async def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> No raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/invoice/resources/comment/client.py b/src/mercoa/resources/invoice/resources/comment/client.py index e115a3a..fa834cd 100644 --- a/src/mercoa/resources/invoice/resources/comment/client.py +++ b/src/mercoa/resources/invoice/resources/comment/client.py @@ -16,7 +16,8 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized -from ....entity.errors.invalid_tax_id import InvalidTaxId +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....invoice_types.types.comment_id import CommentId from ....invoice_types.types.comment_request import CommentRequest from ....invoice_types.types.comment_response import CommentResponse @@ -56,6 +57,10 @@ def get_all(self, invoice_id: InvoiceId) -> typing.List[CommentResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> CommentResponse: @@ -87,6 +92,10 @@ def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> CommentRe raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResponse: @@ -117,6 +126,10 @@ def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update(self, invoice_id: InvoiceId, comment_id: CommentId, *, request: CommentRequest) -> CommentResponse: @@ -148,6 +161,10 @@ def update(self, invoice_id: InvoiceId, comment_id: CommentId, *, request: Comme raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, invoice_id: InvoiceId, comment_id: CommentId) -> None: @@ -178,6 +195,10 @@ def delete(self, invoice_id: InvoiceId, comment_id: CommentId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -215,6 +236,10 @@ async def get_all(self, invoice_id: InvoiceId) -> typing.List[CommentResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> CommentResponse: @@ -247,6 +272,10 @@ async def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> Com raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResponse: @@ -278,6 +307,10 @@ async def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResp raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update(self, invoice_id: InvoiceId, comment_id: CommentId, *, request: CommentRequest) -> CommentResponse: @@ -310,6 +343,10 @@ async def update(self, invoice_id: InvoiceId, comment_id: CommentId, *, request: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, invoice_id: InvoiceId, comment_id: CommentId) -> None: @@ -341,4 +378,8 @@ async def delete(self, invoice_id: InvoiceId, comment_id: CommentId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/invoice/resources/document/client.py b/src/mercoa/resources/invoice/resources/document/client.py index b864db1..b4c1956 100644 --- a/src/mercoa/resources/invoice/resources/document/client.py +++ b/src/mercoa/resources/invoice/resources/document/client.py @@ -15,7 +15,8 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized -from ....entity.errors.invalid_tax_id import InvalidTaxId +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....invoice_types.types.document_response import DocumentResponse from ....invoice_types.types.invoice_id import InvoiceId @@ -53,6 +54,10 @@ def get_all(self, invoice_id: InvoiceId) -> typing.List[DocumentResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -90,4 +95,8 @@ async def get_all(self, invoice_id: InvoiceId) -> typing.List[DocumentResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/invoice_types/types/invoice_line_item_request.py b/src/mercoa/resources/invoice_types/types/invoice_line_item_request.py index 3826f5c..625a1fe 100644 --- a/src/mercoa/resources/invoice_types/types/invoice_line_item_request.py +++ b/src/mercoa/resources/invoice_types/types/invoice_line_item_request.py @@ -15,12 +15,21 @@ class InvoiceLineItemRequest(pydantic.BaseModel): "If provided, will overwrite line item on the invoice with this ID. If not provided, will create a new line item.\n" ) ) - amount: typing.Optional[float] + amount: typing.Optional[float] = pydantic.Field( + description=( + "Total amount of line item in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated.\n" + ) + ) currency: typing.Optional[CurrencyCode] description: typing.Optional[str] name: typing.Optional[str] quantity: typing.Optional[int] - unit_price: typing.Optional[float] = pydantic.Field(alias="unitPrice") + unit_price: typing.Optional[float] = pydantic.Field( + alias="unitPrice", + description=( + "Unit price of the line item in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated.\n" + ), + ) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/resources/invoice_types/types/invoice_line_item_response.py b/src/mercoa/resources/invoice_types/types/invoice_line_item_response.py index 7e14801..027ee17 100644 --- a/src/mercoa/resources/invoice_types/types/invoice_line_item_response.py +++ b/src/mercoa/resources/invoice_types/types/invoice_line_item_response.py @@ -11,12 +11,14 @@ class InvoiceLineItemResponse(pydantic.BaseModel): id: str - amount: typing.Optional[float] + amount: typing.Optional[float] = pydantic.Field(description=("Total amount of line item in major units.\n")) currency: typing.Optional[CurrencyCode] description: typing.Optional[str] name: typing.Optional[str] quantity: typing.Optional[int] - unit_price: typing.Optional[float] = pydantic.Field(alias="unitPrice") + unit_price: typing.Optional[float] = pydantic.Field( + alias="unitPrice", description=("Unit price of line item in major units.\n") + ) created_at: dt.datetime = pydantic.Field(alias="createdAt") updated_at: dt.datetime = pydantic.Field(alias="updatedAt") diff --git a/src/mercoa/resources/invoice_types/types/invoice_request.py b/src/mercoa/resources/invoice_types/types/invoice_request.py index 8772afe..c7b21dd 100644 --- a/src/mercoa/resources/invoice_types/types/invoice_request.py +++ b/src/mercoa/resources/invoice_types/types/invoice_request.py @@ -17,7 +17,11 @@ class InvoiceRequest(pydantic.BaseModel): status: typing.Optional[InvoiceStatus] - amount: typing.Optional[float] + amount: typing.Optional[float] = pydantic.Field( + description=( + "Total amount of invoice in major units. If the entered amount has more decimal places than the currency supports, trailing decimals will be truncated.\n" + ) + ) currency: typing.Optional[CurrencyCode] invoice_date: typing.Optional[dt.datetime] = pydantic.Field( alias="invoiceDate", description=("Date the invoice was created.\n") diff --git a/src/mercoa/resources/invoice_types/types/invoice_response.py b/src/mercoa/resources/invoice_types/types/invoice_response.py index 0488452..6ca003e 100644 --- a/src/mercoa/resources/invoice_types/types/invoice_response.py +++ b/src/mercoa/resources/invoice_types/types/invoice_response.py @@ -25,7 +25,7 @@ class InvoiceResponse(pydantic.BaseModel): id: InvoiceId status: InvoiceStatus - amount: typing.Optional[float] + amount: typing.Optional[float] = pydantic.Field(description=("Total amount of invoice in major units\n")) currency: typing.Optional[CurrencyCode] invoice_date: typing.Optional[dt.datetime] = pydantic.Field( alias="invoiceDate", description=("Date the invoice was created.\n") diff --git a/src/mercoa/resources/ocr/client.py b/src/mercoa/resources/ocr/client.py index eb27f16..8878004 100644 --- a/src/mercoa/resources/ocr/client.py +++ b/src/mercoa/resources/ocr/client.py @@ -16,7 +16,8 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..entity_types.types.entity_id import EntityId from ..entity_types.types.vendor_network import VendorNetwork from .types.ocr_response import OcrResponse @@ -64,6 +65,10 @@ def ocr( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -110,4 +115,8 @@ async def ocr( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/organization/client.py b/src/mercoa/resources/organization/client.py index 135d5ef..1275f5f 100644 --- a/src/mercoa/resources/organization/client.py +++ b/src/mercoa/resources/organization/client.py @@ -18,7 +18,8 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..organization_types.types.email_log_response import EmailLogResponse from ..organization_types.types.organization_request import OrganizationRequest from ..organization_types.types.organization_response import OrganizationResponse @@ -42,11 +43,19 @@ def get( payment_methods: typing.Optional[bool] = None, email_provider: typing.Optional[bool] = None, color_scheme: typing.Optional[bool] = None, + payee_onboarding_options: typing.Optional[bool] = None, + payor_onboarding_options: typing.Optional[bool] = None, ) -> OrganizationResponse: _response = httpx.request( "GET", urllib.parse.urljoin(f"{self._environment.value}/", "organization"), - params={"paymentMethods": payment_methods, "emailProvider": email_provider, "colorScheme": color_scheme}, + params={ + "paymentMethods": payment_methods, + "emailProvider": email_provider, + "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, + }, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} ), @@ -71,6 +80,10 @@ def get( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update(self, *, request: OrganizationRequest) -> OrganizationResponse: @@ -102,6 +115,10 @@ def update(self, *, request: OrganizationRequest) -> OrganizationResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def email_log( @@ -138,6 +155,10 @@ def email_log( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -155,6 +176,8 @@ async def get( payment_methods: typing.Optional[bool] = None, email_provider: typing.Optional[bool] = None, color_scheme: typing.Optional[bool] = None, + payee_onboarding_options: typing.Optional[bool] = None, + payor_onboarding_options: typing.Optional[bool] = None, ) -> OrganizationResponse: async with httpx.AsyncClient() as _client: _response = await _client.request( @@ -164,6 +187,8 @@ async def get( "paymentMethods": payment_methods, "emailProvider": email_provider, "colorScheme": color_scheme, + "payeeOnboardingOptions": payee_onboarding_options, + "payorOnboardingOptions": payor_onboarding_options, }, headers=remove_none_from_headers( {"Authorization": f"Bearer {self._token}" if self._token is not None else None} @@ -189,6 +214,10 @@ async def get( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update(self, *, request: OrganizationRequest) -> OrganizationResponse: @@ -221,6 +250,10 @@ async def update(self, *, request: OrganizationRequest) -> OrganizationResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def email_log( @@ -258,4 +291,8 @@ async def email_log( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/organization/resources/notification_configuration/client.py b/src/mercoa/resources/organization/resources/notification_configuration/client.py index 89c4ebc..bc01e60 100644 --- a/src/mercoa/resources/organization/resources/notification_configuration/client.py +++ b/src/mercoa/resources/organization/resources/notification_configuration/client.py @@ -16,7 +16,8 @@ from ....commons.errors.invalid_postal_code import InvalidPostalCode from ....commons.errors.invalid_state_or_province import InvalidStateOrProvince from ....commons.errors.unauthorized import Unauthorized -from ....entity.errors.invalid_tax_id import InvalidTaxId +from ....entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ....entity_types.errors.invalid_tax_id import InvalidTaxId from ....entity_types.types.notification_type import NotificationType from ....organization_types.types.notification_configuration_request import NotificationConfigurationRequest from ....organization_types.types.notification_configuration_response import NotificationConfigurationResponse @@ -55,6 +56,10 @@ def get_all(self) -> typing.List[NotificationConfigurationResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get(self, notification_type: NotificationType) -> NotificationConfigurationResponse: @@ -87,6 +92,10 @@ def get(self, notification_type: NotificationType) -> NotificationConfigurationR raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -122,6 +131,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def reset(self, notification_type: NotificationType) -> None: @@ -154,6 +167,10 @@ def reset(self, notification_type: NotificationType) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -191,6 +208,10 @@ async def get_all(self) -> typing.List[NotificationConfigurationResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get(self, notification_type: NotificationType) -> NotificationConfigurationResponse: @@ -224,6 +245,10 @@ async def get(self, notification_type: NotificationType) -> NotificationConfigur raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -260,6 +285,10 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def reset(self, notification_type: NotificationType) -> None: @@ -293,4 +322,8 @@ async def reset(self, notification_type: NotificationType) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/organization_types/__init__.py b/src/mercoa/resources/organization_types/__init__.py index 9a0dd5c..eec9433 100644 --- a/src/mercoa/resources/organization_types/__init__.py +++ b/src/mercoa/resources/organization_types/__init__.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. from .types import ( + BusinessOnboardingOptions, ColorSchemeRequest, ColorSchemeResponse, EmailLogResponse, @@ -9,12 +10,16 @@ EmailSenderProvider, EmailSenderRequest, EmailSenderResponse, + IndividualOnboardingOptions, InvoiceNotificationConfigurationRequest, InvoiceNotificationConfigurationResponse, NotificationConfigurationRequest, NotificationConfigurationRequest_Invoice, NotificationConfigurationResponse, NotificationConfigurationResponse_Invoice, + OnboardingOption, + OnboardingOptionsRequest, + OnboardingOptionsResponse, OrganizationId, OrganizationRequest, OrganizationResponse, @@ -27,6 +32,7 @@ ) __all__ = [ + "BusinessOnboardingOptions", "ColorSchemeRequest", "ColorSchemeResponse", "EmailLogResponse", @@ -35,12 +41,16 @@ "EmailSenderProvider", "EmailSenderRequest", "EmailSenderResponse", + "IndividualOnboardingOptions", "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", "NotificationConfigurationRequest", "NotificationConfigurationRequest_Invoice", "NotificationConfigurationResponse", "NotificationConfigurationResponse_Invoice", + "OnboardingOption", + "OnboardingOptionsRequest", + "OnboardingOptionsResponse", "OrganizationId", "OrganizationRequest", "OrganizationResponse", diff --git a/src/mercoa/resources/organization_types/types/__init__.py b/src/mercoa/resources/organization_types/types/__init__.py index 4247564..854a048 100644 --- a/src/mercoa/resources/organization_types/types/__init__.py +++ b/src/mercoa/resources/organization_types/types/__init__.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. +from .business_onboarding_options import BusinessOnboardingOptions from .color_scheme_request import ColorSchemeRequest from .color_scheme_response import ColorSchemeResponse from .email_log_response import EmailLogResponse @@ -8,6 +9,7 @@ from .email_sender_provider import EmailSenderProvider from .email_sender_request import EmailSenderRequest from .email_sender_response import EmailSenderResponse +from .individual_onboarding_options import IndividualOnboardingOptions from .invoice_notification_configuration_request import InvoiceNotificationConfigurationRequest from .invoice_notification_configuration_response import InvoiceNotificationConfigurationResponse from .notification_configuration_request import ( @@ -18,6 +20,9 @@ NotificationConfigurationResponse, NotificationConfigurationResponse_Invoice, ) +from .onboarding_option import OnboardingOption +from .onboarding_options_request import OnboardingOptionsRequest +from .onboarding_options_response import OnboardingOptionsResponse from .organization_id import OrganizationId from .organization_request import OrganizationRequest from .organization_response import OrganizationResponse @@ -29,6 +34,7 @@ from .payment_rail_response import PaymentRailResponse __all__ = [ + "BusinessOnboardingOptions", "ColorSchemeRequest", "ColorSchemeResponse", "EmailLogResponse", @@ -37,12 +43,16 @@ "EmailSenderProvider", "EmailSenderRequest", "EmailSenderResponse", + "IndividualOnboardingOptions", "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", "NotificationConfigurationRequest", "NotificationConfigurationRequest_Invoice", "NotificationConfigurationResponse", "NotificationConfigurationResponse_Invoice", + "OnboardingOption", + "OnboardingOptionsRequest", + "OnboardingOptionsResponse", "OrganizationId", "OrganizationRequest", "OrganizationResponse", diff --git a/src/mercoa/resources/organization_types/types/business_onboarding_options.py b/src/mercoa/resources/organization_types/types/business_onboarding_options.py new file mode 100644 index 0000000..ce6f4c1 --- /dev/null +++ b/src/mercoa/resources/organization_types/types/business_onboarding_options.py @@ -0,0 +1,35 @@ +# 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 .onboarding_option import OnboardingOption + + +class BusinessOnboardingOptions(pydantic.BaseModel): + email: OnboardingOption + name: OnboardingOption + type: OnboardingOption + doing_business_as: OnboardingOption = pydantic.Field(alias="doingBusinessAs") + ein: OnboardingOption + address: OnboardingOption + phone: OnboardingOption + formation_date: OnboardingOption = pydantic.Field(alias="formationDate") + website: OnboardingOption + description: OnboardingOption + + 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 + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/organization_types/types/individual_onboarding_options.py b/src/mercoa/resources/organization_types/types/individual_onboarding_options.py new file mode 100644 index 0000000..9359aa8 --- /dev/null +++ b/src/mercoa/resources/organization_types/types/individual_onboarding_options.py @@ -0,0 +1,31 @@ +# 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 .onboarding_option import OnboardingOption + + +class IndividualOnboardingOptions(pydantic.BaseModel): + email: OnboardingOption + name: OnboardingOption + date_of_birth: OnboardingOption = pydantic.Field(alias="dateOfBirth") + ssn_last_4: OnboardingOption = pydantic.Field(alias="ssnLast4") + address: OnboardingOption + phone: OnboardingOption + + 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 + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/organization_types/types/onboarding_option.py b/src/mercoa/resources/organization_types/types/onboarding_option.py new file mode 100644 index 0000000..9570faf --- /dev/null +++ b/src/mercoa/resources/organization_types/types/onboarding_option.py @@ -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 + + +class OnboardingOption(pydantic.BaseModel): + show: bool + edit: bool + required: bool + + 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} diff --git a/src/mercoa/resources/organization_types/types/onboarding_options_request.py b/src/mercoa/resources/organization_types/types/onboarding_options_request.py new file mode 100644 index 0000000..706adec --- /dev/null +++ b/src/mercoa/resources/organization_types/types/onboarding_options_request.py @@ -0,0 +1,30 @@ +# 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 .business_onboarding_options import BusinessOnboardingOptions +from .individual_onboarding_options import IndividualOnboardingOptions + + +class OnboardingOptionsRequest(pydantic.BaseModel): + enable_business: typing.Optional[bool] = pydantic.Field(alias="enableBusiness") + enable_individual: typing.Optional[bool] = pydantic.Field(alias="enableIndividual") + business: typing.Optional[BusinessOnboardingOptions] + individual: typing.Optional[IndividualOnboardingOptions] + + 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 + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/organization_types/types/onboarding_options_response.py b/src/mercoa/resources/organization_types/types/onboarding_options_response.py new file mode 100644 index 0000000..bc55c57 --- /dev/null +++ b/src/mercoa/resources/organization_types/types/onboarding_options_response.py @@ -0,0 +1,30 @@ +# 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 .business_onboarding_options import BusinessOnboardingOptions +from .individual_onboarding_options import IndividualOnboardingOptions + + +class OnboardingOptionsResponse(pydantic.BaseModel): + enable_business: bool = pydantic.Field(alias="enableBusiness") + enable_individual: bool = pydantic.Field(alias="enableIndividual") + business: BusinessOnboardingOptions + individual: IndividualOnboardingOptions + + 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 + allow_population_by_field_name = True + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/organization_types/types/organization_request.py b/src/mercoa/resources/organization_types/types/organization_request.py index ad4fcb3..ca75257 100644 --- a/src/mercoa/resources/organization_types/types/organization_request.py +++ b/src/mercoa/resources/organization_types/types/organization_request.py @@ -8,6 +8,7 @@ from ....core.datetime_utils import serialize_datetime from .color_scheme_request import ColorSchemeRequest from .email_provider_request import EmailProviderRequest +from .onboarding_options_request import OnboardingOptionsRequest from .payment_methods_request import PaymentMethodsRequest @@ -19,6 +20,8 @@ class OrganizationRequest(pydantic.BaseModel): payment_methods: typing.Optional[PaymentMethodsRequest] = pydantic.Field(alias="paymentMethods") email_provider: typing.Optional[EmailProviderRequest] = pydantic.Field(alias="emailProvider") color_scheme: typing.Optional[ColorSchemeRequest] = pydantic.Field(alias="colorScheme") + payee_onboarding_options: typing.Optional[OnboardingOptionsRequest] = pydantic.Field(alias="payeeOnboardingOptions") + payor_onboarding_options: typing.Optional[OnboardingOptionsRequest] = pydantic.Field(alias="payorOnboardingOptions") def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/resources/organization_types/types/organization_response.py b/src/mercoa/resources/organization_types/types/organization_response.py index f24383c..200e410 100644 --- a/src/mercoa/resources/organization_types/types/organization_response.py +++ b/src/mercoa/resources/organization_types/types/organization_response.py @@ -8,6 +8,7 @@ from ....core.datetime_utils import serialize_datetime from .color_scheme_response import ColorSchemeResponse from .email_provider_response import EmailProviderResponse +from .onboarding_options_response import OnboardingOptionsResponse from .organization_id import OrganizationId from .payment_methods_response import PaymentMethodsResponse @@ -22,6 +23,12 @@ class OrganizationResponse(pydantic.BaseModel): payment_methods: typing.Optional[PaymentMethodsResponse] = pydantic.Field(alias="paymentMethods") email_provider: typing.Optional[EmailProviderResponse] = pydantic.Field(alias="emailProvider") color_scheme: typing.Optional[ColorSchemeResponse] = pydantic.Field(alias="colorScheme") + payee_onboarding_options: typing.Optional[OnboardingOptionsResponse] = pydantic.Field( + alias="payeeOnboardingOptions" + ) + payor_onboarding_options: typing.Optional[OnboardingOptionsResponse] = pydantic.Field( + alias="payorOnboardingOptions" + ) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/mercoa/resources/payment_method_schema/client.py b/src/mercoa/resources/payment_method_schema/client.py index 463bc45..52c6319 100644 --- a/src/mercoa/resources/payment_method_schema/client.py +++ b/src/mercoa/resources/payment_method_schema/client.py @@ -16,7 +16,8 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..payment_method_types.types.payment_method_schema_id import PaymentMethodSchemaId from ..payment_method_types.types.payment_method_schema_request import PaymentMethodSchemaRequest from ..payment_method_types.types.payment_method_schema_response import PaymentMethodSchemaResponse @@ -55,6 +56,10 @@ def get_all(self) -> typing.List[PaymentMethodSchemaResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def create(self, *, request: PaymentMethodSchemaRequest) -> PaymentMethodSchemaResponse: @@ -86,6 +91,10 @@ def create(self, *, request: PaymentMethodSchemaRequest) -> PaymentMethodSchemaR raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def update( @@ -119,6 +128,10 @@ def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get(self, schema_id: PaymentMethodSchemaId) -> PaymentMethodSchemaResponse: @@ -149,6 +162,10 @@ def get(self, schema_id: PaymentMethodSchemaId) -> PaymentMethodSchemaResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def delete(self, schema_id: PaymentMethodSchemaId) -> None: @@ -179,6 +196,10 @@ def delete(self, schema_id: PaymentMethodSchemaId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -216,6 +237,10 @@ async def get_all(self) -> typing.List[PaymentMethodSchemaResponse]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def create(self, *, request: PaymentMethodSchemaRequest) -> PaymentMethodSchemaResponse: @@ -248,6 +273,10 @@ async def create(self, *, request: PaymentMethodSchemaRequest) -> PaymentMethodS raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def update( @@ -282,6 +311,10 @@ async def update( raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get(self, schema_id: PaymentMethodSchemaId) -> PaymentMethodSchemaResponse: @@ -313,6 +346,10 @@ async def get(self, schema_id: PaymentMethodSchemaId) -> PaymentMethodSchemaResp raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def delete(self, schema_id: PaymentMethodSchemaId) -> None: @@ -344,4 +381,8 @@ async def delete(self, schema_id: PaymentMethodSchemaId) -> None: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/mercoa/resources/transaction/client.py b/src/mercoa/resources/transaction/client.py index 6f79ebb..7b1695b 100644 --- a/src/mercoa/resources/transaction/client.py +++ b/src/mercoa/resources/transaction/client.py @@ -15,7 +15,8 @@ from ..commons.errors.invalid_postal_code import InvalidPostalCode from ..commons.errors.invalid_state_or_province import InvalidStateOrProvince from ..commons.errors.unauthorized import Unauthorized -from ..entity.errors.invalid_tax_id import InvalidTaxId +from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists +from ..entity_types.errors.invalid_tax_id import InvalidTaxId from .types.transaction_id import TransactionId from .types.transaction_response import TransactionResponse from .types.transaction_response_expanded import TransactionResponseExpanded @@ -54,6 +55,10 @@ def get_all(self) -> typing.List[TransactionResponseExpanded]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) def get(self, transaction_id: TransactionId) -> TransactionResponse: @@ -84,6 +89,10 @@ def get(self, transaction_id: TransactionId) -> TransactionResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) @@ -121,6 +130,10 @@ async def get_all(self) -> typing.List[TransactionResponseExpanded]: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json) async def get(self, transaction_id: TransactionId) -> TransactionResponse: @@ -152,4 +165,8 @@ async def get(self, transaction_id: TransactionId) -> TransactionResponse: raise InvalidStateOrProvince(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "InvalidTaxId": raise InvalidTaxId(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "EntityForeignIdAlreadyExists": + raise EntityForeignIdAlreadyExists( + pydantic.parse_obj_as(str, _response_json["content"]) # type: ignore + ) raise ApiError(status_code=_response.status_code, body=_response_json)