Skip to content

Commit

Permalink
Release v0.3.39
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jun 4, 2024
1 parent 796090f commit b53648d
Show file tree
Hide file tree
Showing 12 changed files with 211 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.38"
version = "v0.3.39"
description = ""
readme = "README.md"
authors = []
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 @@ -23,7 +23,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.38",
"X-Fern-SDK-Version": "v0.3.39",
}
headers["Authorization"] = f"Bearer {self._get_token()}"
return headers
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/entity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ExternalAccountingSystemCompanyCreationRequest_Rutter,
ExternalAccountingSystemCompanyResponse,
ExternalAccountingSystemCompanyResponse_Codat,
ExternalAccountingSystemCompanyResponse_None,
ExternalAccountingSystemCompanyResponse_Rutter,
RutterCompanyCreationRequest,
RutterCompanyResponse,
Expand All @@ -35,6 +36,7 @@
"ExternalAccountingSystemCompanyCreationRequest_Rutter",
"ExternalAccountingSystemCompanyResponse",
"ExternalAccountingSystemCompanyResponse_Codat",
"ExternalAccountingSystemCompanyResponse_None",
"ExternalAccountingSystemCompanyResponse_Rutter",
"RutterCompanyCreationRequest",
"RutterCompanyResponse",
Expand Down
2 changes: 2 additions & 0 deletions src/mercoa/entity/external_accounting_system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ExternalAccountingSystemCompanyCreationRequest_Rutter,
ExternalAccountingSystemCompanyResponse,
ExternalAccountingSystemCompanyResponse_Codat,
ExternalAccountingSystemCompanyResponse_None,
ExternalAccountingSystemCompanyResponse_Rutter,
RutterCompanyCreationRequest,
RutterCompanyResponse,
Expand All @@ -22,6 +23,7 @@
"ExternalAccountingSystemCompanyCreationRequest_Rutter",
"ExternalAccountingSystemCompanyResponse",
"ExternalAccountingSystemCompanyResponse_Codat",
"ExternalAccountingSystemCompanyResponse_None",
"ExternalAccountingSystemCompanyResponse_Rutter",
"RutterCompanyCreationRequest",
"RutterCompanyResponse",
Expand Down
120 changes: 116 additions & 4 deletions src/mercoa/entity/external_accounting_system/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,62 @@ class ExternalAccountingSystemClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._client_wrapper = client_wrapper

def get(
self, entity_id: EntityId, *, request_options: typing.Optional[RequestOptions] = None
) -> ExternalAccountingSystemCompanyResponse:
"""
Get the external accounting system connected to an entity
Parameters
----------
entity_id : EntityId
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
ExternalAccountingSystemCompanyResponse
Examples
--------
from mercoa.client import Mercoa
client = Mercoa(
token="YOUR_TOKEN",
)
client.entity.external_accounting_system.get(
entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"entity/{jsonable_encoder(entity_id)}/external-accounting-system",
method="GET",
request_options=request_options,
)
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_v1.parse_obj_as(ExternalAccountingSystemCompanyResponse, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "BadRequest":
raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unauthorized":
raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Forbidden":
raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "NotFound":
raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Conflict":
raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "InternalServerError":
raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unimplemented":
raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

def create(
self,
entity_id: EntityId,
Expand All @@ -36,7 +92,7 @@ def create(
request_options: typing.Optional[RequestOptions] = None,
) -> ExternalAccountingSystemCompanyResponse:
"""
Create/Link an entity to an external accounting system like Codat or Rutter
Create/Link an entity to an external accounting system like Codat or Rutter. If the entity is already linked to an external accounting system, this will return the existing connection.
Parameters
----------
Expand Down Expand Up @@ -170,7 +226,7 @@ def sync(
Sync vendors from external accounting system. Default is to pull vendors from external system.
bills : typing.Optional[SyncType]
Sync bills from external accounting system. Default is to not sync bills.
Sync bills from external accounting system. Default is to not sync bills. Invoices that already exist in both systems will not be updated, only new invoices not present in the other system will be created.
gl_accounts : typing.Optional[SyncType]
Sync GL accounts from external accounting system. Default is to pull GL accounts from external system. Pushing GL accounts is not supported.
Expand Down Expand Up @@ -230,6 +286,62 @@ class AsyncExternalAccountingSystemClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._client_wrapper = client_wrapper

async def get(
self, entity_id: EntityId, *, request_options: typing.Optional[RequestOptions] = None
) -> ExternalAccountingSystemCompanyResponse:
"""
Get the external accounting system connected to an entity
Parameters
----------
entity_id : EntityId
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
ExternalAccountingSystemCompanyResponse
Examples
--------
from mercoa.client import AsyncMercoa
client = AsyncMercoa(
token="YOUR_TOKEN",
)
await client.entity.external_accounting_system.get(
entity_id="ent_8545a84e-a45f-41bf-bdf1-33b42a55812c",
)
"""
_response = await self._client_wrapper.httpx_client.request(
f"entity/{jsonable_encoder(entity_id)}/external-accounting-system",
method="GET",
request_options=request_options,
)
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_v1.parse_obj_as(ExternalAccountingSystemCompanyResponse, _response_json) # type: ignore
if "errorName" in _response_json:
if _response_json["errorName"] == "BadRequest":
raise BadRequest(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unauthorized":
raise Unauthorized(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Forbidden":
raise Forbidden(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "NotFound":
raise NotFound(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Conflict":
raise Conflict(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "InternalServerError":
raise InternalServerError(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
if _response_json["errorName"] == "Unimplemented":
raise Unimplemented(pydantic_v1.parse_obj_as(str, _response_json["content"])) # type: ignore
raise ApiError(status_code=_response.status_code, body=_response_json)

async def create(
self,
entity_id: EntityId,
Expand All @@ -238,7 +350,7 @@ async def create(
request_options: typing.Optional[RequestOptions] = None,
) -> ExternalAccountingSystemCompanyResponse:
"""
Create/Link an entity to an external accounting system like Codat or Rutter
Create/Link an entity to an external accounting system like Codat or Rutter. If the entity is already linked to an external accounting system, this will return the existing connection.
Parameters
----------
Expand Down Expand Up @@ -372,7 +484,7 @@ async def sync(
Sync vendors from external accounting system. Default is to pull vendors from external system.
bills : typing.Optional[SyncType]
Sync bills from external accounting system. Default is to not sync bills.
Sync bills from external accounting system. Default is to not sync bills. Invoices that already exist in both systems will not be updated, only new invoices not present in the other system will be created.
gl_accounts : typing.Optional[SyncType]
Sync GL accounts from external accounting system. Default is to pull GL accounts from external system. Pushing GL accounts is not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .external_accounting_system_company_response import (
ExternalAccountingSystemCompanyResponse,
ExternalAccountingSystemCompanyResponse_Codat,
ExternalAccountingSystemCompanyResponse_None,
ExternalAccountingSystemCompanyResponse_Rutter,
)
from .rutter_company_creation_request import RutterCompanyCreationRequest
Expand All @@ -24,6 +25,7 @@
"ExternalAccountingSystemCompanyCreationRequest_Rutter",
"ExternalAccountingSystemCompanyResponse",
"ExternalAccountingSystemCompanyResponse_Codat",
"ExternalAccountingSystemCompanyResponse_None",
"ExternalAccountingSystemCompanyResponse_Rutter",
"RutterCompanyCreationRequest",
"RutterCompanyResponse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ class Config:
json_encoders = {dt.datetime: serialize_datetime}


class ExternalAccountingSystemCompanyResponse_None(pydantic_v1.BaseModel):
company_id: str = pydantic_v1.Field(alias="companyId")
type: typing.Literal["none"] = "none"

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_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

return deep_union_pydantic_dicts(
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
)

class Config:
frozen = True
smart_union = True
allow_population_by_field_name = True
populate_by_name = True
extra = pydantic_v1.Extra.allow
json_encoders = {dt.datetime: serialize_datetime}


ExternalAccountingSystemCompanyResponse = typing.Union[
ExternalAccountingSystemCompanyResponse_Codat, ExternalAccountingSystemCompanyResponse_Rutter
ExternalAccountingSystemCompanyResponse_Codat,
ExternalAccountingSystemCompanyResponse_Rutter,
ExternalAccountingSystemCompanyResponse_None,
]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class PaymentMethodBaseRequest(pydantic_v1.BaseModel):
If true, this payment method will be set as the default destination. Only one payment method can be set as the default destination. If another payment method is already set as the default destination, it will be unset.
"""

external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
"""
ID for this payment method in the external accounting system (e.g Rutter or Codat)
"""

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class PaymentMethodBaseResponse(pydantic_v1.BaseModel):
"""

supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
"""
ID for this payment method in the external accounting system (e.g Rutter or Codat)
"""

created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")

Expand Down
15 changes: 15 additions & 0 deletions src/mercoa/payment_method_types/types/payment_method_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class PaymentMethodRequest_BankAccount(pydantic_v1.BaseModel):
check_options: typing.Optional[BankAccountCheckOptions] = pydantic_v1.Field(alias="checkOptions", default=None)
default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None)
default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None)
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
type: typing.Literal["bankAccount"] = "bankAccount"

def json(self, **kwargs: typing.Any) -> str:
Expand Down Expand Up @@ -81,6 +84,9 @@ class PaymentMethodRequest_Card(pydantic_v1.BaseModel):
token: str
default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None)
default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None)
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
type: typing.Literal["card"] = "card"

def json(self, **kwargs: typing.Any) -> str:
Expand Down Expand Up @@ -126,6 +132,9 @@ class PaymentMethodRequest_Check(pydantic_v1.BaseModel):
country: str
default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None)
default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None)
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
type: typing.Literal["check"] = "check"

def json(self, **kwargs: typing.Any) -> str:
Expand Down Expand Up @@ -169,6 +178,9 @@ class PaymentMethodRequest_Custom(pydantic_v1.BaseModel):
data: typing.Dict[str, str]
default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None)
default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None)
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
type: typing.Literal["custom"] = "custom"

def json(self, **kwargs: typing.Any) -> str:
Expand Down Expand Up @@ -207,6 +219,9 @@ class PaymentMethodRequest_OffPlatform(pydantic_v1.BaseModel):

default_source: typing.Optional[bool] = pydantic_v1.Field(alias="defaultSource", default=None)
default_destination: typing.Optional[bool] = pydantic_v1.Field(alias="defaultDestination", default=None)
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
type: typing.Literal["offPlatform"] = "offPlatform"

def json(self, **kwargs: typing.Any) -> str:
Expand Down
15 changes: 15 additions & 0 deletions src/mercoa/payment_method_types/types/payment_method_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class PaymentMethodResponse_BankAccount(pydantic_v1.BaseModel):
is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource")
is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination")
supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
type: typing.Literal["bankAccount"] = "bankAccount"
Expand Down Expand Up @@ -119,6 +122,9 @@ class PaymentMethodResponse_Card(pydantic_v1.BaseModel):
is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource")
is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination")
supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
type: typing.Literal["card"] = "card"
Expand Down Expand Up @@ -183,6 +189,9 @@ class PaymentMethodResponse_Check(pydantic_v1.BaseModel):
is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource")
is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination")
supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
type: typing.Literal["check"] = "check"
Expand Down Expand Up @@ -246,6 +255,9 @@ class PaymentMethodResponse_Custom(pydantic_v1.BaseModel):
is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource")
is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination")
supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
type: typing.Literal["custom"] = "custom"
Expand Down Expand Up @@ -303,6 +315,9 @@ class PaymentMethodResponse_OffPlatform(pydantic_v1.BaseModel):
is_default_source: bool = pydantic_v1.Field(alias="isDefaultSource")
is_default_destination: bool = pydantic_v1.Field(alias="isDefaultDestination")
supported_currencies: typing.List[CurrencyCode] = pydantic_v1.Field(alias="supportedCurrencies")
external_accounting_system_id: typing.Optional[str] = pydantic_v1.Field(
alias="externalAccountingSystemId", default=None
)
created_at: dt.datetime = pydantic_v1.Field(alias="createdAt")
updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt")
type: typing.Literal["offPlatform"] = "offPlatform"
Expand Down
Loading

0 comments on commit b53648d

Please sign in to comment.