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
24 changes: 16 additions & 8 deletions robosystems_client/api/connections/oauth_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ def sync_detailed(

Completes the OAuth authorization flow after provider redirect. Exchanges the authorization code for
tokens, stores them, and triggers an initial sync. This is a redirect target — not typically called
directly. Plaid: pass Link's public_token as `code`; a bank already connected to the graph is
refused (409 DUPLICATE_BANK_CONNECTION).
directly. QuickBooks: only the company that built the graph's books may connect to them; another
company is refused (409 OTHER_COMPANY_BOOKS) before any token is issued. Plaid: pass Link's
public_token as `code`; a bank already connected to the graph is refused (409
DUPLICATE_BANK_CONNECTION).

Args:
graph_id (str):
Expand Down Expand Up @@ -148,8 +150,10 @@ def sync(

Completes the OAuth authorization flow after provider redirect. Exchanges the authorization code for
tokens, stores them, and triggers an initial sync. This is a redirect target — not typically called
directly. Plaid: pass Link's public_token as `code`; a bank already connected to the graph is
refused (409 DUPLICATE_BANK_CONNECTION).
directly. QuickBooks: only the company that built the graph's books may connect to them; another
company is refused (409 OTHER_COMPANY_BOOKS) before any token is issued. Plaid: pass Link's
public_token as `code`; a bank already connected to the graph is refused (409
DUPLICATE_BANK_CONNECTION).

Args:
graph_id (str):
Expand Down Expand Up @@ -183,8 +187,10 @@ async def asyncio_detailed(

Completes the OAuth authorization flow after provider redirect. Exchanges the authorization code for
tokens, stores them, and triggers an initial sync. This is a redirect target — not typically called
directly. Plaid: pass Link's public_token as `code`; a bank already connected to the graph is
refused (409 DUPLICATE_BANK_CONNECTION).
directly. QuickBooks: only the company that built the graph's books may connect to them; another
company is refused (409 OTHER_COMPANY_BOOKS) before any token is issued. Plaid: pass Link's
public_token as `code`; a bank already connected to the graph is refused (409
DUPLICATE_BANK_CONNECTION).

Args:
graph_id (str):
Expand Down Expand Up @@ -221,8 +227,10 @@ async def asyncio(

Completes the OAuth authorization flow after provider redirect. Exchanges the authorization code for
tokens, stores them, and triggers an initial sync. This is a redirect target — not typically called
directly. Plaid: pass Link's public_token as `code`; a bank already connected to the graph is
refused (409 DUPLICATE_BANK_CONNECTION).
directly. QuickBooks: only the company that built the graph's books may connect to them; another
company is refused (409 OTHER_COMPANY_BOOKS) before any token is issued. Plaid: pass Link's
public_token as `code`; a bank already connected to the graph is refused (409
DUPLICATE_BANK_CONNECTION).

Args:
graph_id (str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def sync_detailed(
monthly_amount / period bounds on the Structure's metadata).

The historical-vs-in-scope split is re-derived from the CURRENT fiscal
calendar `closed_through`, so a rebuild re-scopes the schedule to
today's close state. Use this to pick up a fixed generator (e.g. the
calendar (months through its `closed_through`, or before its first
month, are history), so a rebuild re-scopes the schedule to today's
close state. Use this to pick up a fixed generator (e.g. the
roll-forward direction fix) without orphaning obligations.

Raises:
Expand Down Expand Up @@ -197,8 +198,9 @@ def sync(
monthly_amount / period bounds on the Structure's metadata).

The historical-vs-in-scope split is re-derived from the CURRENT fiscal
calendar `closed_through`, so a rebuild re-scopes the schedule to
today's close state. Use this to pick up a fixed generator (e.g. the
calendar (months through its `closed_through`, or before its first
month, are history), so a rebuild re-scopes the schedule to today's
close state. Use this to pick up a fixed generator (e.g. the
roll-forward direction fix) without orphaning obligations.

Raises:
Expand Down Expand Up @@ -251,8 +253,9 @@ async def asyncio_detailed(
monthly_amount / period bounds on the Structure's metadata).

The historical-vs-in-scope split is re-derived from the CURRENT fiscal
calendar `closed_through`, so a rebuild re-scopes the schedule to
today's close state. Use this to pick up a fixed generator (e.g. the
calendar (months through its `closed_through`, or before its first
month, are history), so a rebuild re-scopes the schedule to today's
close state. Use this to pick up a fixed generator (e.g. the
roll-forward direction fix) without orphaning obligations.

Raises:
Expand Down Expand Up @@ -308,8 +311,9 @@ async def asyncio(
monthly_amount / period bounds on the Structure's metadata).

The historical-vs-in-scope split is re-derived from the CURRENT fiscal
calendar `closed_through`, so a rebuild re-scopes the schedule to
today's close state. Use this to pick up a fixed generator (e.g. the
calendar (months through its `closed_through`, or before its first
month, are history), so a rebuild re-scopes the schedule to today's
close state. Use this to pick up a fixed generator (e.g. the
roll-forward direction fix) without orphaning obligations.

Raises:
Expand Down
282 changes: 282 additions & 0 deletions robosystems_client/api/robo_ledger_ledger_events/accept_suggestions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
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.accept_suggestions_request import AcceptSuggestionsRequest
from ...models.error_response import ErrorResponse
from ...models.operation_envelope_accept_suggestions_response import (
OperationEnvelopeAcceptSuggestionsResponse,
)
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
body: AcceptSuggestionsRequest,
idempotency_key: None | str | Unset = UNSET,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
if not isinstance(idempotency_key, Unset):
headers["Idempotency-Key"] = idempotency_key

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/extensions/roboledger/{graph_id}/operations/accept-suggestions".format(
graph_id=quote(str(graph_id), safe=""),
),
}

_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


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

return response_200

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = ErrorResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = ErrorResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = ErrorResponse.from_dict(response.json())

return response_404

if response.status_code == 409:
response_409 = ErrorResponse.from_dict(response.json())

return response_409

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

return response_422

if response.status_code == 429:
response_429 = ErrorResponse.from_dict(response.json())

return response_429

if response.status_code == 500:
response_500 = ErrorResponse.from_dict(response.json())

return response_500

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[ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse]:
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,
body: AcceptSuggestionsRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse]:
"""Accept Suggestions

Take the suggestion on every open bank line the filters select, oldest first: each is classified to
its `suggested_element_id` through the same update a single line goes through, and posted too with
`commit: true`. Select by `source`, `agent_id`, `suggestion_source` (`agent_default` for the learned
ones), a date range, or explicit `event_ids` from a multi-select. A line it cannot take — no
suggestion to take, already classified or posted, a closed month, a choice the handler refuses —
comes back `skipped` with the reason, never forced. `dry_run: true` reports the counts without
writing; `limit` bounds a call and `truncated` says more matched.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (AcceptSuggestionsRequest): Take the suggestion on every open bank line the filters
select.

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[ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

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

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
body: AcceptSuggestionsRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse | None:
"""Accept Suggestions

Take the suggestion on every open bank line the filters select, oldest first: each is classified to
its `suggested_element_id` through the same update a single line goes through, and posted too with
`commit: true`. Select by `source`, `agent_id`, `suggestion_source` (`agent_default` for the learned
ones), a date range, or explicit `event_ids` from a multi-select. A line it cannot take — no
suggestion to take, already classified or posted, a closed month, a choice the handler refuses —
comes back `skipped` with the reason, never forced. `dry_run: true` reports the counts without
writing; `limit` bounds a call and `truncated` says more matched.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (AcceptSuggestionsRequest): Take the suggestion on every open bank line the filters
select.

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:
ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse
"""

return sync_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
).parsed


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: AcceptSuggestionsRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse]:
"""Accept Suggestions

Take the suggestion on every open bank line the filters select, oldest first: each is classified to
its `suggested_element_id` through the same update a single line goes through, and posted too with
`commit: true`. Select by `source`, `agent_id`, `suggestion_source` (`agent_default` for the learned
ones), a date range, or explicit `event_ids` from a multi-select. A line it cannot take — no
suggestion to take, already classified or posted, a closed month, a choice the handler refuses —
comes back `skipped` with the reason, never forced. `dry_run: true` reports the counts without
writing; `limit` bounds a call and `truncated` says more matched.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (AcceptSuggestionsRequest): Take the suggestion on every open bank line the filters
select.

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[ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

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

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
body: AcceptSuggestionsRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse | None:
"""Accept Suggestions

Take the suggestion on every open bank line the filters select, oldest first: each is classified to
its `suggested_element_id` through the same update a single line goes through, and posted too with
`commit: true`. Select by `source`, `agent_id`, `suggestion_source` (`agent_default` for the learned
ones), a date range, or explicit `event_ids` from a multi-select. A line it cannot take — no
suggestion to take, already classified or posted, a closed month, a choice the handler refuses —
comes back `skipped` with the reason, never forced. `dry_run: true` reports the counts without
writing; `limit` bounds a call and `truncated` says more matched.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (AcceptSuggestionsRequest): Take the suggestion on every open bank line the filters
select.

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:
ErrorResponse | OperationEnvelopeAcceptSuggestionsResponse
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
)
).parsed
Loading
Loading