aiosellers 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. aiosellers-0.1.0/LICENSE +24 -0
  2. aiosellers-0.1.0/PKG-INFO +13 -0
  3. aiosellers-0.1.0/README.md +0 -0
  4. aiosellers-0.1.0/aiosellers/__init__.py +0 -0
  5. aiosellers-0.1.0/aiosellers/playerok/__init__.py +3 -0
  6. aiosellers-0.1.0/aiosellers/playerok/core/__init__.py +5 -0
  7. aiosellers-0.1.0/aiosellers/playerok/core/client.py +64 -0
  8. aiosellers-0.1.0/aiosellers/playerok/core/config.py +23 -0
  9. aiosellers-0.1.0/aiosellers/playerok/core/constants.py +42 -0
  10. aiosellers-0.1.0/aiosellers/playerok/core/exceptions.py +6 -0
  11. aiosellers-0.1.0/aiosellers/playerok/core/utils.py +17 -0
  12. aiosellers-0.1.0/aiosellers/playerok/graphql.py +222 -0
  13. aiosellers-0.1.0/aiosellers/playerok/models/__init__.py +75 -0
  14. aiosellers-0.1.0/aiosellers/playerok/models/account.py +87 -0
  15. aiosellers-0.1.0/aiosellers/playerok/models/basic.py +22 -0
  16. aiosellers-0.1.0/aiosellers/playerok/models/enums.py +211 -0
  17. aiosellers-0.1.0/aiosellers/playerok/models/games.py +224 -0
  18. aiosellers-0.1.0/aiosellers/playerok/models/items.py +46 -0
  19. aiosellers-0.1.0/aiosellers/playerok/services/__init__.py +0 -0
  20. aiosellers-0.1.0/aiosellers/playerok/services/account.py +51 -0
  21. aiosellers-0.1.0/aiosellers/playerok/services/games.py +181 -0
  22. aiosellers-0.1.0/aiosellers/playerok/services/items.py +62 -0
  23. aiosellers-0.1.0/aiosellers.egg-info/PKG-INFO +13 -0
  24. aiosellers-0.1.0/aiosellers.egg-info/SOURCES.txt +27 -0
  25. aiosellers-0.1.0/aiosellers.egg-info/dependency_links.txt +1 -0
  26. aiosellers-0.1.0/aiosellers.egg-info/requires.txt +5 -0
  27. aiosellers-0.1.0/aiosellers.egg-info/top_level.txt +1 -0
  28. aiosellers-0.1.0/pyproject.toml +34 -0
  29. aiosellers-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiosellers
3
+ Version: 0.1.0
4
+ Summary: All In One Sellers API - Universal API for various digital trading platforms (such as PlayerOK or FunPay). Provides developers with a convenient way to create bots on any platform.
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: idna>=3.11
9
+ Requires-Dist: pydantic>=2.12.5
10
+ Requires-Dist: python-dotenv>=1.2.1
11
+ Requires-Dist: ruff>=0.14.10
12
+ Requires-Dist: wrapper-tls-requests>=1.1.9
13
+ Dynamic: license-file
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ from .core import exceptions
2
+
3
+ __all__ = ["exceptions"]
@@ -0,0 +1,5 @@
1
+ from .client import PlayerokClient
2
+ from .config import PlayerokConfig
3
+ from .utils import _dig, _raise_on_gql_errors
4
+
5
+ __all__ = ["PlayerokClient", "PlayerokConfig", "_dig", "_raise_on_gql_errors"]
@@ -0,0 +1,64 @@
1
+ import os
2
+ from typing import Any, Literal
3
+
4
+ from tls_requests import AsyncClient, Response
5
+
6
+ from .config import PlayerokConfig
7
+ from .constants import CLOUDFLARE_SIGNATURES
8
+ from .exceptions import CloudflareDetected
9
+
10
+
11
+ class PlayerokClient:
12
+ def __init__(self, access_token: str | None = None, config: PlayerokConfig | None = None):
13
+ self._access_token = access_token or os.getenv("PLAYEROK_ACCESS_TOKEN")
14
+ self._config = config or PlayerokConfig()
15
+
16
+ if not self._access_token:
17
+ raise RuntimeError(
18
+ "Please provide playerok access token or fill PLAYEROK_ACCESS_TOKEN environment variable."
19
+ )
20
+
21
+ # Initialize network client
22
+ self._client = AsyncClient(
23
+ cookies={"token": self._access_token},
24
+ headers=self._config.headers,
25
+ timeout=self._config.request_timeout,
26
+ )
27
+
28
+ @staticmethod
29
+ def _raise_if_cloudflare(response: Response):
30
+ if any(sig in response.text for sig in CLOUDFLARE_SIGNATURES):
31
+ raise CloudflareDetected("The cloudflare protection is detected.")
32
+
33
+ async def request(
34
+ self,
35
+ method: Literal["get", "post"],
36
+ url: str,
37
+ payload: dict[str, str],
38
+ *,
39
+ headers: dict[str, str] | None = None,
40
+ files: dict[str, Any] | None = None,
41
+ ) -> Response:
42
+ request_headers = self._config.headers.copy()
43
+ if headers is not None:
44
+ request_headers.update(headers)
45
+ if not url.startswith("http"):
46
+ url = self._config.base_url + url
47
+
48
+ if method == "get":
49
+ response = await self._client.get(url=url, headers=request_headers, params=payload)
50
+ elif method == "post":
51
+ if files:
52
+ response = await self._client.post(
53
+ url=url, headers=request_headers, data=payload, files=files
54
+ )
55
+ else:
56
+ response = await self._client.post(url=url, headers=request_headers, json=payload)
57
+ else:
58
+ raise RuntimeError(f"Unsupported HTTP method: {method}")
59
+
60
+ self._raise_if_cloudflare(response)
61
+ return response
62
+
63
+ async def close(self):
64
+ await self._client.aclose()
@@ -0,0 +1,23 @@
1
+ import os
2
+ import random
3
+
4
+ from .constants import BASE_HEADERS, EXAMPLE_USER_AGENTS
5
+
6
+
7
+ class PlayerokConfig:
8
+ def __init__(
9
+ self,
10
+ *,
11
+ user_agent: str | None = None,
12
+ request_timeout: float | None = None,
13
+ base_url: str | None = None,
14
+ ):
15
+ self.user_agent = user_agent or random.choice(EXAMPLE_USER_AGENTS)
16
+ self.request_timeout = request_timeout or 10.0
17
+ self.base_url = base_url or os.getenv("PLAYEROK_BASE_URL", "https://playerok.com/")
18
+
19
+ @property
20
+ def headers(self):
21
+ return BASE_HEADERS | {
22
+ "User-Agent": self.user_agent,
23
+ }
@@ -0,0 +1,42 @@
1
+ BASE_HEADERS = {
2
+ "accept": "*/*",
3
+ "accept-language": "en-US,en;q=0.9",
4
+ "access-control-allow-headers": "sentry-trace, baggage",
5
+ "apollo-require-preflight": "true",
6
+ "apollographql-client-name": "web",
7
+ "content-type": "application/json",
8
+ "origin": "https://playerok.com",
9
+ "priority": "u=1, i",
10
+ "referer": "https://playerok.com/",
11
+ "sec-ch-ua": '"Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
12
+ "sec-ch-ua-mobile": "?0",
13
+ "sec-ch-ua-platform": '"macOS"',
14
+ "sec-fetch-dest": "empty",
15
+ "sec-fetch-mode": "cors",
16
+ "sec-fetch-site": "same-origin",
17
+ "x-gql-op": "viewer",
18
+ "x-gql-path": "/products/[slug]",
19
+ "x-timezone-offset": "-180",
20
+ }
21
+
22
+ EXAMPLE_USER_AGENTS = [
23
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 7_0_2; en-US) Gecko/20100101 Firefox/57.1",
24
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 9_8_3) AppleWebKit/534.47 (KHTML, like Gecko) Chrome/51.0.1124.252 Safari/535",
25
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_2_9) Gecko/20100101 Firefox/65.6",
26
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_0_2) AppleWebKit/536.44 (KHTML, like Gecko) Chrome/49.0.2950.348 Safari/602",
27
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 9_9_9; en-US) Gecko/20130401 Firefox/59.3",
28
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_1_1; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Chrome/53.0.2619.208 Safari/535",
29
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_7_8) Gecko/20130401 Firefox/59.9",
30
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_0) Gecko/20130401 Firefox/68.4",
31
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_3_5; en-US) Gecko/20100101 Firefox/53.9",
32
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 7_1_1; en-US) Gecko/20130401 Firefox/61.0",
33
+ ]
34
+
35
+ CLOUDFLARE_SIGNATURES = [
36
+ "<title>Just a moment...</title>",
37
+ "window._cf_chl_opt",
38
+ "Enable JavaScript and cookies to continue",
39
+ "Checking your browser before accessing",
40
+ "cf-browser-verification",
41
+ "Cloudflare Ray ID",
42
+ ]
@@ -0,0 +1,6 @@
1
+ class CloudflareDetected(Exception):
2
+ pass
3
+
4
+
5
+ class Unauthorized(Exception):
6
+ pass
@@ -0,0 +1,17 @@
1
+ from collections.abc import Iterable
2
+ from typing import Any
3
+
4
+
5
+ def _dig(obj: dict[str, Any], path: Iterable[str]) -> Any:
6
+ cur: Any = obj
7
+ for key in path:
8
+ if cur is None:
9
+ return None
10
+ cur = cur.get(key)
11
+ return cur
12
+
13
+
14
+ def _raise_on_gql_errors(payload: dict[str, Any]) -> None:
15
+ errors = payload.get("errors")
16
+ if errors:
17
+ raise RuntimeError(f"GraphQL errors: {errors}")
@@ -0,0 +1,222 @@
1
+ from typing import Any
2
+
3
+ from .models import (
4
+ GameCategoryDataFieldTypes,
5
+ GameCategoryInstructionTypes,
6
+ GameType,
7
+ ItemsSortOptions,
8
+ QueryID,
9
+ )
10
+
11
+
12
+ def _persisted(
13
+ operation_name: str,
14
+ variables: dict[str, Any],
15
+ *,
16
+ sha256_hash: Any | None = None,
17
+ query: str | None = None,
18
+ ) -> dict[str, Any]:
19
+ r = {
20
+ "operationName": operation_name,
21
+ "variables": variables,
22
+ }
23
+ if query:
24
+ r["query"] = query
25
+ if sha256_hash:
26
+ r["extensions"] = {
27
+ "persistedQuery": {
28
+ "version": 1,
29
+ "sha256Hash": sha256_hash,
30
+ }
31
+ }
32
+ return r
33
+
34
+
35
+ class GraphQLQuery:
36
+ @staticmethod
37
+ def get_me():
38
+ return _persisted(
39
+ operation_name="viewer",
40
+ variables={},
41
+ query="query viewer {\n viewer {\n ...Viewer\n __typename\n }\n}\n\nfragment Viewer on User {\n id\n username\n email\n role\n hasFrozenBalance\n supportChatId\n systemChatId\n unreadChatsCounter\n isBlocked\n isBlockedFor\n isFundsProtectionActive\n createdAt\n lastItemCreatedAt\n hasConfirmedPhoneNumber\n canPublishItems\n chosenVerifiedCard {\n ...MinimalUserBankCard\n __typename\n }\n profile {\n id\n avatarURL\n testimonialCounter\n __typename\n }\n __typename\n}\n\nfragment MinimalUserBankCard on UserBankCard {\n id\n cardFirstSix\n cardLastFour\n cardType\n isChosen\n __typename\n}",
42
+ )
43
+
44
+ @staticmethod
45
+ def get_user(username: str | None = None, id: str | None = None) -> dict[str, Any]:
46
+ return _persisted(
47
+ operation_name="user",
48
+ variables={"id": id, "username": username, "hasSupportAccess": False},
49
+ sha256_hash=QueryID.user.value,
50
+ )
51
+
52
+ @staticmethod
53
+ def get_games(
54
+ count: int = 24, type: GameType | None = None, cursor: str | None = None
55
+ ) -> dict[str, Any]:
56
+ return _persisted(
57
+ operation_name="games",
58
+ variables={
59
+ "pagination": {"first": count, "after": cursor},
60
+ "filter": {"type": type.name} if type else {},
61
+ },
62
+ sha256_hash=QueryID.games.value,
63
+ )
64
+
65
+ @staticmethod
66
+ def get_game(id: str | None = None, slug: str | None = None) -> dict[str, Any]:
67
+ return _persisted(
68
+ operation_name="GamePage",
69
+ variables={"id": id, "slug": slug},
70
+ sha256_hash=QueryID.game.value,
71
+ )
72
+
73
+ @staticmethod
74
+ def get_game_category(
75
+ game_id: str | None = None,
76
+ slug: str | None = None,
77
+ id: str | None = None,
78
+ ) -> dict[str, Any]:
79
+ return _persisted(
80
+ operation_name="GamePageCategory",
81
+ variables={"id": id, "gameId": game_id, "slug": slug},
82
+ sha256_hash=QueryID.game_category.value,
83
+ )
84
+
85
+ @staticmethod
86
+ def get_game_category_agreements(
87
+ game_category_id: str,
88
+ user_id: str | None = None,
89
+ count: int = 24,
90
+ cursor: str | None = None,
91
+ ) -> dict[str, Any]:
92
+ return _persisted(
93
+ operation_name="gameCategoryAgreements",
94
+ variables={
95
+ "pagination": {"first": count, "after": cursor},
96
+ "filter": {"gameCategoryId": game_category_id, "userId": user_id},
97
+ },
98
+ sha256_hash=QueryID.game_category_agreements.value,
99
+ )
100
+
101
+ @staticmethod
102
+ def get_game_category_obtaining_types(
103
+ game_category_id: str,
104
+ count: int = 24,
105
+ cursor: str | None = None,
106
+ ) -> dict[str, Any]:
107
+ return _persisted(
108
+ operation_name="gameCategoryObtainingTypes",
109
+ variables={
110
+ "pagination": {"first": count, "after": cursor},
111
+ "filter": {"gameCategoryId": game_category_id},
112
+ },
113
+ sha256_hash=QueryID.game_category_obtaining_types.value,
114
+ )
115
+
116
+ @staticmethod
117
+ def get_game_category_instructions(
118
+ game_category_id: str,
119
+ obtaining_type_id: str,
120
+ count: int = 24,
121
+ type: GameCategoryInstructionTypes | None = None,
122
+ cursor: str | None = None,
123
+ ) -> dict[str, Any]:
124
+ return _persisted(
125
+ operation_name="gameCategoryInstructions",
126
+ variables={
127
+ "pagination": {"first": count, "after": cursor},
128
+ "filter": {
129
+ "gameCategoryId": game_category_id,
130
+ "obtainingTypeId": obtaining_type_id,
131
+ "type": type.name if type else None,
132
+ },
133
+ },
134
+ sha256_hash=QueryID.game_category_instructions.value,
135
+ )
136
+
137
+ @staticmethod
138
+ def get_game_category_data_fields(
139
+ game_category_id: str,
140
+ obtaining_type_id: str,
141
+ count: int = 24,
142
+ type: GameCategoryDataFieldTypes | None = None,
143
+ cursor: str | None = None,
144
+ ) -> dict[str, Any]:
145
+ return _persisted(
146
+ operation_name="gameCategoryDataFields",
147
+ variables={
148
+ "pagination": {"first": count, "after": cursor},
149
+ "filter": {
150
+ "gameCategoryId": game_category_id,
151
+ "obtainingTypeId": obtaining_type_id,
152
+ "type": type.name if type else None,
153
+ },
154
+ },
155
+ sha256_hash=QueryID.game_category_data_fields.value,
156
+ )
157
+
158
+ @staticmethod
159
+ def get_items(
160
+ count: int = 24,
161
+ cursor: str | None = None,
162
+ game_id: str | None = None,
163
+ category_id: str | None = None,
164
+ minimal_price: int | None = None,
165
+ maximal_price: int | None = None,
166
+ has_discount: bool | None = None,
167
+ has_reviews: bool | None = None,
168
+ attributes: list[dict[str, str]] | None = None,
169
+ search: str | None = None,
170
+ sort: ItemsSortOptions | None = None,
171
+ ) -> dict[str, Any]:
172
+ filters = {
173
+ "gameId": game_id,
174
+ "gameCategoryId": category_id,
175
+ "status": ["APPROVED"],
176
+ }
177
+ sort_field = None
178
+
179
+ if minimal_price or maximal_price:
180
+ filters["price"] = {"min": minimal_price, "max": maximal_price}
181
+ if has_discount:
182
+ filters["hasDiscount"] = has_discount
183
+ if has_reviews:
184
+ filters["hasTestimonials"] = has_reviews
185
+ if attributes:
186
+ filters["attributes"] = attributes
187
+ if search:
188
+ filters["searchQuery"] = search
189
+ if sort:
190
+ if "PRICE" in sort:
191
+ field = "price"
192
+ else:
193
+ field = "userRating"
194
+ if "ASC" in sort:
195
+ direction = "ASC"
196
+ else:
197
+ direction = "DESC"
198
+
199
+ sort_field = {"field": field, "direction": direction}
200
+
201
+ return _persisted(
202
+ operation_name="items",
203
+ variables={
204
+ "pagination": {"first": count, "after": cursor},
205
+ "filter": filters,
206
+ "sort": sort_field,
207
+ },
208
+ sha256_hash=QueryID.items.value,
209
+ )
210
+
211
+ @staticmethod
212
+ def get_item(id: str | None = None, slug: str | None = None) -> dict[str, Any]:
213
+ return _persisted(
214
+ operation_name="item",
215
+ variables={
216
+ "id": id,
217
+ "slug": slug,
218
+ "hasSupportAccess": False,
219
+ "showForbiddenImage": True,
220
+ },
221
+ sha256_hash=QueryID.item.value,
222
+ )
@@ -0,0 +1,75 @@
1
+ from .basic import ApiModel, PageInfo # noqa: I001
2
+ from .enums import UserType, QueryID # noqa: I001
3
+
4
+ from .account import Account, AccountProfile, UserProfile
5
+
6
+ from .enums import (
7
+ BankCardTypes,
8
+ ChatMessageButtonTypes,
9
+ ChatStatuses,
10
+ ChatTypes,
11
+ EventTypes,
12
+ GameCategoryAgreementIconTypes,
13
+ GameCategoryAutoConfirmPeriods,
14
+ GameCategoryDataFieldInputTypes,
15
+ GameCategoryDataFieldTypes,
16
+ GameCategoryInstructionTypes,
17
+ GameCategoryOptionTypes,
18
+ GameType,
19
+ ItemDealDirections,
20
+ ItemDealStatuses,
21
+ ItemLogEvents,
22
+ ItemsSortOptions,
23
+ ItemStatuses,
24
+ PriorityTypes,
25
+ ReviewStatuses,
26
+ SortDirections,
27
+ TransactionDirections,
28
+ TransactionOperations,
29
+ TransactionPaymentMethodIds,
30
+ TransactionProviderDirections,
31
+ TransactionProviderIds,
32
+ TransactionStatuses,
33
+ )
34
+ from .games import Game, GameList
35
+ from .items import Item, ItemList
36
+
37
+ __all__ = [
38
+ "Account",
39
+ "UserProfile",
40
+ "AccountProfile",
41
+ "QueryID",
42
+ "GameType",
43
+ "ApiModel",
44
+ "PageInfo",
45
+ "UserType",
46
+ "GameCategoryDataFieldTypes",
47
+ "EventTypes",
48
+ "ItemLogEvents",
49
+ "TransactionOperations",
50
+ "TransactionDirections",
51
+ "TransactionStatuses",
52
+ "TransactionPaymentMethodIds",
53
+ "TransactionProviderDirections",
54
+ "TransactionProviderIds",
55
+ "BankCardTypes",
56
+ "ItemDealStatuses",
57
+ "ItemDealDirections",
58
+ "ChatTypes",
59
+ "ChatStatuses",
60
+ "ChatMessageButtonTypes",
61
+ "ItemStatuses",
62
+ "ReviewStatuses",
63
+ "SortDirections",
64
+ "PriorityTypes",
65
+ "GameCategoryAgreementIconTypes",
66
+ "GameCategoryOptionTypes",
67
+ "GameCategoryDataFieldInputTypes",
68
+ "GameCategoryAutoConfirmPeriods",
69
+ "GameCategoryInstructionTypes",
70
+ "Game",
71
+ "GameList",
72
+ "Item",
73
+ "ItemList",
74
+ "ItemsSortOptions",
75
+ ]
@@ -0,0 +1,87 @@
1
+ from datetime import datetime
2
+ from typing import Any
3
+
4
+ from pydantic import AliasChoices, Field
5
+
6
+ from . import ApiModel, UserType
7
+
8
+
9
+ class Account(ApiModel):
10
+ id: str = Field(..., alias="id")
11
+ username: str = Field(..., alias="username")
12
+ email: str = Field(..., alias="email")
13
+ role: UserType = Field(..., alias="role")
14
+ has_frozen_balance: bool = Field(..., alias="hasFrozenBalance")
15
+ support_chat_id: str = Field(..., alias="supportChatId")
16
+ system_chat_id: str = Field(..., alias="systemChatId")
17
+ unread_chats_counter: int = Field(..., alias="unreadChatsCounter")
18
+ is_blocked: bool = Field(..., alias="isBlocked")
19
+ is_blocked_for: Any = Field(None, alias="isBlockedFor")
20
+ created_at: datetime = Field(..., alias="createdAt")
21
+ last_item_created_at: datetime = Field(None, alias="lastItemCreatedAt")
22
+ has_confirmed_phone_number: bool = Field(..., alias="hasConfirmedPhoneNumber")
23
+ can_publish_items: bool = Field(..., alias="canPublishItems")
24
+ is_funds_protection_active: bool = Field(..., alias="isFundsProtectionActive")
25
+ chosen_verified_card: Any = Field(None, alias="chosenVerifiedCard")
26
+
27
+
28
+ class UserProfile(ApiModel):
29
+ id: str = Field(..., alias="id")
30
+ username: str = Field(..., alias="username")
31
+ role: UserType = Field(..., alias="role")
32
+ avatar_url: str | None = Field(None, alias="avatarURL")
33
+ is_online: bool | None = Field(None, alias="isOnline")
34
+ is_blocked: bool = Field(..., alias="isBlocked")
35
+ rating: float | None = Field(None, alias="rating")
36
+ reviews_count: int | None = Field(
37
+ None,
38
+ alias="reviewsCount",
39
+ validation_alias=AliasChoices("reviewsCount", "testimonialCounter"),
40
+ )
41
+ created_at: datetime | None = Field(None, alias="createdAt")
42
+
43
+
44
+ class AccountBalance(ApiModel):
45
+ id: str = Field(..., alias="id")
46
+ value: float = Field(..., alias="value")
47
+ available: float = Field(..., alias="available")
48
+ frozen: float = Field(..., alias="frozen")
49
+ pending_income: float = Field(..., alias="pendingIncome")
50
+ withdrawable: float = Field(..., alias="withdrawable")
51
+
52
+
53
+ class AccountItemsStats(ApiModel):
54
+ total: int = Field(..., alias="total")
55
+ finished: int = Field(..., alias="finished")
56
+
57
+
58
+ class AccountIncomingDealsStats(ApiModel):
59
+ total: int = Field(..., alias="total")
60
+ finished: int = Field(..., alias="finished")
61
+
62
+
63
+ class AccountOutgoingDealsStats(ApiModel):
64
+ total: int = Field(..., alias="total")
65
+ finished: int = Field(..., alias="finished")
66
+
67
+
68
+ class AccountDealsStats(ApiModel):
69
+ incoming: AccountIncomingDealsStats = Field(..., alias="incoming")
70
+ outgoing: AccountOutgoingDealsStats = Field(..., alias="outgoing")
71
+
72
+
73
+ class AccountStats(ApiModel):
74
+ items: AccountItemsStats = Field(..., alias="items")
75
+ deals: AccountDealsStats = Field(..., alias="deals")
76
+
77
+
78
+ class AccountProfile(UserProfile):
79
+ email: str = Field(..., alias="email")
80
+ balance: AccountBalance = Field(..., alias="balance")
81
+ stats: AccountStats = Field(..., alias="stats")
82
+ is_blocked_for: Any = Field(None, alias="isBlockedFor")
83
+ is_verified: bool | None = Field(None, alias="isVerified")
84
+ has_frozen_balance: bool = Field(..., alias="hasFrozenBalance")
85
+ has_enabled_notifications: bool = Field(..., alias="hasEnabledNotifications")
86
+ support_chat_id: str = Field(..., alias="supportChatId")
87
+ system_chat_id: str = Field(..., alias="systemChatId")
@@ -0,0 +1,22 @@
1
+ from pydantic import BaseModel, ConfigDict, Field
2
+
3
+
4
+ class ApiModel(BaseModel):
5
+ model_config = ConfigDict(
6
+ populate_by_name=True,
7
+ extra="ignore",
8
+ )
9
+
10
+
11
+ class PageInfo(ApiModel):
12
+ start_cursor: str | None = Field(None, alias="startCursor")
13
+ end_cursor: str | None = Field(None, alias="endCursor")
14
+ has_previous_page: bool | None = Field(None, alias="hasPreviousPage")
15
+ has_next_page: bool | None = Field(None, alias="hasNextPage")
16
+
17
+
18
+ class File(ApiModel):
19
+ id: str = Field(alias="id")
20
+ url: str = Field(alias="url")
21
+ filename: str | None = Field(None, alias="filename")
22
+ mime: str | None = Field(None, alias="mime")