polyticket-api/poly-ticket-api-client/poly_ticket_api_client/models/user_registration.py

141 lines
4.2 KiB
Python

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 .. import types
from ..types import UNSET, Unset
T = TypeVar("T", bound="UserRegistration")
@_attrs_define
class UserRegistration:
"""Serializer for PolyTicketUser registration
Attributes:
id (int):
email (str):
password (str): The password associated with your account
captcha (str): Captcha response token from the Recaptcha JS library challenge
first_name (Union[Unset, str]):
last_name (Union[Unset, str]):
captcha_bypass (Union[Unset, str]): For testing purposes, permits to bypass captcha verification. This field
expects a shared secret. This feature is only usable on DEV and INT environnments.
"""
id: int
email: str
password: str
captcha: str
first_name: Union[Unset, str] = UNSET
last_name: Union[Unset, str] = UNSET
captcha_bypass: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
id = self.id
email = self.email
password = self.password
captcha = self.captcha
first_name = self.first_name
last_name = self.last_name
captcha_bypass = self.captcha_bypass
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
"email": email,
"password": password,
"captcha": captcha,
}
)
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 captcha_bypass is not UNSET:
field_dict["captcha_bypass"] = captcha_bypass
return field_dict
def to_multipart(self) -> types.RequestFiles:
files: types.RequestFiles = []
files.append(("id", (None, str(self.id).encode(), "text/plain")))
files.append(("email", (None, str(self.email).encode(), "text/plain")))
files.append(("password", (None, str(self.password).encode(), "text/plain")))
files.append(("captcha", (None, str(self.captcha).encode(), "text/plain")))
if not isinstance(self.first_name, Unset):
files.append(("first_name", (None, str(self.first_name).encode(), "text/plain")))
if not isinstance(self.last_name, Unset):
files.append(("last_name", (None, str(self.last_name).encode(), "text/plain")))
if not isinstance(self.captcha_bypass, Unset):
files.append(("captcha_bypass", (None, str(self.captcha_bypass).encode(), "text/plain")))
for prop_name, prop in self.additional_properties.items():
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
return files
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
id = d.pop("id")
email = d.pop("email")
password = d.pop("password")
captcha = d.pop("captcha")
first_name = d.pop("first_name", UNSET)
last_name = d.pop("last_name", UNSET)
captcha_bypass = d.pop("captcha_bypass", UNSET)
user_registration = cls(
id=id,
email=email,
password=password,
captcha=captcha,
first_name=first_name,
last_name=last_name,
captcha_bypass=captcha_bypass,
)
user_registration.additional_properties = d
return user_registration
@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