add openapi-python-client generator + client

This commit is contained in:
2025-07-11 12:00:23 +02:00
parent 6910cf37f2
commit 1cc7d01c27
485 changed files with 72495 additions and 0 deletions
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,154 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.refund import Refund
from ...types import Response
def _get_kwargs(
id: int,
*,
body: Union[
Refund,
Refund,
Refund,
],
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/api/v2/accounting/invoices/{id}/actions/refund/",
}
if isinstance(body, Refund):
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
if isinstance(body, Refund):
_kwargs["data"] = body.to_dict()
headers["Content-Type"] = "application/x-www-form-urlencoded"
if isinstance(body, Refund):
_kwargs["files"] = body.to_multipart()
headers["Content-Type"] = "multipart/form-data"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
if response.status_code == 204:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
id: int,
*,
client: AuthenticatedClient,
body: Union[
Refund,
Refund,
Refund,
],
) -> Response[Any]:
"""Proceed to a refund on an invoice, verifying the status and the validity of the amount.
Calls the method `refund_payment` on the payment module.
Args:
id (int):
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
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[Any]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
async def asyncio_detailed(
id: int,
*,
client: AuthenticatedClient,
body: Union[
Refund,
Refund,
Refund,
],
) -> Response[Any]:
"""Proceed to a refund on an invoice, verifying the status and the validity of the amount.
Calls the method `refund_payment` on the payment module.
Args:
id (int):
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
body (Refund): Write only serializer used to provide `refund_amount` and `payment_intent`
to the action `refund` on `InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields
are not part of the invoice model.
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[Any]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
@@ -0,0 +1,253 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.accounting_invoices_list_status import AccountingInvoicesListStatus
from ...models.paginated_invoice_list import PaginatedInvoiceList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
basket_id: Union[Unset, float] = UNSET,
event_id: Union[Unset, int] = UNSET,
o: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
page_limit: Union[Unset, int] = UNSET,
q: Union[Unset, str] = UNSET,
status: Union[Unset, AccountingInvoicesListStatus] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["basket_id"] = basket_id
params["event_id"] = event_id
params["o"] = o
params["offset"] = offset
params["page_limit"] = page_limit
params["q"] = q
json_status: Union[Unset, str] = UNSET
if not isinstance(status, Unset):
json_status = status.value
params["status"] = json_status
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": "/api/v2/accounting/invoices/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedInvoiceList]:
if response.status_code == 200:
response_200 = PaginatedInvoiceList.from_dict(response.json())
return response_200
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[PaginatedInvoiceList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
basket_id: Union[Unset, float] = UNSET,
event_id: Union[Unset, int] = UNSET,
o: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
page_limit: Union[Unset, int] = UNSET,
q: Union[Unset, str] = UNSET,
status: Union[Unset, AccountingInvoicesListStatus] = UNSET,
) -> Response[PaginatedInvoiceList]:
"""ViewSet for `Invoice` object
Args:
basket_id (Union[Unset, float]):
event_id (Union[Unset, int]):
o (Union[Unset, str]):
offset (Union[Unset, int]):
page_limit (Union[Unset, int]):
q (Union[Unset, str]):
status (Union[Unset, AccountingInvoicesListStatus]):
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[PaginatedInvoiceList]
"""
kwargs = _get_kwargs(
basket_id=basket_id,
event_id=event_id,
o=o,
offset=offset,
page_limit=page_limit,
q=q,
status=status,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
basket_id: Union[Unset, float] = UNSET,
event_id: Union[Unset, int] = UNSET,
o: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
page_limit: Union[Unset, int] = UNSET,
q: Union[Unset, str] = UNSET,
status: Union[Unset, AccountingInvoicesListStatus] = UNSET,
) -> Optional[PaginatedInvoiceList]:
"""ViewSet for `Invoice` object
Args:
basket_id (Union[Unset, float]):
event_id (Union[Unset, int]):
o (Union[Unset, str]):
offset (Union[Unset, int]):
page_limit (Union[Unset, int]):
q (Union[Unset, str]):
status (Union[Unset, AccountingInvoicesListStatus]):
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:
PaginatedInvoiceList
"""
return sync_detailed(
client=client,
basket_id=basket_id,
event_id=event_id,
o=o,
offset=offset,
page_limit=page_limit,
q=q,
status=status,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
basket_id: Union[Unset, float] = UNSET,
event_id: Union[Unset, int] = UNSET,
o: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
page_limit: Union[Unset, int] = UNSET,
q: Union[Unset, str] = UNSET,
status: Union[Unset, AccountingInvoicesListStatus] = UNSET,
) -> Response[PaginatedInvoiceList]:
"""ViewSet for `Invoice` object
Args:
basket_id (Union[Unset, float]):
event_id (Union[Unset, int]):
o (Union[Unset, str]):
offset (Union[Unset, int]):
page_limit (Union[Unset, int]):
q (Union[Unset, str]):
status (Union[Unset, AccountingInvoicesListStatus]):
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[PaginatedInvoiceList]
"""
kwargs = _get_kwargs(
basket_id=basket_id,
event_id=event_id,
o=o,
offset=offset,
page_limit=page_limit,
q=q,
status=status,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
basket_id: Union[Unset, float] = UNSET,
event_id: Union[Unset, int] = UNSET,
o: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
page_limit: Union[Unset, int] = UNSET,
q: Union[Unset, str] = UNSET,
status: Union[Unset, AccountingInvoicesListStatus] = UNSET,
) -> Optional[PaginatedInvoiceList]:
"""ViewSet for `Invoice` object
Args:
basket_id (Union[Unset, float]):
event_id (Union[Unset, int]):
o (Union[Unset, str]):
offset (Union[Unset, int]):
page_limit (Union[Unset, int]):
q (Union[Unset, str]):
status (Union[Unset, AccountingInvoicesListStatus]):
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:
PaginatedInvoiceList
"""
return (
await asyncio_detailed(
client=client,
basket_id=basket_id,
event_id=event_id,
o=o,
offset=offset,
page_limit=page_limit,
q=q,
status=status,
)
).parsed
@@ -0,0 +1,146 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.invoice import Invoice
from ...types import Response
def _get_kwargs(
id: int,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/api/v2/accounting/invoices/{id}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Invoice]:
if response.status_code == 200:
response_200 = Invoice.from_dict(response.json())
return response_200
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Invoice]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
id: int,
*,
client: AuthenticatedClient,
) -> Response[Invoice]:
"""ViewSet for `Invoice` object
Args:
id (int):
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[Invoice]
"""
kwargs = _get_kwargs(
id=id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: int,
*,
client: AuthenticatedClient,
) -> Optional[Invoice]:
"""ViewSet for `Invoice` object
Args:
id (int):
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:
Invoice
"""
return sync_detailed(
id=id,
client=client,
).parsed
async def asyncio_detailed(
id: int,
*,
client: AuthenticatedClient,
) -> Response[Invoice]:
"""ViewSet for `Invoice` object
Args:
id (int):
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[Invoice]
"""
kwargs = _get_kwargs(
id=id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
id: int,
*,
client: AuthenticatedClient,
) -> Optional[Invoice]:
"""ViewSet for `Invoice` object
Args:
id (int):
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:
Invoice
"""
return (
await asyncio_detailed(
id=id,
client=client,
)
).parsed