Skip to content

Commit bd2066e

Browse files
committed
feat(documents): upload, store and read document files; events cite them
Regenerated from robosystems v1.16.11. A document can now be a stored file (PDF, PNG, JPEG): create_document_upload presigns the PUT, complete_document_upload checks it and makes the document, get_document_file returns a short-lived download URL. Event blocks take and return document_id; document detail lists the events it is evidence for. Reconciliation requests take entity_id, and record_statement_balance takes the statement's document_id. Also picked up from v1.16.10: change_calendar_start, plus doc-only changes on resolve_reconciling_item and the Mercury and Plaid backfill windows. Claude-Session: https://claude.ai/code/session_01AQkGGPDmpba9eBV9PkLTfv
1 parent 7cb8e3d commit bd2066e

27 files changed

Lines changed: 2212 additions & 23 deletions
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
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.complete_document_upload_op import CompleteDocumentUploadOp
10+
from ...models.error_response import ErrorResponse
11+
from ...models.operation_envelope import OperationEnvelope
12+
from ...types import UNSET, Response, Unset
13+
14+
15+
def _get_kwargs(
16+
graph_id: str,
17+
*,
18+
body: CompleteDocumentUploadOp,
19+
idempotency_key: None | str | Unset = UNSET,
20+
) -> dict[str, Any]:
21+
headers: dict[str, Any] = {}
22+
if not isinstance(idempotency_key, Unset):
23+
headers["Idempotency-Key"] = idempotency_key
24+
25+
_kwargs: dict[str, Any] = {
26+
"method": "post",
27+
"url": "/v1/graphs/{graph_id}/operations/complete-document-upload".format(
28+
graph_id=quote(str(graph_id), safe=""),
29+
),
30+
}
31+
32+
_kwargs["json"] = body.to_dict()
33+
34+
headers["Content-Type"] = "application/json"
35+
36+
_kwargs["headers"] = headers
37+
return _kwargs
38+
39+
40+
def _parse_response(
41+
*, client: AuthenticatedClient | Client, response: httpx.Response
42+
) -> ErrorResponse | OperationEnvelope | None:
43+
if response.status_code == 200:
44+
response_200 = OperationEnvelope.from_dict(response.json())
45+
46+
return response_200
47+
48+
if response.status_code == 400:
49+
response_400 = ErrorResponse.from_dict(response.json())
50+
51+
return response_400
52+
53+
if response.status_code == 401:
54+
response_401 = ErrorResponse.from_dict(response.json())
55+
56+
return response_401
57+
58+
if response.status_code == 403:
59+
response_403 = ErrorResponse.from_dict(response.json())
60+
61+
return response_403
62+
63+
if response.status_code == 404:
64+
response_404 = ErrorResponse.from_dict(response.json())
65+
66+
return response_404
67+
68+
if response.status_code == 409:
69+
response_409 = ErrorResponse.from_dict(response.json())
70+
71+
return response_409
72+
73+
if response.status_code == 422:
74+
response_422 = ErrorResponse.from_dict(response.json())
75+
76+
return response_422
77+
78+
if response.status_code == 429:
79+
response_429 = ErrorResponse.from_dict(response.json())
80+
81+
return response_429
82+
83+
if response.status_code == 500:
84+
response_500 = ErrorResponse.from_dict(response.json())
85+
86+
return response_500
87+
88+
if client.raise_on_unexpected_status:
89+
raise errors.UnexpectedStatus(response.status_code, response.content)
90+
else:
91+
return None
92+
93+
94+
def _build_response(
95+
*, client: AuthenticatedClient | Client, response: httpx.Response
96+
) -> Response[ErrorResponse | OperationEnvelope]:
97+
return Response(
98+
status_code=HTTPStatus(response.status_code),
99+
content=response.content,
100+
headers=response.headers,
101+
parsed=_parse_response(client=client, response=response),
102+
)
103+
104+
105+
def sync_detailed(
106+
graph_id: str,
107+
*,
108+
client: AuthenticatedClient,
109+
body: CompleteDocumentUploadOp,
110+
idempotency_key: None | str | Unset = UNSET,
111+
) -> Response[ErrorResponse | OperationEnvelope]:
112+
"""Complete a Document File Upload
113+
114+
Store an uploaded file as a document. The uploaded bytes are checked against the file's type and
115+
size cap and hashed (SHA-256); a file that fails the check is discarded. Completing the same upload
116+
again returns the document it created. Returns the document.
117+
118+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
119+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
120+
121+
Args:
122+
graph_id (str):
123+
idempotency_key (None | str | Unset):
124+
body (CompleteDocumentUploadOp): Body for complete-document-upload: store the uploaded
125+
file as a document.
126+
127+
Raises:
128+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129+
httpx.TimeoutException: If the request takes longer than Client.timeout.
130+
131+
Returns:
132+
Response[ErrorResponse | OperationEnvelope]
133+
"""
134+
135+
kwargs = _get_kwargs(
136+
graph_id=graph_id,
137+
body=body,
138+
idempotency_key=idempotency_key,
139+
)
140+
141+
response = client.get_httpx_client().request(
142+
**kwargs,
143+
)
144+
145+
return _build_response(client=client, response=response)
146+
147+
148+
def sync(
149+
graph_id: str,
150+
*,
151+
client: AuthenticatedClient,
152+
body: CompleteDocumentUploadOp,
153+
idempotency_key: None | str | Unset = UNSET,
154+
) -> ErrorResponse | OperationEnvelope | None:
155+
"""Complete a Document File Upload
156+
157+
Store an uploaded file as a document. The uploaded bytes are checked against the file's type and
158+
size cap and hashed (SHA-256); a file that fails the check is discarded. Completing the same upload
159+
again returns the document it created. Returns the document.
160+
161+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
162+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
163+
164+
Args:
165+
graph_id (str):
166+
idempotency_key (None | str | Unset):
167+
body (CompleteDocumentUploadOp): Body for complete-document-upload: store the uploaded
168+
file as a document.
169+
170+
Raises:
171+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
172+
httpx.TimeoutException: If the request takes longer than Client.timeout.
173+
174+
Returns:
175+
ErrorResponse | OperationEnvelope
176+
"""
177+
178+
return sync_detailed(
179+
graph_id=graph_id,
180+
client=client,
181+
body=body,
182+
idempotency_key=idempotency_key,
183+
).parsed
184+
185+
186+
async def asyncio_detailed(
187+
graph_id: str,
188+
*,
189+
client: AuthenticatedClient,
190+
body: CompleteDocumentUploadOp,
191+
idempotency_key: None | str | Unset = UNSET,
192+
) -> Response[ErrorResponse | OperationEnvelope]:
193+
"""Complete a Document File Upload
194+
195+
Store an uploaded file as a document. The uploaded bytes are checked against the file's type and
196+
size cap and hashed (SHA-256); a file that fails the check is discarded. Completing the same upload
197+
again returns the document it created. Returns the document.
198+
199+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
200+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
201+
202+
Args:
203+
graph_id (str):
204+
idempotency_key (None | str | Unset):
205+
body (CompleteDocumentUploadOp): Body for complete-document-upload: store the uploaded
206+
file as a document.
207+
208+
Raises:
209+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
210+
httpx.TimeoutException: If the request takes longer than Client.timeout.
211+
212+
Returns:
213+
Response[ErrorResponse | OperationEnvelope]
214+
"""
215+
216+
kwargs = _get_kwargs(
217+
graph_id=graph_id,
218+
body=body,
219+
idempotency_key=idempotency_key,
220+
)
221+
222+
response = await client.get_async_httpx_client().request(**kwargs)
223+
224+
return _build_response(client=client, response=response)
225+
226+
227+
async def asyncio(
228+
graph_id: str,
229+
*,
230+
client: AuthenticatedClient,
231+
body: CompleteDocumentUploadOp,
232+
idempotency_key: None | str | Unset = UNSET,
233+
) -> ErrorResponse | OperationEnvelope | None:
234+
"""Complete a Document File Upload
235+
236+
Store an uploaded file as a document. The uploaded bytes are checked against the file's type and
237+
size cap and hashed (SHA-256); a file that fails the check is discarded. Completing the same upload
238+
again returns the document it created. Returns the document.
239+
240+
**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
241+
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
242+
243+
Args:
244+
graph_id (str):
245+
idempotency_key (None | str | Unset):
246+
body (CompleteDocumentUploadOp): Body for complete-document-upload: store the uploaded
247+
file as a document.
248+
249+
Raises:
250+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
251+
httpx.TimeoutException: If the request takes longer than Client.timeout.
252+
253+
Returns:
254+
ErrorResponse | OperationEnvelope
255+
"""
256+
257+
return (
258+
await asyncio_detailed(
259+
graph_id=graph_id,
260+
client=client,
261+
body=body,
262+
idempotency_key=idempotency_key,
263+
)
264+
).parsed

0 commit comments

Comments
 (0)