Skip to content

Commit

Permalink
Release v0.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 21, 2023
1 parent 4f04d90 commit f675f6a
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mercoa"
version = "v0.3.7"
version = "v0.3.8"
description = ""
readme = "README.md"
authors = []
Expand Down
8 changes: 8 additions & 0 deletions src/mercoa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
OrganizationId,
OrganizationRequest,
OrganizationResponse,
PaymentMethodBalanceResponse,
PaymentMethodBaseRequest,
PaymentMethodBaseResponse,
PaymentMethodError,
Expand All @@ -142,11 +143,13 @@
PaymentMethodRequest_Card,
PaymentMethodRequest_Check,
PaymentMethodRequest_Custom,
PaymentMethodRequest_OffPlatform,
PaymentMethodResponse,
PaymentMethodResponse_BankAccount,
PaymentMethodResponse_Card,
PaymentMethodResponse_Check,
PaymentMethodResponse_Custom,
PaymentMethodResponse_OffPlatform,
PaymentMethodSchemaField,
PaymentMethodSchemaFieldType,
PaymentMethodSchemaId,
Expand All @@ -158,6 +161,7 @@
PaymentMethodUpdateRequest_Card,
PaymentMethodUpdateRequest_Check,
PaymentMethodUpdateRequest_Custom,
PaymentMethodUpdateRequest_OffPlatform,
PaymentMethodsRequest,
PaymentMethodsResponse,
PaymentRailMarkup,
Expand Down Expand Up @@ -341,6 +345,7 @@
"OrganizationId",
"OrganizationRequest",
"OrganizationResponse",
"PaymentMethodBalanceResponse",
"PaymentMethodBaseRequest",
"PaymentMethodBaseResponse",
"PaymentMethodError",
Expand All @@ -350,11 +355,13 @@
"PaymentMethodRequest_Card",
"PaymentMethodRequest_Check",
"PaymentMethodRequest_Custom",
"PaymentMethodRequest_OffPlatform",
"PaymentMethodResponse",
"PaymentMethodResponse_BankAccount",
"PaymentMethodResponse_Card",
"PaymentMethodResponse_Check",
"PaymentMethodResponse_Custom",
"PaymentMethodResponse_OffPlatform",
"PaymentMethodSchemaField",
"PaymentMethodSchemaFieldType",
"PaymentMethodSchemaId",
Expand All @@ -366,6 +373,7 @@
"PaymentMethodUpdateRequest_Card",
"PaymentMethodUpdateRequest_Check",
"PaymentMethodUpdateRequest_Custom",
"PaymentMethodUpdateRequest_OffPlatform",
"PaymentMethodsRequest",
"PaymentMethodsResponse",
"PaymentRailMarkup",
Expand Down
2 changes: 1 addition & 1 deletion src/mercoa/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.7",
"X-Fern-SDK-Version": "v0.3.8",
}
headers["Authorization"] = f"Bearer {self._get_token()}"
return headers
Expand Down
8 changes: 8 additions & 0 deletions src/mercoa/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
CustomPaymentMethodRequest,
CustomPaymentMethodResponse,
CustomPaymentMethodUpdateRequest,
PaymentMethodBalanceResponse,
PaymentMethodBaseRequest,
PaymentMethodBaseResponse,
PaymentMethodError,
Expand All @@ -192,11 +193,13 @@
PaymentMethodRequest_Card,
PaymentMethodRequest_Check,
PaymentMethodRequest_Custom,
PaymentMethodRequest_OffPlatform,
PaymentMethodResponse,
PaymentMethodResponse_BankAccount,
PaymentMethodResponse_Card,
PaymentMethodResponse_Check,
PaymentMethodResponse_Custom,
PaymentMethodResponse_OffPlatform,
PaymentMethodSchemaField,
PaymentMethodSchemaFieldType,
PaymentMethodSchemaId,
Expand All @@ -208,6 +211,7 @@
PaymentMethodUpdateRequest_Card,
PaymentMethodUpdateRequest_Check,
PaymentMethodUpdateRequest_Custom,
PaymentMethodUpdateRequest_OffPlatform,
PlaidLinkRequest,
)

Expand Down Expand Up @@ -344,6 +348,7 @@
"OrganizationId",
"OrganizationRequest",
"OrganizationResponse",
"PaymentMethodBalanceResponse",
"PaymentMethodBaseRequest",
"PaymentMethodBaseResponse",
"PaymentMethodError",
Expand All @@ -353,11 +358,13 @@
"PaymentMethodRequest_Card",
"PaymentMethodRequest_Check",
"PaymentMethodRequest_Custom",
"PaymentMethodRequest_OffPlatform",
"PaymentMethodResponse",
"PaymentMethodResponse_BankAccount",
"PaymentMethodResponse_Card",
"PaymentMethodResponse_Check",
"PaymentMethodResponse_Custom",
"PaymentMethodResponse_OffPlatform",
"PaymentMethodSchemaField",
"PaymentMethodSchemaFieldType",
"PaymentMethodSchemaId",
Expand All @@ -369,6 +376,7 @@
"PaymentMethodUpdateRequest_Card",
"PaymentMethodUpdateRequest_Check",
"PaymentMethodUpdateRequest_Custom",
"PaymentMethodUpdateRequest_OffPlatform",
"PaymentMethodsRequest",
"PaymentMethodsResponse",
"PaymentRailMarkup",
Expand Down
85 changes: 85 additions & 0 deletions src/mercoa/resources/entity/resources/payment_method/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ....commons.errors.unimplemented import Unimplemented
from ....entity_types.types.entity_id import EntityId
from ....payment_method_types.errors.payment_method_error import PaymentMethodError
from ....payment_method_types.types.payment_method_balance_response import PaymentMethodBalanceResponse
from ....payment_method_types.types.payment_method_id import PaymentMethodId
from ....payment_method_types.types.payment_method_request import PaymentMethodRequest
from ....payment_method_types.types.payment_method_response import PaymentMethodResponse
Expand Down Expand Up @@ -324,6 +325,47 @@ def complete_micro_deposits(
raise Unimplemented(pydantic.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def get_balance(self, entity_id: EntityId, payment_method_id: PaymentMethodId) -> PaymentMethodBalanceResponse:
"""
Get the available balance of a payment method. Only bank accounts added with Plaid are supported.
Parameters:
- entity_id: EntityId.
- payment_method_id: PaymentMethodId.
"""
_response = self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/",
f"entity/{entity_id}/paymentMethod/{payment_method_id}/balance",
),
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(PaymentMethodBalanceResponse, _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
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 AsyncPaymentMethodClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
Expand Down Expand Up @@ -619,3 +661,46 @@ async def complete_micro_deposits(
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_balance(
self, entity_id: EntityId, payment_method_id: PaymentMethodId
) -> PaymentMethodBalanceResponse:
"""
Get the available balance of a payment method. Only bank accounts added with Plaid are supported.
Parameters:
- entity_id: EntityId.
- payment_method_id: PaymentMethodId.
"""
_response = await self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(
f"{self._client_wrapper.get_base_url()}/",
f"entity/{entity_id}/paymentMethod/{payment_method_id}/balance",
),
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(PaymentMethodBalanceResponse, _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
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)
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

class TokenGenerationInvoiceOptions(pydantic.BaseModel):
status: typing.List[InvoiceStatus]
mark_paid: typing.Optional[bool] = pydantic.Field(
alias="markPaid", description="If true, the user will be able to mark invoices as paid."
)

def json(self, **kwargs: typing.Any) -> str:
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
Expand All @@ -29,5 +26,4 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
class Config:
frozen = True
smart_union = True
allow_population_by_field_name = True
json_encoders = {dt.datetime: serialize_datetime}
8 changes: 8 additions & 0 deletions src/mercoa/resources/payment_method_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CustomPaymentMethodRequest,
CustomPaymentMethodResponse,
CustomPaymentMethodUpdateRequest,
PaymentMethodBalanceResponse,
PaymentMethodBaseRequest,
PaymentMethodBaseResponse,
PaymentMethodId,
Expand All @@ -24,11 +25,13 @@
PaymentMethodRequest_Card,
PaymentMethodRequest_Check,
PaymentMethodRequest_Custom,
PaymentMethodRequest_OffPlatform,
PaymentMethodResponse,
PaymentMethodResponse_BankAccount,
PaymentMethodResponse_Card,
PaymentMethodResponse_Check,
PaymentMethodResponse_Custom,
PaymentMethodResponse_OffPlatform,
PaymentMethodSchemaField,
PaymentMethodSchemaFieldType,
PaymentMethodSchemaId,
Expand All @@ -40,6 +43,7 @@
PaymentMethodUpdateRequest_Card,
PaymentMethodUpdateRequest_Check,
PaymentMethodUpdateRequest_Custom,
PaymentMethodUpdateRequest_OffPlatform,
PlaidLinkRequest,
)
from .errors import PaymentMethodError
Expand All @@ -60,6 +64,7 @@
"CustomPaymentMethodRequest",
"CustomPaymentMethodResponse",
"CustomPaymentMethodUpdateRequest",
"PaymentMethodBalanceResponse",
"PaymentMethodBaseRequest",
"PaymentMethodBaseResponse",
"PaymentMethodError",
Expand All @@ -69,11 +74,13 @@
"PaymentMethodRequest_Card",
"PaymentMethodRequest_Check",
"PaymentMethodRequest_Custom",
"PaymentMethodRequest_OffPlatform",
"PaymentMethodResponse",
"PaymentMethodResponse_BankAccount",
"PaymentMethodResponse_Card",
"PaymentMethodResponse_Check",
"PaymentMethodResponse_Custom",
"PaymentMethodResponse_OffPlatform",
"PaymentMethodSchemaField",
"PaymentMethodSchemaFieldType",
"PaymentMethodSchemaId",
Expand All @@ -85,5 +92,6 @@
"PaymentMethodUpdateRequest_Card",
"PaymentMethodUpdateRequest_Check",
"PaymentMethodUpdateRequest_Custom",
"PaymentMethodUpdateRequest_OffPlatform",
"PlaidLinkRequest",
]
8 changes: 8 additions & 0 deletions src/mercoa/resources/payment_method_types/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .custom_payment_method_request import CustomPaymentMethodRequest
from .custom_payment_method_response import CustomPaymentMethodResponse
from .custom_payment_method_update_request import CustomPaymentMethodUpdateRequest
from .payment_method_balance_response import PaymentMethodBalanceResponse
from .payment_method_base_request import PaymentMethodBaseRequest
from .payment_method_base_response import PaymentMethodBaseResponse
from .payment_method_id import PaymentMethodId
Expand All @@ -24,13 +25,15 @@
PaymentMethodRequest_Card,
PaymentMethodRequest_Check,
PaymentMethodRequest_Custom,
PaymentMethodRequest_OffPlatform,
)
from .payment_method_response import (
PaymentMethodResponse,
PaymentMethodResponse_BankAccount,
PaymentMethodResponse_Card,
PaymentMethodResponse_Check,
PaymentMethodResponse_Custom,
PaymentMethodResponse_OffPlatform,
)
from .payment_method_schema_field import PaymentMethodSchemaField
from .payment_method_schema_field_type import PaymentMethodSchemaFieldType
Expand All @@ -44,6 +47,7 @@
PaymentMethodUpdateRequest_Card,
PaymentMethodUpdateRequest_Check,
PaymentMethodUpdateRequest_Custom,
PaymentMethodUpdateRequest_OffPlatform,
)
from .plaid_link_request import PlaidLinkRequest

Expand All @@ -63,6 +67,7 @@
"CustomPaymentMethodRequest",
"CustomPaymentMethodResponse",
"CustomPaymentMethodUpdateRequest",
"PaymentMethodBalanceResponse",
"PaymentMethodBaseRequest",
"PaymentMethodBaseResponse",
"PaymentMethodId",
Expand All @@ -71,11 +76,13 @@
"PaymentMethodRequest_Card",
"PaymentMethodRequest_Check",
"PaymentMethodRequest_Custom",
"PaymentMethodRequest_OffPlatform",
"PaymentMethodResponse",
"PaymentMethodResponse_BankAccount",
"PaymentMethodResponse_Card",
"PaymentMethodResponse_Check",
"PaymentMethodResponse_Custom",
"PaymentMethodResponse_OffPlatform",
"PaymentMethodSchemaField",
"PaymentMethodSchemaFieldType",
"PaymentMethodSchemaId",
Expand All @@ -87,5 +94,6 @@
"PaymentMethodUpdateRequest_Card",
"PaymentMethodUpdateRequest_Check",
"PaymentMethodUpdateRequest_Custom",
"PaymentMethodUpdateRequest_OffPlatform",
"PlaidLinkRequest",
]
Loading

0 comments on commit f675f6a

Please sign in to comment.