add getting user info
This commit is contained in:
parent
f0f7454797
commit
a177fae35b
49 changed files with 4683 additions and 6 deletions
|
|
@ -12,8 +12,12 @@ OAUTH2_PROVIDER_BASE_PUBLIC_URL=https://accounts.example.com/oauth2
|
|||
OAUTH2_PROVIDER_BASE_PRIVATE_URL=https://accounts.example.com/oauth2
|
||||
OAUTH2_PROVIDER_CLIENT_ID=
|
||||
OAUTH2_PROVIDER_CLIENT_SECRET=
|
||||
# Must include accounts.profile:retrieve for the accounts client (see ACCOUNTS_BASE_PUBLIC_URL) to read user profiles
|
||||
OAUTH2_PROVIDER_SCOPES=
|
||||
|
||||
# Gooyal Accounts service — used to fetch public user profiles (name, avatar) for chat responses
|
||||
ACCOUNTS_BASE_PUBLIC_URL=https://accounts.example.com
|
||||
|
||||
# Redis (used for cache, channel layer, and long-poll)
|
||||
REDIS_BASE_URL=redis://127.0.0.1:6379/1
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,40 @@ from drf_spectacular.utils import extend_schema_field
|
|||
from rest_framework import serializers
|
||||
|
||||
from apps.chat.models import Conversation, ConversationParticipant
|
||||
from apps.chat.services.account import AccountService
|
||||
|
||||
|
||||
class ParticipantInfoSerializer(serializers.Serializer):
|
||||
uuid = serializers.UUIDField()
|
||||
name = serializers.CharField(allow_null=True)
|
||||
username = serializers.CharField(allow_null=True)
|
||||
avatar = serializers.CharField(allow_null=True)
|
||||
|
||||
|
||||
def build_participants_info(participant_uuids: list, info_map: dict | None = None) -> list[dict]:
|
||||
"""
|
||||
Resolve participant UUIDs to public profile info (name, avatar) via
|
||||
AccountService, falling back to nulls for any UUID the accounts
|
||||
service didn't return (down service, unknown user, etc).
|
||||
|
||||
Pass a pre-fetched `info_map` (str(uuid) -> profile dict) when info for
|
||||
several conversations' participants is being resolved together, so the
|
||||
accounts service is only called once for the whole batch.
|
||||
"""
|
||||
if info_map is None:
|
||||
info_map = AccountService().get_public_info(participant_uuids)
|
||||
result = []
|
||||
for uid in participant_uuids:
|
||||
profile = info_map.get(str(uid)) or {}
|
||||
result.append(
|
||||
{
|
||||
"uuid": uid,
|
||||
"name": profile.get("name"),
|
||||
"username": profile.get("username"),
|
||||
"avatar": profile.get("avatar"),
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
class CreateConversationSerializer(serializers.Serializer):
|
||||
|
|
@ -18,6 +52,7 @@ class ConversationUserActionSerializer(serializers.Serializer):
|
|||
|
||||
class ConversationSerializer(serializers.ModelSerializer):
|
||||
participants = serializers.SerializerMethodField()
|
||||
participants_info = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = Conversation
|
||||
|
|
@ -29,16 +64,24 @@ class ConversationSerializer(serializers.ModelSerializer):
|
|||
"closed_by_uuid",
|
||||
"created_at",
|
||||
"participants",
|
||||
"participants_info",
|
||||
]
|
||||
|
||||
@extend_schema_field(serializers.ListField(child=serializers.UUIDField()))
|
||||
def get_participants(self, obj):
|
||||
def _participant_uuids(self, obj):
|
||||
return list(
|
||||
ConversationParticipant.objects.filter(conversation_id=obj.uuid)
|
||||
.order_by("joined_at")
|
||||
.values_list("user_uuid", flat=True)
|
||||
)
|
||||
|
||||
@extend_schema_field(serializers.ListField(child=serializers.UUIDField()))
|
||||
def get_participants(self, obj):
|
||||
return self._participant_uuids(obj)
|
||||
|
||||
@extend_schema_field(ParticipantInfoSerializer(many=True))
|
||||
def get_participants_info(self, obj):
|
||||
return build_participants_info(self._participant_uuids(obj))
|
||||
|
||||
|
||||
class ConversationListSerializer(serializers.Serializer):
|
||||
uuid = serializers.UUIDField()
|
||||
|
|
@ -48,5 +91,6 @@ class ConversationListSerializer(serializers.Serializer):
|
|||
closed_by_uuid = serializers.UUIDField(allow_null=True)
|
||||
created_at = serializers.DateTimeField()
|
||||
participants = serializers.ListField(child=serializers.UUIDField())
|
||||
participants_info = ParticipantInfoSerializer(many=True)
|
||||
has_unread = serializers.BooleanField()
|
||||
last_message = serializers.DictField(allow_null=True, required=False)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,26 @@
|
|||
from uuid import UUID
|
||||
|
||||
from utils.clients.accounts_client import get_users_public_info_bulk
|
||||
|
||||
|
||||
class AccountService:
|
||||
def validate_user(self, user_uuid: UUID) -> bool:
|
||||
# Future: call external Account Service HTTP API
|
||||
return True
|
||||
|
||||
def get_public_info(self, user_uuids: list[UUID]) -> dict[str, dict]:
|
||||
"""
|
||||
Fetch public profiles (name, avatar) for the given user UUIDs from
|
||||
the Gooyal Accounts service, keyed by str(uuid).
|
||||
|
||||
Individual profiles are cached by the accounts client, so repeated
|
||||
calls for the same users only hit the network for cache misses.
|
||||
Never raises — callers get an empty dict on any failure so a down
|
||||
accounts service degrades chat responses rather than breaking them.
|
||||
"""
|
||||
if not user_uuids:
|
||||
return {}
|
||||
try:
|
||||
return get_users_public_info_bulk(user_uuids)
|
||||
except Exception:
|
||||
return {}
|
||||
|
|
|
|||
98
apps/chat/tests/test_account_client.py
Normal file
98
apps/chat/tests/test_account_client.py
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
import uuid
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from django.core.cache import cache
|
||||
|
||||
from utils.clients import accounts_client
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clear_account_cache():
|
||||
cache.clear()
|
||||
yield
|
||||
cache.clear()
|
||||
|
||||
|
||||
@patch("utils.clients.accounts_client.requests.post")
|
||||
def test_login_as_client_credentials_caches_token(mock_post):
|
||||
mock_post.return_value = Mock(
|
||||
status_code=200,
|
||||
json=lambda: {"access_token": "tok-1", "expires_in": 300},
|
||||
)
|
||||
mock_post.return_value.raise_for_status = Mock()
|
||||
|
||||
first = accounts_client.login_as_client_credentials()
|
||||
second = accounts_client.login_as_client_credentials()
|
||||
|
||||
assert first["access_token"] == "tok-1"
|
||||
assert second["access_token"] == "tok-1"
|
||||
mock_post.assert_called_once() # second call served from cache, no network hit
|
||||
|
||||
|
||||
@patch("utils.clients.accounts_client.get_client")
|
||||
def test_get_users_public_info_bulk_fetches_and_caches(mock_get_client):
|
||||
user_1, user_2 = uuid.uuid4(), uuid.uuid4()
|
||||
mock_httpx = Mock()
|
||||
mock_httpx.request.return_value = Mock(
|
||||
status_code=200,
|
||||
json=lambda: {
|
||||
"results": [
|
||||
{"uuid": str(user_1), "name": "Alice", "username": "alice", "avatar": "https://a/av1.png"},
|
||||
{"uuid": str(user_2), "name": "Bob", "username": "bob", "avatar": None},
|
||||
]
|
||||
},
|
||||
)
|
||||
mock_get_client.return_value.get_httpx_client.return_value = mock_httpx
|
||||
|
||||
result = accounts_client.get_users_public_info_bulk([user_1, user_2])
|
||||
|
||||
assert result[str(user_1)]["name"] == "Alice"
|
||||
assert result[str(user_2)]["avatar"] is None
|
||||
mock_httpx.request.assert_called_once()
|
||||
|
||||
# Second call for the same UUIDs should be served entirely from cache.
|
||||
mock_get_client.reset_mock()
|
||||
result_again = accounts_client.get_users_public_info_bulk([user_1, user_2])
|
||||
|
||||
assert result_again[str(user_1)]["name"] == "Alice"
|
||||
mock_get_client.assert_not_called()
|
||||
|
||||
|
||||
@patch("utils.clients.accounts_client.get_client")
|
||||
def test_get_users_public_info_bulk_only_fetches_uncached_uuids(mock_get_client):
|
||||
cached_user = uuid.uuid4()
|
||||
uncached_user = uuid.uuid4()
|
||||
cache.set(
|
||||
accounts_client.USER_PUBLIC_INFO_CACHE_KEY.format(uuid=cached_user),
|
||||
{"uuid": str(cached_user), "name": "Cached", "username": "c", "avatar": None},
|
||||
)
|
||||
|
||||
mock_httpx = Mock()
|
||||
mock_httpx.request.return_value = Mock(
|
||||
status_code=200,
|
||||
json=lambda: {
|
||||
"results": [
|
||||
{"uuid": str(uncached_user), "name": "Fresh", "username": "f", "avatar": None},
|
||||
]
|
||||
},
|
||||
)
|
||||
mock_get_client.return_value.get_httpx_client.return_value = mock_httpx
|
||||
|
||||
result = accounts_client.get_users_public_info_bulk([cached_user, uncached_user])
|
||||
|
||||
assert result[str(cached_user)]["name"] == "Cached"
|
||||
assert result[str(uncached_user)]["name"] == "Fresh"
|
||||
requested_url = mock_httpx.request.call_args.kwargs["url"]
|
||||
assert str(cached_user) not in requested_url
|
||||
assert str(uncached_user) in requested_url
|
||||
|
||||
|
||||
def test_get_users_public_info_bulk_empty_input_short_circuits():
|
||||
assert accounts_client.get_users_public_info_bulk([]) == {}
|
||||
|
||||
|
||||
@patch("utils.clients.accounts_client.get_client", side_effect=RuntimeError("network down"))
|
||||
def test_get_users_public_info_bulk_swallows_errors(mock_get_client):
|
||||
result = accounts_client.get_users_public_info_bulk([uuid.uuid4()])
|
||||
assert result == {}
|
||||
112
apps/chat/tests/test_participants_info.py
Normal file
112
apps/chat/tests/test_participants_info.py
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
import uuid
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from django.core.cache import cache
|
||||
|
||||
from apps.chat.models import Conversation, ConversationParticipant
|
||||
from apps.chat.serializers.conversations import (
|
||||
ConversationListSerializer,
|
||||
ConversationSerializer,
|
||||
build_participants_info,
|
||||
)
|
||||
from apps.chat.services.account import AccountService
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clear_account_cache():
|
||||
cache.clear()
|
||||
yield
|
||||
cache.clear()
|
||||
|
||||
|
||||
def test_account_service_get_public_info_empty_list_short_circuits():
|
||||
assert AccountService().get_public_info([]) == {}
|
||||
|
||||
|
||||
@patch("apps.chat.services.account.get_users_public_info_bulk")
|
||||
def test_account_service_get_public_info_delegates_to_client(mock_bulk):
|
||||
user = uuid.uuid4()
|
||||
mock_bulk.return_value = {str(user): {"name": "Alice", "avatar": None}}
|
||||
|
||||
result = AccountService().get_public_info([user])
|
||||
|
||||
assert result[str(user)]["name"] == "Alice"
|
||||
mock_bulk.assert_called_once_with([user])
|
||||
|
||||
|
||||
@patch("apps.chat.services.account.get_users_public_info_bulk", side_effect=RuntimeError("boom"))
|
||||
def test_account_service_get_public_info_swallows_errors(mock_bulk):
|
||||
result = AccountService().get_public_info([uuid.uuid4()])
|
||||
assert result == {}
|
||||
|
||||
|
||||
def test_build_participants_info_fills_gaps_with_nulls():
|
||||
known_user = uuid.uuid4()
|
||||
unknown_user = uuid.uuid4()
|
||||
info_map = {str(known_user): {"name": "Alice", "username": "alice", "avatar": "url"}}
|
||||
|
||||
result = build_participants_info([known_user, unknown_user], info_map=info_map)
|
||||
|
||||
assert result[0] == {"uuid": known_user, "name": "Alice", "username": "alice", "avatar": "url"}
|
||||
assert result[1] == {"uuid": unknown_user, "name": None, "username": None, "avatar": None}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch("apps.chat.services.account.get_users_public_info_bulk")
|
||||
def test_conversation_serializer_includes_both_sides_info(mock_bulk):
|
||||
user_1, user_2 = uuid.uuid4(), uuid.uuid4()
|
||||
mock_bulk.return_value = {
|
||||
str(user_1): {"name": "Alice", "username": "alice", "avatar": "https://a/1.png"},
|
||||
str(user_2): {"name": "Bob", "username": "bob", "avatar": "https://a/2.png"},
|
||||
}
|
||||
|
||||
conv = Conversation.objects.create(mattermost_channel_id="ch-info")
|
||||
ConversationParticipant.objects.create(conversation=conv, user_uuid=user_1)
|
||||
ConversationParticipant.objects.create(conversation=conv, user_uuid=user_2)
|
||||
|
||||
data = ConversationSerializer(conv).data
|
||||
|
||||
names = {p["name"] for p in data["participants_info"]}
|
||||
assert names == {"Alice", "Bob"}
|
||||
mock_bulk.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@patch("apps.chat.services.account.get_users_public_info_bulk")
|
||||
@patch("apps.chat.views.conversations.ReadStateService")
|
||||
@patch("apps.chat.views.conversations.MessageService")
|
||||
@patch("apps.chat.views.conversations.ConversationService")
|
||||
def test_user_conversation_list_view_enriches_participants_once_per_page(
|
||||
mock_conv_svc_cls, mock_msg_svc_cls, mock_read_svc_cls, mock_bulk
|
||||
):
|
||||
# ConversationService/MessageService/ReadStateService are mocked at the
|
||||
# class level so this stays a unit test of the participants_info wiring
|
||||
# and never opens a real connection to Mattermost.
|
||||
from rest_framework.test import APIRequestFactory
|
||||
|
||||
from apps.chat.views.conversations import UserConversationListView
|
||||
|
||||
user_1, user_2 = uuid.uuid4(), uuid.uuid4()
|
||||
mock_bulk.return_value = {
|
||||
str(user_1): {"name": "Alice", "username": "alice", "avatar": None},
|
||||
str(user_2): {"name": "Bob", "username": "bob", "avatar": None},
|
||||
}
|
||||
|
||||
conv = Conversation.objects.create(mattermost_channel_id="ch-list-info")
|
||||
ConversationParticipant.objects.create(conversation=conv, user_uuid=user_1)
|
||||
ConversationParticipant.objects.create(conversation=conv, user_uuid=user_2)
|
||||
|
||||
mock_conv_svc_cls.return_value.list_for_user.return_value = [conv]
|
||||
mock_msg_svc_cls.return_value.list_messages.return_value = []
|
||||
mock_read_svc_cls.return_value.has_unread.return_value = False
|
||||
|
||||
request = APIRequestFactory().get(f"/api/users/{user_1}/chats/")
|
||||
response = UserConversationListView.as_view()(request, user_uuid=user_1)
|
||||
|
||||
assert response.status_code == 200
|
||||
entry = response.data[0]
|
||||
names = {p["name"] for p in entry["participants_info"]}
|
||||
assert names == {"Alice", "Bob"}
|
||||
# One bulk accounts-service call for the whole page, not one per conversation/participant.
|
||||
mock_bulk.assert_called_once()
|
||||
|
|
@ -11,7 +11,9 @@ from apps.chat.serializers.conversations import (
|
|||
ConversationSerializer,
|
||||
ConversationUserActionSerializer,
|
||||
CreateConversationSerializer,
|
||||
build_participants_info,
|
||||
)
|
||||
from apps.chat.services.account import AccountService
|
||||
from apps.chat.services.conversation import ConversationService
|
||||
from apps.chat.services.message import MessageService
|
||||
from apps.chat.services.read_state import ReadStateService
|
||||
|
|
@ -63,13 +65,25 @@ class UserConversationListView(APIView):
|
|||
|
||||
conversations = conv_svc.list_for_user(uid, page, page_size)
|
||||
|
||||
result = []
|
||||
for conv in conversations:
|
||||
participants = list(
|
||||
participants_by_conv = {
|
||||
conv.uuid: list(
|
||||
ConversationParticipant.objects.filter(conversation_id=conv.uuid)
|
||||
.order_by("joined_at")
|
||||
.values_list("user_uuid", flat=True)
|
||||
)
|
||||
for conv in conversations
|
||||
}
|
||||
all_participant_uuids = {
|
||||
p for participants in participants_by_conv.values() for p in participants
|
||||
}
|
||||
# Single bulk lookup (cache-backed) across the whole page, instead of
|
||||
# one accounts-service round trip per conversation.
|
||||
info_map = AccountService().get_public_info(list(all_participant_uuids))
|
||||
|
||||
result = []
|
||||
for conv in conversations:
|
||||
participants = participants_by_conv[conv.uuid]
|
||||
participants_info = build_participants_info(participants, info_map=info_map)
|
||||
|
||||
try:
|
||||
has_unread = read_svc.has_unread(conv.uuid, uid)
|
||||
|
|
@ -91,6 +105,7 @@ class UserConversationListView(APIView):
|
|||
"closed_by_uuid": conv.closed_by_uuid,
|
||||
"created_at": conv.created_at,
|
||||
"participants": participants,
|
||||
"participants_info": participants_info,
|
||||
"has_unread": has_unread,
|
||||
"last_message": last_message,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ 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=QkeJuvsPvwV2wjO2InQ7AIKfhCr0HqBWNtit2EHj
|
||||
OAUTH2_PROVIDER_CLIENT_SECRET=S9AYajQRffgI7SzsxUmpzY7IMkVqlux8sW0A1scoBKgNfUFjXk3uwIMGbkBF9erMYONNVbSWemgODo6ArCDlg4UXYhaSZ8zolLhagfJ5Fk92RmrMLyY2rKv4cb209tPw
|
||||
OAUTH2_PROVIDER_SCOPES=wallet.application.deposit:verify wallet.application.deposit:submit
|
||||
OAUTH2_PROVIDER_SCOPES=accounts.profile:retrieve wallet.application.deposit:verify wallet.application.deposit:submit
|
||||
ACCOUNTS_BASE_PUBLIC_URL=https://accounts-staging.gooyal.ir
|
||||
REDIS_BASE_URL=redis://127.0.0.1:6379/1
|
||||
|
||||
MATTERMOST_TOKEN=3fktq5yzw7yp7m4ty7d3nx8gph
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL = "gooyal_oauth2.RefreshToken"
|
|||
OAUTH2_PROVIDER_BASE_PUBLIC_URL = config("OAUTH2_PROVIDER_BASE_PUBLIC_URL")
|
||||
OAUTH2_PROVIDER_BASE_PRIVATE_URL = config("OAUTH2_PROVIDER_BASE_PRIVATE_URL")
|
||||
|
||||
# Gooyal Accounts service — used to fetch public user profiles (name, avatar)
|
||||
ACCOUNTS_BASE_PUBLIC_URL = config("ACCOUNTS_BASE_PUBLIC_URL")
|
||||
|
||||
OAUTH2_PROVIDER_CLIENT_ID = config('OAUTH2_PROVIDER_CLIENT_ID')
|
||||
OAUTH2_PROVIDER_CLIENT_SECRET = config('OAUTH2_PROVIDER_CLIENT_SECRET')
|
||||
OAUTH2_PROVIDER_SCOPES = config('OAUTH2_PROVIDER_SCOPES', default='')
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ django-oauth-toolkit
|
|||
redis
|
||||
celery
|
||||
httpx
|
||||
attrs
|
||||
django-redis
|
||||
xlsxwriter
|
||||
xlrd
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ asgiref==3.11.1
|
|||
# django-cors-headers
|
||||
attrs==26.1.0
|
||||
# via
|
||||
# -r requirements.in
|
||||
# jsonschema
|
||||
# referencing
|
||||
billiard==4.2.4
|
||||
|
|
|
|||
101
utils/clients/accounts_client.py
Normal file
101
utils/clients/accounts_client.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import time
|
||||
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
|
||||
from utils.clients.gooyal_accounts_client import AuthenticatedClient
|
||||
from utils.clients.gooyal_accounts_client.models import PublicUser
|
||||
from utils.clients.gooyal_accounts_client.api.users import users_api_users_retrieve
|
||||
|
||||
ACCESS_TOKEN_CACHE_KEY = "chat_account_access_token"
|
||||
USER_PUBLIC_INFO_CACHE_KEY = "chat_account_public_info_{uuid}"
|
||||
USER_PUBLIC_INFO_CACHE_TIMEOUT_SECONDS = 300
|
||||
|
||||
|
||||
def login_as_client_credentials() -> dict:
|
||||
"""
|
||||
Client-credentials OAuth2 grant against the gooyal accounts service,
|
||||
reusing a cached access token until it's within 5s of expiry.
|
||||
"""
|
||||
cached = cache.get(ACCESS_TOKEN_CACHE_KEY)
|
||||
if cached:
|
||||
return cached
|
||||
|
||||
data = {
|
||||
"grant_type": "client_credentials",
|
||||
"scope": settings.OAUTH2_PROVIDER_SCOPES,
|
||||
}
|
||||
auth = (settings.OAUTH2_PROVIDER_CLIENT_ID, settings.OAUTH2_PROVIDER_CLIENT_SECRET)
|
||||
|
||||
response = requests.post(
|
||||
f"{settings.OAUTH2_PROVIDER_BASE_PUBLIC_URL}/token/", data=data, auth=auth
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
auth_data = response.json()
|
||||
if "access_token" in auth_data:
|
||||
auth_data["created_at"] = time.time()
|
||||
cache.set(
|
||||
ACCESS_TOKEN_CACHE_KEY, auth_data, timeout=auth_data.get("expires_in", 300) - 5
|
||||
)
|
||||
|
||||
return auth_data
|
||||
|
||||
|
||||
def get_client() -> AuthenticatedClient:
|
||||
access_token = login_as_client_credentials()["access_token"]
|
||||
return AuthenticatedClient(
|
||||
base_url=settings.ACCOUNTS_BASE_PUBLIC_URL, token=access_token
|
||||
)
|
||||
|
||||
|
||||
def get_user_public_info(uuid) -> PublicUser | None:
|
||||
"""Fetch a single user's public profile (name, avatar) — not cached."""
|
||||
client = get_client()
|
||||
return users_api_users_retrieve.sync(uuid=uuid, client=client)
|
||||
|
||||
|
||||
def get_users_public_info_bulk(uuids: list) -> dict[str, dict]:
|
||||
"""
|
||||
Fetch public profiles (name, avatar) for multiple users in one call.
|
||||
Checks the cache per UUID first; only uncached UUIDs hit the network.
|
||||
Returns {str(uuid): profile_dict} for every user found.
|
||||
"""
|
||||
if not uuids:
|
||||
return {}
|
||||
|
||||
result = {}
|
||||
uncached = []
|
||||
|
||||
for uid in uuids:
|
||||
cache_key = USER_PUBLIC_INFO_CACHE_KEY.format(uuid=uid)
|
||||
cached = cache.get(cache_key)
|
||||
if cached is not None:
|
||||
result[str(uid)] = cached
|
||||
else:
|
||||
uncached.append(uid)
|
||||
|
||||
if not uncached:
|
||||
return result
|
||||
|
||||
try:
|
||||
client = get_client()
|
||||
uuid_in = ",".join(str(u) for u in uncached)
|
||||
response = client.get_httpx_client().request(
|
||||
method="get",
|
||||
url=f"/users/api/users/?uuid__in={uuid_in}",
|
||||
)
|
||||
if response.status_code == 200:
|
||||
for profile in response.json().get("results", []):
|
||||
uid_str = profile.get("uuid")
|
||||
if uid_str:
|
||||
cache_key = USER_PUBLIC_INFO_CACHE_KEY.format(uuid=uid_str)
|
||||
cache.set(
|
||||
cache_key, profile, timeout=USER_PUBLIC_INFO_CACHE_TIMEOUT_SECONDS
|
||||
)
|
||||
result[uid_str] = profile
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return result
|
||||
8
utils/clients/gooyal_accounts_client/__init__.py
Normal file
8
utils/clients/gooyal_accounts_client/__init__.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
"""A client library for accessing Gooyal Accounts"""
|
||||
|
||||
from .client import AuthenticatedClient, Client
|
||||
|
||||
__all__ = (
|
||||
"AuthenticatedClient",
|
||||
"Client",
|
||||
)
|
||||
1
utils/clients/gooyal_accounts_client/api/__init__.py
Normal file
1
utils/clients/gooyal_accounts_client/api/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
"""Contains methods for accessing the API"""
|
||||
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
268
utils/clients/gooyal_accounts_client/client.py
Normal file
268
utils/clients/gooyal_accounts_client/client.py
Normal 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)
|
||||
16
utils/clients/gooyal_accounts_client/errors.py
Normal file
16
utils/clients/gooyal_accounts_client/errors.py
Normal 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"]
|
||||
33
utils/clients/gooyal_accounts_client/models/__init__.py
Normal file
33
utils/clients/gooyal_accounts_client/models/__init__.py
Normal 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",
|
||||
)
|
||||
410
utils/clients/gooyal_accounts_client/models/account.py
Normal file
410
utils/clients/gooyal_accounts_client/models/account.py
Normal 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
|
||||
106
utils/clients/gooyal_accounts_client/models/application.py
Normal file
106
utils/clients/gooyal_accounts_client/models/application.py
Normal 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
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class BlankEnum(str, Enum):
|
||||
VALUE_0 = ""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class GenderEnum(str, Enum):
|
||||
F = "f"
|
||||
M = "m"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
425
utils/clients/gooyal_accounts_client/models/patched_account.py
Normal file
425
utils/clients/gooyal_accounts_client/models/patched_account.py
Normal 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
|
||||
|
|
@ -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
|
||||
113
utils/clients/gooyal_accounts_client/models/public_user.py
Normal file
113
utils/clients/gooyal_accounts_client/models/public_user.py
Normal 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
|
||||
94
utils/clients/gooyal_accounts_client/models/request_otp.py
Normal file
94
utils/clients/gooyal_accounts_client/models/request_otp.py
Normal 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
|
||||
100
utils/clients/gooyal_accounts_client/models/request_ott.py
Normal file
100
utils/clients/gooyal_accounts_client/models/request_ott.py
Normal 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
|
||||
68
utils/clients/gooyal_accounts_client/models/user_inquiry.py
Normal file
68
utils/clients/gooyal_accounts_client/models/user_inquiry.py
Normal 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
|
||||
1
utils/clients/gooyal_accounts_client/py.typed
Normal file
1
utils/clients/gooyal_accounts_client/py.typed
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Marker file for PEP 561
|
||||
46
utils/clients/gooyal_accounts_client/types.py
Normal file
46
utils/clients/gooyal_accounts_client/types.py
Normal 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"]
|
||||
Loading…
Add table
Reference in a new issue