Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions robosystems_client/api/ledger/get_account_rollups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
import datetime
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.account_rollups_response import AccountRollupsResponse
from ...models.http_validation_error import HTTPValidationError
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
mapping_id: None | str | Unset = UNSET,
start_date: datetime.date | None | Unset = UNSET,
end_date: datetime.date | None | Unset = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}

json_mapping_id: None | str | Unset
if isinstance(mapping_id, Unset):
json_mapping_id = UNSET
else:
json_mapping_id = mapping_id
params["mapping_id"] = json_mapping_id

json_start_date: None | str | Unset
if isinstance(start_date, Unset):
json_start_date = UNSET
elif isinstance(start_date, datetime.date):
json_start_date = start_date.isoformat()
else:
json_start_date = start_date
params["start_date"] = json_start_date

json_end_date: None | str | Unset
if isinstance(end_date, Unset):
json_end_date = UNSET
elif isinstance(end_date, datetime.date):
json_end_date = end_date.isoformat()
else:
json_end_date = end_date
params["end_date"] = json_end_date

params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

_kwargs: dict[str, Any] = {
"method": "get",
"url": "/v1/ledger/{graph_id}/account-rollups".format(
graph_id=quote(str(graph_id), safe=""),
),
"params": params,
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> AccountRollupsResponse | HTTPValidationError | None:
if response.status_code == 200:
response_200 = AccountRollupsResponse.from_dict(response.json())

return response_200

if response.status_code == 422:
response_422 = HTTPValidationError.from_dict(response.json())

return response_422

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[AccountRollupsResponse | HTTPValidationError]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
mapping_id: None | str | Unset = UNSET,
start_date: datetime.date | None | Unset = UNSET,
end_date: datetime.date | None | Unset = UNSET,
) -> Response[AccountRollupsResponse | HTTPValidationError]:
"""Account Rollups

Account rollups — CoA accounts grouped by reporting element with balances.

Shows how company-specific accounts roll up to standardized reporting
line items. Auto-discovers the mapping structure if mapping_id is not provided.

Args:
graph_id (str):
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
start_date (datetime.date | None | Unset): Start date (inclusive)
end_date (datetime.date | None | Unset): End date (inclusive)

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[AccountRollupsResponse | HTTPValidationError]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
mapping_id=mapping_id,
start_date=start_date,
end_date=end_date,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
mapping_id: None | str | Unset = UNSET,
start_date: datetime.date | None | Unset = UNSET,
end_date: datetime.date | None | Unset = UNSET,
) -> AccountRollupsResponse | HTTPValidationError | None:
"""Account Rollups

Account rollups — CoA accounts grouped by reporting element with balances.

Shows how company-specific accounts roll up to standardized reporting
line items. Auto-discovers the mapping structure if mapping_id is not provided.

Args:
graph_id (str):
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
start_date (datetime.date | None | Unset): Start date (inclusive)
end_date (datetime.date | None | Unset): End date (inclusive)

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
AccountRollupsResponse | HTTPValidationError
"""

return sync_detailed(
graph_id=graph_id,
client=client,
mapping_id=mapping_id,
start_date=start_date,
end_date=end_date,
).parsed


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
mapping_id: None | str | Unset = UNSET,
start_date: datetime.date | None | Unset = UNSET,
end_date: datetime.date | None | Unset = UNSET,
) -> Response[AccountRollupsResponse | HTTPValidationError]:
"""Account Rollups

Account rollups — CoA accounts grouped by reporting element with balances.

Shows how company-specific accounts roll up to standardized reporting
line items. Auto-discovers the mapping structure if mapping_id is not provided.

Args:
graph_id (str):
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
start_date (datetime.date | None | Unset): Start date (inclusive)
end_date (datetime.date | None | Unset): End date (inclusive)

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[AccountRollupsResponse | HTTPValidationError]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
mapping_id=mapping_id,
start_date=start_date,
end_date=end_date,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
mapping_id: None | str | Unset = UNSET,
start_date: datetime.date | None | Unset = UNSET,
end_date: datetime.date | None | Unset = UNSET,
) -> AccountRollupsResponse | HTTPValidationError | None:
"""Account Rollups

Account rollups — CoA accounts grouped by reporting element with balances.

Shows how company-specific accounts roll up to standardized reporting
line items. Auto-discovers the mapping structure if mapping_id is not provided.

Args:
graph_id (str):
mapping_id (None | str | Unset): Mapping structure ID (auto-discovers if omitted)
start_date (datetime.date | None | Unset): Start date (inclusive)
end_date (datetime.date | None | Unset): End date (inclusive)

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
AccountRollupsResponse | HTTPValidationError
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
mapping_id=mapping_id,
start_date=start_date,
end_date=end_date,
)
).parsed
Loading
Loading