Repository navigation
Expand file tree
/
Copy pathuser_response.py
More file actions
145 lines (111 loc) · 3.96 KB
/
Copy pathuser_response.py
File metadata and controls
145 lines (111 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from __future__ import annotations
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, 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.account_info import AccountInfo
T = TypeVar("T", bound="UserResponse")
@_attrs_define
class UserResponse:
"""User information response model.
Example:
{'accounts': [{'provider': 'github', 'provider_account_id': '12345', 'provider_type': 'oauth'}, {'provider':
'google', 'provider_account_id': '67890', 'provider_type': 'oauth'}], 'email': 'john@example.com',
'email_verified': True, 'id': 'user-123', 'name': 'johndoe'}
Attributes:
id (str): Unique identifier for the user
name (None | str | Unset): User's display name
email (None | str | Unset): User's email address
email_verified (bool | Unset): Whether user's email is verified Default: False.
accounts (list[AccountInfo] | Unset): User's authentication accounts
"""
id: str
name: None | str | Unset = UNSET
email: None | str | Unset = UNSET
email_verified: bool | Unset = False
accounts: list[AccountInfo] | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
id = self.id
name: None | str | Unset
if isinstance(self.name, Unset):
name = UNSET
else:
name = self.name
email: None | str | Unset
if isinstance(self.email, Unset):
email = UNSET
else:
email = self.email
email_verified = self.email_verified
accounts: list[dict[str, Any]] | Unset = UNSET
if not isinstance(self.accounts, Unset):
accounts = []
for accounts_item_data in self.accounts:
accounts_item = accounts_item_data.to_dict()
accounts.append(accounts_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
}
)
if name is not UNSET:
field_dict["name"] = name
if email is not UNSET:
field_dict["email"] = email
if email_verified is not UNSET:
field_dict["email_verified"] = email_verified
if accounts is not UNSET:
field_dict["accounts"] = accounts
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.account_info import AccountInfo
d = dict(src_dict)
id = d.pop("id")
def _parse_name(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
name = _parse_name(d.pop("name", UNSET))
def _parse_email(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
email = _parse_email(d.pop("email", UNSET))
email_verified = d.pop("email_verified", UNSET)
_accounts = d.pop("accounts", UNSET)
accounts: list[AccountInfo] | Unset = UNSET
if _accounts is not UNSET:
accounts = []
for accounts_item_data in _accounts:
accounts_item = AccountInfo.from_dict(accounts_item_data)
accounts.append(accounts_item)
user_response = cls(
id=id,
name=name,
email=email,
email_verified=email_verified,
accounts=accounts,
)
user_response.additional_properties = d
return user_response
@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