Skip to content

Commit

Permalink
Release v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed May 19, 2023
1 parent 29ac931 commit 1225aa3
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[tool.poetry]
name = "mercoa"
version = "v0.0.8"
version = "v0.0.9"
description = ""
authors = []
packages = [
Expand All @@ -10,10 +10,10 @@ packages = [

[tool.poetry.dependencies]
python = "^3.7"
backports-cached_property = "1.0.2"
httpx = "0.23.3"
types-backports = "0.1.3"
pydantic = "^1.9.2"
backports-cached_property = "1.0.2"
types-backports = "0.1.3"

[tool.poetry.dev-dependencies]
mypy = "0.971"
Expand Down
6 changes: 6 additions & 0 deletions src/mercoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
PaymentRailRequest,
PaymentRailResponse,
PhoneNumber,
ProcessInvoiceRequest,
ProfileRequest,
ProfileResponse,
RepresentativeId,
Expand All @@ -96,6 +97,7 @@
TaxID,
TransactionId,
TransactionResponse,
TransactionResponseExpanded,
TransactionStatus,
UnauthorizedError,
bank_lookup,
Expand All @@ -108,6 +110,7 @@
organization,
payment_method,
payment_method_schema,
process_invoice,
representative,
transaction,
)
Expand Down Expand Up @@ -198,6 +201,7 @@
"PaymentRailRequest",
"PaymentRailResponse",
"PhoneNumber",
"ProcessInvoiceRequest",
"ProfileRequest",
"ProfileResponse",
"RepresentativeId",
Expand All @@ -208,6 +212,7 @@
"TaxID",
"TransactionId",
"TransactionResponse",
"TransactionResponseExpanded",
"TransactionStatus",
"UnauthorizedError",
"bank_lookup",
Expand All @@ -220,6 +225,7 @@
"organization",
"payment_method",
"payment_method_schema",
"process_invoice",
"representative",
"transaction",
]
9 changes: 9 additions & 0 deletions src/mercoa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .resources.organization.client import AsyncOrganizationClient, OrganizationClient
from .resources.payment_method.client import AsyncPaymentMethodClient, PaymentMethodClient
from .resources.payment_method_schema.client import AsyncPaymentMethodSchemaClient, PaymentMethodSchemaClient
from .resources.process_invoice.client import AsyncProcessInvoiceClient, ProcessInvoiceClient
from .resources.representative.client import AsyncRepresentativeClient, RepresentativeClient
from .resources.transaction.client import AsyncTransactionClient, TransactionClient

Expand Down Expand Up @@ -61,6 +62,10 @@ def payment_method_schema(self) -> PaymentMethodSchemaClient:
def payment_method(self) -> PaymentMethodClient:
return PaymentMethodClient(environment=self._environment, token=self._token)

@cached_property
def process_invoice(self) -> ProcessInvoiceClient:
return ProcessInvoiceClient(environment=self._environment, token=self._token)

@cached_property
def representative(self) -> RepresentativeClient:
return RepresentativeClient(environment=self._environment, token=self._token)
Expand Down Expand Up @@ -113,6 +118,10 @@ def payment_method_schema(self) -> AsyncPaymentMethodSchemaClient:
def payment_method(self) -> AsyncPaymentMethodClient:
return AsyncPaymentMethodClient(environment=self._environment, token=self._token)

@cached_property
def process_invoice(self) -> AsyncProcessInvoiceClient:
return AsyncProcessInvoiceClient(environment=self._environment, token=self._token)

@cached_property
def representative(self) -> AsyncRepresentativeClient:
return AsyncRepresentativeClient(environment=self._environment, token=self._token)
Expand Down
7 changes: 6 additions & 1 deletion src/mercoa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
organization,
payment_method,
payment_method_schema,
process_invoice,
representative,
transaction,
)
Expand Down Expand Up @@ -99,8 +100,9 @@
PaymentMethodSchemaRequest,
PaymentMethodSchemaResponse,
)
from .process_invoice import ProcessInvoiceRequest
from .representative import RepresentativeId, RepresentativeRequest, RepresentativeResponse, Responsibilities
from .transaction import TransactionId, TransactionResponse, TransactionStatus
from .transaction import TransactionId, TransactionResponse, TransactionResponseExpanded, TransactionStatus

__all__ = [
"AccountType",
Expand Down Expand Up @@ -187,6 +189,7 @@
"PaymentRailRequest",
"PaymentRailResponse",
"PhoneNumber",
"ProcessInvoiceRequest",
"ProfileRequest",
"ProfileResponse",
"RepresentativeId",
Expand All @@ -197,6 +200,7 @@
"TaxID",
"TransactionId",
"TransactionResponse",
"TransactionResponseExpanded",
"TransactionStatus",
"UnauthorizedError",
"bank_lookup",
Expand All @@ -209,6 +213,7 @@
"organization",
"payment_method",
"payment_method_schema",
"process_invoice",
"representative",
"transaction",
]
21 changes: 19 additions & 2 deletions src/mercoa/resources/entity/types/entity_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,34 @@
class EntityRequest(pydantic.BaseModel):
foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId")
email_to: typing.Optional[str] = pydantic.Field(
alias="emailTo", description=("Email inbox address. Do not inclue the @domain.com\n")
alias="emailTo", description=("Email inbox address. Do not include the @domain.com\n")
)
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. Include the full email address.\n"
),
)
owned_by_org: typing.Optional[bool] = pydantic.Field(alias="ownedByOrg")
owned_by_org: typing.Optional[bool] = pydantic.Field(
alias="ownedByOrg",
description=(
"If this entity has a direct relationship with your organization, set this to true. Otherwise, set to false.\n"
),
)
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.\n"
),
)
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.\n"
),
)

def json(self, **kwargs: typing.Any) -> str:
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/resources/entity/types/entity_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class EntityResponse(pydantic.BaseModel):
profile: ProfileResponse
status: EntityStatus
accepted_tos: bool = pydantic.Field(alias="acceptedTos")
is_payor: bool = pydantic.Field(alias="isPayor", description=("True if this entity can pay invoices.\n"))
is_payee: bool = pydantic.Field(alias="isPayee", description=("True if this entity can receive payments.\n"))
created_at: dt.datetime = pydantic.Field(alias="createdAt")
updated_at: dt.datetime = pydantic.Field(alias="updatedAt")

Expand Down
15 changes: 13 additions & 2 deletions src/mercoa/resources/entity/types/entity_update_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@
class EntityUpdateRequest(pydantic.BaseModel):
foreign_id: typing.Optional[str] = pydantic.Field(alias="foreignId")
email_to: typing.Optional[str] = pydantic.Field(
alias="emailTo", description=("Email inbox address. Do not inclue the @domain.com\n")
alias="emailTo", description=("Email inbox address. Do not include the @domain.com\n")
)
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. Include the full email address.\n"
),
)
owned_by_org: typing.Optional[bool] = pydantic.Field(alias="ownedByOrg")
owned_by_org: typing.Optional[bool] = pydantic.Field(
alias="ownedByOrg",
description=(
"If this entity has a direct relationship with your organization, set this to true. Otherwise, set to false.\n"
),
)
account_type: typing.Optional[AccountType] = pydantic.Field(alias="accountType")
profile: typing.Optional[ProfileRequest]
is_payor: typing.Optional[bool] = pydantic.Field(
alias="isPayor", description=("If this entity will be paying invoices, set this to true.\n")
)
is_payee: typing.Optional[bool] = pydantic.Field(
alias="isPayee", description=("If this entity will be receiving payments, set this to true.\n")
)

def json(self, **kwargs: typing.Any) -> str:
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
Expand Down
4 changes: 4 additions & 0 deletions src/mercoa/resources/invoice/types/invoice_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class InvoiceStatus(str, enum.Enum):
REFUSED = "REFUSED"
APPROVED = "APPROVED"
ARCHIVED = "ARCHIVED"
SCHEDULED = "SCHEDULED"

def visit(
self,
Expand All @@ -26,6 +27,7 @@ def visit(
refused: typing.Callable[[], T_Result],
approved: typing.Callable[[], T_Result],
archived: typing.Callable[[], T_Result],
scheduled: typing.Callable[[], T_Result],
) -> T_Result:
if self is InvoiceStatus.DRAFT:
return draft()
Expand All @@ -43,3 +45,5 @@ def visit(
return approved()
if self is InvoiceStatus.ARCHIVED:
return archived()
if self is InvoiceStatus.SCHEDULED:
return scheduled()
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pydantic

from ....core.datetime_utils import serialize_datetime
from ...invoice.types.currency_code import CurrencyCode
from .bank_account_response import BankAccountResponse
from .card_response import CardResponse
from .check_response import CheckResponse
Expand All @@ -21,6 +22,7 @@ class PaymentMethodResponse(pydantic.BaseModel):
check: typing.Optional[CheckResponse]
card: typing.Optional[CardResponse]
custom: typing.Optional[CustomPaymentMethodResponse]
supported_currencies: typing.List[CurrencyCode] = pydantic.Field(alias="supportedCurrencies")
created_at: dt.datetime = pydantic.Field(alias="createdAt")
updated_at: dt.datetime = pydantic.Field(alias="updatedAt")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pydantic

from ....core.datetime_utils import serialize_datetime
from ...invoice.types.currency_code import CurrencyCode
from .payment_method_schema_field import PaymentMethodSchemaField


Expand All @@ -17,6 +18,12 @@ class PaymentMethodSchemaRequest(pydantic.BaseModel):
is_destination: bool = pydantic.Field(
alias="isDestination", description=("This payment method can be used as a payment destination for an invoice\n")
)
supported_currencies: typing.Optional[typing.List[CurrencyCode]] = pydantic.Field(
alias="supportedCurrencies",
description=(
"List of currencies that this payment method supports. If not provided, the payment method will support only USD.\n"
),
)
fields: typing.List[PaymentMethodSchemaField]

def json(self, **kwargs: typing.Any) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pydantic

from ....core.datetime_utils import serialize_datetime
from ...invoice.types.currency_code import CurrencyCode
from .payment_method_schema_field import PaymentMethodSchemaField
from .payment_method_schema_id import PaymentMethodSchemaId

Expand All @@ -19,6 +20,9 @@ class PaymentMethodSchemaResponse(pydantic.BaseModel):
is_destination: bool = pydantic.Field(
alias="isDestination", description=("This payment method can be used as a payment destination for an invoice\n")
)
supported_currencies: typing.List[CurrencyCode] = pydantic.Field(
alias="supportedCurrencies", description=("List of currencies that this payment method supports.\n")
)
fields: typing.List[PaymentMethodSchemaField]
created_at: dt.datetime = pydantic.Field(alias="createdAt")
updated_at: dt.datetime = pydantic.Field(alias="updatedAt")
Expand Down
5 changes: 5 additions & 0 deletions src/mercoa/resources/process_invoice/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

from .types import ProcessInvoiceRequest

__all__ = ["ProcessInvoiceRequest"]
64 changes: 64 additions & 0 deletions src/mercoa/resources/process_invoice/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file was auto-generated by Fern from our API Definition.

import typing
import urllib.parse
from json.decoder import JSONDecodeError

import httpx

from ...core.api_error import ApiError
from ...core.jsonable_encoder import jsonable_encoder
from ...core.remove_none_from_headers import remove_none_from_headers
from ...environment import MercoaEnvironment
from .types.process_invoice_request import ProcessInvoiceRequest


class ProcessInvoiceClient:
def __init__(
self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: typing.Optional[str] = None
):
self._environment = environment
self._token = token

def process_invoices(self, *, request: ProcessInvoiceRequest) -> None:
_response = httpx.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", "process-invoices"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
)
if 200 <= _response.status_code < 300:
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncProcessInvoiceClient:
def __init__(
self, *, environment: MercoaEnvironment = MercoaEnvironment.PRODUCTION, token: typing.Optional[str] = None
):
self._environment = environment
self._token = token

async def process_invoices(self, *, request: ProcessInvoiceRequest) -> None:
async with httpx.AsyncClient() as _client:
_response = await _client.request(
"POST",
urllib.parse.urljoin(f"{self._environment.value}/", "process-invoices"),
json=jsonable_encoder(request),
headers=remove_none_from_headers(
{"Authorization": f"Bearer {self._token}" if self._token is not None else None}
),
)
if 200 <= _response.status_code < 300:
return
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
5 changes: 5 additions & 0 deletions src/mercoa/resources/process_invoice/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

from .process_invoice_request import ProcessInvoiceRequest

__all__ = ["ProcessInvoiceRequest"]
Loading

0 comments on commit 1225aa3

Please sign in to comment.