Compare commits

...

10 commits

Author SHA1 Message Date
fa34e459cb add fallback 2026-08-01 10:15:23 +03:30
7e04edbc48 remove unnecessary clients 2026-08-01 09:27:10 +03:30
3c78cd2205 update the labels 2026-06-13 16:42:56 +03:30
d806136b3f update the labels 2026-06-13 16:42:56 +03:30
f5a68ccaee env update 2026-06-09 17:38:33 +03:30
2c715c614c edit example env 2026-06-07 13:15:11 +03:30
b293509e20 generate a zip file containing two reports of users and tickets 2026-06-07 12:38:04 +03:30
ebffc9db61 add advertising client 2026-06-07 11:34:17 +03:30
c9b18e8d3a FEATURE(crm-backend): add other service clients
add other service clients
2026-06-01 13:41:36 +03:30
db55ed87b5 change url 2026-06-01 13:09:19 +03:30
244 changed files with 28744 additions and 366 deletions

View file

@ -11,8 +11,23 @@ DRF_PAGE_SIZE=20
DRF_ANON_THROTTLE_RATE=100/hour
DRF_USER_THROTTLE_RATE=1000/hour
SERVICE_REQUEST_TIMEOUT=30
OAUTH2_PROVIDER_PUBLIC_URL=
OAUTH2_PROVIDER_PRIVATE_URL=
OAUTH2_CLIENT_ID=
OAUTH2_CLIENT_SECRET=
OAUTH2_SCOPES=
OAUTH2_PROVIDER_PUBLIC_URL=https://accounts.gooyal.ir/oauth2
OAUTH2_PROVIDER_PRIVATE_URL=https://accounts.gooyal.ir/oauth2
OAUTH2_CLIENT_ID=sample1
OAUTH2_CLIENT_SECRET=sample2
# OAUTH2_SCOPES=profile email phone accounts.profile:inquiry accounts.profile:detailed_retrieve accounts.profile:retrieve
OAUTH2_PROVIDER_BASE_PUBLIC_URL=https://accounts-staging.gooyal.ir/oauth2
OAUTH2_PROVIDER_BASE_PRIVATE_URL=https://accounts-staging.gooyal.ir/oauth2
OAUTH2_PROVIDER_CLIENT_ID=sample1
OAUTH2_PROVIDER_CLIENT_SECRET=sample2
OAUTH2_PROVIDER_SCOPES=accounts.profile:retrieve accounts.profile:detailed_retrieve application.crm.message:retrieve
ACCOUNTS_BASE_PUBLIC_URL=https://accounts-staging.gooyal.ir
WALLET_BASE_PUBLIC_URL=https://wallet-staging.gooyal.ir
WALLET_RIAL=af7d967f-30c0-409b-9066-2549f2da5e5e
WALLET_REWARD=e7c9d4d1-4d1f-43b2-96f7-4d4a168f480d
ADVERTISING_BASE_PUBLIC_URL=https://advertising-staging.winsoo.ir
CHAT_BASE_PUBLIC_URL=
NOTIFICATIONS_BASE_PUBLIC_URL=
PROMOTIONS_BASE_PUBLIC_URL=
CAMPAIGN_BASE_PUBLIC_URL=
IPG_BASE_PUBLIC_URL=

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.idea
.DS_Store
.env
.venv/

View file

@ -1,3 +1,4 @@
from drf_spectacular.utils import extend_schema
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView
@ -7,5 +8,11 @@ class HealthCheckView(APIView):
authentication_classes = []
permission_classes = [AllowAny]
@extend_schema(
tags=["Health"],
summary="Health check",
description="Returns service availability status.",
responses={200: {"type": "object", "properties": {"status": {"type": "string"}}}},
)
def get(self, request):
return Response({"status": "ok"})

0
apps/proxy/__init__.py Normal file
View file

6
apps/proxy/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ProxyConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.proxy"

114
apps/proxy/schema.py Normal file
View file

@ -0,0 +1,114 @@
import concurrent.futures
import copy
import logging
import requests
from django.conf import settings
from django.core.cache import cache
from utils.http_fallback import request_with_ssl_fallback
logger = logging.getLogger(__name__)
CACHE_KEY_TEMPLATE = "proxy_upstream_openapi_schema_{service}"
CACHE_TIMEOUT_SECONDS = 300
FETCH_TIMEOUT_SECONDS = 5
def _rewrite_schema_refs(node, rename):
"""Recursively repoint `$ref: '#/components/schemas/<Name>'` at the
renamed (service-prefixed) schema, in place."""
if isinstance(node, dict):
ref = node.get("$ref")
if isinstance(ref, str) and ref.startswith("#/components/schemas/"):
name = ref.rsplit("/", 1)[-1]
if name in rename:
node["$ref"] = f"#/components/schemas/{rename[name]}"
for value in node.values():
_rewrite_schema_refs(value, rename)
elif isinstance(node, list):
for item in node:
_rewrite_schema_refs(item, rename)
def _fetch_service_schema(service, base_url, schema_path):
cache_key = CACHE_KEY_TEMPLATE.format(service=service)
cached = cache.get(cache_key)
if cached is not None:
return cached
url = f"{base_url.rstrip('/')}{schema_path}"
try:
response = request_with_ssl_fallback("GET", url, timeout=FETCH_TIMEOUT_SECONDS)
response.raise_for_status()
schema = response.json()
except (requests.RequestException, ValueError) as exc:
logger.warning("Could not fetch OpenAPI schema for service %r from %s: %s", service, url, exc)
return None
cache.set(cache_key, schema, timeout=CACHE_TIMEOUT_SECONDS)
return schema
def merge_upstream_schemas(result, generator, request, public):
"""drf-spectacular POSTPROCESSING_HOOKS entry point.
Folds every proxied service's own OpenAPI document into this service's
schema under `/<service>/...` paths (mirroring apps.proxy.views), so the
combined swagger covers every endpoint this proxy forwards to, DTOs
included. Schemas are cached per service; a service that's unconfigured
or unreachable is skipped rather than failing the whole document.
"""
services = {
service: base_url
for service, base_url in settings.PROXY_SERVICE_BASE_URLS.items()
if base_url
}
if not services:
return result
schema_paths = settings.PROXY_SERVICE_SCHEMA_PATHS
with concurrent.futures.ThreadPoolExecutor(max_workers=len(services)) as executor:
futures = {
executor.submit(
_fetch_service_schema,
service,
base_url,
schema_paths.get(service, "/swagger/?format=json"),
): service
for service, base_url in services.items()
}
fetched = {}
for future in concurrent.futures.as_completed(futures):
service = futures[future]
schema = future.result()
if schema:
fetched[service] = schema
result.setdefault("paths", {})
result.setdefault("components", {}).setdefault("schemas", {})
for service, schema in fetched.items():
schema = copy.deepcopy(schema)
upstream_schemas = schema.get("components", {}).get("schemas", {})
rename = {name: f"{service}_{name}" for name in upstream_schemas}
_rewrite_schema_refs(schema.get("paths", {}), rename)
_rewrite_schema_refs(upstream_schemas, rename)
for name, definition in upstream_schemas.items():
result["components"]["schemas"][rename[name]] = definition
label = service.capitalize()
for path, operations in schema.get("paths", {}).items():
proxied_operations = copy.deepcopy(operations)
for operation in proxied_operations.values():
if not isinstance(operation, dict):
continue
operation["tags"] = [label]
if "operationId" in operation:
operation["operationId"] = f"{service}_{operation['operationId']}"
result["paths"][f"/{service}{path}"] = proxied_operations
return result

11
apps/proxy/urls.py Normal file
View file

@ -0,0 +1,11 @@
from django.urls import path
from apps.proxy.views import ServiceProxyView
app_name = "proxy"
urlpatterns = [
path("<str:service>/", ServiceProxyView.as_view(), name="proxy-root"),
path("<str:service>/<path:rest>", ServiceProxyView.as_view(), name="proxy"),
]

79
apps/proxy/views.py Normal file
View file

@ -0,0 +1,79 @@
import requests
from django.conf import settings
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.csrf import csrf_exempt
from utils.http_fallback import request_with_ssl_fallback
# Headers that must not be copied verbatim between hops (RFC 7230 6.1) plus
# framing headers that HttpResponse recomputes itself.
HOP_BY_HOP_HEADERS = {
"connection",
"keep-alive",
"proxy-authenticate",
"proxy-authorization",
"te",
"trailers",
"transfer-encoding",
"upgrade",
"content-encoding",
"content-length",
}
def _incoming_headers(request):
headers = {}
for key, value in request.META.items():
if key.startswith("HTTP_"):
name = key[5:].replace("_", "-").title()
elif key in ("CONTENT_TYPE", "CONTENT_LENGTH") and value:
name = key.replace("_", "-").title()
else:
continue
headers[name] = value
headers.pop("Host", None)
return headers
@method_decorator(csrf_exempt, name="dispatch")
class ServiceProxyView(View):
"""Forwards `/<service>/<rest>` to the configured base URL for `service`."""
def dispatch(self, request, service, rest="", *args, **kwargs):
base_url = settings.PROXY_SERVICE_BASE_URLS.get(service)
if not base_url:
return HttpResponse(
f'Unknown or unconfigured service "{service}".',
status=404,
content_type="text/plain",
)
target_url = f"{base_url.rstrip('/')}/{rest.lstrip('/')}"
query_string = request.META.get("QUERY_STRING", "")
if query_string:
target_url = f"{target_url}?{query_string}"
try:
upstream = request_with_ssl_fallback(
request.method,
target_url,
headers=_incoming_headers(request),
data=request.body,
timeout=settings.SERVICE_REQUEST_TIMEOUT,
allow_redirects=False,
)
except requests.RequestException as exc:
return HttpResponse(
f'Error contacting upstream service "{service}": {exc}',
status=502,
content_type="text/plain",
)
response = HttpResponse(content=upstream.content, status=upstream.status_code)
for name, value in upstream.headers.items():
if name.lower() in HOP_BY_HOP_HEADERS:
continue
response[name] = value
return response

View file

@ -1,8 +0,0 @@
from rest_framework import serializers
from apps.reports.services.orchestrator import ReportOrchestrator
class ReportGenerateSerializer(serializers.Serializer):
report_type = serializers.ChoiceField(choices=ReportOrchestrator.available_reports())
filters = serializers.DictField(required=False, default=dict)

View file

@ -1,41 +1,46 @@
from urllib.parse import urljoin
import logging
import requests
from django.conf import settings
from utils.accounts_client import get_user_detailed_info
from utils.advertising_client import get_crm_application_tickets
from apps.reports.services.oauth import OAuth2ClientCredentials
logger = logging.getLogger(__name__)
class ReportDataSources:
"""
Keep downstream calls for report generation in one place.
def fetch_application_tickets(self):
tickets = []
offset = 0
limit = 1000
The concrete service endpoints are intentionally placeholders until the
exact internal service URLs and response shapes are known.
"""
while True:
response = get_crm_application_tickets(limit=limit, offset=offset)
if not response or not response.results:
break
def __init__(self, oauth_client=None):
self.oauth_client = oauth_client or OAuth2ClientCredentials()
tickets.extend(response.results)
if response.next_ is None:
break
offset += limit
def fetch_users(self, filters):
return []
return tickets
def fetch_user_metrics(self, user_ids, filters):
return {}
def fetch_users_for_tickets(self, tickets):
users = []
seen = set()
def fetch_tickets(self, filters):
return []
for ticket in tickets:
user_id = str(ticket.user)
if user_id in seen:
continue
seen.add(user_id)
def fetch_ticket_metrics(self, ticket_ids, filters):
return {}
try:
user = get_user_detailed_info(user_id)
except Exception:
logger.exception("Failed to fetch user %s", user_id)
continue
def get_json(self, base_url, path, params=None):
url = urljoin(f"{base_url.rstrip('/')}/", path.lstrip("/"))
response = requests.get(
url,
params=params,
headers=self.oauth_client.authorization_header(),
timeout=settings.SERVICE_REQUEST_TIMEOUT,
)
response.raise_for_status()
return response.json()
if user is not None:
users.append(user)
return users

View file

@ -41,3 +41,13 @@ def build_report_workbook(title, columns, rows):
output = BytesIO()
workbook.save(output)
return output.getvalue()
def build_report_zip(files: dict[str, bytes]) -> bytes:
from zipfile import ZipFile, ZIP_DEFLATED
output = BytesIO()
with ZipFile(output, "w", ZIP_DEFLATED) as zip_file:
for filename, content in files.items():
zip_file.writestr(filename, content)
return output.getvalue()

View file

@ -1,69 +0,0 @@
from dataclasses import dataclass
from time import monotonic
from urllib.parse import urljoin
import requests
from django.conf import settings
class OAuth2ConfigurationError(RuntimeError):
pass
@dataclass
class OAuth2Token:
access_token: str
expires_at: float
token_type: str = "Bearer"
def is_valid(self) -> bool:
return bool(self.access_token) and monotonic() < self.expires_at
class OAuth2ClientCredentials:
def __init__(self):
self._token = None
@property
def token_url(self):
provider_private_url = settings.OAUTH2_PROVIDER_PRIVATE_URL.rstrip("/")
if not provider_private_url:
raise OAuth2ConfigurationError("OAUTH2_PROVIDER_PRIVATE_URL is required.")
return urljoin(f"{provider_private_url}/", "oauth2/token")
def get_access_token(self):
if self._token and self._token.is_valid():
return self._token.access_token
if not settings.OAUTH2_CLIENT_ID or not settings.OAUTH2_CLIENT_SECRET:
raise OAuth2ConfigurationError(
"OAUTH2_CLIENT_ID and OAUTH2_CLIENT_SECRET are required."
)
response = requests.post(
self.token_url,
data={
"grant_type": "client_credentials",
"scope": settings.OAUTH2_SCOPES,
},
auth=(settings.OAUTH2_CLIENT_ID, settings.OAUTH2_CLIENT_SECRET),
timeout=settings.SERVICE_REQUEST_TIMEOUT,
)
response.raise_for_status()
payload = response.json()
access_token = payload.get("access_token")
if not access_token:
raise OAuth2ConfigurationError("OAuth2 response did not include access_token.")
expires_in = int(payload.get("expires_in", 3600))
token_type = payload.get("token_type", "Bearer")
self._token = OAuth2Token(
access_token=access_token,
expires_at=monotonic() + max(expires_in - 60, 1),
token_type=token_type,
)
return self._token.access_token
def authorization_header(self):
return {"Authorization": f"Bearer {self.get_access_token()}"}

View file

@ -1,11 +0,0 @@
from apps.reports.services.report_types import REPORT_TYPES
class ReportOrchestrator:
@classmethod
def available_reports(cls):
return [(report_type, report_type) for report_type in REPORT_TYPES.keys()]
def generate(self, payload):
report = REPORT_TYPES[payload["report_type"]]()
return report.generate(payload.get("filters") or {})

View file

@ -0,0 +1,78 @@
TICKET_STATE_LABELS = {
1: "INIT",
10: "CLOSED",
}
USERS_COLUMNS = [
{"key": "user_uuid", "label": "accounts_user_uuid"},
{"key": "username", "label": "accounts_username"},
{"key": "first_name", "label": "accounts_first_name"},
{"key": "last_name", "label": "accounts_last_name"},
{"key": "email", "label": "accounts_email"},
{"key": "phone_number", "label": "accounts_phone_number"},
{"key": "address", "label": "accounts_address"},
]
TICKETS_COLUMNS = [
{"key": "ticket_uuid", "label": "advertising_ticket_uuid"},
{"key": "user_uuid", "label": "advertising_user_uuid"},
{"key": "title", "label": "advertising_title"},
{"key": "description", "label": "advertising_description"},
{"key": "state", "label": "advertising_state"},
{"key": "created_at", "label": "advertising_created_at"},
{"key": "updated_at", "label": "advertising_updated_at"},
]
def _format_value(value):
if value is None:
return ""
if type(value).__name__ == "Unset":
return ""
if hasattr(value, "value") and not isinstance(value, (str, bytes)):
value = value.value
if value is None:
return ""
return value
def _format_ticket_state(state):
if not state:
return ""
return TICKET_STATE_LABELS.get(state.value, str(state.value))
def build_user_rows(users):
rows = []
for user in users:
if user is None:
continue
rows.append(
{
"user_uuid": str(user.uuid),
"username": _format_value(user.username),
"first_name": _format_value(user.first_name),
"last_name": _format_value(user.last_name),
"email": _format_value(user.email),
"phone_number": _format_value(user.phone_number),
"address": _format_value(user.address),
}
)
return rows
def build_ticket_rows(tickets):
rows = []
for ticket in tickets:
rows.append(
{
"ticket_uuid": str(ticket.uuid),
"user_uuid": str(ticket.user),
"title": _format_value(ticket.title),
"description": _format_value(ticket.description),
"state": _format_ticket_state(ticket.state),
"created_at": str(ticket.created_at) if ticket.created_at else "",
"updated_at": str(ticket.updated_at) if ticket.updated_at else "",
}
)
return rows

View file

@ -1,100 +0,0 @@
from apps.reports.services.data_sources import ReportDataSources
class BaseReport:
report_type = None
title = None
filename = None
columns = []
def __init__(self, data_sources=None):
self.data_sources = data_sources or ReportDataSources()
def generate(self, filters):
return {
"title": self.title,
"filename": self.filename,
"columns": self.columns,
"rows": self.build_rows(filters),
}
def build_rows(self, filters):
raise NotImplementedError
class UserReport(BaseReport):
report_type = "user"
title = "User Report"
filename = "user-report.xlsx"
columns = [
{"key": "user_id", "label": "User ID"},
{"key": "full_name", "label": "Full Name"},
{"key": "email", "label": "Email"},
{"key": "status", "label": "Status"},
{"key": "ticket_count", "label": "Ticket Count"},
]
def build_rows(self, filters):
users = self.data_sources.fetch_users(filters)
user_ids = [user.get("id") for user in users if user.get("id")]
metrics_by_user_id = self.data_sources.fetch_user_metrics(user_ids, filters)
rows = []
for user in users:
user_id = user.get("id")
metrics = metrics_by_user_id.get(user_id, {})
rows.append(
{
"user_id": user_id,
"full_name": user.get("full_name") or user.get("name") or "",
"email": user.get("email", ""),
"status": user.get("status", ""),
"ticket_count": metrics.get("ticket_count", 0),
}
)
return rows
class TicketsReport(BaseReport):
report_type = "tickets"
title = "Tickets Report"
filename = "tickets-report.xlsx"
columns = [
{"key": "ticket_id", "label": "Ticket ID"},
{"key": "title", "label": "Title"},
{"key": "status", "label": "Status"},
{"key": "priority", "label": "Priority"},
{"key": "assignee", "label": "Assignee"},
{"key": "created_at", "label": "Created At"},
]
def build_rows(self, filters):
tickets = self.data_sources.fetch_tickets(filters)
ticket_ids = [ticket.get("id") for ticket in tickets if ticket.get("id")]
metrics_by_ticket_id = self.data_sources.fetch_ticket_metrics(ticket_ids, filters)
rows = []
for ticket in tickets:
ticket_id = ticket.get("id")
metrics = metrics_by_ticket_id.get(ticket_id, {})
rows.append(
{
"ticket_id": ticket_id,
"title": ticket.get("title", ""),
"status": ticket.get("status", ""),
"priority": ticket.get("priority", ""),
"assignee": (
ticket.get("assignee_name")
or ticket.get("assignee", {}).get("name", "")
),
"created_at": ticket.get("created_at", ""),
**metrics,
}
)
return rows
REPORT_TYPES = {
UserReport.report_type: UserReport,
TicketsReport.report_type: TicketsReport,
}

View file

@ -1,151 +1,138 @@
from datetime import datetime
from io import BytesIO
from unittest.mock import patch
from unittest.mock import MagicMock, patch
from uuid import uuid4
from zipfile import ZipFile
from django.test import override_settings
from openpyxl import load_workbook
from rest_framework import status
from rest_framework.test import APITestCase
from apps.reports.services.oauth import OAuth2ClientCredentials
from utils.clients.gooyal_advertising_client.models.ticket_state_enum import TicketStateEnum
class GenerateReportTests(APITestCase):
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_user_metrics")
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_users")
def test_generate_user_report_is_public_and_returns_excel(
self,
mock_fetch_users,
mock_fetch_user_metrics,
):
mock_fetch_users.return_value = [
{
"id": 1,
"full_name": "Alice Doe",
"email": "alice@example.com",
"status": "active",
}
]
mock_fetch_user_metrics.return_value = {
1: {"ticket_count": 3},
}
def _build_ticket(self, user_uuid=None):
ticket = MagicMock()
ticket.uuid = uuid4()
ticket.user = user_uuid or uuid4()
ticket.title = "Login issue"
ticket.description = "Cannot login"
ticket.state = TicketStateEnum(10)
ticket.created_at = datetime(2026, 5, 20, 10, 0)
ticket.updated_at = datetime(2026, 5, 21, 10, 0)
return ticket
response = self.client.post(
"/api/reports/generate/",
{
"report_type": "user",
"filters": {"status": "active"},
},
format="json",
)
def _build_user(self, user_uuid):
user = MagicMock()
user.uuid = user_uuid
user.username = "alice"
user.first_name = "Alice"
user.last_name = "Doe"
user.email = "alice@example.com"
user.phone_number = "09120000000"
user.address = "Tehran"
return user
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response["Content-Type"],
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
self.assertEqual(
response["Content-Disposition"],
'attachment; filename="user-report.xlsx"',
)
workbook = load_workbook(BytesIO(response.content))
worksheet = workbook.active
self.assertEqual(worksheet["A1"].value, "User Report")
self.assertEqual(
[cell.value for cell in worksheet[2]],
["User ID", "Full Name", "Email", "Status", "Ticket Count"],
)
self.assertEqual(
[cell.value for cell in worksheet[3]],
[1, "Alice Doe", "alice@example.com", "active", 3],
)
mock_fetch_users.assert_called_once_with({"status": "active"})
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_ticket_metrics")
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_tickets")
def test_generate_tickets_report_uses_static_columns(
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_users_for_tickets")
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_application_tickets")
def test_generate_report_returns_zip_with_two_excel_files(
self,
mock_fetch_tickets,
mock_fetch_ticket_metrics,
mock_fetch_users,
):
mock_fetch_tickets.return_value = [
{
"id": 11,
"title": "Login issue",
"status": "open",
"priority": "high",
"assignee": {"name": "Support Agent"},
"created_at": "2026-05-20T10:00:00Z",
}
]
mock_fetch_ticket_metrics.return_value = {}
ticket = self._build_ticket()
user = self._build_user(ticket.user)
mock_fetch_tickets.return_value = [ticket]
mock_fetch_users.return_value = [user]
response = self.client.post(
"/api/reports/generate/",
{"report_type": "tickets"},
format="json",
)
response = self.client.post("/api/reports/generate/")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response["Content-Type"], "application/zip")
self.assertEqual(
response["Content-Disposition"],
'attachment; filename="tickets-report.xlsx"',
'attachment; filename="crm-reports.zip"',
)
workbook = load_workbook(BytesIO(response.content))
worksheet = workbook.active
self.assertEqual(worksheet["A1"].value, "Tickets Report")
self.assertEqual(
[cell.value for cell in worksheet[2]],
["Ticket ID", "Title", "Status", "Priority", "Assignee", "Created At"],
)
self.assertEqual(
[cell.value for cell in worksheet[3]],
[
11,
"Login issue",
"open",
"high",
"Support Agent",
"2026-05-20T10:00:00Z",
],
)
with ZipFile(BytesIO(response.content)) as archive:
self.assertEqual(
set(archive.namelist()),
{"users-report.xlsx", "tickets-report.xlsx"},
)
def test_unknown_report_type_returns_validation_error(self):
response = self.client.post(
"/api/reports/generate/",
{"report_type": "unknown"},
format="json",
)
users_workbook = load_workbook(BytesIO(archive.read("users-report.xlsx")))
users_sheet = users_workbook.active
self.assertEqual(users_sheet["A1"].value, "Users Report")
self.assertEqual(
[cell.value for cell in users_sheet[2]],
[
"accounts_uuid",
"accounts_username",
"accounts_first_name",
"accounts_last_name",
"accounts_email",
"accounts_phone_number",
"accounts_address",
],
)
self.assertEqual(
[cell.value for cell in users_sheet[3]],
[
str(user.uuid),
"alice",
"Alice",
"Doe",
"alice@example.com",
"09120000000",
"Tehran",
],
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
tickets_workbook = load_workbook(
BytesIO(archive.read("tickets-report.xlsx"))
)
tickets_sheet = tickets_workbook.active
self.assertEqual(tickets_sheet["A1"].value, "Tickets Report")
self.assertEqual(
[cell.value for cell in tickets_sheet[2]],
[
"advertising_uuid",
"advertising_user",
"advertising_title",
"advertising_description",
"advertising_state",
"advertising_created_at",
"advertising_updated_at",
],
)
self.assertEqual(
[cell.value for cell in tickets_sheet[3]],
[
str(ticket.uuid),
str(ticket.user),
"Login issue",
"Cannot login",
"CLOSED",
"2026-05-20 10:00:00",
"2026-05-21 10:00:00",
],
)
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_users_for_tickets")
@patch("apps.reports.services.data_sources.ReportDataSources.fetch_application_tickets")
def test_generate_report_skips_missing_users(
self,
mock_fetch_tickets,
mock_fetch_users,
):
ticket = self._build_ticket()
mock_fetch_tickets.return_value = [ticket]
mock_fetch_users.return_value = [None]
class OAuth2ClientCredentialsTests(APITestCase):
@override_settings(
OAUTH2_PROVIDER_PRIVATE_URL="https://auth.internal",
OAUTH2_CLIENT_ID="client-id",
OAUTH2_CLIENT_SECRET="client-secret",
OAUTH2_SCOPES="reports:read customers:read",
SERVICE_REQUEST_TIMEOUT=10,
)
@patch("apps.reports.services.oauth.requests.post")
def test_get_access_token_uses_client_credentials(self, mock_post):
mock_post.return_value.json.return_value = {
"access_token": "token-value",
"expires_in": 3600,
}
mock_post.return_value.raise_for_status.return_value = None
response = self.client.post("/api/reports/generate/")
token = OAuth2ClientCredentials().get_access_token()
self.assertEqual(token, "token-value")
mock_post.assert_called_once_with(
"https://auth.internal/oauth2/token",
data={
"grant_type": "client_credentials",
"scope": "reports:read customers:read",
},
auth=("client-id", "client-secret"),
timeout=10,
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
with ZipFile(BytesIO(response.content)) as archive:
users_workbook = load_workbook(BytesIO(archive.read("users-report.xlsx")))
self.assertIsNone(users_workbook.active["A3"].value)

View file

@ -1,36 +1,60 @@
from django.http import HttpResponse
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiResponse, extend_schema
from rest_framework import status
from rest_framework.views import APIView
from apps.reports.serializers import ReportGenerateSerializer
from apps.reports.services.excel import build_report_workbook
from apps.reports.services.orchestrator import ReportOrchestrator
from apps.reports.services.data_sources import ReportDataSources
from apps.reports.services.excel import build_report_workbook, build_report_zip
from apps.reports.services.report_builder import (
TICKETS_COLUMNS,
USERS_COLUMNS,
build_ticket_rows,
build_user_rows,
)
class GenerateReportView(APIView):
authentication_classes = []
permission_classes = []
@extend_schema(
tags=["Reports"],
summary="Generate CRM reports",
description=(
"Fetches application tickets and related user profiles, then returns a "
"ZIP archive containing `users-report.xlsx` and `tickets-report.xlsx`."
),
request=None,
responses={
(200, "application/zip"): OpenApiResponse(
response=OpenApiTypes.BINARY,
description="ZIP archive with users and tickets Excel reports.",
),
},
)
def post(self, request):
serializer = ReportGenerateSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
data_sources = ReportDataSources()
tickets = data_sources.fetch_application_tickets()
users = data_sources.fetch_users_for_tickets(tickets)
orchestrator = ReportOrchestrator()
report_data = orchestrator.generate(serializer.validated_data)
workbook = build_report_workbook(
title=report_data["title"],
columns=report_data["columns"],
rows=report_data["rows"],
)
files = {
"users-report.xlsx": build_report_workbook(
title="Users Report",
columns=USERS_COLUMNS,
rows=build_user_rows(users),
),
"tickets-report.xlsx": build_report_workbook(
title="Tickets Report",
columns=TICKETS_COLUMNS,
rows=build_ticket_rows(tickets),
),
}
response = HttpResponse(
workbook,
content_type=(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
),
build_report_zip(files),
content_type="application/zip",
status=status.HTTP_200_OK,
)
response["Content-Disposition"] = (
f'attachment; filename="{report_data["filename"]}"'
)
response["Content-Disposition"] = 'attachment; filename="crm-reports.zip"'
return response

View file

@ -37,11 +37,13 @@ DJANGO_APPS = [
THIRD_PARTY_APPS = [
"corsheaders",
"rest_framework",
"drf_spectacular",
]
LOCAL_APPS = [
"apps.core",
"apps.reports",
"apps.proxy",
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
@ -123,6 +125,7 @@ CORS_ALLOW_CREDENTIALS = env.bool("CORS_ALLOW_CREDENTIALS", default=True)
REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_RENDERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
],
@ -148,10 +151,67 @@ REST_FRAMEWORK = {
}
SPECTACULAR_SETTINGS = {
"TITLE": "CRM Backend API",
"DESCRIPTION": (
"API for CRM report generation and health checks, plus a merged view of "
"every proxied service's own API (see apps.proxy)."
),
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
"POSTPROCESSING_HOOKS": [
"drf_spectacular.hooks.postprocess_schema_enums",
"apps.proxy.schema.merge_upstream_schemas",
],
}
SERVICE_REQUEST_TIMEOUT = env.int("SERVICE_REQUEST_TIMEOUT", default=30)
OAUTH2_PROVIDER_PUBLIC_URL = env("OAUTH2_PROVIDER_PUBLIC_URL", default="")
OAUTH2_PROVIDER_PRIVATE_URL = env("OAUTH2_PROVIDER_PRIVATE_URL", default="")
OAUTH2_PROVIDER_BASE_PUBLIC_URL = env("OAUTH2_PROVIDER_BASE_PUBLIC_URL", default="")
OAUTH2_PROVIDER_BASE_PRIVATE_URL = env("OAUTH2_PROVIDER_BASE_PRIVATE_URL", default="")
OAUTH2_PROVIDER_CLIENT_ID = env("OAUTH2_PROVIDER_CLIENT_ID", default="")
OAUTH2_PROVIDER_CLIENT_SECRET = env("OAUTH2_PROVIDER_CLIENT_SECRET", default="")
OAUTH2_PROVIDER_SCOPES = env("OAUTH2_PROVIDER_SCOPES", default="")
OAUTH2_CLIENT_ID = env("OAUTH2_CLIENT_ID", default="")
OAUTH2_CLIENT_SECRET = env("OAUTH2_CLIENT_SECRET", default="")
OAUTH2_SCOPES = env("OAUTH2_SCOPES", default="")
ADVERTISING_BASE_PUBLIC_URL = env("ADVERTISING_BASE_PUBLIC_URL", default="")
ACCOUNTS_BASE_PUBLIC_URL = env("ACCOUNTS_BASE_PUBLIC_URL", default="")
WALLET_BASE_PUBLIC_URL = env("WALLET_BASE_PUBLIC_URL", default="")
WALLET_RIAL = env("WALLET_RIAL", default="")
WALLET_REWARD = env("WALLET_REWARD", default="")
CHAT_BASE_PUBLIC_URL = env("CHAT_BASE_PUBLIC_URL", default="")
NOTIFICATIONS_BASE_PUBLIC_URL = env("NOTIFICATIONS_BASE_PUBLIC_URL", default="")
PROMOTIONS_BASE_PUBLIC_URL = env("PROMOTIONS_BASE_PUBLIC_URL", default="")
CAMPAIGN_BASE_PUBLIC_URL = env("CAMPAIGN_BASE_PUBLIC_URL", default="")
IPG_BASE_PUBLIC_URL = env("IPG_BASE_PUBLIC_URL", default="")
# Maps the first path segment of a proxied request (thisprojectbaseurl/<service>/<rest>)
# to the upstream service's base URL. See apps.proxy.views.ServiceProxyView.
PROXY_SERVICE_BASE_URLS = {
"accounts": ACCOUNTS_BASE_PUBLIC_URL,
"wallet": WALLET_BASE_PUBLIC_URL,
"advertising": ADVERTISING_BASE_PUBLIC_URL,
"chat": CHAT_BASE_PUBLIC_URL,
"notifications": NOTIFICATIONS_BASE_PUBLIC_URL,
"promotions": PROMOTIONS_BASE_PUBLIC_URL,
"campaign": CAMPAIGN_BASE_PUBLIC_URL,
"ipg": IPG_BASE_PUBLIC_URL,
}
# Where each service publishes its own raw OpenAPI document (drf-spectacular's
# SpectacularAPIView, mounted at different prefixes per service). Used by
# apps.proxy.schema to fold every proxied endpoint into this service's swagger.
PROXY_SERVICE_SCHEMA_PATHS = {
"accounts": "/swagger/?format=json",
"wallet": "/swagger/?format=json",
"advertising": "/swagger/?format=json",
"chat": "/swagger/?format=json",
"notifications": "/swagger/?format=json",
"promotions": "/swagger/?format=json",
"campaign": "/api/swagger/schema/?format=json",
"ipg": "/swagger/?format=json",
}

View file

@ -1,9 +1,20 @@
from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
urlpatterns = [
path("admin/", admin.site.urls),
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
path("api/docs/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui"),
path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
path("api/", include("apps.core.urls")),
path("api/reports/", include("apps.reports.urls")),
# Catch-all reverse proxy: thisprojectbaseurl/<service>/<rest of url>.
# Must stay last so it never shadows the routes above.
path("", include("apps.proxy.urls")),
]

View file

@ -1,5 +1,6 @@
Django>=4.2,<5.0
djangorestframework>=3.15,<4.0
drf-spectacular>=0.27,<1.0
django-environ>=0.11,<1.0
django-cors-headers>=4.3,<5.0
whitenoise>=6.6,<7.0
@ -7,3 +8,4 @@ psycopg[binary]>=3.1,<4.0
requests>=2.32,<3.0
urllib3>=1.26,<2.0
openpyxl>=3.1,<4.0
openapi-python-client

76
utils/accounts_client.py Normal file
View file

@ -0,0 +1,76 @@
import time
import requests
from django.conf import settings
from django.core.cache import cache
from django.db import models
from httpx import Request
from utils.clients.gooyal_accounts_client import AuthenticatedClient
from utils.clients.gooyal_accounts_client.models import Account
from utils.clients.gooyal_accounts_client.api.users import (users_api_users_details_retrieve)
from utils.http_fallback import request_with_ssl_fallback, resolve_verify_ssl
def login_as_client_credentials():
access_token = cache.get('settlement_access_token')
# expires_in = self.auth_data.get('expires_in')
# created_at = self.auth_data.get('created_at')
#
# if access_token and expires_in > time.time() - created_at:
# return self.auth_data
if access_token:
print('already in cache')
return access_token
print('not in cache')
data = {
"grant_type": 'client_credentials',
"scope": settings.OAUTH2_PROVIDER_SCOPES,
}
auth = (settings.OAUTH2_PROVIDER_CLIENT_ID, settings.OAUTH2_PROVIDER_CLIENT_SECRET)
response = request_with_ssl_fallback('POST', f'{settings.OAUTH2_PROVIDER_BASE_PUBLIC_URL}/token/',
data=data,
auth=auth)
print(response.content)
auth_data = response.json()
if 'access_token' in auth_data:
auth_data['created_at'] = time.time()
cache.set('settlement_access_token', auth_data, timeout=auth_data.get('expires_in') - 5)
return auth_data
def log_request(request: Request):
print(request.headers['authorization'])
print(
f"Request event hook: {request.method} {request.url} {request.method} {request.headers} - Waiting for response")
def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
def get_client():
access_token = login_as_client_credentials()['access_token']
verify_ssl = resolve_verify_ssl(settings.ACCOUNTS_BASE_PUBLIC_URL)
client = AuthenticatedClient(base_url=settings.ACCOUNTS_BASE_PUBLIC_URL, token=access_token,
verify_ssl=verify_ssl,
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
return client
def get_user_detailed_info(uuid):
client = get_client()
response: Account = users_api_users_details_retrieve.sync(uuid=uuid, client=client)
print(response)
return response

107
utils/advertising_client.py Normal file
View file

@ -0,0 +1,107 @@
import time
import requests
from django.conf import settings
from django.core.cache import cache
from httpx import Request
from utils.clients.gooyal_advertising_client import AuthenticatedClient
from utils.clients.gooyal_advertising_client.api.crm.crm_tickets_list import sync as crm_tickets_list_sync
from utils.clients.gooyal_advertising_client.api.crm.crm_application_tickets_list import sync as crm_application_tickets_list_sync
from utils.clients.gooyal_advertising_client.api.suggestions.suggestions_suggest_list import sync as suggestions_suggest_list_sync
from utils.clients.gooyal_advertising_client.models.paginated_ticket_list import PaginatedTicketList
from utils.clients.gooyal_advertising_client.models.paginated_suggestion_list import PaginatedSuggestionList
from utils.http_fallback import request_with_ssl_fallback, resolve_verify_ssl
def login_as_client_credentials():
access_token = cache.get('advertising_access_token')
if access_token:
print('already in cache')
return access_token
print('not in cache')
data = {
'grant_type': 'client_credentials',
'scope': settings.OAUTH2_PROVIDER_SCOPES,
}
auth = (settings.OAUTH2_PROVIDER_CLIENT_ID, settings.OAUTH2_PROVIDER_CLIENT_SECRET)
response = request_with_ssl_fallback(
'POST',
f'{settings.OAUTH2_PROVIDER_BASE_PUBLIC_URL}/token/',
data=data,
auth=auth,
)
print(response.content)
auth_data = response.json()
if 'access_token' in auth_data:
auth_data['created_at'] = time.time()
cache.set('advertising_access_token', auth_data, timeout=auth_data.get('expires_in') - 5)
return auth_data
def log_request(request: Request):
print(request.headers.get('authorization'))
print(
f'Request event hook: {request.method} {request.url} {request.headers} - Waiting for response'
)
def log_response(response):
request = response.request
print(f'Response event hook: {request.method} {request.url} - Status {response.status_code}')
def get_client():
access_token = login_as_client_credentials()['access_token']
verify_ssl = resolve_verify_ssl(settings.ADVERTISING_BASE_PUBLIC_URL)
client = AuthenticatedClient(
base_url=settings.ADVERTISING_BASE_PUBLIC_URL,
token=access_token,
verify_ssl=verify_ssl,
httpx_args={
'event_hooks': {
'request': [log_request],
'response': [log_response],
}
},
)
return client
def get_suggestions(limit=None, offset=None):
client = get_client()
response: PaginatedSuggestionList = suggestions_suggest_list_sync(
client=client,
limit=limit,
offset=offset,
)
print(response)
return response
def get_crm_tickets(limit=None, offset=None):
client = get_client()
response: PaginatedTicketList = crm_tickets_list_sync(
client=client,
limit=limit,
offset=offset,
)
print(response)
return response
def get_crm_application_tickets(limit=None, offset=None):
client = get_client()
response: PaginatedTicketList = crm_application_tickets_list_sync(
client=client,
limit=limit,
offset=offset,
)
print(response)
return response

View file

@ -0,0 +1,8 @@
"""A client library for accessing Gooyal Accounts"""
from .client import AuthenticatedClient, Client
__all__ = (
"AuthenticatedClient",
"Client",
)

View file

@ -0,0 +1 @@
"""Contains methods for accessing the API"""

View file

@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -0,0 +1,142 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application import Application
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/oauth2/apis/applications/{id}/avatar/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Application]:
if response.status_code == 200:
response_200 = Application.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[Application]:
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: str,
*,
client: AuthenticatedClient,
) -> Response[Application]:
"""
Args:
id (str):
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[Application]
"""
kwargs = _get_kwargs(
id=id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Application]:
"""
Args:
id (str):
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:
Application
"""
return sync_detailed(
id=id,
client=client,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Application]:
"""
Args:
id (str):
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[Application]
"""
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: str,
*,
client: AuthenticatedClient,
) -> Optional[Application]:
"""
Args:
id (str):
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:
Application
"""
return (
await asyncio_detailed(
id=id,
client=client,
)
).parsed

View file

@ -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.paginated_application_list import PaginatedApplicationList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
page: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["page"] = page
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": "/oauth2/apis/applications/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedApplicationList]:
if response.status_code == 200:
response_200 = PaginatedApplicationList.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[PaginatedApplicationList]:
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,
page: Union[Unset, int] = UNSET,
) -> Response[PaginatedApplicationList]:
"""
Args:
page (Union[Unset, 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[PaginatedApplicationList]
"""
kwargs = _get_kwargs(
page=page,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Optional[PaginatedApplicationList]:
"""
Args:
page (Union[Unset, 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:
PaginatedApplicationList
"""
return sync_detailed(
client=client,
page=page,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Response[PaginatedApplicationList]:
"""
Args:
page (Union[Unset, 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[PaginatedApplicationList]
"""
kwargs = _get_kwargs(
page=page,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Optional[PaginatedApplicationList]:
"""
Args:
page (Union[Unset, 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:
PaginatedApplicationList
"""
return (
await asyncio_detailed(
client=client,
page=page,
)
).parsed

View file

@ -0,0 +1,142 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application import Application
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/oauth2/apis/applications/{id}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Application]:
if response.status_code == 200:
response_200 = Application.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[Application]:
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: str,
*,
client: AuthenticatedClient,
) -> Response[Application]:
"""
Args:
id (str):
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[Application]
"""
kwargs = _get_kwargs(
id=id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Application]:
"""
Args:
id (str):
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:
Application
"""
return sync_detailed(
id=id,
client=client,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Application]:
"""
Args:
id (str):
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[Application]
"""
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: str,
*,
client: AuthenticatedClient,
) -> Optional[Application]:
"""
Args:
id (str):
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:
Application
"""
return (
await asyncio_detailed(
id=id,
client=client,
)
).parsed

View file

@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -0,0 +1,152 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.account import Account
from ...models.patched_account import PatchedAccount
from ...types import Response
def _get_kwargs(
*,
body: PatchedAccount,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": "/users/api/account/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Account]:
if response.status_code == 200:
response_200 = Account.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[Account]:
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,
body: PatchedAccount,
) -> Response[Account]:
"""
Args:
body (PatchedAccount):
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[Account]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: PatchedAccount,
) -> Optional[Account]:
"""
Args:
body (PatchedAccount):
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:
Account
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: PatchedAccount,
) -> Response[Account]:
"""
Args:
body (PatchedAccount):
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[Account]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: PatchedAccount,
) -> Optional[Account]:
"""
Args:
body (PatchedAccount):
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:
Account
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,118 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.account import Account
from ...types import Response
def _get_kwargs() -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/users/api/account/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Account]:
if response.status_code == 200:
response_200 = Account.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[Account]:
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,
) -> Response[Account]:
"""
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[Account]
"""
kwargs = _get_kwargs()
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
) -> Optional[Account]:
"""
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:
Account
"""
return sync_detailed(
client=client,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Account]:
"""
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[Account]
"""
kwargs = _get_kwargs()
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
) -> Optional[Account]:
"""
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:
Account
"""
return (
await asyncio_detailed(
client=client,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.account import Account
from ...types import Response
def _get_kwargs(
*,
body: Account,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "put",
"url": "/users/api/account/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Account]:
if response.status_code == 200:
response_200 = Account.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[Account]:
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,
body: Account,
) -> Response[Account]:
"""
Args:
body (Account):
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[Account]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: Account,
) -> Optional[Account]:
"""
Args:
body (Account):
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:
Account
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: Account,
) -> Response[Account]:
"""
Args:
body (Account):
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[Account]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: Account,
) -> Optional[Account]:
"""
Args:
body (Account):
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:
Account
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,156 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.change_password import ChangePassword
from ...models.patched_change_password import PatchedChangePassword
from ...types import Response
def _get_kwargs(
*,
body: PatchedChangePassword,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": "/users/api/change_password/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ChangePassword]:
if response.status_code == 200:
response_200 = ChangePassword.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[ChangePassword]:
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,
body: PatchedChangePassword,
) -> Response[ChangePassword]:
"""
Args:
body (PatchedChangePassword):
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[ChangePassword]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: PatchedChangePassword,
) -> Optional[ChangePassword]:
"""
Args:
body (PatchedChangePassword):
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:
ChangePassword
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: PatchedChangePassword,
) -> Response[ChangePassword]:
"""
Args:
body (PatchedChangePassword):
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[ChangePassword]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: PatchedChangePassword,
) -> Optional[ChangePassword]:
"""
Args:
body (PatchedChangePassword):
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:
ChangePassword
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,155 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.change_password import ChangePassword
from ...types import Response
def _get_kwargs(
*,
body: ChangePassword,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "put",
"url": "/users/api/change_password/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ChangePassword]:
if response.status_code == 200:
response_200 = ChangePassword.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[ChangePassword]:
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,
body: ChangePassword,
) -> Response[ChangePassword]:
"""
Args:
body (ChangePassword):
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[ChangePassword]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: ChangePassword,
) -> Optional[ChangePassword]:
"""
Args:
body (ChangePassword):
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:
ChangePassword
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: ChangePassword,
) -> Response[ChangePassword]:
"""
Args:
body (ChangePassword):
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[ChangePassword]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: ChangePassword,
) -> Optional[ChangePassword]:
"""
Args:
body (ChangePassword):
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:
ChangePassword
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.user_inquiry import UserInquiry
from ...types import Response
def _get_kwargs(
*,
body: UserInquiry,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/users/api/inquiry/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[UserInquiry]:
if response.status_code == 201:
response_201 = UserInquiry.from_dict(response.json())
return response_201
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[UserInquiry]:
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,
body: UserInquiry,
) -> Response[UserInquiry]:
"""
Args:
body (UserInquiry):
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[UserInquiry]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: UserInquiry,
) -> Optional[UserInquiry]:
"""
Args:
body (UserInquiry):
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:
UserInquiry
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: UserInquiry,
) -> Response[UserInquiry]:
"""
Args:
body (UserInquiry):
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[UserInquiry]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: UserInquiry,
) -> Optional[UserInquiry]:
"""
Args:
body (UserInquiry):
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:
UserInquiry
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.request_otp import RequestOTP
from ...types import Response
def _get_kwargs(
*,
body: RequestOTP,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/users/api/request_otp/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[RequestOTP]:
if response.status_code == 201:
response_201 = RequestOTP.from_dict(response.json())
return response_201
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[RequestOTP]:
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,
body: RequestOTP,
) -> Response[RequestOTP]:
"""
Args:
body (RequestOTP):
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[RequestOTP]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: RequestOTP,
) -> Optional[RequestOTP]:
"""
Args:
body (RequestOTP):
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:
RequestOTP
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: RequestOTP,
) -> Response[RequestOTP]:
"""
Args:
body (RequestOTP):
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[RequestOTP]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: RequestOTP,
) -> Optional[RequestOTP]:
"""
Args:
body (RequestOTP):
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:
RequestOTP
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.request_ott import RequestOTT
from ...types import Response
def _get_kwargs(
*,
body: RequestOTT,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/users/api/request_ott/",
}
_body = body.to_dict()
_kwargs["json"] = _body
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[RequestOTT]:
if response.status_code == 201:
response_201 = RequestOTT.from_dict(response.json())
return response_201
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[RequestOTT]:
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,
body: RequestOTT,
) -> Response[RequestOTT]:
"""
Args:
body (RequestOTT):
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[RequestOTT]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: RequestOTT,
) -> Optional[RequestOTT]:
"""
Args:
body (RequestOTT):
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:
RequestOTT
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: RequestOTT,
) -> Response[RequestOTT]:
"""
Args:
body (RequestOTT):
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[RequestOTT]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: RequestOTT,
) -> Optional[RequestOTT]:
"""
Args:
body (RequestOTT):
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:
RequestOTT
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,92 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/users/api/users/{uuid}/avatar",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
if response.status_code == 200:
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(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
uuid (UUID):
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(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
uuid (UUID):
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(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View file

@ -0,0 +1,143 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.account import Account
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/users/api/users/{uuid}/details",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Account]:
if response.status_code == 200:
response_200 = Account.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[Account]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Account]:
"""
Args:
uuid (UUID):
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[Account]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Account]:
"""
Args:
uuid (UUID):
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:
Account
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Account]:
"""
Args:
uuid (UUID):
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[Account]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Account]:
"""
Args:
uuid (UUID):
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:
Account
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -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.paginated_public_user_list import PaginatedPublicUserList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
page: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["page"] = page
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": "/users/api/users/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedPublicUserList]:
if response.status_code == 200:
response_200 = PaginatedPublicUserList.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[PaginatedPublicUserList]:
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,
page: Union[Unset, int] = UNSET,
) -> Response[PaginatedPublicUserList]:
"""
Args:
page (Union[Unset, 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[PaginatedPublicUserList]
"""
kwargs = _get_kwargs(
page=page,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Optional[PaginatedPublicUserList]:
"""
Args:
page (Union[Unset, 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:
PaginatedPublicUserList
"""
return sync_detailed(
client=client,
page=page,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Response[PaginatedPublicUserList]:
"""
Args:
page (Union[Unset, 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[PaginatedPublicUserList]
"""
kwargs = _get_kwargs(
page=page,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
page: Union[Unset, int] = UNSET,
) -> Optional[PaginatedPublicUserList]:
"""
Args:
page (Union[Unset, 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:
PaginatedPublicUserList
"""
return (
await asyncio_detailed(
client=client,
page=page,
)
).parsed

View file

@ -0,0 +1,143 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.public_user import PublicUser
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/users/api/users/{uuid}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[PublicUser]:
if response.status_code == 200:
response_200 = PublicUser.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[PublicUser]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[PublicUser]:
"""
Args:
uuid (UUID):
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[PublicUser]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[PublicUser]:
"""
Args:
uuid (UUID):
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:
PublicUser
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[PublicUser]:
"""
Args:
uuid (UUID):
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[PublicUser]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[PublicUser]:
"""
Args:
uuid (UUID):
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:
PublicUser
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -0,0 +1,268 @@
import ssl
from typing import Any, Optional, Union
import httpx
from attrs import define, evolve, field
@define
class Client:
"""A class for keeping track of data related to the API
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
def with_headers(self, headers: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "Client":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "Client":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "Client":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@define
class AuthenticatedClient:
"""A Client which has been authenticated for use on secured endpoints
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
token: The token to use for authentication
prefix: The prefix to use for the Authorization header
auth_header_name: The name of the Authorization header
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
token: str
prefix: str = "Bearer"
auth_header_name: str = "Authorization"
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "AuthenticatedClient":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "AuthenticatedClient":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)

View file

@ -0,0 +1,16 @@
"""Contains shared errors types that can be raised from API functions"""
class UnexpectedStatus(Exception):
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
def __init__(self, status_code: int, content: bytes):
self.status_code = status_code
self.content = content
super().__init__(
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
)
__all__ = ["UnexpectedStatus"]

View file

@ -0,0 +1,33 @@
"""Contains all the data models used in inputs/outputs"""
from .account import Account
from .application import Application
from .blank_enum import BlankEnum
from .change_password import ChangePassword
from .education_degree_enum import EducationDegreeEnum
from .gender_enum import GenderEnum
from .paginated_application_list import PaginatedApplicationList
from .paginated_public_user_list import PaginatedPublicUserList
from .patched_account import PatchedAccount
from .patched_change_password import PatchedChangePassword
from .public_user import PublicUser
from .request_otp import RequestOTP
from .request_ott import RequestOTT
from .user_inquiry import UserInquiry
__all__ = (
"Account",
"Application",
"BlankEnum",
"ChangePassword",
"EducationDegreeEnum",
"GenderEnum",
"PaginatedApplicationList",
"PaginatedPublicUserList",
"PatchedAccount",
"PatchedChangePassword",
"PublicUser",
"RequestOTP",
"RequestOTT",
"UserInquiry",
)

View file

@ -0,0 +1,410 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.blank_enum import BlankEnum
from ..models.education_degree_enum import EducationDegreeEnum
from ..models.gender_enum import GenderEnum
from ..types import UNSET, Unset
T = TypeVar("T", bound="Account")
@_attrs_define
class Account:
"""
Attributes:
uuid (UUID):
email (str):
phone_number (str):
iban_verified (Union[None, bool]):
province_name (str):
city_name (str):
username (Union[None, Unset, str]): Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
first_name (Union[Unset, str]):
last_name (Union[Unset, str]):
name (Union[Unset, str]):
avatar (Union[None, Unset, str]):
gender (Union[BlankEnum, GenderEnum, None, Unset]):
education_degree (Union[BlankEnum, EducationDegreeEnum, None, Unset]):
education_field (Union[None, Unset, str]):
birthdate (Union[None, Unset, datetime.date]):
iban (Union[None, Unset, str]):
province (Union[None, Unset, int]):
city (Union[None, Unset, int]):
postal_code (Union[None, Unset, str]):
address (Union[None, Unset, str]):
"""
uuid: UUID
email: str
phone_number: str
iban_verified: Union[None, bool]
province_name: str
city_name: str
username: Union[None, Unset, str] = UNSET
first_name: Union[Unset, str] = UNSET
last_name: Union[Unset, str] = UNSET
name: Union[Unset, str] = UNSET
avatar: Union[None, Unset, str] = UNSET
gender: Union[BlankEnum, GenderEnum, None, Unset] = UNSET
education_degree: Union[BlankEnum, EducationDegreeEnum, None, Unset] = UNSET
education_field: Union[None, Unset, str] = UNSET
birthdate: Union[None, Unset, datetime.date] = UNSET
iban: Union[None, Unset, str] = UNSET
province: Union[None, Unset, int] = UNSET
city: Union[None, Unset, int] = UNSET
postal_code: Union[None, Unset, str] = UNSET
address: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
uuid = str(self.uuid)
email = self.email
phone_number = self.phone_number
iban_verified: Union[None, bool]
iban_verified = self.iban_verified
province_name = self.province_name
city_name = self.city_name
username: Union[None, Unset, str]
if isinstance(self.username, Unset):
username = UNSET
else:
username = self.username
first_name = self.first_name
last_name = self.last_name
name = self.name
avatar: Union[None, Unset, str]
if isinstance(self.avatar, Unset):
avatar = UNSET
else:
avatar = self.avatar
gender: Union[None, Unset, str]
if isinstance(self.gender, Unset):
gender = UNSET
elif isinstance(self.gender, GenderEnum):
gender = self.gender.value
elif isinstance(self.gender, BlankEnum):
gender = self.gender.value
else:
gender = self.gender
education_degree: Union[None, Unset, str]
if isinstance(self.education_degree, Unset):
education_degree = UNSET
elif isinstance(self.education_degree, EducationDegreeEnum):
education_degree = self.education_degree.value
elif isinstance(self.education_degree, BlankEnum):
education_degree = self.education_degree.value
else:
education_degree = self.education_degree
education_field: Union[None, Unset, str]
if isinstance(self.education_field, Unset):
education_field = UNSET
else:
education_field = self.education_field
birthdate: Union[None, Unset, str]
if isinstance(self.birthdate, Unset):
birthdate = UNSET
elif isinstance(self.birthdate, datetime.date):
birthdate = self.birthdate.isoformat()
else:
birthdate = self.birthdate
iban: Union[None, Unset, str]
if isinstance(self.iban, Unset):
iban = UNSET
else:
iban = self.iban
province: Union[None, Unset, int]
if isinstance(self.province, Unset):
province = UNSET
else:
province = self.province
city: Union[None, Unset, int]
if isinstance(self.city, Unset):
city = UNSET
else:
city = self.city
postal_code: Union[None, Unset, str]
if isinstance(self.postal_code, Unset):
postal_code = UNSET
else:
postal_code = self.postal_code
address: Union[None, Unset, str]
if isinstance(self.address, Unset):
address = UNSET
else:
address = self.address
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"uuid": uuid,
"email": email,
"phone_number": phone_number,
"iban_verified": iban_verified,
"province_name": province_name,
"city_name": city_name,
}
)
if username is not UNSET:
field_dict["username"] = username
if first_name is not UNSET:
field_dict["first_name"] = first_name
if last_name is not UNSET:
field_dict["last_name"] = last_name
if name is not UNSET:
field_dict["name"] = name
if avatar is not UNSET:
field_dict["avatar"] = avatar
if gender is not UNSET:
field_dict["gender"] = gender
if education_degree is not UNSET:
field_dict["education_degree"] = education_degree
if education_field is not UNSET:
field_dict["education_field"] = education_field
if birthdate is not UNSET:
field_dict["birthdate"] = birthdate
if iban is not UNSET:
field_dict["iban"] = iban
if province is not UNSET:
field_dict["province"] = province
if city is not UNSET:
field_dict["city"] = city
if postal_code is not UNSET:
field_dict["postal_code"] = postal_code
if address is not UNSET:
field_dict["address"] = address
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
uuid = UUID(d.pop("uuid"))
email = d.pop("email")
phone_number = d.pop("phone_number")
def _parse_iban_verified(data: object) -> Union[None, bool]:
if data is None:
return data
return cast(Union[None, bool], data)
iban_verified = _parse_iban_verified(d.pop("iban_verified"))
province_name = d.pop("province_name")
city_name = d.pop("city_name")
def _parse_username(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
username = _parse_username(d.pop("username", UNSET))
first_name = d.pop("first_name", UNSET)
last_name = d.pop("last_name", UNSET)
name = d.pop("name", UNSET)
def _parse_avatar(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
avatar = _parse_avatar(d.pop("avatar", UNSET))
def _parse_gender(data: object) -> Union[BlankEnum, GenderEnum, None, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
gender_type_0 = GenderEnum(data)
return gender_type_0
except: # noqa: E722
pass
try:
if not isinstance(data, str):
raise TypeError()
gender_type_1 = BlankEnum(data)
return gender_type_1
except: # noqa: E722
pass
return cast(Union[BlankEnum, GenderEnum, None, Unset], data)
gender = _parse_gender(d.pop("gender", UNSET))
def _parse_education_degree(data: object) -> Union[BlankEnum, EducationDegreeEnum, None, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
education_degree_type_0 = EducationDegreeEnum(data)
return education_degree_type_0
except: # noqa: E722
pass
try:
if not isinstance(data, str):
raise TypeError()
education_degree_type_1 = BlankEnum(data)
return education_degree_type_1
except: # noqa: E722
pass
return cast(Union[BlankEnum, EducationDegreeEnum, None, Unset], data)
education_degree = _parse_education_degree(d.pop("education_degree", UNSET))
def _parse_education_field(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
education_field = _parse_education_field(d.pop("education_field", UNSET))
def _parse_birthdate(data: object) -> Union[None, Unset, datetime.date]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
birthdate_type_0 = isoparse(data).date()
return birthdate_type_0
except: # noqa: E722
pass
return cast(Union[None, Unset, datetime.date], data)
birthdate = _parse_birthdate(d.pop("birthdate", UNSET))
def _parse_iban(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
iban = _parse_iban(d.pop("iban", UNSET))
def _parse_province(data: object) -> Union[None, Unset, int]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, int], data)
province = _parse_province(d.pop("province", UNSET))
def _parse_city(data: object) -> Union[None, Unset, int]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, int], data)
city = _parse_city(d.pop("city", UNSET))
def _parse_postal_code(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
postal_code = _parse_postal_code(d.pop("postal_code", UNSET))
def _parse_address(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
address = _parse_address(d.pop("address", UNSET))
account = cls(
uuid=uuid,
email=email,
phone_number=phone_number,
iban_verified=iban_verified,
province_name=province_name,
city_name=city_name,
username=username,
first_name=first_name,
last_name=last_name,
name=name,
avatar=avatar,
gender=gender,
education_degree=education_degree,
education_field=education_field,
birthdate=birthdate,
iban=iban,
province=province,
city=city,
postal_code=postal_code,
address=address,
)
account.additional_properties = d
return account
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,106 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
T = TypeVar("T", bound="Application")
@_attrs_define
class Application:
"""
Attributes:
uuid (UUID):
name (str):
avatar (Union[None, str]):
client_id (str):
user (UUID):
allowed_scope (str):
"""
uuid: UUID
name: str
avatar: Union[None, str]
client_id: str
user: UUID
allowed_scope: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
uuid = str(self.uuid)
name = self.name
avatar: Union[None, str]
avatar = self.avatar
client_id = self.client_id
user = str(self.user)
allowed_scope = self.allowed_scope
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"uuid": uuid,
"name": name,
"avatar": avatar,
"client_id": client_id,
"user": user,
"allowed_scope": allowed_scope,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
uuid = UUID(d.pop("uuid"))
name = d.pop("name")
def _parse_avatar(data: object) -> Union[None, str]:
if data is None:
return data
return cast(Union[None, str], data)
avatar = _parse_avatar(d.pop("avatar"))
client_id = d.pop("client_id")
user = UUID(d.pop("user"))
allowed_scope = d.pop("allowed_scope")
application = cls(
uuid=uuid,
name=name,
avatar=avatar,
client_id=client_id,
user=user,
allowed_scope=allowed_scope,
)
application.additional_properties = d
return application
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,8 @@
from enum import Enum
class BlankEnum(str, Enum):
VALUE_0 = ""
def __str__(self) -> str:
return str(self.value)

View file

@ -0,0 +1,78 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="ChangePassword")
@_attrs_define
class ChangePassword:
"""
Attributes:
old_password (str):
new_password (str):
old_password_field (Union[Unset, str]): Default: 'password'.
"""
old_password: str
new_password: str
old_password_field: Union[Unset, str] = "password"
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
old_password = self.old_password
new_password = self.new_password
old_password_field = self.old_password_field
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"old_password": old_password,
"new_password": new_password,
}
)
if old_password_field is not UNSET:
field_dict["old_password_field"] = old_password_field
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
old_password = d.pop("old_password")
new_password = d.pop("new_password")
old_password_field = d.pop("old_password_field", UNSET)
change_password = cls(
old_password=old_password,
new_password=new_password,
old_password_field=old_password_field,
)
change_password.additional_properties = d
return change_password
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,14 @@
from enum import Enum
class EducationDegreeEnum(str, Enum):
ASSOCIATE = "associate"
BACHELORS = "bachelors"
DOCTORATE = "doctorate"
HIGH = "high"
MASTERS = "masters"
MIDDLE = "middle"
PRIMARY = "primary"
def __str__(self) -> str:
return str(self.value)

View file

@ -0,0 +1,9 @@
from enum import Enum
class GenderEnum(str, Enum):
F = "f"
M = "m"
def __str__(self) -> str:
return str(self.value)

View file

@ -0,0 +1,123 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.application import Application
T = TypeVar("T", bound="PaginatedApplicationList")
@_attrs_define
class PaginatedApplicationList:
"""
Attributes:
count (int): Example: 123.
results (list['Application']):
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
"""
count: int
results: list["Application"]
next_: Union[None, Unset, str] = UNSET
previous: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
count = self.count
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
next_: Union[None, Unset, str]
if isinstance(self.next_, Unset):
next_ = UNSET
else:
next_ = self.next_
previous: Union[None, Unset, str]
if isinstance(self.previous, Unset):
previous = UNSET
else:
previous = self.previous
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"count": count,
"results": results,
}
)
if next_ is not UNSET:
field_dict["next"] = next_
if previous is not UNSET:
field_dict["previous"] = previous
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.application import Application
d = dict(src_dict)
count = d.pop("count")
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = Application.from_dict(results_item_data)
results.append(results_item)
def _parse_next_(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
next_ = _parse_next_(d.pop("next", UNSET))
def _parse_previous(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
previous = _parse_previous(d.pop("previous", UNSET))
paginated_application_list = cls(
count=count,
results=results,
next_=next_,
previous=previous,
)
paginated_application_list.additional_properties = d
return paginated_application_list
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,123 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.public_user import PublicUser
T = TypeVar("T", bound="PaginatedPublicUserList")
@_attrs_define
class PaginatedPublicUserList:
"""
Attributes:
count (int): Example: 123.
results (list['PublicUser']):
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
"""
count: int
results: list["PublicUser"]
next_: Union[None, Unset, str] = UNSET
previous: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
count = self.count
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
next_: Union[None, Unset, str]
if isinstance(self.next_, Unset):
next_ = UNSET
else:
next_ = self.next_
previous: Union[None, Unset, str]
if isinstance(self.previous, Unset):
previous = UNSET
else:
previous = self.previous
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"count": count,
"results": results,
}
)
if next_ is not UNSET:
field_dict["next"] = next_
if previous is not UNSET:
field_dict["previous"] = previous
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.public_user import PublicUser
d = dict(src_dict)
count = d.pop("count")
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = PublicUser.from_dict(results_item_data)
results.append(results_item)
def _parse_next_(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
next_ = _parse_next_(d.pop("next", UNSET))
def _parse_previous(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
previous = _parse_previous(d.pop("previous", UNSET))
paginated_public_user_list = cls(
count=count,
results=results,
next_=next_,
previous=previous,
)
paginated_public_user_list.additional_properties = d
return paginated_public_user_list
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,425 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.blank_enum import BlankEnum
from ..models.education_degree_enum import EducationDegreeEnum
from ..models.gender_enum import GenderEnum
from ..types import UNSET, Unset
T = TypeVar("T", bound="PatchedAccount")
@_attrs_define
class PatchedAccount:
"""
Attributes:
uuid (Union[Unset, UUID]):
username (Union[None, Unset, str]): Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
email (Union[Unset, str]):
phone_number (Union[Unset, str]):
first_name (Union[Unset, str]):
last_name (Union[Unset, str]):
name (Union[Unset, str]):
avatar (Union[None, Unset, str]):
gender (Union[BlankEnum, GenderEnum, None, Unset]):
education_degree (Union[BlankEnum, EducationDegreeEnum, None, Unset]):
education_field (Union[None, Unset, str]):
birthdate (Union[None, Unset, datetime.date]):
iban (Union[None, Unset, str]):
iban_verified (Union[None, Unset, bool]):
province (Union[None, Unset, int]):
province_name (Union[Unset, str]):
city (Union[None, Unset, int]):
city_name (Union[Unset, str]):
postal_code (Union[None, Unset, str]):
address (Union[None, Unset, str]):
"""
uuid: Union[Unset, UUID] = UNSET
username: Union[None, Unset, str] = UNSET
email: Union[Unset, str] = UNSET
phone_number: Union[Unset, str] = UNSET
first_name: Union[Unset, str] = UNSET
last_name: Union[Unset, str] = UNSET
name: Union[Unset, str] = UNSET
avatar: Union[None, Unset, str] = UNSET
gender: Union[BlankEnum, GenderEnum, None, Unset] = UNSET
education_degree: Union[BlankEnum, EducationDegreeEnum, None, Unset] = UNSET
education_field: Union[None, Unset, str] = UNSET
birthdate: Union[None, Unset, datetime.date] = UNSET
iban: Union[None, Unset, str] = UNSET
iban_verified: Union[None, Unset, bool] = UNSET
province: Union[None, Unset, int] = UNSET
province_name: Union[Unset, str] = UNSET
city: Union[None, Unset, int] = UNSET
city_name: Union[Unset, str] = UNSET
postal_code: Union[None, Unset, str] = UNSET
address: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
uuid: Union[Unset, str] = UNSET
if not isinstance(self.uuid, Unset):
uuid = str(self.uuid)
username: Union[None, Unset, str]
if isinstance(self.username, Unset):
username = UNSET
else:
username = self.username
email = self.email
phone_number = self.phone_number
first_name = self.first_name
last_name = self.last_name
name = self.name
avatar: Union[None, Unset, str]
if isinstance(self.avatar, Unset):
avatar = UNSET
else:
avatar = self.avatar
gender: Union[None, Unset, str]
if isinstance(self.gender, Unset):
gender = UNSET
elif isinstance(self.gender, GenderEnum):
gender = self.gender.value
elif isinstance(self.gender, BlankEnum):
gender = self.gender.value
else:
gender = self.gender
education_degree: Union[None, Unset, str]
if isinstance(self.education_degree, Unset):
education_degree = UNSET
elif isinstance(self.education_degree, EducationDegreeEnum):
education_degree = self.education_degree.value
elif isinstance(self.education_degree, BlankEnum):
education_degree = self.education_degree.value
else:
education_degree = self.education_degree
education_field: Union[None, Unset, str]
if isinstance(self.education_field, Unset):
education_field = UNSET
else:
education_field = self.education_field
birthdate: Union[None, Unset, str]
if isinstance(self.birthdate, Unset):
birthdate = UNSET
elif isinstance(self.birthdate, datetime.date):
birthdate = self.birthdate.isoformat()
else:
birthdate = self.birthdate
iban: Union[None, Unset, str]
if isinstance(self.iban, Unset):
iban = UNSET
else:
iban = self.iban
iban_verified: Union[None, Unset, bool]
if isinstance(self.iban_verified, Unset):
iban_verified = UNSET
else:
iban_verified = self.iban_verified
province: Union[None, Unset, int]
if isinstance(self.province, Unset):
province = UNSET
else:
province = self.province
province_name = self.province_name
city: Union[None, Unset, int]
if isinstance(self.city, Unset):
city = UNSET
else:
city = self.city
city_name = self.city_name
postal_code: Union[None, Unset, str]
if isinstance(self.postal_code, Unset):
postal_code = UNSET
else:
postal_code = self.postal_code
address: Union[None, Unset, str]
if isinstance(self.address, Unset):
address = UNSET
else:
address = self.address
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if uuid is not UNSET:
field_dict["uuid"] = uuid
if username is not UNSET:
field_dict["username"] = username
if email is not UNSET:
field_dict["email"] = email
if phone_number is not UNSET:
field_dict["phone_number"] = phone_number
if first_name is not UNSET:
field_dict["first_name"] = first_name
if last_name is not UNSET:
field_dict["last_name"] = last_name
if name is not UNSET:
field_dict["name"] = name
if avatar is not UNSET:
field_dict["avatar"] = avatar
if gender is not UNSET:
field_dict["gender"] = gender
if education_degree is not UNSET:
field_dict["education_degree"] = education_degree
if education_field is not UNSET:
field_dict["education_field"] = education_field
if birthdate is not UNSET:
field_dict["birthdate"] = birthdate
if iban is not UNSET:
field_dict["iban"] = iban
if iban_verified is not UNSET:
field_dict["iban_verified"] = iban_verified
if province is not UNSET:
field_dict["province"] = province
if province_name is not UNSET:
field_dict["province_name"] = province_name
if city is not UNSET:
field_dict["city"] = city
if city_name is not UNSET:
field_dict["city_name"] = city_name
if postal_code is not UNSET:
field_dict["postal_code"] = postal_code
if address is not UNSET:
field_dict["address"] = address
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
_uuid = d.pop("uuid", UNSET)
uuid: Union[Unset, UUID]
if isinstance(_uuid, Unset):
uuid = UNSET
else:
uuid = UUID(_uuid)
def _parse_username(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
username = _parse_username(d.pop("username", UNSET))
email = d.pop("email", UNSET)
phone_number = d.pop("phone_number", UNSET)
first_name = d.pop("first_name", UNSET)
last_name = d.pop("last_name", UNSET)
name = d.pop("name", UNSET)
def _parse_avatar(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
avatar = _parse_avatar(d.pop("avatar", UNSET))
def _parse_gender(data: object) -> Union[BlankEnum, GenderEnum, None, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
gender_type_0 = GenderEnum(data)
return gender_type_0
except: # noqa: E722
pass
try:
if not isinstance(data, str):
raise TypeError()
gender_type_1 = BlankEnum(data)
return gender_type_1
except: # noqa: E722
pass
return cast(Union[BlankEnum, GenderEnum, None, Unset], data)
gender = _parse_gender(d.pop("gender", UNSET))
def _parse_education_degree(data: object) -> Union[BlankEnum, EducationDegreeEnum, None, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
education_degree_type_0 = EducationDegreeEnum(data)
return education_degree_type_0
except: # noqa: E722
pass
try:
if not isinstance(data, str):
raise TypeError()
education_degree_type_1 = BlankEnum(data)
return education_degree_type_1
except: # noqa: E722
pass
return cast(Union[BlankEnum, EducationDegreeEnum, None, Unset], data)
education_degree = _parse_education_degree(d.pop("education_degree", UNSET))
def _parse_education_field(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
education_field = _parse_education_field(d.pop("education_field", UNSET))
def _parse_birthdate(data: object) -> Union[None, Unset, datetime.date]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
birthdate_type_0 = isoparse(data).date()
return birthdate_type_0
except: # noqa: E722
pass
return cast(Union[None, Unset, datetime.date], data)
birthdate = _parse_birthdate(d.pop("birthdate", UNSET))
def _parse_iban(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
iban = _parse_iban(d.pop("iban", UNSET))
def _parse_iban_verified(data: object) -> Union[None, Unset, bool]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, bool], data)
iban_verified = _parse_iban_verified(d.pop("iban_verified", UNSET))
def _parse_province(data: object) -> Union[None, Unset, int]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, int], data)
province = _parse_province(d.pop("province", UNSET))
province_name = d.pop("province_name", UNSET)
def _parse_city(data: object) -> Union[None, Unset, int]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, int], data)
city = _parse_city(d.pop("city", UNSET))
city_name = d.pop("city_name", UNSET)
def _parse_postal_code(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
postal_code = _parse_postal_code(d.pop("postal_code", UNSET))
def _parse_address(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
address = _parse_address(d.pop("address", UNSET))
patched_account = cls(
uuid=uuid,
username=username,
email=email,
phone_number=phone_number,
first_name=first_name,
last_name=last_name,
name=name,
avatar=avatar,
gender=gender,
education_degree=education_degree,
education_field=education_field,
birthdate=birthdate,
iban=iban,
iban_verified=iban_verified,
province=province,
province_name=province_name,
city=city,
city_name=city_name,
postal_code=postal_code,
address=address,
)
patched_account.additional_properties = d
return patched_account
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,77 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="PatchedChangePassword")
@_attrs_define
class PatchedChangePassword:
"""
Attributes:
old_password (Union[Unset, str]):
old_password_field (Union[Unset, str]): Default: 'password'.
new_password (Union[Unset, str]):
"""
old_password: Union[Unset, str] = UNSET
old_password_field: Union[Unset, str] = "password"
new_password: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
old_password = self.old_password
old_password_field = self.old_password_field
new_password = self.new_password
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if old_password is not UNSET:
field_dict["old_password"] = old_password
if old_password_field is not UNSET:
field_dict["old_password_field"] = old_password_field
if new_password is not UNSET:
field_dict["new_password"] = new_password
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
old_password = d.pop("old_password", UNSET)
old_password_field = d.pop("old_password_field", UNSET)
new_password = d.pop("new_password", UNSET)
patched_change_password = cls(
old_password=old_password,
old_password_field=old_password_field,
new_password=new_password,
)
patched_change_password.additional_properties = d
return patched_change_password
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,113 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
T = TypeVar("T", bound="PublicUser")
@_attrs_define
class PublicUser:
"""
Attributes:
avatar (Union[None, str]):
name (str):
username (Union[None, str]): Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
first_name (str):
last_name (str):
uuid (UUID):
"""
avatar: Union[None, str]
name: str
username: Union[None, str]
first_name: str
last_name: str
uuid: UUID
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
avatar: Union[None, str]
avatar = self.avatar
name = self.name
username: Union[None, str]
username = self.username
first_name = self.first_name
last_name = self.last_name
uuid = str(self.uuid)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"avatar": avatar,
"name": name,
"username": username,
"first_name": first_name,
"last_name": last_name,
"uuid": uuid,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
def _parse_avatar(data: object) -> Union[None, str]:
if data is None:
return data
return cast(Union[None, str], data)
avatar = _parse_avatar(d.pop("avatar"))
name = d.pop("name")
def _parse_username(data: object) -> Union[None, str]:
if data is None:
return data
return cast(Union[None, str], data)
username = _parse_username(d.pop("username"))
first_name = d.pop("first_name")
last_name = d.pop("last_name")
uuid = UUID(d.pop("uuid"))
public_user = cls(
avatar=avatar,
name=name,
username=username,
first_name=first_name,
last_name=last_name,
uuid=uuid,
)
public_user.additional_properties = d
return public_user
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,94 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
T = TypeVar("T", bound="RequestOTP")
@_attrs_define
class RequestOTP:
"""
Attributes:
phone_number (str):
otp_expire (Union[None, datetime.datetime]):
ttl (str):
"""
phone_number: str
otp_expire: Union[None, datetime.datetime]
ttl: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
phone_number = self.phone_number
otp_expire: Union[None, str]
if isinstance(self.otp_expire, datetime.datetime):
otp_expire = self.otp_expire.isoformat()
else:
otp_expire = self.otp_expire
ttl = self.ttl
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"phone_number": phone_number,
"otp_expire": otp_expire,
"ttl": ttl,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
phone_number = d.pop("phone_number")
def _parse_otp_expire(data: object) -> Union[None, datetime.datetime]:
if data is None:
return data
try:
if not isinstance(data, str):
raise TypeError()
otp_expire_type_0 = isoparse(data)
return otp_expire_type_0
except: # noqa: E722
pass
return cast(Union[None, datetime.datetime], data)
otp_expire = _parse_otp_expire(d.pop("otp_expire"))
ttl = d.pop("ttl")
request_otp = cls(
phone_number=phone_number,
otp_expire=otp_expire,
ttl=ttl,
)
request_otp.additional_properties = d
return request_otp
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,100 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
T = TypeVar("T", bound="RequestOTT")
@_attrs_define
class RequestOTT:
"""
Attributes:
application (str):
ott (Union[None, str]):
ott_expire (Union[None, datetime.datetime]):
"""
application: str
ott: Union[None, str]
ott_expire: Union[None, datetime.datetime]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
application = self.application
ott: Union[None, str]
ott = self.ott
ott_expire: Union[None, str]
if isinstance(self.ott_expire, datetime.datetime):
ott_expire = self.ott_expire.isoformat()
else:
ott_expire = self.ott_expire
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"application": application,
"ott": ott,
"ott_expire": ott_expire,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
application = d.pop("application")
def _parse_ott(data: object) -> Union[None, str]:
if data is None:
return data
return cast(Union[None, str], data)
ott = _parse_ott(d.pop("ott"))
def _parse_ott_expire(data: object) -> Union[None, datetime.datetime]:
if data is None:
return data
try:
if not isinstance(data, str):
raise TypeError()
ott_expire_type_0 = isoparse(data)
return ott_expire_type_0
except: # noqa: E722
pass
return cast(Union[None, datetime.datetime], data)
ott_expire = _parse_ott_expire(d.pop("ott_expire"))
request_ott = cls(
application=application,
ott=ott,
ott_expire=ott_expire,
)
request_ott.additional_properties = d
return request_ott
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1,68 @@
from collections.abc import Mapping
from typing import Any, TypeVar
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
T = TypeVar("T", bound="UserInquiry")
@_attrs_define
class UserInquiry:
"""
Attributes:
uuid (UUID):
phone_number (str):
"""
uuid: UUID
phone_number: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
uuid = str(self.uuid)
phone_number = self.phone_number
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"uuid": uuid,
"phone_number": phone_number,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
uuid = UUID(d.pop("uuid"))
phone_number = d.pop("phone_number")
user_inquiry = cls(
uuid=uuid,
phone_number=phone_number,
)
user_inquiry.additional_properties = d
return user_inquiry
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -0,0 +1 @@
# Marker file for PEP 561

View file

@ -0,0 +1,46 @@
"""Contains some shared types for properties"""
from collections.abc import MutableMapping
from http import HTTPStatus
from typing import BinaryIO, Generic, Literal, Optional, TypeVar
from attrs import define
class Unset:
def __bool__(self) -> Literal[False]:
return False
UNSET: Unset = Unset()
FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]]
@define
class File:
"""Contains information for file uploads"""
payload: BinaryIO
file_name: Optional[str] = None
mime_type: Optional[str] = None
def to_tuple(self) -> FileJsonType:
"""Return a tuple representation that httpx will accept for multipart/form-data"""
return self.file_name, self.payload, self.mime_type
T = TypeVar("T")
@define
class Response(Generic[T]):
"""A response from an endpoint"""
status_code: HTTPStatus
content: bytes
headers: MutableMapping[str, str]
parsed: Optional[T]
__all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"]

View file

@ -0,0 +1,8 @@
"""A client library for accessing merchants"""
from .client import AuthenticatedClient, Client
__all__ = (
"AuthenticatedClient",
"Client",
)

View file

@ -0,0 +1 @@
"""Contains methods for accessing the API"""

View file

@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -0,0 +1,170 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_config_list import PaginatedConfigList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
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/config/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedConfigList]:
if response.status_code == 200:
response_200 = PaginatedConfigList.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[PaginatedConfigList]:
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,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedConfigList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedConfigList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedConfigList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedConfigList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -0,0 +1,78 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response
def _get_kwargs() -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/api/status",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
if response.status_code == 200:
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(
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
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()
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
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()
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View file

@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
*,
body: Ticket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/crm/application/tickets/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 201:
response_201 = Ticket.from_dict(response.json())
return response_201
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[Ticket]:
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,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
body (Ticket):
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:
Ticket
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
body (Ticket):
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:
Ticket
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,92 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/crm/application/tickets/{id}/",
}
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: str,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
id (str):
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,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
id (str):
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,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View file

@ -0,0 +1,170 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ticket_list import PaginatedTicketList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
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": "/crm/application/tickets/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedTicketList]:
if response.status_code == 200:
response_200 = PaginatedTicketList.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[PaginatedTicketList]:
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,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedTicketList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedTicketList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedTicketList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedTicketList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.patched_ticket import PatchedTicket
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
*,
body: PatchedTicket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/crm/application/tickets/{id}/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,143 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/crm/application/tickets/{id}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
) -> Response[Ticket]:
"""
Args:
id (str):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Ticket]:
"""
Args:
id (str):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Ticket]:
"""
Args:
id (str):
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[Ticket]
"""
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: str,
*,
client: AuthenticatedClient,
) -> Optional[Ticket]:
"""
Args:
id (str):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
)
).parsed

View file

@ -0,0 +1,164 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
*,
body: Ticket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "put",
"url": f"/crm/application/tickets/{id}/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (Ticket):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (Ticket):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
*,
body: Ticket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/crm/tickets/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 201:
response_201 = Ticket.from_dict(response.json())
return response_201
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[Ticket]:
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,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
body (Ticket):
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:
Ticket
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
body (Ticket):
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:
Ticket
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,92 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/crm/tickets/{id}/",
}
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: str,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
id (str):
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,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Any]:
"""
Args:
id (str):
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,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)

View file

@ -0,0 +1,170 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ticket_list import PaginatedTicketList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
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": "/crm/tickets/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedTicketList]:
if response.status_code == 200:
response_200 = PaginatedTicketList.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[PaginatedTicketList]:
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,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedTicketList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedTicketList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedTicketList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedTicketList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedTicketList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.patched_ticket import PatchedTicket
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
*,
body: PatchedTicket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/crm/tickets/{id}/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
id: str,
*,
client: AuthenticatedClient,
body: PatchedTicket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (PatchedTicket):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,143 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/crm/tickets/{id}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
) -> Response[Ticket]:
"""
Args:
id (str):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
) -> Optional[Ticket]:
"""
Args:
id (str):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
) -> Response[Ticket]:
"""
Args:
id (str):
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[Ticket]
"""
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: str,
*,
client: AuthenticatedClient,
) -> Optional[Ticket]:
"""
Args:
id (str):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
)
).parsed

View file

@ -0,0 +1,164 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ticket import Ticket
from ...types import Response
def _get_kwargs(
id: str,
*,
body: Ticket,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "put",
"url": f"/crm/tickets/{id}/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ticket]:
if response.status_code == 200:
response_200 = Ticket.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[Ticket]:
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: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (Ticket):
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:
Ticket
"""
return sync_detailed(
id=id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Response[Ticket]:
"""
Args:
id (str):
body (Ticket):
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[Ticket]
"""
kwargs = _get_kwargs(
id=id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
id: str,
*,
client: AuthenticatedClient,
body: Ticket,
) -> Optional[Ticket]:
"""
Args:
id (str):
body (Ticket):
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:
Ticket
"""
return (
await asyncio_detailed(
id=id,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -0,0 +1,445 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_with_visit_list import PaginatedAdWithVisitList
from ...models.stores_ads_bookmarked_list_ordering_item import StoresAdsBookmarkedListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsBookmarkedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["limit"] = limit
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
params["offset"] = offset
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/bookmarked/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdWithVisitList]:
if response.status_code == 200:
response_200 = PaginatedAdWithVisitList.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[PaginatedAdWithVisitList]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsBookmarkedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsBookmarkedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsBookmarkedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsBookmarkedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsBookmarkedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsBookmarkedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsBookmarkedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsBookmarkedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,420 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.cluster import Cluster
from ...models.stores_ads_clusterized_list_ordering_item import StoresAdsClusterizedListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/clusterized/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[list["Cluster"]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = Cluster.from_dict(response_200_item_data)
response_200.append(response_200_item)
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[list["Cluster"]]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[list['Cluster']]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
list['Cluster']
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[list['Cluster']]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
list['Cluster']
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,445 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_list import PaginatedAdList
from ...models.stores_ads_list_ordering_item import StoresAdsListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["limit"] = limit
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
params["offset"] = offset
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdList]:
if response.status_code == 200:
response_200 = PaginatedAdList.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[PaginatedAdList]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdList
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdList
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,420 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.cluster import Cluster
from ...models.stores_ads_public_clusterized_list_ordering_item import StoresAdsPublicClusterizedListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/public_clusterized/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[list["Cluster"]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = Cluster.from_dict(response_200_item_data)
response_200.append(response_200_item)
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[list["Cluster"]]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[list['Cluster']]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
list['Cluster']
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[list['Cluster']]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[list["Cluster"]]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
ordering (Union[Unset, list[StoresAdsPublicClusterizedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
list['Cluster']
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,445 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_public_list import PaginatedAdPublicList
from ...models.stores_ads_public_list_list_ordering_item import StoresAdsPublicListListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicListListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["limit"] = limit
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
params["offset"] = offset
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/public_list/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdPublicList]:
if response.status_code == 200:
response_200 = PaginatedAdPublicList.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[PaginatedAdPublicList]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicListListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdPublicList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsPublicListListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdPublicList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicListListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdPublicList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsPublicListListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdPublicList
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicListListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdPublicList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsPublicListListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdPublicList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsPublicListListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdPublicList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsPublicListListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdPublicList
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,144 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ad_public import AdPublic
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/stores/ads/{uuid}/public_retrieve/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[AdPublic]:
if response.status_code == 200:
response_200 = AdPublic.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[AdPublic]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[AdPublic]:
"""
Args:
uuid (UUID):
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[AdPublic]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[AdPublic]:
"""
Args:
uuid (UUID):
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:
AdPublic
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[AdPublic]:
"""
Args:
uuid (UUID):
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[AdPublic]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[AdPublic]:
"""
Args:
uuid (UUID):
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:
AdPublic
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.visit_reaction import VisitReaction
from ...types import Response
def _get_kwargs(
uuid: UUID,
*,
body: VisitReaction,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/ads/{uuid}/react/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[VisitReaction]:
if response.status_code == 200:
response_200 = VisitReaction.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[VisitReaction]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: VisitReaction,
) -> Response[VisitReaction]:
"""
Args:
uuid (UUID):
body (VisitReaction):
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[VisitReaction]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
body: VisitReaction,
) -> Optional[VisitReaction]:
"""
Args:
uuid (UUID):
body (VisitReaction):
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:
VisitReaction
"""
return sync_detailed(
uuid=uuid,
client=client,
body=body,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: VisitReaction,
) -> Response[VisitReaction]:
"""
Args:
uuid (UUID):
body (VisitReaction):
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[VisitReaction]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
body: VisitReaction,
) -> Optional[VisitReaction]:
"""
Args:
uuid (UUID):
body (VisitReaction):
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:
VisitReaction
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ad_report import AdReport
from ...types import Response
def _get_kwargs(
uuid: UUID,
*,
body: AdReport,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/ads/{uuid}/report/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[AdReport]:
if response.status_code == 200:
response_200 = AdReport.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[AdReport]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: AdReport,
) -> Response[AdReport]:
"""
Args:
uuid (UUID):
body (AdReport):
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[AdReport]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
body: AdReport,
) -> Optional[AdReport]:
"""
Args:
uuid (UUID):
body (AdReport):
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:
AdReport
"""
return sync_detailed(
uuid=uuid,
client=client,
body=body,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: AdReport,
) -> Response[AdReport]:
"""
Args:
uuid (UUID):
body (AdReport):
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[AdReport]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
body: AdReport,
) -> Optional[AdReport]:
"""
Args:
uuid (UUID):
body (AdReport):
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:
AdReport
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,144 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ad import Ad
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/stores/ads/{uuid}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Ad]:
if response.status_code == 200:
response_200 = Ad.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[Ad]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Ad]:
"""
Args:
uuid (UUID):
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[Ad]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Ad]:
"""
Args:
uuid (UUID):
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:
Ad
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Ad]:
"""
Args:
uuid (UUID):
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[Ad]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Ad]:
"""
Args:
uuid (UUID):
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:
Ad
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -0,0 +1,445 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_with_visit_list import PaginatedAdWithVisitList
from ...models.stores_ads_visited_list_ordering_item import StoresAdsVisitedListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsVisitedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["limit"] = limit
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
params["offset"] = offset
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/visited/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdWithVisitList]:
if response.status_code == 200:
response_200 = PaginatedAdWithVisitList.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[PaginatedAdWithVisitList]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsVisitedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsVisitedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsVisitedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsVisitedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsVisitedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsVisitedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsVisitedListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsVisitedListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,445 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_with_visit_list import PaginatedAdWithVisitList
from ...models.stores_ads_with_visits_list_ordering_item import StoresAdsWithVisitsListOrderingItem
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsWithVisitsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["bookmark"] = bookmark
params["favorite"] = favorite
params["limit"] = limit
params["location_dst"] = location_dst
params["location_lat"] = location_lat
params["location_lon"] = location_lon
params["max_lat"] = max_lat
params["max_lon"] = max_lon
params["min_lat"] = min_lat
params["min_lon"] = min_lon
params["offset"] = offset
json_ordering: Union[Unset, list[str]] = UNSET
if not isinstance(ordering, Unset):
json_ordering = []
for ordering_item_data in ordering:
ordering_item = ordering_item_data.value
json_ordering.append(ordering_item)
params["ordering"] = json_ordering
json_payment_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(payment_state_in, Unset):
json_payment_state_in = payment_state_in
params["payment_state__in"] = json_payment_state_in
params["search"] = search
json_state_in: Union[Unset, list[int]] = UNSET
if not isinstance(state_in, Unset):
json_state_in = state_in
params["state__in"] = json_state_in
params["tags"] = tags
params["title__icontains"] = title_icontains
json_type_in: Union[Unset, list[int]] = UNSET
if not isinstance(type_in, Unset):
json_type_in = type_in
params["type__in"] = json_type_in
params["visited"] = visited
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": "/stores/ads/with_visits/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdWithVisitList]:
if response.status_code == 200:
response_200 = PaginatedAdWithVisitList.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[PaginatedAdWithVisitList]:
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,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsWithVisitsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsWithVisitsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsWithVisitsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsWithVisitsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return sync_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsWithVisitsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Response[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsWithVisitsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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[PaginatedAdWithVisitList]
"""
kwargs = _get_kwargs(
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
bookmark: Union[Unset, bool] = UNSET,
favorite: Union[Unset, bool] = UNSET,
limit: Union[Unset, int] = UNSET,
location_dst: Union[Unset, str] = UNSET,
location_lat: Union[Unset, str] = UNSET,
location_lon: Union[Unset, str] = UNSET,
max_lat: Union[Unset, str] = UNSET,
max_lon: Union[Unset, str] = UNSET,
min_lat: Union[Unset, str] = UNSET,
min_lon: Union[Unset, str] = UNSET,
offset: Union[Unset, int] = UNSET,
ordering: Union[Unset, list[StoresAdsWithVisitsListOrderingItem]] = UNSET,
payment_state_in: Union[Unset, list[int]] = UNSET,
search: Union[Unset, str] = UNSET,
state_in: Union[Unset, list[int]] = UNSET,
tags: Union[Unset, str] = UNSET,
title_icontains: Union[Unset, str] = UNSET,
type_in: Union[Unset, list[int]] = UNSET,
visited: Union[Unset, bool] = UNSET,
) -> Optional[PaginatedAdWithVisitList]:
"""
Args:
bookmark (Union[Unset, bool]):
favorite (Union[Unset, bool]):
limit (Union[Unset, int]):
location_dst (Union[Unset, str]):
location_lat (Union[Unset, str]):
location_lon (Union[Unset, str]):
max_lat (Union[Unset, str]):
max_lon (Union[Unset, str]):
min_lat (Union[Unset, str]):
min_lon (Union[Unset, str]):
offset (Union[Unset, int]):
ordering (Union[Unset, list[StoresAdsWithVisitsListOrderingItem]]):
payment_state_in (Union[Unset, list[int]]):
search (Union[Unset, str]):
state_in (Union[Unset, list[int]]):
tags (Union[Unset, str]):
title_icontains (Union[Unset, str]):
type_in (Union[Unset, list[int]]):
visited (Union[Unset, bool]):
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:
PaginatedAdWithVisitList
"""
return (
await asyncio_detailed(
client=client,
bookmark=bookmark,
favorite=favorite,
limit=limit,
location_dst=location_dst,
location_lat=location_lat,
location_lon=location_lon,
max_lat=max_lat,
max_lon=max_lon,
min_lat=min_lat,
min_lon=min_lon,
offset=offset,
ordering=ordering,
payment_state_in=payment_state_in,
search=search,
state_in=state_in,
tags=tags,
title_icontains=title_icontains,
type_in=type_in,
visited=visited,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.comment_create import CommentCreate
from ...types import Response
def _get_kwargs(
*,
body: CommentCreate,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/stores/comments/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[CommentCreate]:
if response.status_code == 201:
response_201 = CommentCreate.from_dict(response.json())
return response_201
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[CommentCreate]:
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,
body: CommentCreate,
) -> Response[CommentCreate]:
"""
Args:
body (CommentCreate):
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[CommentCreate]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Optional[CommentCreate]:
"""
Args:
body (CommentCreate):
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:
CommentCreate
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Response[CommentCreate]:
"""
Args:
body (CommentCreate):
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[CommentCreate]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Optional[CommentCreate]:
"""
Args:
body (CommentCreate):
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:
CommentCreate
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,207 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_comment_list import PaginatedCommentList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
ad: Union[Unset, UUID] = UNSET,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
user: Union[Unset, UUID] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
json_ad: Union[Unset, str] = UNSET
if not isinstance(ad, Unset):
json_ad = str(ad)
params["ad"] = json_ad
params["limit"] = limit
params["offset"] = offset
json_user: Union[Unset, str] = UNSET
if not isinstance(user, Unset):
json_user = str(user)
params["user"] = json_user
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": "/stores/comments/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedCommentList]:
if response.status_code == 200:
response_200 = PaginatedCommentList.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[PaginatedCommentList]:
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,
ad: Union[Unset, UUID] = UNSET,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
user: Union[Unset, UUID] = UNSET,
) -> Response[PaginatedCommentList]:
"""
Args:
ad (Union[Unset, UUID]):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
user (Union[Unset, UUID]):
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[PaginatedCommentList]
"""
kwargs = _get_kwargs(
ad=ad,
limit=limit,
offset=offset,
user=user,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
ad: Union[Unset, UUID] = UNSET,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
user: Union[Unset, UUID] = UNSET,
) -> Optional[PaginatedCommentList]:
"""
Args:
ad (Union[Unset, UUID]):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
user (Union[Unset, UUID]):
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:
PaginatedCommentList
"""
return sync_detailed(
client=client,
ad=ad,
limit=limit,
offset=offset,
user=user,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
ad: Union[Unset, UUID] = UNSET,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
user: Union[Unset, UUID] = UNSET,
) -> Response[PaginatedCommentList]:
"""
Args:
ad (Union[Unset, UUID]):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
user (Union[Unset, UUID]):
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[PaginatedCommentList]
"""
kwargs = _get_kwargs(
ad=ad,
limit=limit,
offset=offset,
user=user,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
ad: Union[Unset, UUID] = UNSET,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
user: Union[Unset, UUID] = UNSET,
) -> Optional[PaginatedCommentList]:
"""
Args:
ad (Union[Unset, UUID]):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
user (Union[Unset, UUID]):
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:
PaginatedCommentList
"""
return (
await asyncio_detailed(
client=client,
ad=ad,
limit=limit,
offset=offset,
user=user,
)
).parsed

View file

@ -0,0 +1,168 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.reaction_toggle import ReactionToggle
from ...types import Response
def _get_kwargs(
uuid: str,
*,
body: ReactionToggle,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/comments/{uuid}/react/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ReactionToggle]:
if response.status_code == 200:
response_200 = ReactionToggle.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[ReactionToggle]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: str,
*,
client: AuthenticatedClient,
body: ReactionToggle,
) -> Response[ReactionToggle]:
"""
Args:
uuid (str):
body (ReactionToggle):
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[ReactionToggle]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: str,
*,
client: AuthenticatedClient,
body: ReactionToggle,
) -> Optional[ReactionToggle]:
"""
Args:
uuid (str):
body (ReactionToggle):
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:
ReactionToggle
"""
return sync_detailed(
uuid=uuid,
client=client,
body=body,
).parsed
async def asyncio_detailed(
uuid: str,
*,
client: AuthenticatedClient,
body: ReactionToggle,
) -> Response[ReactionToggle]:
"""
Args:
uuid (str):
body (ReactionToggle):
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[ReactionToggle]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: str,
*,
client: AuthenticatedClient,
body: ReactionToggle,
) -> Optional[ReactionToggle]:
"""
Args:
uuid (str):
body (ReactionToggle):
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:
ReactionToggle
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,164 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.comment_create import CommentCreate
from ...types import Response
def _get_kwargs(
uuid: str,
*,
body: CommentCreate,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/comments/{uuid}/reply/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[CommentCreate]:
if response.status_code == 201:
response_201 = CommentCreate.from_dict(response.json())
return response_201
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[CommentCreate]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: str,
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Response[CommentCreate]:
"""
Args:
uuid (str):
body (CommentCreate):
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[CommentCreate]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: str,
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Optional[CommentCreate]:
"""
Args:
uuid (str):
body (CommentCreate):
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:
CommentCreate
"""
return sync_detailed(
uuid=uuid,
client=client,
body=body,
).parsed
async def asyncio_detailed(
uuid: str,
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Response[CommentCreate]:
"""
Args:
uuid (str):
body (CommentCreate):
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[CommentCreate]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: str,
*,
client: AuthenticatedClient,
body: CommentCreate,
) -> Optional[CommentCreate]:
"""
Args:
uuid (str):
body (CommentCreate):
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:
CommentCreate
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,170 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_config_list import PaginatedConfigList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
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": "/stores/config/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedConfigList]:
if response.status_code == 200:
response_200 = PaginatedConfigList.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[PaginatedConfigList]:
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,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedConfigList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedConfigList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedConfigList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedConfigList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedConfigList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.capture import Capture
from ...types import Response
def _get_kwargs(
uuid: UUID,
*,
body: Capture,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/my_ads/{uuid}/capture/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Capture]:
if response.status_code == 200:
response_200 = Capture.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[Capture]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: Capture,
) -> Response[Capture]:
"""
Args:
uuid (UUID):
body (Capture):
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[Capture]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
body: Capture,
) -> Optional[Capture]:
"""
Args:
uuid (UUID):
body (Capture):
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:
Capture
"""
return sync_detailed(
uuid=uuid,
client=client,
body=body,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
body: Capture,
) -> Response[Capture]:
"""
Args:
uuid (UUID):
body (Capture):
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[Capture]
"""
kwargs = _get_kwargs(
uuid=uuid,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
body: Capture,
) -> Optional[Capture]:
"""
Args:
uuid (UUID):
body (Capture):
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:
Capture
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,144 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.capture import Capture
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/stores/my_ads/{uuid}/capturing_detail/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Capture]:
if response.status_code == 200:
response_200 = Capture.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[Capture]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Capture]:
"""
Args:
uuid (UUID):
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[Capture]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Capture]:
"""
Args:
uuid (UUID):
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:
Capture
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Capture]:
"""
Args:
uuid (UUID):
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[Capture]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Capture]:
"""
Args:
uuid (UUID):
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:
Capture
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ad_content import AdContent
from ...types import Response
def _get_kwargs(
ad: UUID,
*,
body: AdContent,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/stores/my_ads/{ad}/contents/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[AdContent]:
if response.status_code == 201:
response_201 = AdContent.from_dict(response.json())
return response_201
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[AdContent]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
ad: UUID,
*,
client: AuthenticatedClient,
body: AdContent,
) -> Response[AdContent]:
"""
Args:
ad (UUID):
body (AdContent):
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[AdContent]
"""
kwargs = _get_kwargs(
ad=ad,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
ad: UUID,
*,
client: AuthenticatedClient,
body: AdContent,
) -> Optional[AdContent]:
"""
Args:
ad (UUID):
body (AdContent):
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:
AdContent
"""
return sync_detailed(
ad=ad,
client=client,
body=body,
).parsed
async def asyncio_detailed(
ad: UUID,
*,
client: AuthenticatedClient,
body: AdContent,
) -> Response[AdContent]:
"""
Args:
ad (UUID):
body (AdContent):
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[AdContent]
"""
kwargs = _get_kwargs(
ad=ad,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
ad: UUID,
*,
client: AuthenticatedClient,
body: AdContent,
) -> Optional[AdContent]:
"""
Args:
ad (UUID):
body (AdContent):
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:
AdContent
"""
return (
await asyncio_detailed(
ad=ad,
client=client,
body=body,
)
).parsed

View file

@ -0,0 +1,184 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_ad_content_list import PaginatedAdContentList
from ...types import UNSET, Response, Unset
def _get_kwargs(
ad: UUID,
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
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": f"/stores/my_ads/{ad}/contents/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAdContentList]:
if response.status_code == 200:
response_200 = PaginatedAdContentList.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[PaginatedAdContentList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
ad: UUID,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedAdContentList]:
"""
Args:
ad (UUID):
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedAdContentList]
"""
kwargs = _get_kwargs(
ad=ad,
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
ad: UUID,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedAdContentList]:
"""
Args:
ad (UUID):
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedAdContentList
"""
return sync_detailed(
ad=ad,
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
ad: UUID,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedAdContentList]:
"""
Args:
ad (UUID):
limit (Union[Unset, int]):
offset (Union[Unset, 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[PaginatedAdContentList]
"""
kwargs = _get_kwargs(
ad=ad,
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
ad: UUID,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedAdContentList]:
"""
Args:
ad (UUID):
limit (Union[Unset, int]):
offset (Union[Unset, 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:
PaginatedAdContentList
"""
return (
await asyncio_detailed(
ad=ad,
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -0,0 +1,151 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.ad_create import AdCreate
from ...types import Response
def _get_kwargs(
*,
body: AdCreate,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/stores/my_ads/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[AdCreate]:
if response.status_code == 201:
response_201 = AdCreate.from_dict(response.json())
return response_201
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[AdCreate]:
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,
body: AdCreate,
) -> Response[AdCreate]:
"""
Args:
body (AdCreate):
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[AdCreate]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: AdCreate,
) -> Optional[AdCreate]:
"""
Args:
body (AdCreate):
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:
AdCreate
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: AdCreate,
) -> Response[AdCreate]:
"""
Args:
body (AdCreate):
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[AdCreate]
"""
kwargs = _get_kwargs(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: AdCreate,
) -> Optional[AdCreate]:
"""
Args:
body (AdCreate):
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:
AdCreate
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed

Some files were not shown because too many files have changed in this diff Show more