diff --git a/pyproject.toml b/pyproject.toml index c2a7fd5..0840041 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mercoa" -version = "v0.2.15" +version = "v0.3.0" description = "" readme = "README.md" authors = [] diff --git a/src/mercoa/__init__.py b/src/mercoa/__init__.py index 6d6c6e1..9b6449f 100644 --- a/src/mercoa/__init__.py +++ b/src/mercoa/__init__.py @@ -57,10 +57,10 @@ EmailSenderResponse, EntityAddPayeesRequest, EntityAddPayorsRequest, - EntityArchivePayeesRequest, - EntityArchivePayorsRequest, EntityError, EntityForeignIdAlreadyExists, + EntityHidePayeesRequest, + EntityHidePayorsRequest, EntityId, EntityMetadataResponse, EntityOnboardingLinkType, @@ -96,13 +96,14 @@ InvoiceNotificationConfigurationRequest, InvoiceNotificationConfigurationResponse, InvoiceOrderByField, + InvoiceQueryError, InvoiceRequest, InvoiceResponse, InvoiceStatus, InvoiceStatusError, Itin, - MetadataConditional, MetadataSchema, + MetadataShowConditions, MetadataType, NotFound, NotificationConfigurationRequest, @@ -172,10 +173,6 @@ TokenGenerationPagesOptions, TokenGenerationStyleOptions, TokenGenerationVendorOptions, - TransactionId, - TransactionResponse, - TransactionResponseExpanded, - TransactionStatus, Trigger, Trigger_All, Trigger_Amount, @@ -195,7 +192,6 @@ organization_types, payment_method_schema, payment_method_types, - transaction, ) from .environment import MercoaEnvironment @@ -256,10 +252,10 @@ "EmailSenderResponse", "EntityAddPayeesRequest", "EntityAddPayorsRequest", - "EntityArchivePayeesRequest", - "EntityArchivePayorsRequest", "EntityError", "EntityForeignIdAlreadyExists", + "EntityHidePayeesRequest", + "EntityHidePayorsRequest", "EntityId", "EntityMetadataResponse", "EntityOnboardingLinkType", @@ -295,14 +291,15 @@ "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", "InvoiceOrderByField", + "InvoiceQueryError", "InvoiceRequest", "InvoiceResponse", "InvoiceStatus", "InvoiceStatusError", "Itin", "MercoaEnvironment", - "MetadataConditional", "MetadataSchema", + "MetadataShowConditions", "MetadataType", "NotFound", "NotificationConfigurationRequest", @@ -372,10 +369,6 @@ "TokenGenerationPagesOptions", "TokenGenerationStyleOptions", "TokenGenerationVendorOptions", - "TransactionId", - "TransactionResponse", - "TransactionResponseExpanded", - "TransactionStatus", "Trigger", "Trigger_All", "Trigger_Amount", @@ -395,5 +388,4 @@ "organization_types", "payment_method_schema", "payment_method_types", - "transaction", ] diff --git a/src/mercoa/client.py b/src/mercoa/client.py index 54cc626..b688475 100644 --- a/src/mercoa/client.py +++ b/src/mercoa/client.py @@ -12,7 +12,6 @@ from .resources.ocr.client import AsyncOcrClient, OcrClient from .resources.organization.client import AsyncOrganizationClient, OrganizationClient from .resources.payment_method_schema.client import AsyncPaymentMethodSchemaClient, PaymentMethodSchemaClient -from .resources.transaction.client import AsyncTransactionClient, TransactionClient class Mercoa: @@ -35,7 +34,6 @@ def __init__( self.bank_lookup = BankLookupClient(client_wrapper=self._client_wrapper) self.ocr = OcrClient(client_wrapper=self._client_wrapper) self.payment_method_schema = PaymentMethodSchemaClient(client_wrapper=self._client_wrapper) - self.transaction = TransactionClient(client_wrapper=self._client_wrapper) class AsyncMercoa: @@ -58,7 +56,6 @@ def __init__( self.bank_lookup = AsyncBankLookupClient(client_wrapper=self._client_wrapper) self.ocr = AsyncOcrClient(client_wrapper=self._client_wrapper) self.payment_method_schema = AsyncPaymentMethodSchemaClient(client_wrapper=self._client_wrapper) - self.transaction = AsyncTransactionClient(client_wrapper=self._client_wrapper) def _get_base_url(*, base_url: typing.Optional[str] = None, environment: MercoaEnvironment) -> str: diff --git a/src/mercoa/core/client_wrapper.py b/src/mercoa/core/client_wrapper.py index bbb14b6..6be1a18 100644 --- a/src/mercoa/core/client_wrapper.py +++ b/src/mercoa/core/client_wrapper.py @@ -14,7 +14,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "mercoa", - "X-Fern-SDK-Version": "v0.2.15", + "X-Fern-SDK-Version": "v0.3.0", } headers["Authorization"] = f"Bearer {self._get_token()}" return headers diff --git a/src/mercoa/resources/__init__.py b/src/mercoa/resources/__init__.py index f585ba6..60f983b 100644 --- a/src/mercoa/resources/__init__.py +++ b/src/mercoa/resources/__init__.py @@ -12,7 +12,6 @@ organization_types, payment_method_schema, payment_method_types, - transaction, ) from .bank_lookup import BankAddress, BankLookupResponse from .commons import ( @@ -50,10 +49,10 @@ Ein, EntityAddPayeesRequest, EntityAddPayorsRequest, - EntityArchivePayeesRequest, - EntityArchivePayorsRequest, EntityError, EntityForeignIdAlreadyExists, + EntityHidePayeesRequest, + EntityHidePayorsRequest, EntityId, EntityMetadataResponse, EntityOnboardingLinkType, @@ -119,6 +118,7 @@ InvoiceLineItemResponse, InvoiceMetricsResponse, InvoiceOrderByField, + InvoiceQueryError, InvoiceRequest, InvoiceResponse, InvoiceStatus, @@ -139,8 +139,8 @@ IndividualOnboardingOptions, InvoiceNotificationConfigurationRequest, InvoiceNotificationConfigurationResponse, - MetadataConditional, MetadataSchema, + MetadataShowConditions, MetadataType, NotificationConfigurationRequest, NotificationConfigurationRequest_Invoice, @@ -201,7 +201,6 @@ PaymentMethodUpdateRequest_Custom, PlaidLinkRequest, ) -from .transaction import TransactionId, TransactionResponse, TransactionResponseExpanded, TransactionStatus __all__ = [ "AccountType", @@ -260,10 +259,10 @@ "EmailSenderResponse", "EntityAddPayeesRequest", "EntityAddPayorsRequest", - "EntityArchivePayeesRequest", - "EntityArchivePayorsRequest", "EntityError", "EntityForeignIdAlreadyExists", + "EntityHidePayeesRequest", + "EntityHidePayorsRequest", "EntityId", "EntityMetadataResponse", "EntityOnboardingLinkType", @@ -299,13 +298,14 @@ "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", "InvoiceOrderByField", + "InvoiceQueryError", "InvoiceRequest", "InvoiceResponse", "InvoiceStatus", "InvoiceStatusError", "Itin", - "MetadataConditional", "MetadataSchema", + "MetadataShowConditions", "MetadataType", "NotFound", "NotificationConfigurationRequest", @@ -375,10 +375,6 @@ "TokenGenerationPagesOptions", "TokenGenerationStyleOptions", "TokenGenerationVendorOptions", - "TransactionId", - "TransactionResponse", - "TransactionResponseExpanded", - "TransactionStatus", "Trigger", "Trigger_All", "Trigger_Amount", @@ -398,5 +394,4 @@ "organization_types", "payment_method_schema", "payment_method_types", - "transaction", ] diff --git a/src/mercoa/resources/entity/client.py b/src/mercoa/resources/entity/client.py index ffb2487..84bf43b 100644 --- a/src/mercoa/resources/entity/client.py +++ b/src/mercoa/resources/entity/client.py @@ -22,10 +22,6 @@ from ..entity_types.errors.entity_foreign_id_already_exists import EntityForeignIdAlreadyExists from ..entity_types.errors.invalid_tax_id import InvalidTaxId from ..entity_types.errors.token_generation_failed import TokenGenerationFailed -from ..entity_types.types.entity_add_payees_request import EntityAddPayeesRequest -from ..entity_types.types.entity_add_payors_request import EntityAddPayorsRequest -from ..entity_types.types.entity_archive_payees_request import EntityArchivePayeesRequest -from ..entity_types.types.entity_archive_payors_request import EntityArchivePayorsRequest 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 @@ -59,51 +55,10 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self.payment_method = PaymentMethodClient(client_wrapper=self._client_wrapper) self.representative = RepresentativeClient(client_wrapper=self._client_wrapper) - def get_all( - self, *, is_payee: typing.Optional[bool] = None, is_payor: typing.Optional[bool] = None - ) -> typing.List[EntityResponse]: - """ - Get all entities - - Parameters: - - is_payee: typing.Optional[bool]. If true, entities that are marked as payees will be returned. - If false or not provided, entities that are marked as payees will not be returned. - - - is_payor: typing.Optional[bool]. If true or not provided, entities that are marked as payors will be returned. - If false, entities that are marked as payors will not be returned. - - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entities"), - params=remove_none_from_dict({"isPayee": is_payee, "isPayor": is_payor}), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(typing.List[EntityResponse], _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - def find( self, *, + owned_by_org: typing.Optional[bool] = None, foreign_id: typing.Union[typing.Optional[str], typing.List[str]], status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]], is_payee: typing.Optional[bool] = None, @@ -113,8 +68,12 @@ def find( starting_after: typing.Optional[EntityId] = None, ) -> FindEntityResponse: """ + Search all entities with the given filters. If no filters are provided, all entities will be returned. + Parameters: - - foreign_id: typing.Union[typing.Optional[str], typing.List[str]]. + - owned_by_org: typing.Optional[bool]. If true, only entities with a direct relationship to the requesting organization will be returned. If false or not provided, all entities will be returned. + + - foreign_id: typing.Union[typing.Optional[str], typing.List[str]]. ID used to identify this entity in your system - status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]]. @@ -135,6 +94,7 @@ def find( urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), params=remove_none_from_dict( { + "ownedByOrg": owned_by_org, "foreignId": foreign_id, "status": status, "isPayee": is_payee, @@ -215,8 +175,6 @@ def create(self, *, request: EntityRequest) -> EntityResponse: def get(self, entity_id: EntityId) -> EntityResponse: """ - Get entity - Parameters: - entity_id: EntityId. """ @@ -249,8 +207,6 @@ def get(self, entity_id: EntityId) -> EntityResponse: def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> EntityResponse: """ - Update entity - Parameters: - entity_id: EntityId. @@ -298,8 +254,6 @@ def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> Entity def delete(self, entity_id: EntityId) -> None: """ - Delete entity - Parameters: - entity_id: EntityId. """ @@ -332,7 +286,7 @@ def delete(self, entity_id: EntityId) -> None: def accept_terms_of_service(self, entity_id: EntityId) -> None: """ - End user accepts Terms of Service + This endpoint is used to indicate acceptance of Mercoa's terms of service for an entity. Send a request to this endpoint only after the entity has accepted the Mercoa ToS. Entities must accept Mercoa ToS before they can be send or pay invoices using Mercoa's payment rails. Parameters: - entity_id: EntityId. @@ -368,6 +322,10 @@ def accept_terms_of_service(self, entity_id: EntityId) -> None: def initiate_kyb(self, entity_id: EntityId) -> None: """ + This endpoint is used to initiate KYB for an entity. + Send a request to this endpoint only after the entity has accepted the Mercoa ToS, + all representatives have been added, and all required fields have been filled out. + Parameters: - entity_id: EntityId. """ @@ -400,45 +358,9 @@ def initiate_kyb(self, entity_id: EntityId) -> None: raise Unimplemented(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: - """ - Get JWT token for entity - - Parameters: - - entity_id: EntityId. - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/token"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: """ - Get JWT token for entity with iFrame options + Generate a JWT token for an entity with the given options. This token can be used to authenticate the entity in the Mercoa API and iFrame. Parameters: - entity_id: EntityId. @@ -475,190 +397,6 @@ def get_token(self, entity_id: EntityId, *, request: TokenGenerationOptions) -> raise Unimplemented(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: - """ - Get Plaid token - - Parameters: - - entity_id: EntityId. - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/plaidLinkToken"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: - """ - Create association between Entity and a given list of Payees. If a Payee has previously been archived, unarchives the Payee. - - Parameters: - - entity_id: EntityId. - - - request: EntityAddPayeesRequest. - """ - _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayees"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: - """ - Marks Payees as unsearchable by Entity via Counterparty search. Invoices associated with these Payees will still be searchable via Invoice search. - - Parameters: - - entity_id: EntityId. - - - request: EntityArchivePayeesRequest. - """ - _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/archivePayees"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_payors(self, entity_id: EntityId, *, request: EntityAddPayorsRequest) -> None: - """ - Create association between Entity and a given list of Payors. If a Payor has previously been archived, unarchives the Payor. - - Parameters: - - entity_id: EntityId. - - - request: EntityAddPayorsRequest. - """ - _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayors"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - def archive_payors(self, entity_id: EntityId, *, request: EntityArchivePayorsRequest) -> None: - """ - Marks Payors as unsearchable by Entity via Counterparty search. Invoices associated with these Payors will still be searchable via Invoice search. - - Parameters: - - entity_id: EntityId. - - - request: EntityArchivePayorsRequest. - """ - _response = self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/archivePayors"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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, @@ -762,51 +500,10 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self.payment_method = AsyncPaymentMethodClient(client_wrapper=self._client_wrapper) self.representative = AsyncRepresentativeClient(client_wrapper=self._client_wrapper) - async def get_all( - self, *, is_payee: typing.Optional[bool] = None, is_payor: typing.Optional[bool] = None - ) -> typing.List[EntityResponse]: - """ - Get all entities - - Parameters: - - is_payee: typing.Optional[bool]. If true, entities that are marked as payees will be returned. - If false or not provided, entities that are marked as payees will not be returned. - - - is_payor: typing.Optional[bool]. If true or not provided, entities that are marked as payors will be returned. - If false, entities that are marked as payors will not be returned. - - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entities"), - params=remove_none_from_dict({"isPayee": is_payee, "isPayor": is_payor}), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(typing.List[EntityResponse], _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - async def find( self, *, + owned_by_org: typing.Optional[bool] = None, foreign_id: typing.Union[typing.Optional[str], typing.List[str]], status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]], is_payee: typing.Optional[bool] = None, @@ -816,8 +513,12 @@ async def find( starting_after: typing.Optional[EntityId] = None, ) -> FindEntityResponse: """ + Search all entities with the given filters. If no filters are provided, all entities will be returned. + Parameters: - - foreign_id: typing.Union[typing.Optional[str], typing.List[str]]. + - owned_by_org: typing.Optional[bool]. If true, only entities with a direct relationship to the requesting organization will be returned. If false or not provided, all entities will be returned. + + - foreign_id: typing.Union[typing.Optional[str], typing.List[str]]. ID used to identify this entity in your system - status: typing.Union[typing.Optional[EntityStatus], typing.List[EntityStatus]]. @@ -838,6 +539,7 @@ async def find( urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "entity"), params=remove_none_from_dict( { + "ownedByOrg": owned_by_org, "foreignId": foreign_id, "status": status, "isPayee": is_payee, @@ -918,8 +620,6 @@ async def create(self, *, request: EntityRequest) -> EntityResponse: async def get(self, entity_id: EntityId) -> EntityResponse: """ - Get entity - Parameters: - entity_id: EntityId. """ @@ -952,8 +652,6 @@ async def get(self, entity_id: EntityId) -> EntityResponse: async def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> EntityResponse: """ - Update entity - Parameters: - entity_id: EntityId. @@ -1001,8 +699,6 @@ async def update(self, entity_id: EntityId, *, request: EntityUpdateRequest) -> async def delete(self, entity_id: EntityId) -> None: """ - Delete entity - Parameters: - entity_id: EntityId. """ @@ -1035,7 +731,7 @@ async def delete(self, entity_id: EntityId) -> None: async def accept_terms_of_service(self, entity_id: EntityId) -> None: """ - End user accepts Terms of Service + This endpoint is used to indicate acceptance of Mercoa's terms of service for an entity. Send a request to this endpoint only after the entity has accepted the Mercoa ToS. Entities must accept Mercoa ToS before they can be send or pay invoices using Mercoa's payment rails. Parameters: - entity_id: EntityId. @@ -1071,6 +767,10 @@ async def accept_terms_of_service(self, entity_id: EntityId) -> None: async def initiate_kyb(self, entity_id: EntityId) -> None: """ + This endpoint is used to initiate KYB for an entity. + Send a request to this endpoint only after the entity has accepted the Mercoa ToS, + all representatives have been added, and all required fields have been filled out. + Parameters: - entity_id: EntityId. """ @@ -1103,45 +803,9 @@ async def initiate_kyb(self, entity_id: EntityId) -> None: raise Unimplemented(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: - """ - Get JWT token for entity - - Parameters: - - entity_id: EntityId. - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/token"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: """ - Get JWT token for entity with iFrame options + Generate a JWT token for an entity with the given options. This token can be used to authenticate the entity in the Mercoa API and iFrame. Parameters: - entity_id: EntityId. @@ -1178,190 +842,6 @@ async def get_token(self, entity_id: EntityId, *, request: TokenGenerationOption raise Unimplemented(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: - """ - Get Plaid token - - Parameters: - - entity_id: EntityId. - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/plaidLinkToken"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: - """ - Create association between Entity and a given list of Payees. If a Payee has previously been archived, unarchives the Payee. - - Parameters: - - entity_id: EntityId. - - - request: EntityAddPayeesRequest. - """ - _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayees"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def archive_payees(self, entity_id: EntityId, *, request: EntityArchivePayeesRequest) -> None: - """ - Marks Payees as unsearchable by Entity via Counterparty search. Invoices associated with these Payees will still be searchable via Invoice search. - - Parameters: - - entity_id: EntityId. - - - request: EntityArchivePayeesRequest. - """ - _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/archivePayees"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_payors(self, entity_id: EntityId, *, request: EntityAddPayorsRequest) -> None: - """ - Create association between Entity and a given list of Payors. If a Payor has previously been archived, unarchives the Payor. - - Parameters: - - entity_id: EntityId. - - - request: EntityAddPayorsRequest. - """ - _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayors"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def archive_payors(self, entity_id: EntityId, *, request: EntityArchivePayorsRequest) -> None: - """ - Marks Payors as unsearchable by Entity via Counterparty search. Invoices associated with these Payors will still be searchable via Invoice search. - - Parameters: - - entity_id: EntityId. - - - request: EntityArchivePayorsRequest. - """ - _response = await self._client_wrapper.httpx_client.request( - "POST", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/archivePayors"), - json=jsonable_encoder(request), - headers=self._client_wrapper.get_headers(), - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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, diff --git a/src/mercoa/resources/entity/resources/approval_policy/client.py b/src/mercoa/resources/entity/resources/approval_policy/client.py index 550e74e..f743d17 100644 --- a/src/mercoa/resources/entity/resources/approval_policy/client.py +++ b/src/mercoa/resources/entity/resources/approval_policy/client.py @@ -33,7 +33,7 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyResponse]: """ - Retrieve all invoice approval policies associated with Entity + Retrieve all invoice approval policies associated with an entity Parameters: - entity_id: EntityId. @@ -67,7 +67,7 @@ def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyResponse]: def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> ApprovalPolicyResponse: """ - Create an invoice approval policy associated with Entity + Create an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. @@ -110,7 +110,7 @@ def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> Appr def get(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> ApprovalPolicyResponse: """ - Retrieve an invoice approval policy associated with Entity + Retrieve an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. @@ -150,7 +150,7 @@ def update( self, entity_id: EntityId, policy_id: ApprovalPolicyId, *, request: ApprovalPolicyUpdateRequest ) -> ApprovalPolicyResponse: """ - Update an invoice approval policy associated with Entity + Update an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. @@ -240,7 +240,7 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): async def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyResponse]: """ - Retrieve all invoice approval policies associated with Entity + Retrieve all invoice approval policies associated with an entity Parameters: - entity_id: EntityId. @@ -274,7 +274,7 @@ async def get_all(self, entity_id: EntityId) -> typing.List[ApprovalPolicyRespon async def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) -> ApprovalPolicyResponse: """ - Create an invoice approval policy associated with Entity + Create an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. @@ -317,7 +317,7 @@ async def create(self, entity_id: EntityId, *, request: ApprovalPolicyRequest) - async def get(self, entity_id: EntityId, policy_id: ApprovalPolicyId) -> ApprovalPolicyResponse: """ - Retrieve an invoice approval policy associated with Entity + Retrieve an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. @@ -357,7 +357,7 @@ async def update( self, entity_id: EntityId, policy_id: ApprovalPolicyId, *, request: ApprovalPolicyUpdateRequest ) -> ApprovalPolicyResponse: """ - Update an invoice approval policy associated with Entity + Update an invoice approval policy associated with an entity Parameters: - entity_id: EntityId. diff --git a/src/mercoa/resources/entity/resources/counterparty/client.py b/src/mercoa/resources/entity/resources/counterparty/client.py index 4e8159b..9653e2f 100644 --- a/src/mercoa/resources/entity/resources/counterparty/client.py +++ b/src/mercoa/resources/entity/resources/counterparty/client.py @@ -8,6 +8,7 @@ from .....core.api_error import ApiError from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.jsonable_encoder import jsonable_encoder from .....core.remove_none_from_dict import remove_none_from_dict from ....commons.errors.auth_header_malformed_error import AuthHeaderMalformedError from ....commons.errors.auth_header_missing_error import AuthHeaderMissingError @@ -17,9 +18,16 @@ from ....commons.errors.unimplemented import Unimplemented from ....entity_types.types.counterparties_response import CounterpartiesResponse from ....entity_types.types.counterparty_network_type import CounterpartyNetworkType +from ....entity_types.types.entity_add_payees_request import EntityAddPayeesRequest +from ....entity_types.types.entity_add_payors_request import EntityAddPayorsRequest +from ....entity_types.types.entity_hide_payees_request import EntityHidePayeesRequest +from ....entity_types.types.entity_hide_payors_request import EntityHidePayorsRequest from ....entity_types.types.entity_id import EntityId from ....entity_types.types.find_counterparties_response import FindCounterpartiesResponse +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + class CounterpartyClient: def __init__(self, *, client_wrapper: SyncClientWrapper): @@ -190,6 +198,154 @@ def find_payors( raise Unimplemented(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: + """ + Create association between Entity and a given list of Payees. If a Payee has previously been archived, unarchive the Payee. + + Parameters: + - entity_id: EntityId. + + - request: EntityAddPayeesRequest. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayees"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def hide_payees(self, entity_id: EntityId, *, request: EntityHidePayeesRequest) -> None: + """ + Marks Payees as unsearchable by Entity via Counterparty search. Invoices associated with these Payees will still be searchable via Invoice search. + + Parameters: + - entity_id: EntityId. + + - request: EntityHidePayeesRequest. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/hidePayees"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def add_payors(self, entity_id: EntityId, *, request: EntityAddPayorsRequest) -> None: + """ + Create association between Entity and a given list of Payors. If a Payor has previously been archived, unarchive the Payor. + + Parameters: + - entity_id: EntityId. + + - request: EntityAddPayorsRequest. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayors"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + def hide_payors(self, entity_id: EntityId, *, request: EntityHidePayorsRequest) -> None: + """ + Marks Payors as unsearchable by Entity via Counterparty search. Invoices associated with these Payors will still be searchable via Invoice search. + + Parameters: + - entity_id: EntityId. + + - request: EntityHidePayorsRequest. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/hidePayors"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + class AsyncCounterpartyClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -359,3 +515,151 @@ async def find_payors( if _response_json["errorName"] == "Unimplemented": raise Unimplemented(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: + """ + Create association between Entity and a given list of Payees. If a Payee has previously been archived, unarchive the Payee. + + Parameters: + - entity_id: EntityId. + + - request: EntityAddPayeesRequest. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayees"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def hide_payees(self, entity_id: EntityId, *, request: EntityHidePayeesRequest) -> None: + """ + Marks Payees as unsearchable by Entity via Counterparty search. Invoices associated with these Payees will still be searchable via Invoice search. + + Parameters: + - entity_id: EntityId. + + - request: EntityHidePayeesRequest. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/hidePayees"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def add_payors(self, entity_id: EntityId, *, request: EntityAddPayorsRequest) -> None: + """ + Create association between Entity and a given list of Payors. If a Payor has previously been archived, unarchive the Payor. + + Parameters: + - entity_id: EntityId. + + - request: EntityAddPayorsRequest. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/addPayors"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def hide_payors(self, entity_id: EntityId, *, request: EntityHidePayorsRequest) -> None: + """ + Marks Payors as unsearchable by Entity via Counterparty search. Invoices associated with these Payors will still be searchable via Invoice search. + + Parameters: + - entity_id: EntityId. + + - request: EntityHidePayorsRequest. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/hidePayors"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(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 977517a..940044c 100644 --- a/src/mercoa/resources/entity/resources/invoice/client.py +++ b/src/mercoa/resources/entity/resources/invoice/client.py @@ -20,10 +20,12 @@ from ....commons.types.order_direction import OrderDirection from ....entity_types.types.entity_id import EntityId from ....entity_types.types.entity_user_id import EntityUserId +from ....invoice_types.errors.invoice_query_error import InvoiceQueryError from ....invoice_types.types.find_invoice_response import FindInvoiceResponse from ....invoice_types.types.invoice_id import InvoiceId from ....invoice_types.types.invoice_metrics_response import InvoiceMetricsResponse from ....invoice_types.types.invoice_order_by_field import InvoiceOrderByField +from ....invoice_types.types.invoice_response import InvoiceResponse from ....invoice_types.types.invoice_status import InvoiceStatus from ....payment_method_types.types.currency_code import CurrencyCode @@ -36,6 +38,8 @@ def find( self, entity_id: EntityId, *, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, start_date: typing.Optional[dt.datetime] = None, end_date: typing.Optional[dt.datetime] = None, order_by: typing.Optional[InvoiceOrderByField] = None, @@ -44,16 +48,21 @@ def find( starting_after: typing.Optional[InvoiceId] = None, search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], + payer_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: """ - Get invoices for an entity + Get invoices for an entity with the given filters. Parameters: - entity_id: EntityId. + - exclude_payables: typing.Optional[bool]. Return only invoices that are receivable by the entity. + + - exclude_receivables: typing.Optional[bool]. Return only invoices that are payable by the entity. + - start_date: typing.Optional[dt.datetime]. Start date for invoice created on date filter. - end_date: typing.Optional[dt.datetime]. End date for invoice created date filter. @@ -70,6 +79,8 @@ def find( - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. - invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]]. Filter invoices by invoice ID. @@ -81,6 +92,8 @@ def find( urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/invoices"), params=remove_none_from_dict( { + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, "startDate": serialize_datetime(start_date) if start_date is not None else None, "endDate": serialize_datetime(end_date) if end_date is not None else None, "orderBy": order_by, @@ -89,6 +102,7 @@ def find( "startingAfter": starting_after, "search": search, "vendorId": vendor_id, + "payerId": payer_id, "approverId": approver_id, "invoiceId": invoice_id, "status": status, @@ -103,6 +117,42 @@ def find( raise ApiError(status_code=_response.status_code, body=_response.text) if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(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, invoice_id: InvoiceId) -> InvoiceResponse: + """ + Parameters: + - entity_id: EntityId. + + - invoice_id: InvoiceId. ID of the invoice to retrieve. This can be the full invoice ID (in_11aa2b77-6391-49e4-8c3f-b198009202c1) or the first 8 characters of the ID (11aa2b77). + """ + _response = self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/invoice/{invoice_id}"), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(InvoiceResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() @@ -123,6 +173,9 @@ def metrics( entity_id: EntityId, *, search: typing.Optional[str] = None, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], 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]], @@ -134,13 +187,19 @@ def metrics( currency: typing.Union[typing.Optional[CurrencyCode], typing.List[CurrencyCode]], ) -> typing.List[InvoiceMetricsResponse]: """ - Get invoice metrics for an entity + Get invoice metrics for an entity with the given filters. Parameters: - entity_id: EntityId. - search: typing.Optional[str]. Filter vendors by name. Partial matches are supported. + - exclude_payables: typing.Optional[bool]. Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + + - exclude_receivables: typing.Optional[bool]. Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. @@ -165,6 +224,9 @@ def metrics( params=remove_none_from_dict( { "search": search, + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "payerId": payer_id, "vendorId": vendor_id, "approverId": approver_id, "invoiceId": invoice_id, @@ -188,6 +250,8 @@ def metrics( if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(typing.List[InvoiceMetricsResponse], _response_json) # type: ignore if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() if _response_json["errorName"] == "AuthHeaderMalformedError": @@ -211,6 +275,8 @@ async def find( self, entity_id: EntityId, *, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, start_date: typing.Optional[dt.datetime] = None, end_date: typing.Optional[dt.datetime] = None, order_by: typing.Optional[InvoiceOrderByField] = None, @@ -219,16 +285,21 @@ async def find( starting_after: typing.Optional[InvoiceId] = None, search: typing.Optional[str] = None, vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], + payer_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: """ - Get invoices for an entity + Get invoices for an entity with the given filters. Parameters: - entity_id: EntityId. + - exclude_payables: typing.Optional[bool]. Return only invoices that are receivable by the entity. + + - exclude_receivables: typing.Optional[bool]. Return only invoices that are payable by the entity. + - start_date: typing.Optional[dt.datetime]. Start date for invoice created on date filter. - end_date: typing.Optional[dt.datetime]. End date for invoice created date filter. @@ -245,6 +316,8 @@ async def find( - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. - invoice_id: typing.Union[typing.Optional[InvoiceId], typing.List[InvoiceId]]. Filter invoices by invoice ID. @@ -256,6 +329,8 @@ async def find( urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/invoices"), params=remove_none_from_dict( { + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, "startDate": serialize_datetime(start_date) if start_date is not None else None, "endDate": serialize_datetime(end_date) if end_date is not None else None, "orderBy": order_by, @@ -264,6 +339,7 @@ async def find( "startingAfter": starting_after, "search": search, "vendorId": vendor_id, + "payerId": payer_id, "approverId": approver_id, "invoiceId": invoice_id, "status": status, @@ -278,6 +354,42 @@ async def find( raise ApiError(status_code=_response.status_code, body=_response.text) if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore + if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(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, invoice_id: InvoiceId) -> InvoiceResponse: + """ + Parameters: + - entity_id: EntityId. + + - invoice_id: InvoiceId. ID of the invoice to retrieve. This can be the full invoice ID (in_11aa2b77-6391-49e4-8c3f-b198009202c1) or the first 8 characters of the ID (11aa2b77). + """ + _response = await self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/invoice/{invoice_id}"), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(InvoiceResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() @@ -298,6 +410,9 @@ async def metrics( entity_id: EntityId, *, search: typing.Optional[str] = None, + exclude_payables: typing.Optional[bool] = None, + exclude_receivables: typing.Optional[bool] = None, + payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], 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]], @@ -309,13 +424,19 @@ async def metrics( currency: typing.Union[typing.Optional[CurrencyCode], typing.List[CurrencyCode]], ) -> typing.List[InvoiceMetricsResponse]: """ - Get invoice metrics for an entity + Get invoice metrics for an entity with the given filters. Parameters: - entity_id: EntityId. - search: typing.Optional[str]. Filter vendors by name. Partial matches are supported. + - exclude_payables: typing.Optional[bool]. Only return invoices that are not payable by the entity. This will return only invoices that are receivable by the entity. + + - exclude_receivables: typing.Optional[bool]. Only return invoices that are not receivable by the entity. This will return only invoices that are payable by the entity. + + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. @@ -340,6 +461,9 @@ async def metrics( params=remove_none_from_dict( { "search": search, + "excludePayables": exclude_payables, + "excludeReceivables": exclude_receivables, + "payerId": payer_id, "vendorId": vendor_id, "approverId": approver_id, "invoiceId": invoice_id, @@ -363,6 +487,8 @@ async def metrics( if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(typing.List[InvoiceMetricsResponse], _response_json) # type: ignore if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() if _response_json["errorName"] == "AuthHeaderMalformedError": diff --git a/src/mercoa/resources/entity/resources/metadata/client.py b/src/mercoa/resources/entity/resources/metadata/client.py index 1986cea..5134e3b 100644 --- a/src/mercoa/resources/entity/resources/metadata/client.py +++ b/src/mercoa/resources/entity/resources/metadata/client.py @@ -135,6 +135,42 @@ def update(self, entity_id: EntityId, key: str, *, request: typing.List[str]) -> raise Unimplemented(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, key: str) -> None: + """ + Delete all metadata associated with a specific key + + Parameters: + - entity_id: EntityId. + + - key: str. + """ + _response = self._client_wrapper.httpx_client.request( + "DELETE", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/metadata/{key}"), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + raise ApiError(status_code=_response.status_code, body=_response_json) + class AsyncMetadataClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -248,3 +284,39 @@ async def update(self, entity_id: EntityId, key: str, *, request: typing.List[st if _response_json["errorName"] == "Unimplemented": raise Unimplemented(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, key: str) -> None: + """ + Delete all metadata associated with a specific key + + Parameters: + - entity_id: EntityId. + + - key: str. + """ + _response = await self._client_wrapper.httpx_client.request( + "DELETE", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/metadata/{key}"), + headers=self._client_wrapper.get_headers(), + 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"] == "Forbidden": + raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "NotFound": + raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore + if _response_json["errorName"] == "Unimplemented": + raise Unimplemented(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 d2634bb..023a4e5 100644 --- a/src/mercoa/resources/entity/resources/payment_method/client.py +++ b/src/mercoa/resources/entity/resources/payment_method/client.py @@ -76,8 +76,6 @@ def get_all( def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> PaymentMethodResponse: """ - Create payment method - Parameters: - entity_id: EntityId. @@ -115,8 +113,6 @@ def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> Payme def get(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> PaymentMethodResponse: """ - Get payment method - Parameters: - entity_id: EntityId. @@ -157,7 +153,7 @@ def update( self, entity_id: EntityId, payment_method_id: PaymentMethodId, *, request: PaymentMethodUpdateRequest ) -> PaymentMethodResponse: """ - Update payment method. Only custom payment methods can be updated. + Only custom payment methods can be updated. Parameters: - entity_id: EntityId. @@ -200,8 +196,6 @@ def update( def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: """ - Delete payment method - Parameters: - entity_id: EntityId. @@ -238,7 +232,7 @@ def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> Non raise Unimplemented(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: + def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> PaymentMethodResponse: """ Initiate micro deposits for a bank account @@ -256,12 +250,12 @@ def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: Paymen headers=self._client_wrapper.get_headers(), 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 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PaymentMethodResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "PaymentMethodError": raise PaymentMethodError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore @@ -281,7 +275,7 @@ def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: Paymen def complete_micro_deposits( self, entity_id: EntityId, payment_method_id: PaymentMethodId, *, amounts: typing.List[int] - ) -> None: + ) -> PaymentMethodResponse: """ Complete micro deposit verification @@ -302,12 +296,12 @@ def complete_micro_deposits( headers=self._client_wrapper.get_headers(), 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 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PaymentMethodResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "PaymentMethodError": raise PaymentMethodError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore @@ -374,8 +368,6 @@ async def get_all( async def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> PaymentMethodResponse: """ - Create payment method - Parameters: - entity_id: EntityId. @@ -413,8 +405,6 @@ async def create(self, entity_id: EntityId, *, request: PaymentMethodRequest) -> async def get(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> PaymentMethodResponse: """ - Get payment method - Parameters: - entity_id: EntityId. @@ -455,7 +445,7 @@ async def update( self, entity_id: EntityId, payment_method_id: PaymentMethodId, *, request: PaymentMethodUpdateRequest ) -> PaymentMethodResponse: """ - Update payment method. Only custom payment methods can be updated. + Only custom payment methods can be updated. Parameters: - entity_id: EntityId. @@ -498,8 +488,6 @@ async def update( async def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> None: """ - Delete payment method - Parameters: - entity_id: EntityId. @@ -536,7 +524,9 @@ async def delete(self, entity_id: EntityId, payment_method_id: PaymentMethodId) raise Unimplemented(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: + async def initiate_micro_deposits( + self, entity_id: EntityId, payment_method_id: PaymentMethodId + ) -> PaymentMethodResponse: """ Initiate micro deposits for a bank account @@ -554,12 +544,12 @@ async def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: headers=self._client_wrapper.get_headers(), 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 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PaymentMethodResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "PaymentMethodError": raise PaymentMethodError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore @@ -579,7 +569,7 @@ async def initiate_micro_deposits(self, entity_id: EntityId, payment_method_id: async def complete_micro_deposits( self, entity_id: EntityId, payment_method_id: PaymentMethodId, *, amounts: typing.List[int] - ) -> None: + ) -> PaymentMethodResponse: """ Complete micro deposit verification @@ -600,12 +590,12 @@ async def complete_micro_deposits( headers=self._client_wrapper.get_headers(), 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 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PaymentMethodResponse, _response_json) # type: ignore if "errorName" in _response_json: if _response_json["errorName"] == "PaymentMethodError": raise PaymentMethodError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore diff --git a/src/mercoa/resources/entity/resources/representative/client.py b/src/mercoa/resources/entity/resources/representative/client.py index 1d7a828..5bace9c 100644 --- a/src/mercoa/resources/entity/resources/representative/client.py +++ b/src/mercoa/resources/entity/resources/representative/client.py @@ -68,8 +68,6 @@ def get_all(self, entity_id: EntityId) -> typing.List[RepresentativeResponse]: def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> RepresentativeResponse: """ - Create representative - Parameters: - entity_id: EntityId. @@ -113,8 +111,6 @@ def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> Repr def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> RepresentativeResponse: """ - Get representative - Parameters: - entity_id: EntityId. @@ -151,8 +147,6 @@ def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> Repre def delete(self, entity_id: EntityId, representative_id: RepresentativeId) -> None: """ - Delete representative - Parameters: - entity_id: EntityId. @@ -228,8 +222,6 @@ async def get_all(self, entity_id: EntityId) -> typing.List[RepresentativeRespon async def create(self, entity_id: EntityId, *, request: RepresentativeRequest) -> RepresentativeResponse: """ - Create representative - Parameters: - entity_id: EntityId. @@ -273,8 +265,6 @@ async def create(self, entity_id: EntityId, *, request: RepresentativeRequest) - async def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> RepresentativeResponse: """ - Get representative - Parameters: - entity_id: EntityId. @@ -311,8 +301,6 @@ async def get(self, entity_id: EntityId, representative_id: RepresentativeId) -> async def delete(self, entity_id: EntityId, representative_id: RepresentativeId) -> None: """ - Delete representative - Parameters: - entity_id: EntityId. diff --git a/src/mercoa/resources/entity/resources/user/client.py b/src/mercoa/resources/entity/resources/user/client.py index 99f72ba..0b3ca20 100644 --- a/src/mercoa/resources/entity/resources/user/client.py +++ b/src/mercoa/resources/entity/resources/user/client.py @@ -214,47 +214,9 @@ def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: raise Unimplemented(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: - """ - Get JWT token for entity user - - Parameters: - - entity_id: EntityId. - - - user_id: EntityUserId. - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/user/{user_id}/token"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: """ - Get JWT token for entity user with iFrame options + Generate a JWT token for an entity user with the given options. This token can be used to authenticate the entity and entity user in the Mercoa API and iFrame. Parameters: - entity_id: EntityId. @@ -482,47 +444,9 @@ async def delete(self, entity_id: EntityId, user_id: EntityUserId) -> None: raise Unimplemented(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: - """ - Get JWT token for entity user - - Parameters: - - entity_id: EntityId. - - - user_id: EntityUserId. - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"entity/{entity_id}/user/{user_id}/token"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(str, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "TokenGenerationFailed": - raise TokenGenerationFailed(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - 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"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: """ - Get JWT token for entity user with iFrame options + Generate a JWT token for an entity user with the given options. This token can be used to authenticate the entity and entity user in the Mercoa API and iFrame. Parameters: - entity_id: EntityId. 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 b7fa5fb..4eec790 100644 --- a/src/mercoa/resources/entity/resources/user/resources/notifications/client.py +++ b/src/mercoa/resources/entity/resources/user/resources/notifications/client.py @@ -43,8 +43,6 @@ def find( notification_type: typing.Union[typing.Optional[NotificationType], typing.List[NotificationType]], ) -> FindNotificationResponse: """ - Get all notifications - Parameters: - entity_id: EntityId. @@ -103,8 +101,6 @@ def find( def get(self, entity_id: EntityId, user_id: EntityUserId, notification_id: NotificationId) -> NotificationResponse: """ - Get notification - Parameters: - entity_id: EntityId. @@ -160,8 +156,6 @@ async def find( notification_type: typing.Union[typing.Optional[NotificationType], typing.List[NotificationType]], ) -> FindNotificationResponse: """ - Get all notifications - Parameters: - entity_id: EntityId. @@ -222,8 +216,6 @@ async def get( self, entity_id: EntityId, user_id: EntityUserId, notification_id: NotificationId ) -> NotificationResponse: """ - Get notification - Parameters: - entity_id: EntityId. diff --git a/src/mercoa/resources/entity_types/__init__.py b/src/mercoa/resources/entity_types/__init__.py index 916f4c4..ca65203 100644 --- a/src/mercoa/resources/entity_types/__init__.py +++ b/src/mercoa/resources/entity_types/__init__.py @@ -17,8 +17,8 @@ Ein, EntityAddPayeesRequest, EntityAddPayorsRequest, - EntityArchivePayeesRequest, - EntityArchivePayorsRequest, + EntityHidePayeesRequest, + EntityHidePayorsRequest, EntityId, EntityMetadataResponse, EntityOnboardingLinkType, @@ -81,10 +81,10 @@ "Ein", "EntityAddPayeesRequest", "EntityAddPayorsRequest", - "EntityArchivePayeesRequest", - "EntityArchivePayorsRequest", "EntityError", "EntityForeignIdAlreadyExists", + "EntityHidePayeesRequest", + "EntityHidePayorsRequest", "EntityId", "EntityMetadataResponse", "EntityOnboardingLinkType", diff --git a/src/mercoa/resources/entity_types/types/__init__.py b/src/mercoa/resources/entity_types/types/__init__.py index eec17ff..12c143f 100644 --- a/src/mercoa/resources/entity_types/types/__init__.py +++ b/src/mercoa/resources/entity_types/types/__init__.py @@ -16,8 +16,8 @@ from .ein import Ein from .entity_add_payees_request import EntityAddPayeesRequest from .entity_add_payors_request import EntityAddPayorsRequest -from .entity_archive_payees_request import EntityArchivePayeesRequest -from .entity_archive_payors_request import EntityArchivePayorsRequest +from .entity_hide_payees_request import EntityHidePayeesRequest +from .entity_hide_payors_request import EntityHidePayorsRequest from .entity_id import EntityId from .entity_metadata_response import EntityMetadataResponse from .entity_onboarding_link_type import EntityOnboardingLinkType @@ -73,8 +73,8 @@ "Ein", "EntityAddPayeesRequest", "EntityAddPayorsRequest", - "EntityArchivePayeesRequest", - "EntityArchivePayorsRequest", + "EntityHidePayeesRequest", + "EntityHidePayorsRequest", "EntityId", "EntityMetadataResponse", "EntityOnboardingLinkType", diff --git a/src/mercoa/resources/entity_types/types/approval_policy_request.py b/src/mercoa/resources/entity_types/types/approval_policy_request.py index a00b32f..3adda0e 100644 --- a/src/mercoa/resources/entity_types/types/approval_policy_request.py +++ b/src/mercoa/resources/entity_types/types/approval_policy_request.py @@ -15,7 +15,8 @@ class ApprovalPolicyRequest(pydantic.BaseModel): trigger: Trigger rule: Rule upstream_policy_id: ApprovalPolicyId = pydantic.Field( - alias="upstreamPolicyId", description="Use 'root' if no upstreamPolicyId is intended to be set." + alias="upstreamPolicyId", + description="The policy ID of the previous approval policy in the chain of policies. Use 'root' if no upstreamPolicyId is intended to be set.", ) def json(self, **kwargs: typing.Any) -> str: diff --git a/src/mercoa/resources/entity_types/types/business_profile_request.py b/src/mercoa/resources/entity_types/types/business_profile_request.py index 4e6668a..11957f8 100644 --- a/src/mercoa/resources/entity_types/types/business_profile_request.py +++ b/src/mercoa/resources/entity_types/types/business_profile_request.py @@ -26,8 +26,7 @@ class BusinessProfileRequest(pydantic.BaseModel): ) address: typing.Optional[Address] tax_id: typing.Optional[TaxId] = pydantic.Field( - alias="taxId", - description="Tax ID for the business. Currently only EIN is supported. Must be in the format XX-XXXXXXX.", + alias="taxId", description="Tax ID for the business. Currently only EIN is supported." ) formation_date: typing.Optional[dt.datetime] = pydantic.Field( alias="formationDate", description="Date of business formation" diff --git a/src/mercoa/resources/entity_types/types/business_profile_response.py b/src/mercoa/resources/entity_types/types/business_profile_response.py index 8c8e78d..455d081 100644 --- a/src/mercoa/resources/entity_types/types/business_profile_response.py +++ b/src/mercoa/resources/entity_types/types/business_profile_response.py @@ -20,7 +20,9 @@ class BusinessProfileResponse(pydantic.BaseModel): website: typing.Optional[str] description: typing.Optional[str] address: typing.Optional[Address] - owners_provided: typing.Optional[bool] = pydantic.Field(alias="ownersProvided") + owners_provided: typing.Optional[bool] = pydantic.Field( + alias="ownersProvided", description="True if all representatives have been provided for this business." + ) tax_id_provided: bool = pydantic.Field(alias="taxIDProvided") def json(self, **kwargs: typing.Any) -> str: diff --git a/src/mercoa/resources/entity_types/types/ein.py b/src/mercoa/resources/entity_types/types/ein.py index 8bce528..2d1652d 100644 --- a/src/mercoa/resources/entity_types/types/ein.py +++ b/src/mercoa/resources/entity_types/types/ein.py @@ -9,7 +9,7 @@ class Ein(pydantic.BaseModel): - number: str + number: str = pydantic.Field(description="Must be in the format XX-XXXXXXX.") 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/entity_types/types/entity_archive_payees_request.py b/src/mercoa/resources/entity_types/types/entity_hide_payees_request.py similarity index 89% rename from src/mercoa/resources/entity_types/types/entity_archive_payees_request.py rename to src/mercoa/resources/entity_types/types/entity_hide_payees_request.py index 8f4842a..1cede81 100644 --- a/src/mercoa/resources/entity_types/types/entity_archive_payees_request.py +++ b/src/mercoa/resources/entity_types/types/entity_hide_payees_request.py @@ -9,8 +9,8 @@ from .entity_id import EntityId -class EntityArchivePayeesRequest(pydantic.BaseModel): - payees: typing.List[EntityId] = pydantic.Field(description="List of payee entity IDs to archive") +class EntityHidePayeesRequest(pydantic.BaseModel): + payees: typing.List[EntityId] = pydantic.Field(description="List of payee entity IDs to hide") 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/entity_types/types/entity_archive_payors_request.py b/src/mercoa/resources/entity_types/types/entity_hide_payors_request.py similarity index 89% rename from src/mercoa/resources/entity_types/types/entity_archive_payors_request.py rename to src/mercoa/resources/entity_types/types/entity_hide_payors_request.py index 31e1c32..09ab5e3 100644 --- a/src/mercoa/resources/entity_types/types/entity_archive_payors_request.py +++ b/src/mercoa/resources/entity_types/types/entity_hide_payors_request.py @@ -9,8 +9,8 @@ from .entity_id import EntityId -class EntityArchivePayorsRequest(pydantic.BaseModel): - payors: typing.List[EntityId] = pydantic.Field(description="List of payor entity IDs to archive") +class EntityHidePayorsRequest(pydantic.BaseModel): + payors: typing.List[EntityId] = pydantic.Field(description="List of payor entity IDs to hide") 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/entity_types/types/entity_request.py b/src/mercoa/resources/entity_types/types/entity_request.py index 5ac0ef0..989fec8 100644 --- a/src/mercoa/resources/entity_types/types/entity_request.py +++ b/src/mercoa/resources/entity_types/types/entity_request.py @@ -11,9 +11,13 @@ class EntityRequest(pydantic.BaseModel): - foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId") + foreign_id: typing.Optional[str] = pydantic.Field( + alias="foreignId", + description="The ID used to identify this entity in your system. This ID must be unique across all entities in your system.", + ) email_to: typing.Optional[str] = pydantic.Field( - alias="emailTo", description="Email inbox address. Do not include the @domain.com" + alias="emailTo", + description="Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com", ) email_to_alias: typing.Optional[typing.List[str]] = pydantic.Field( alias="emailToAlias", @@ -25,13 +29,11 @@ class EntityRequest(pydantic.BaseModel): ) account_type: AccountType = pydantic.Field(alias="accountType") profile: ProfileRequest - is_payor: typing.Optional[bool] = pydantic.Field( - alias="isPayor", - description="If this entity will be paying invoices, set this to true. In the near future, this will be a required parameter. Currently if this parameter is not set, it will default to true if ownedByOrg is true, and false otherwise.", + is_payor: bool = pydantic.Field( + alias="isPayor", description="If this entity will be paying invoices, set this to true." ) - is_payee: typing.Optional[bool] = pydantic.Field( - alias="isPayee", - description="If this entity will be receiving payments, set this to true. In the near future, this will be a required parameter. Currently if this parameter is not set, it will default to false if ownedByOrg is true, and true otherwise.", + is_payee: bool = pydantic.Field( + alias="isPayee", description="If this entity will be receiving payments, set this to true." ) def json(self, **kwargs: typing.Any) -> str: diff --git a/src/mercoa/resources/entity_types/types/entity_response.py b/src/mercoa/resources/entity_types/types/entity_response.py index b4cf172..a198547 100644 --- a/src/mercoa/resources/entity_types/types/entity_response.py +++ b/src/mercoa/resources/entity_types/types/entity_response.py @@ -14,16 +14,28 @@ class EntityResponse(pydantic.BaseModel): id: EntityId - foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId") - email_to: typing.Optional[str] = pydantic.Field(alias="emailTo") - email_to_alias: typing.Optional[typing.List[str]] = pydantic.Field(alias="emailToAlias") - owned_by_org: bool = pydantic.Field(alias="ownedByOrg") - account_type: AccountType = pydantic.Field(alias="accountType") name: str email: str + foreign_id: typing.Optional[str] = pydantic.Field( + alias="foreignId", description="The ID used to identify this entity in your system" + ) + email_to: typing.Optional[str] = pydantic.Field( + alias="emailTo", + description="Local-part/username of the email address to which to send invoices to be added to the Invoice Inbox.", + ) + email_to_alias: typing.Optional[typing.List[str]] = pydantic.Field( + alias="emailToAlias", + description="Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias.", + ) + owned_by_org: bool = pydantic.Field( + alias="ownedByOrg", description="True if this entity has a direct relationship with your organization." + ) + account_type: AccountType = pydantic.Field(alias="accountType") profile: ProfileResponse status: EntityStatus - accepted_tos: bool = pydantic.Field(alias="acceptedTos") + accepted_tos: bool = pydantic.Field( + alias="acceptedTos", description="True if this entity has accepted the terms of service." + ) is_payor: bool = pydantic.Field(alias="isPayor", description="True if this entity can pay invoices.") is_payee: bool = pydantic.Field(alias="isPayee", description="True if this entity can receive payments.") created_at: dt.datetime = pydantic.Field(alias="createdAt") diff --git a/src/mercoa/resources/entity_types/types/entity_update_request.py b/src/mercoa/resources/entity_types/types/entity_update_request.py index 259fc3a..19f6c5d 100644 --- a/src/mercoa/resources/entity_types/types/entity_update_request.py +++ b/src/mercoa/resources/entity_types/types/entity_update_request.py @@ -11,9 +11,13 @@ class EntityUpdateRequest(pydantic.BaseModel): - foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId") + foreign_id: typing.Optional[str] = pydantic.Field( + alias="foreignId", + description="The ID used to identify this entity in your system. This ID must be unique across all entities in your system.", + ) email_to: typing.Optional[str] = pydantic.Field( - alias="emailTo", description="Email inbox address. Do not include the @domain.com" + alias="emailTo", + description="Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com", ) email_to_alias: typing.Optional[typing.List[str]] = pydantic.Field( alias="emailToAlias", diff --git a/src/mercoa/resources/entity_types/types/entity_user_request.py b/src/mercoa/resources/entity_types/types/entity_user_request.py index 7dc7769..055e1f0 100644 --- a/src/mercoa/resources/entity_types/types/entity_user_request.py +++ b/src/mercoa/resources/entity_types/types/entity_user_request.py @@ -9,7 +9,9 @@ class EntityUserRequest(pydantic.BaseModel): - foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId") + foreign_id: typing.Optional[str] = pydantic.Field( + alias="foreignId", description="The ID used to identify this user in your system." + ) email: typing.Optional[str] name: typing.Optional[str] roles: typing.Optional[typing.List[str]] = pydantic.Field( diff --git a/src/mercoa/resources/entity_types/types/entity_user_response.py b/src/mercoa/resources/entity_types/types/entity_user_response.py index 804e501..f48c48b 100644 --- a/src/mercoa/resources/entity_types/types/entity_user_response.py +++ b/src/mercoa/resources/entity_types/types/entity_user_response.py @@ -12,7 +12,7 @@ class EntityUserResponse(pydantic.BaseModel): id: EntityUserId foreign_id: typing.Optional[str] = pydantic.Field( - alias="foreignId", description="Id from external auth provider or your auth system" + alias="foreignId", description="The ID used to identify this user in your system." ) email: typing.Optional[str] name: typing.Optional[str] diff --git a/src/mercoa/resources/entity_types/types/profile_request.py b/src/mercoa/resources/entity_types/types/profile_request.py index dd600c4..24f3f56 100644 --- a/src/mercoa/resources/entity_types/types/profile_request.py +++ b/src/mercoa/resources/entity_types/types/profile_request.py @@ -11,8 +11,12 @@ class ProfileRequest(pydantic.BaseModel): - business: typing.Optional[BusinessProfileRequest] - individual: typing.Optional[IndividualProfileRequest] + business: typing.Optional[BusinessProfileRequest] = pydantic.Field( + description="If this entity is a business, set this field" + ) + individual: typing.Optional[IndividualProfileRequest] = pydantic.Field( + description="If this entity is a individual, set this field" + ) 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/entity_types/types/profile_response.py b/src/mercoa/resources/entity_types/types/profile_response.py index d2143d8..9f42718 100644 --- a/src/mercoa/resources/entity_types/types/profile_response.py +++ b/src/mercoa/resources/entity_types/types/profile_response.py @@ -11,8 +11,12 @@ class ProfileResponse(pydantic.BaseModel): - business: typing.Optional[BusinessProfileResponse] - individual: typing.Optional[IndividualProfileResponse] + business: typing.Optional[BusinessProfileResponse] = pydantic.Field( + description="Will be set if the entity is a business" + ) + individual: typing.Optional[IndividualProfileResponse] = pydantic.Field( + description="Will be set if the entity is a individual" + ) 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/entity_types/types/responsibilities.py b/src/mercoa/resources/entity_types/types/responsibilities.py index 8567f8a..7af0b60 100644 --- a/src/mercoa/resources/entity_types/types/responsibilities.py +++ b/src/mercoa/resources/entity_types/types/responsibilities.py @@ -10,9 +10,17 @@ class Responsibilities(pydantic.BaseModel): job_title: typing.Optional[str] = pydantic.Field(alias="jobTitle") - is_controller: typing.Optional[bool] = pydantic.Field(alias="isController") - is_owner: typing.Optional[bool] = pydantic.Field(alias="isOwner") - ownership_percentage: typing.Optional[float] = pydantic.Field(alias="ownershipPercentage") + is_controller: typing.Optional[bool] = pydantic.Field( + alias="isController", + description="Indicates whether this individual has significant management responsibilities within the business", + ) + is_owner: typing.Optional[bool] = pydantic.Field( + alias="isOwner", + description="Indicates whether this individual has an ownership stake of at least 25% in the business", + ) + ownership_percentage: typing.Optional[float] = pydantic.Field( + alias="ownershipPercentage", description="Percentage of ownership in the business. Must be between 0 and 100." + ) 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/client.py b/src/mercoa/resources/invoice/client.py index 0e93f71..eadbfce 100644 --- a/src/mercoa/resources/invoice/client.py +++ b/src/mercoa/resources/invoice/client.py @@ -23,6 +23,7 @@ from ..entity_types.types.entity_user_id import EntityUserId from ..invoice_types.errors.duplicate_invoice_number import DuplicateInvoiceNumber from ..invoice_types.errors.invoice_error import InvoiceError +from ..invoice_types.errors.invoice_query_error import InvoiceQueryError from ..invoice_types.errors.invoice_status_error import InvoiceStatusError from ..invoice_types.errors.vendor_not_found import VendorNotFound from ..invoice_types.types.find_invoice_response import FindInvoiceResponse @@ -57,6 +58,7 @@ def find( limit: typing.Optional[int] = None, starting_after: typing.Optional[InvoiceId] = None, search: typing.Optional[str] = None, + payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], 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]], @@ -66,7 +68,7 @@ def find( Search invoices for all entities in the organization Parameters: - - entity_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by entity ID. + - entity_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by the ID of the entity that created the invoice. - start_date: typing.Optional[dt.datetime]. Start date for invoice created on date filter. @@ -82,6 +84,8 @@ def find( - search: typing.Optional[str]. Filter vendors by name. Partial matches are supported. + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. @@ -103,6 +107,7 @@ def find( "limit": limit, "startingAfter": starting_after, "search": search, + "payerId": payer_id, "vendorId": vendor_id, "approverId": approver_id, "invoiceId": invoice_id, @@ -119,6 +124,8 @@ def find( if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() if _response_json["errorName"] == "AuthHeaderMalformedError": @@ -135,8 +142,6 @@ def find( def create(self, *, request: InvoiceRequest) -> InvoiceResponse: """ - Create invoice - Parameters: - request: InvoiceRequest. """ @@ -174,8 +179,6 @@ def create(self, *, request: InvoiceRequest) -> InvoiceResponse: def get(self, invoice_id: InvoiceId) -> InvoiceResponse: """ - Get invoice - Parameters: - invoice_id: InvoiceId. """ @@ -208,8 +211,6 @@ def get(self, invoice_id: InvoiceId) -> InvoiceResponse: def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceResponse: """ - Update invoice - Parameters: - invoice_id: InvoiceId. @@ -249,7 +250,7 @@ def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceRe def delete(self, invoice_id: InvoiceId) -> None: """ - Delete invoice. Only invoices in the DRAFT and NEW status can be deleted. + Only invoices in the DRAFT and NEW status can be deleted. Parameters: - invoice_id: InvoiceId. @@ -446,6 +447,7 @@ async def find( limit: typing.Optional[int] = None, starting_after: typing.Optional[InvoiceId] = None, search: typing.Optional[str] = None, + payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]], 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]], @@ -455,7 +457,7 @@ async def find( Search invoices for all entities in the organization Parameters: - - entity_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by entity ID. + - entity_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by the ID of the entity that created the invoice. - start_date: typing.Optional[dt.datetime]. Start date for invoice created on date filter. @@ -471,6 +473,8 @@ async def find( - search: typing.Optional[str]. Filter vendors by name. Partial matches are supported. + - payer_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by payer ID. + - vendor_id: typing.Union[typing.Optional[EntityId], typing.List[EntityId]]. Filter invoices by vendor ID. - approver_id: typing.Union[typing.Optional[EntityUserId], typing.List[EntityUserId]]. Filter invoices by assigned approver user ID. @@ -492,6 +496,7 @@ async def find( "limit": limit, "startingAfter": starting_after, "search": search, + "payerId": payer_id, "vendorId": vendor_id, "approverId": approver_id, "invoiceId": invoice_id, @@ -508,6 +513,8 @@ async def find( if 200 <= _response.status_code < 300: return pydantic.parse_obj_as(FindInvoiceResponse, _response_json) # type: ignore if "errorName" in _response_json: + if _response_json["errorName"] == "InvoiceQueryError": + raise InvoiceQueryError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore if _response_json["errorName"] == "AuthHeaderMissingError": raise AuthHeaderMissingError() if _response_json["errorName"] == "AuthHeaderMalformedError": @@ -524,8 +531,6 @@ async def find( async def create(self, *, request: InvoiceRequest) -> InvoiceResponse: """ - Create invoice - Parameters: - request: InvoiceRequest. """ @@ -563,8 +568,6 @@ async def create(self, *, request: InvoiceRequest) -> InvoiceResponse: async def get(self, invoice_id: InvoiceId) -> InvoiceResponse: """ - Get invoice - Parameters: - invoice_id: InvoiceId. """ @@ -597,8 +600,6 @@ async def get(self, invoice_id: InvoiceId) -> InvoiceResponse: async def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> InvoiceResponse: """ - Update invoice - Parameters: - invoice_id: InvoiceId. @@ -638,7 +639,7 @@ async def update(self, invoice_id: InvoiceId, *, request: InvoiceRequest) -> Inv async def delete(self, invoice_id: InvoiceId) -> None: """ - Delete invoice. Only invoices in the DRAFT and NEW status can be deleted. + Only invoices in the DRAFT and NEW status can be deleted. Parameters: - invoice_id: InvoiceId. diff --git a/src/mercoa/resources/invoice/resources/approval/client.py b/src/mercoa/resources/invoice/resources/approval/client.py index c2458ac..1bafd21 100644 --- a/src/mercoa/resources/invoice/resources/approval/client.py +++ b/src/mercoa/resources/invoice/resources/approval/client.py @@ -30,8 +30,6 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: """ - Approve invoice - Parameters: - invoice_id: InvoiceId. @@ -71,8 +69,6 @@ def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: """ - Reject invoice - Parameters: - invoice_id: InvoiceId. @@ -117,8 +113,6 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): async def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: """ - Approve invoice - Parameters: - invoice_id: InvoiceId. @@ -158,8 +152,6 @@ async def approve(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> N async def reject(self, invoice_id: InvoiceId, *, request: ApprovalRequest) -> None: """ - Reject invoice - Parameters: - invoice_id: InvoiceId. diff --git a/src/mercoa/resources/invoice/resources/comment/client.py b/src/mercoa/resources/invoice/resources/comment/client.py index 0bff215..6362eeb 100644 --- a/src/mercoa/resources/invoice/resources/comment/client.py +++ b/src/mercoa/resources/invoice/resources/comment/client.py @@ -101,8 +101,6 @@ def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> CommentRe def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResponse: """ - Get a comment on this invoice - Parameters: - invoice_id: InvoiceId. @@ -294,8 +292,6 @@ async def create(self, invoice_id: InvoiceId, *, request: CommentRequest) -> Com async def get(self, invoice_id: InvoiceId, comment_id: CommentId) -> CommentResponse: """ - Get a comment on this invoice - Parameters: - invoice_id: InvoiceId. diff --git a/src/mercoa/resources/invoice_types/__init__.py b/src/mercoa/resources/invoice_types/__init__.py index bc90796..9a595fc 100644 --- a/src/mercoa/resources/invoice_types/__init__.py +++ b/src/mercoa/resources/invoice_types/__init__.py @@ -22,7 +22,7 @@ InvoiceResponse, InvoiceStatus, ) -from .errors import DuplicateInvoiceNumber, InvoiceError, InvoiceStatusError, VendorNotFound +from .errors import DuplicateInvoiceNumber, InvoiceError, InvoiceQueryError, InvoiceStatusError, VendorNotFound __all__ = [ "ApprovalRequest", @@ -44,6 +44,7 @@ "InvoiceLineItemResponse", "InvoiceMetricsResponse", "InvoiceOrderByField", + "InvoiceQueryError", "InvoiceRequest", "InvoiceResponse", "InvoiceStatus", diff --git a/src/mercoa/resources/invoice_types/errors/__init__.py b/src/mercoa/resources/invoice_types/errors/__init__.py index 61a340f..4c07e5a 100644 --- a/src/mercoa/resources/invoice_types/errors/__init__.py +++ b/src/mercoa/resources/invoice_types/errors/__init__.py @@ -2,7 +2,8 @@ from .duplicate_invoice_number import DuplicateInvoiceNumber from .invoice_error import InvoiceError +from .invoice_query_error import InvoiceQueryError from .invoice_status_error import InvoiceStatusError from .vendor_not_found import VendorNotFound -__all__ = ["DuplicateInvoiceNumber", "InvoiceError", "InvoiceStatusError", "VendorNotFound"] +__all__ = ["DuplicateInvoiceNumber", "InvoiceError", "InvoiceQueryError", "InvoiceStatusError", "VendorNotFound"] diff --git a/src/mercoa/resources/invoice_types/errors/invoice_query_error.py b/src/mercoa/resources/invoice_types/errors/invoice_query_error.py new file mode 100644 index 0000000..14b7454 --- /dev/null +++ b/src/mercoa/resources/invoice_types/errors/invoice_query_error.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +from ....core.api_error import ApiError + + +class InvoiceQueryError(ApiError): + def __init__(self, body: str): + super().__init__(status_code=400, body=body) 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 d1c37a4..4f1b928 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 @@ -24,6 +24,9 @@ class InvoiceLineItemRequest(pydantic.BaseModel): 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.", ) + service_start_date: typing.Optional[dt.datetime] = pydantic.Field(alias="serviceStartDate") + service_end_date: typing.Optional[dt.datetime] = pydantic.Field(alias="serviceEndDate") + metadata: typing.Optional[typing.Dict[str, str]] 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 86e8045..6f284ae 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 @@ -19,6 +19,9 @@ class InvoiceLineItemResponse(pydantic.BaseModel): unit_price: typing.Optional[float] = pydantic.Field( alias="unitPrice", description="Unit price of line item in major units." ) + service_start_date: typing.Optional[dt.datetime] = pydantic.Field(alias="serviceStartDate") + service_end_date: typing.Optional[dt.datetime] = pydantic.Field(alias="serviceEndDate") + metadata: typing.Optional[typing.Dict[str, str]] 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_response.py b/src/mercoa/resources/invoice_types/types/invoice_response.py index d922cc1..b11f3d6 100644 --- a/src/mercoa/resources/invoice_types/types/invoice_response.py +++ b/src/mercoa/resources/invoice_types/types/invoice_response.py @@ -13,7 +13,6 @@ from ...payment_method_types.types.currency_code import CurrencyCode from ...payment_method_types.types.payment_method_id import PaymentMethodId from ...payment_method_types.types.payment_method_response import PaymentMethodResponse -from ...transaction.types.transaction_response import TransactionResponse from .approval_slot import ApprovalSlot from .comment_response import CommentResponse from .invoice_failure_type import InvoiceFailureType @@ -49,10 +48,14 @@ class InvoiceResponse(pydantic.BaseModel): vendor: typing.Optional[EntityResponse] payment_destination: typing.Optional[PaymentMethodResponse] = pydantic.Field(alias="paymentDestination") payment_destination_id: typing.Optional[PaymentMethodId] = pydantic.Field(alias="paymentDestinationId") - payment_destination_confirmed: bool = pydantic.Field(alias="paymentDestinationConfirmed") - has_documents: bool = pydantic.Field(alias="hasDocuments") + payment_destination_confirmed: bool = pydantic.Field( + alias="paymentDestinationConfirmed", + description="True if the payment destination has been confirmed by the vendor. False if the payment destination has been set (for example, a check to an address) but has not been confirmed by the vendor.", + ) + has_documents: bool = pydantic.Field( + alias="hasDocuments", description="True if the invoice has documents attached." + ) comments: typing.Optional[typing.List[CommentResponse]] - transactions: typing.Optional[typing.List[TransactionResponse]] line_items: typing.Optional[typing.List[InvoiceLineItemResponse]] = pydantic.Field(alias="lineItems") approvers: typing.List[ApprovalSlot] approval_policy: typing.List[ApprovalPolicyResponse] = pydantic.Field(alias="approvalPolicy") diff --git a/src/mercoa/resources/organization/client.py b/src/mercoa/resources/organization/client.py index edd9dde..c7f4b80 100644 --- a/src/mercoa/resources/organization/client.py +++ b/src/mercoa/resources/organization/client.py @@ -46,7 +46,7 @@ def get( metadata_schema: typing.Optional[bool] = None, ) -> OrganizationResponse: """ - Get current organization information + Get Parameters: - payment_methods: typing.Optional[bool]. include supported payment methods in response @@ -194,7 +194,7 @@ async def get( metadata_schema: typing.Optional[bool] = None, ) -> OrganizationResponse: """ - Get current organization information + Get Parameters: - payment_methods: typing.Optional[bool]. include supported payment methods in response diff --git a/src/mercoa/resources/organization_types/__init__.py b/src/mercoa/resources/organization_types/__init__.py index 342d801..3c82c9d 100644 --- a/src/mercoa/resources/organization_types/__init__.py +++ b/src/mercoa/resources/organization_types/__init__.py @@ -13,8 +13,8 @@ IndividualOnboardingOptions, InvoiceNotificationConfigurationRequest, InvoiceNotificationConfigurationResponse, - MetadataConditional, MetadataSchema, + MetadataShowConditions, MetadataType, NotificationConfigurationRequest, NotificationConfigurationRequest_Invoice, @@ -47,8 +47,8 @@ "IndividualOnboardingOptions", "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", - "MetadataConditional", "MetadataSchema", + "MetadataShowConditions", "MetadataType", "NotificationConfigurationRequest", "NotificationConfigurationRequest_Invoice", diff --git a/src/mercoa/resources/organization_types/types/__init__.py b/src/mercoa/resources/organization_types/types/__init__.py index 930ac45..b01ab99 100644 --- a/src/mercoa/resources/organization_types/types/__init__.py +++ b/src/mercoa/resources/organization_types/types/__init__.py @@ -12,8 +12,8 @@ from .individual_onboarding_options import IndividualOnboardingOptions from .invoice_notification_configuration_request import InvoiceNotificationConfigurationRequest from .invoice_notification_configuration_response import InvoiceNotificationConfigurationResponse -from .metadata_conditional import MetadataConditional from .metadata_schema import MetadataSchema +from .metadata_show_conditions import MetadataShowConditions from .metadata_type import MetadataType from .notification_configuration_request import ( NotificationConfigurationRequest, @@ -49,8 +49,8 @@ "IndividualOnboardingOptions", "InvoiceNotificationConfigurationRequest", "InvoiceNotificationConfigurationResponse", - "MetadataConditional", "MetadataSchema", + "MetadataShowConditions", "MetadataType", "NotificationConfigurationRequest", "NotificationConfigurationRequest_Invoice", diff --git a/src/mercoa/resources/organization_types/types/metadata_schema.py b/src/mercoa/resources/organization_types/types/metadata_schema.py index 4a70a25..1c25521 100644 --- a/src/mercoa/resources/organization_types/types/metadata_schema.py +++ b/src/mercoa/resources/organization_types/types/metadata_schema.py @@ -6,7 +6,7 @@ import pydantic from ....core.datetime_utils import serialize_datetime -from .metadata_conditional import MetadataConditional +from .metadata_show_conditions import MetadataShowConditions from .metadata_type import MetadataType @@ -19,8 +19,9 @@ class MetadataSchema(pydantic.BaseModel): alias="allowMultiple", description="Whether or not multiple values are allowed for this field. Defaults to false. If true, the value will be a list of the specified type.", ) - conditional: typing.Optional[MetadataConditional] = pydantic.Field( - description="A list of conditional rules that determine whether or not this field should be shown. The field will only be shown if all of the conditions are met. If no conditions are specified, the field will always be shown." + show_conditions: typing.Optional[MetadataShowConditions] = pydantic.Field( + alias="showConditions", + description="A list of conditional rules that determine whether or not this field should be shown. The field will only be shown if all of the conditions are met. If no conditions are specified, the field will always be shown.", ) def json(self, **kwargs: typing.Any) -> str: diff --git a/src/mercoa/resources/organization_types/types/metadata_conditional.py b/src/mercoa/resources/organization_types/types/metadata_show_conditions.py similarity index 90% rename from src/mercoa/resources/organization_types/types/metadata_conditional.py rename to src/mercoa/resources/organization_types/types/metadata_show_conditions.py index 8df5acf..a6efb64 100644 --- a/src/mercoa/resources/organization_types/types/metadata_conditional.py +++ b/src/mercoa/resources/organization_types/types/metadata_show_conditions.py @@ -9,7 +9,10 @@ from ...payment_method_types.types.payment_method_type import PaymentMethodType -class MetadataConditional(pydantic.BaseModel): +class MetadataShowConditions(pydantic.BaseModel): + has_options: typing.Optional[bool] = pydantic.Field( + alias="hasOptions", description="Show this field only if the entity has values set for the metadata key." + ) has_document: typing.Optional[bool] = pydantic.Field( alias="hasDocument", description="Show this field only if a document has been attached." ) diff --git a/src/mercoa/resources/organization_types/types/payment_methods_request.py b/src/mercoa/resources/organization_types/types/payment_methods_request.py index bb8559b..312a36a 100644 --- a/src/mercoa/resources/organization_types/types/payment_methods_request.py +++ b/src/mercoa/resources/organization_types/types/payment_methods_request.py @@ -10,9 +10,17 @@ class PaymentMethodsRequest(pydantic.BaseModel): - payer_payments: typing.List[PaymentRailRequest] = pydantic.Field(alias="payerPayments") - backup_disbursements: typing.List[PaymentRailRequest] = pydantic.Field(alias="backupDisbursements") - vendor_disbursements: typing.List[PaymentRailRequest] = pydantic.Field(alias="vendorDisbursements") + payer_payments: typing.List[PaymentRailRequest] = pydantic.Field( + alias="payerPayments", description="List of payment methods that can be used to pay invoices." + ) + backup_disbursements: typing.List[PaymentRailRequest] = pydantic.Field( + alias="backupDisbursements", + description="List of payment methods that can be created by a payor to send disbursements.", + ) + vendor_disbursements: typing.List[PaymentRailRequest] = pydantic.Field( + alias="vendorDisbursements", + description="List of payment methods that can be created by a payee to receive disbursements.", + ) 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/payment_methods_response.py b/src/mercoa/resources/organization_types/types/payment_methods_response.py index 4dfcf96..6ac68ae 100644 --- a/src/mercoa/resources/organization_types/types/payment_methods_response.py +++ b/src/mercoa/resources/organization_types/types/payment_methods_response.py @@ -10,9 +10,17 @@ class PaymentMethodsResponse(pydantic.BaseModel): - payer_payments: typing.List[PaymentRailResponse] = pydantic.Field(alias="payerPayments") - backup_disbursements: typing.List[PaymentRailResponse] = pydantic.Field(alias="backupDisbursements") - vendor_disbursements: typing.List[PaymentRailResponse] = pydantic.Field(alias="vendorDisbursements") + payer_payments: typing.List[PaymentRailResponse] = pydantic.Field( + alias="payerPayments", description="List of payment methods that can be used to pay invoices." + ) + backup_disbursements: typing.List[PaymentRailResponse] = pydantic.Field( + alias="backupDisbursements", + description="List of payment methods that can be created by a payor to send disbursements.", + ) + vendor_disbursements: typing.List[PaymentRailResponse] = pydantic.Field( + alias="vendorDisbursements", + description="List of payment methods that can be created by a payee to receive disbursements.", + ) 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/transaction/__init__.py b/src/mercoa/resources/transaction/__init__.py deleted file mode 100644 index e583f67..0000000 --- a/src/mercoa/resources/transaction/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .types import TransactionId, TransactionResponse, TransactionResponseExpanded, TransactionStatus - -__all__ = ["TransactionId", "TransactionResponse", "TransactionResponseExpanded", "TransactionStatus"] diff --git a/src/mercoa/resources/transaction/client.py b/src/mercoa/resources/transaction/client.py deleted file mode 100644 index a64ad99..0000000 --- a/src/mercoa/resources/transaction/client.py +++ /dev/null @@ -1,159 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -import urllib.parse -from json.decoder import JSONDecodeError - -import pydantic - -from ...core.api_error import ApiError -from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..commons.errors.auth_header_malformed_error import AuthHeaderMalformedError -from ..commons.errors.auth_header_missing_error import AuthHeaderMissingError -from ..commons.errors.forbidden import Forbidden -from ..commons.errors.not_found import NotFound -from ..commons.errors.unauthorized import Unauthorized -from ..commons.errors.unimplemented import Unimplemented -from .types.transaction_id import TransactionId -from .types.transaction_response import TransactionResponse -from .types.transaction_response_expanded import TransactionResponseExpanded - - -class TransactionClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def get_all(self) -> typing.List[TransactionResponseExpanded]: - """ - Get all transactions - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "transactions"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(typing.List[TransactionResponseExpanded], _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: - """ - Get Transaction - - Parameters: - - transaction_id: TransactionId. - """ - _response = self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"transaction/{transaction_id}"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(TransactionResponse, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncTransactionClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def get_all(self) -> typing.List[TransactionResponseExpanded]: - """ - Get all transactions - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "transactions"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(typing.List[TransactionResponseExpanded], _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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: - """ - Get Transaction - - Parameters: - - transaction_id: TransactionId. - """ - _response = await self._client_wrapper.httpx_client.request( - "GET", - urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"transaction/{transaction_id}"), - headers=self._client_wrapper.get_headers(), - timeout=60, - ) - try: - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - if 200 <= _response.status_code < 300: - return pydantic.parse_obj_as(TransactionResponse, _response_json) # type: ignore - if "errorName" in _response_json: - if _response_json["errorName"] == "AuthHeaderMissingError": - raise AuthHeaderMissingError() - if _response_json["errorName"] == "AuthHeaderMalformedError": - raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unauthorized": - raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Forbidden": - raise Forbidden(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "NotFound": - raise NotFound(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore - if _response_json["errorName"] == "Unimplemented": - raise Unimplemented(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/types/__init__.py b/src/mercoa/resources/transaction/types/__init__.py deleted file mode 100644 index bb45b63..0000000 --- a/src/mercoa/resources/transaction/types/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .transaction_id import TransactionId -from .transaction_response import TransactionResponse -from .transaction_response_expanded import TransactionResponseExpanded -from .transaction_status import TransactionStatus - -__all__ = ["TransactionId", "TransactionResponse", "TransactionResponseExpanded", "TransactionStatus"] diff --git a/src/mercoa/resources/transaction/types/transaction_id.py b/src/mercoa/resources/transaction/types/transaction_id.py deleted file mode 100644 index bf03c5f..0000000 --- a/src/mercoa/resources/transaction/types/transaction_id.py +++ /dev/null @@ -1,3 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -TransactionId = str diff --git a/src/mercoa/resources/transaction/types/transaction_response.py b/src/mercoa/resources/transaction/types/transaction_response.py deleted file mode 100644 index eb64d5f..0000000 --- a/src/mercoa/resources/transaction/types/transaction_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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 ...payment_method_types.types.currency_code import CurrencyCode -from .transaction_status import TransactionStatus - - -class TransactionResponse(pydantic.BaseModel): - id: str - status: TransactionStatus - amount: float - currency: typing.Optional[CurrencyCode] - created_at: dt.datetime = pydantic.Field(alias="createdAt") - updated_at: dt.datetime = pydantic.Field(alias="updatedAt") - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/transaction/types/transaction_response_expanded.py b/src/mercoa/resources/transaction/types/transaction_response_expanded.py deleted file mode 100644 index f21524f..0000000 --- a/src/mercoa/resources/transaction/types/transaction_response_expanded.py +++ /dev/null @@ -1,36 +0,0 @@ -# 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_types.types.entity_response import EntityResponse -from ...invoice_types.types.invoice_id import InvoiceId -from ...payment_method_types.types.payment_method_response import PaymentMethodResponse -from .transaction_response import TransactionResponse - - -class TransactionResponseExpanded(TransactionResponse): - invoice_id: InvoiceId = pydantic.Field(alias="invoiceId") - deduction_date: typing.Optional[dt.datetime] = pydantic.Field(alias="deductionDate") - due_date: typing.Optional[dt.datetime] = pydantic.Field(alias="dueDate") - payer: typing.Optional[EntityResponse] - vendor: typing.Optional[EntityResponse] - payment_source: typing.Optional[PaymentMethodResponse] = pydantic.Field(alias="paymentSource") - payment_destination: typing.Optional[PaymentMethodResponse] = pydantic.Field(alias="paymentDestination") - - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().json(**kwargs_with_defaults) - - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - return super().dict(**kwargs_with_defaults) - - class Config: - frozen = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/mercoa/resources/transaction/types/transaction_status.py b/src/mercoa/resources/transaction/types/transaction_status.py deleted file mode 100644 index 89cc04e..0000000 --- a/src/mercoa/resources/transaction/types/transaction_status.py +++ /dev/null @@ -1,41 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import enum -import typing - -T_Result = typing.TypeVar("T_Result") - - -class TransactionStatus(str, enum.Enum): - CREATED = "created" - PENDING = "pending" - COMPLETED = "completed" - FAILED = "failed" - REVERSED = "reversed" - QUEUED = "queued" - CANCELED = "canceled" - - def visit( - self, - created: typing.Callable[[], T_Result], - pending: typing.Callable[[], T_Result], - completed: typing.Callable[[], T_Result], - failed: typing.Callable[[], T_Result], - reversed: typing.Callable[[], T_Result], - queued: typing.Callable[[], T_Result], - canceled: typing.Callable[[], T_Result], - ) -> T_Result: - if self is TransactionStatus.CREATED: - return created() - if self is TransactionStatus.PENDING: - return pending() - if self is TransactionStatus.COMPLETED: - return completed() - if self is TransactionStatus.FAILED: - return failed() - if self is TransactionStatus.REVERSED: - return reversed() - if self is TransactionStatus.QUEUED: - return queued() - if self is TransactionStatus.CANCELED: - return canceled()