Skip to content

Commit

Permalink
Release 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 1, 2023
1 parent 7f9e95d commit 95d3d9e
Show file tree
Hide file tree
Showing 46 changed files with 759 additions and 66 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mercoa"
version = "v0.2.6"
version = "v0.2.7"
description = ""
readme = "README.md"
authors = []
Expand All @@ -10,8 +10,8 @@ packages = [

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

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
26 changes: 26 additions & 0 deletions src/mercoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
FindInvoiceResponse,
FindNotificationResponse,
FullName,
GlobalNotificationConfigurationRequest,
IdentifierList,
IdentifierList_RolesList,
IdentifierList_UserList,
Expand All @@ -85,11 +86,17 @@
InvoiceLineItemRequest,
InvoiceLineItemResponse,
InvoiceMetricsResponse,
InvoiceNotificationConfigurationRequest,
InvoiceNotificationConfigurationResponse,
InvoiceOrderByField,
InvoiceRequest,
InvoiceResponse,
InvoiceStatus,
Itin,
NotificationConfigurationRequest,
NotificationConfigurationRequest_Invoice,
NotificationConfigurationResponse,
NotificationConfigurationResponse_Invoice,
NotificationId,
NotificationPolicyRequest,
NotificationPolicyResponse,
Expand Down Expand Up @@ -137,6 +144,11 @@
Rule_Approver,
Ssn,
TaxId,
TokenGenerationInvoiceOptions,
TokenGenerationOptions,
TokenGenerationPagesOptions,
TokenGenerationStyleOptions,
TokenGenerationVendorOptions,
TransactionId,
TransactionResponse,
TransactionResponseExpanded,
Expand All @@ -155,6 +167,7 @@
invoice_types,
ocr,
organization,
organization_types,
payment_method_schema,
payment_method_types,
transaction,
Expand Down Expand Up @@ -234,6 +247,7 @@
"FindInvoiceResponse",
"FindNotificationResponse",
"FullName",
"GlobalNotificationConfigurationRequest",
"IdentifierList",
"IdentifierList_RolesList",
"IdentifierList_UserList",
Expand All @@ -244,12 +258,18 @@
"InvoiceLineItemRequest",
"InvoiceLineItemResponse",
"InvoiceMetricsResponse",
"InvoiceNotificationConfigurationRequest",
"InvoiceNotificationConfigurationResponse",
"InvoiceOrderByField",
"InvoiceRequest",
"InvoiceResponse",
"InvoiceStatus",
"Itin",
"MercoaEnvironment",
"NotificationConfigurationRequest",
"NotificationConfigurationRequest_Invoice",
"NotificationConfigurationResponse",
"NotificationConfigurationResponse_Invoice",
"NotificationId",
"NotificationPolicyRequest",
"NotificationPolicyResponse",
Expand Down Expand Up @@ -297,6 +317,11 @@
"Rule_Approver",
"Ssn",
"TaxId",
"TokenGenerationInvoiceOptions",
"TokenGenerationOptions",
"TokenGenerationPagesOptions",
"TokenGenerationStyleOptions",
"TokenGenerationVendorOptions",
"TransactionId",
"TransactionResponse",
"TransactionResponseExpanded",
Expand All @@ -315,6 +340,7 @@
"invoice_types",
"ocr",
"organization",
"organization_types",
"payment_method_schema",
"payment_method_types",
"transaction",
Expand Down
4 changes: 2 additions & 2 deletions src/mercoa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCT
self._token = token
self.entity = EntityClient(environment=self._environment, token=self._token)
self.invoice = InvoiceClient(environment=self._environment, token=self._token)
self.organization = OrganizationClient(environment=self._environment, token=self._token)
self.bank_lookup = BankLookupClient(environment=self._environment, token=self._token)
self.ocr = OcrClient(environment=self._environment, token=self._token)
self.organization = OrganizationClient(environment=self._environment, token=self._token)
self.payment_method_schema = PaymentMethodSchemaClient(environment=self._environment, token=self._token)
self.transaction = TransactionClient(environment=self._environment, token=self._token)

Expand All @@ -29,8 +29,8 @@ def __init__(self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCT
self._token = token
self.entity = AsyncEntityClient(environment=self._environment, token=self._token)
self.invoice = AsyncInvoiceClient(environment=self._environment, token=self._token)
self.organization = AsyncOrganizationClient(environment=self._environment, token=self._token)
self.bank_lookup = AsyncBankLookupClient(environment=self._environment, token=self._token)
self.ocr = AsyncOcrClient(environment=self._environment, token=self._token)
self.organization = AsyncOrganizationClient(environment=self._environment, token=self._token)
self.payment_method_schema = AsyncPaymentMethodSchemaClient(environment=self._environment, token=self._token)
self.transaction = AsyncTransactionClient(environment=self._environment, token=self._token)
31 changes: 29 additions & 2 deletions src/mercoa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
invoice_types,
ocr,
organization,
organization_types,
payment_method_schema,
payment_method_types,
transaction,
Expand Down Expand Up @@ -71,10 +72,16 @@
Rule,
Rule_Approver,
TaxId,
TokenGenerationInvoiceOptions,
TokenGenerationOptions,
TokenGenerationPagesOptions,
TokenGenerationStyleOptions,
TokenGenerationVendorOptions,
Trigger,
Trigger_All,
Trigger_Amount,
UserNotificationPolicyResponse,
VendorNetwork,
)
from .invoice_types import (
ApprovalRequest,
Expand All @@ -97,8 +104,8 @@
InvoiceResponse,
InvoiceStatus,
)
from .ocr import OcrResponse, VendorNetwork
from .organization import (
from .ocr import OcrResponse
from .organization_types import (
ColorSchemeRequest,
ColorSchemeResponse,
EmailLogResponse,
Expand All @@ -107,6 +114,13 @@
EmailSenderProvider,
EmailSenderRequest,
EmailSenderResponse,
GlobalNotificationConfigurationRequest,
InvoiceNotificationConfigurationRequest,
InvoiceNotificationConfigurationResponse,
NotificationConfigurationRequest,
NotificationConfigurationRequest_Invoice,
NotificationConfigurationResponse,
NotificationConfigurationResponse_Invoice,
OrganizationId,
OrganizationRequest,
OrganizationResponse,
Expand Down Expand Up @@ -238,6 +252,7 @@
"FindInvoiceResponse",
"FindNotificationResponse",
"FullName",
"GlobalNotificationConfigurationRequest",
"IdentifierList",
"IdentifierList_RolesList",
"IdentifierList_UserList",
Expand All @@ -248,11 +263,17 @@
"InvoiceLineItemRequest",
"InvoiceLineItemResponse",
"InvoiceMetricsResponse",
"InvoiceNotificationConfigurationRequest",
"InvoiceNotificationConfigurationResponse",
"InvoiceOrderByField",
"InvoiceRequest",
"InvoiceResponse",
"InvoiceStatus",
"Itin",
"NotificationConfigurationRequest",
"NotificationConfigurationRequest_Invoice",
"NotificationConfigurationResponse",
"NotificationConfigurationResponse_Invoice",
"NotificationId",
"NotificationPolicyRequest",
"NotificationPolicyResponse",
Expand Down Expand Up @@ -300,6 +321,11 @@
"Rule_Approver",
"Ssn",
"TaxId",
"TokenGenerationInvoiceOptions",
"TokenGenerationOptions",
"TokenGenerationPagesOptions",
"TokenGenerationStyleOptions",
"TokenGenerationVendorOptions",
"TransactionId",
"TransactionResponse",
"TransactionResponseExpanded",
Expand All @@ -318,6 +344,7 @@
"invoice_types",
"ocr",
"organization",
"organization_types",
"payment_method_schema",
"payment_method_types",
"transaction",
Expand Down
56 changes: 54 additions & 2 deletions src/mercoa/resources/entity/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..entity_types.types.entity_status import EntityStatus
from ..entity_types.types.entity_update_request import EntityUpdateRequest
from ..entity_types.types.find_entity_response import FindEntityResponse
from ..entity_types.types.token_generation_options import TokenGenerationOptions
from .resources.approval_policy.client import ApprovalPolicyClient, AsyncApprovalPolicyClient
from .resources.counterparty.client import AsyncCounterpartyClient, CounterpartyClient
from .resources.invoice.client import AsyncInvoiceClient, InvoiceClient
Expand Down Expand Up @@ -258,7 +259,7 @@ def initiate_kyb(self, entity_id: EntityId) -> None:
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def get_token(self, entity_id: EntityId) -> str:
def get_raw_token(self, entity_id: EntityId) -> str:
_response = httpx.request(
"GET",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/token"),
Expand All @@ -282,6 +283,31 @@ def get_token(self, entity_id: EntityId) -> str:
raise Unauthorized(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:
_response = httpx.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/token"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(str, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
if _response_json["errorName"] == "AuthHeaderMalformedError":
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unauthorized":
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def plaid_link_token(self, entity_id: EntityId) -> str:
_response = httpx.request(
"GET",
Expand Down Expand Up @@ -592,7 +618,7 @@ async def initiate_kyb(self, entity_id: EntityId) -> None:
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def get_token(self, entity_id: EntityId) -> str:
async def get_raw_token(self, entity_id: EntityId) -> str:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"GET",
Expand All @@ -617,6 +643,32 @@ async def get_token(self, entity_id: EntityId) -> str:
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def get_token(self, entity_id: EntityId, *, request: TokenGenerationOptions) -> str:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", f"entity/{entity_id}/token"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
timeout=60,
)
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(str, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "AuthHeaderMissingError":
raise AuthHeaderMissingError()
if _response_json["errorName"] == "AuthHeaderMalformedError":
raise AuthHeaderMalformedError(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unauthorized":
raise Unauthorized(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def plaid_link_token(self, entity_id: EntityId) -> str:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
Expand Down
Loading

0 comments on commit 95d3d9e

Please sign in to comment.