Skip to content

Commit 11f09da

Browse files
committed
Add new data models to the client library
## Summary This commit introduces several new data models to the `robosystems_client` library, enhancing the API's capabilities for handling account and ledger-related information. ## Key Accomplishments - **New Account Models**: Added `AccountListResponse`, `AccountResponse`, `AccountTreeNode`, and `AccountTreeResponse` to support account-related data structures. - **New Ledger Models**: Introduced `LedgerEntryResponse`, `LedgerLineItemResponse`, `LedgerSummaryResponse`, `LedgerTransactionDetailResponse`, `LedgerTransactionListResponse`, and `LedgerTransactionSummaryResponse` for comprehensive ledger management. - **Pagination Support**: Included `PaginationInfo` to facilitate paginated responses in API calls. - **Trial Balance Models**: Added `TrialBalanceResponse` and `TrialBalanceRow` to support trial balance reporting. ## Changes Breakdown - Updated `__init__.py` to include new models in the public API. ## Testing Notes - Ensure that the new models are correctly integrated and accessible within the client library. ## Infrastructure Considerations - No breaking changes introduced; existing functionality remains intact.
1 parent 31950e0 commit 11f09da

21 files changed

Lines changed: 3232 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.account_tree_response import AccountTreeResponse
10+
from ...models.http_validation_error import HTTPValidationError
11+
from ...types import Response
12+
13+
14+
def _get_kwargs(
15+
graph_id: str,
16+
) -> dict[str, Any]:
17+
_kwargs: dict[str, Any] = {
18+
"method": "get",
19+
"url": "/v1/ledger/{graph_id}/accounts/tree".format(
20+
graph_id=quote(str(graph_id), safe=""),
21+
),
22+
}
23+
24+
return _kwargs
25+
26+
27+
def _parse_response(
28+
*, client: AuthenticatedClient | Client, response: httpx.Response
29+
) -> AccountTreeResponse | HTTPValidationError | None:
30+
if response.status_code == 200:
31+
response_200 = AccountTreeResponse.from_dict(response.json())
32+
33+
return response_200
34+
35+
if response.status_code == 422:
36+
response_422 = HTTPValidationError.from_dict(response.json())
37+
38+
return response_422
39+
40+
if client.raise_on_unexpected_status:
41+
raise errors.UnexpectedStatus(response.status_code, response.content)
42+
else:
43+
return None
44+
45+
46+
def _build_response(
47+
*, client: AuthenticatedClient | Client, response: httpx.Response
48+
) -> Response[AccountTreeResponse | HTTPValidationError]:
49+
return Response(
50+
status_code=HTTPStatus(response.status_code),
51+
content=response.content,
52+
headers=response.headers,
53+
parsed=_parse_response(client=client, response=response),
54+
)
55+
56+
57+
def sync_detailed(
58+
graph_id: str,
59+
*,
60+
client: AuthenticatedClient,
61+
) -> Response[AccountTreeResponse | HTTPValidationError]:
62+
"""Account Tree
63+
64+
Args:
65+
graph_id (str):
66+
67+
Raises:
68+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
69+
httpx.TimeoutException: If the request takes longer than Client.timeout.
70+
71+
Returns:
72+
Response[AccountTreeResponse | HTTPValidationError]
73+
"""
74+
75+
kwargs = _get_kwargs(
76+
graph_id=graph_id,
77+
)
78+
79+
response = client.get_httpx_client().request(
80+
**kwargs,
81+
)
82+
83+
return _build_response(client=client, response=response)
84+
85+
86+
def sync(
87+
graph_id: str,
88+
*,
89+
client: AuthenticatedClient,
90+
) -> AccountTreeResponse | HTTPValidationError | None:
91+
"""Account Tree
92+
93+
Args:
94+
graph_id (str):
95+
96+
Raises:
97+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98+
httpx.TimeoutException: If the request takes longer than Client.timeout.
99+
100+
Returns:
101+
AccountTreeResponse | HTTPValidationError
102+
"""
103+
104+
return sync_detailed(
105+
graph_id=graph_id,
106+
client=client,
107+
).parsed
108+
109+
110+
async def asyncio_detailed(
111+
graph_id: str,
112+
*,
113+
client: AuthenticatedClient,
114+
) -> Response[AccountTreeResponse | HTTPValidationError]:
115+
"""Account Tree
116+
117+
Args:
118+
graph_id (str):
119+
120+
Raises:
121+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122+
httpx.TimeoutException: If the request takes longer than Client.timeout.
123+
124+
Returns:
125+
Response[AccountTreeResponse | HTTPValidationError]
126+
"""
127+
128+
kwargs = _get_kwargs(
129+
graph_id=graph_id,
130+
)
131+
132+
response = await client.get_async_httpx_client().request(**kwargs)
133+
134+
return _build_response(client=client, response=response)
135+
136+
137+
async def asyncio(
138+
graph_id: str,
139+
*,
140+
client: AuthenticatedClient,
141+
) -> AccountTreeResponse | HTTPValidationError | None:
142+
"""Account Tree
143+
144+
Args:
145+
graph_id (str):
146+
147+
Raises:
148+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
149+
httpx.TimeoutException: If the request takes longer than Client.timeout.
150+
151+
Returns:
152+
AccountTreeResponse | HTTPValidationError
153+
"""
154+
155+
return (
156+
await asyncio_detailed(
157+
graph_id=graph_id,
158+
client=client,
159+
)
160+
).parsed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
from urllib.parse import quote
4+
5+
import httpx
6+
7+
from ... import errors
8+
from ...client import AuthenticatedClient, Client
9+
from ...models.http_validation_error import HTTPValidationError
10+
from ...models.ledger_summary_response import LedgerSummaryResponse
11+
from ...types import Response
12+
13+
14+
def _get_kwargs(
15+
graph_id: str,
16+
) -> dict[str, Any]:
17+
_kwargs: dict[str, Any] = {
18+
"method": "get",
19+
"url": "/v1/ledger/{graph_id}/summary".format(
20+
graph_id=quote(str(graph_id), safe=""),
21+
),
22+
}
23+
24+
return _kwargs
25+
26+
27+
def _parse_response(
28+
*, client: AuthenticatedClient | Client, response: httpx.Response
29+
) -> HTTPValidationError | LedgerSummaryResponse | None:
30+
if response.status_code == 200:
31+
response_200 = LedgerSummaryResponse.from_dict(response.json())
32+
33+
return response_200
34+
35+
if response.status_code == 422:
36+
response_422 = HTTPValidationError.from_dict(response.json())
37+
38+
return response_422
39+
40+
if client.raise_on_unexpected_status:
41+
raise errors.UnexpectedStatus(response.status_code, response.content)
42+
else:
43+
return None
44+
45+
46+
def _build_response(
47+
*, client: AuthenticatedClient | Client, response: httpx.Response
48+
) -> Response[HTTPValidationError | LedgerSummaryResponse]:
49+
return Response(
50+
status_code=HTTPStatus(response.status_code),
51+
content=response.content,
52+
headers=response.headers,
53+
parsed=_parse_response(client=client, response=response),
54+
)
55+
56+
57+
def sync_detailed(
58+
graph_id: str,
59+
*,
60+
client: AuthenticatedClient,
61+
) -> Response[HTTPValidationError | LedgerSummaryResponse]:
62+
"""Ledger Summary
63+
64+
Args:
65+
graph_id (str):
66+
67+
Raises:
68+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
69+
httpx.TimeoutException: If the request takes longer than Client.timeout.
70+
71+
Returns:
72+
Response[HTTPValidationError | LedgerSummaryResponse]
73+
"""
74+
75+
kwargs = _get_kwargs(
76+
graph_id=graph_id,
77+
)
78+
79+
response = client.get_httpx_client().request(
80+
**kwargs,
81+
)
82+
83+
return _build_response(client=client, response=response)
84+
85+
86+
def sync(
87+
graph_id: str,
88+
*,
89+
client: AuthenticatedClient,
90+
) -> HTTPValidationError | LedgerSummaryResponse | None:
91+
"""Ledger Summary
92+
93+
Args:
94+
graph_id (str):
95+
96+
Raises:
97+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98+
httpx.TimeoutException: If the request takes longer than Client.timeout.
99+
100+
Returns:
101+
HTTPValidationError | LedgerSummaryResponse
102+
"""
103+
104+
return sync_detailed(
105+
graph_id=graph_id,
106+
client=client,
107+
).parsed
108+
109+
110+
async def asyncio_detailed(
111+
graph_id: str,
112+
*,
113+
client: AuthenticatedClient,
114+
) -> Response[HTTPValidationError | LedgerSummaryResponse]:
115+
"""Ledger Summary
116+
117+
Args:
118+
graph_id (str):
119+
120+
Raises:
121+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122+
httpx.TimeoutException: If the request takes longer than Client.timeout.
123+
124+
Returns:
125+
Response[HTTPValidationError | LedgerSummaryResponse]
126+
"""
127+
128+
kwargs = _get_kwargs(
129+
graph_id=graph_id,
130+
)
131+
132+
response = await client.get_async_httpx_client().request(**kwargs)
133+
134+
return _build_response(client=client, response=response)
135+
136+
137+
async def asyncio(
138+
graph_id: str,
139+
*,
140+
client: AuthenticatedClient,
141+
) -> HTTPValidationError | LedgerSummaryResponse | None:
142+
"""Ledger Summary
143+
144+
Args:
145+
graph_id (str):
146+
147+
Raises:
148+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
149+
httpx.TimeoutException: If the request takes longer than Client.timeout.
150+
151+
Returns:
152+
HTTPValidationError | LedgerSummaryResponse
153+
"""
154+
155+
return (
156+
await asyncio_detailed(
157+
graph_id=graph_id,
158+
client=client,
159+
)
160+
).parsed

0 commit comments

Comments
 (0)