cloudtips 0.2.0__tar.gz → 0.3.1__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.
- {cloudtips-0.2.0 → cloudtips-0.3.1}/PKG-INFO +1 -1
- {cloudtips-0.2.0 → cloudtips-0.3.1}/cloudtips/__init__.py +3 -2
- {cloudtips-0.2.0 → cloudtips-0.3.1}/cloudtips/client.py +36 -10
- {cloudtips-0.2.0 → cloudtips-0.3.1}/cloudtips/models.py +48 -0
- {cloudtips-0.2.0 → cloudtips-0.3.1}/pyproject.toml +1 -1
- {cloudtips-0.2.0 → cloudtips-0.3.1}/.github/workflows/publish.yml +0 -0
- {cloudtips-0.2.0 → cloudtips-0.3.1}/LICENSE +0 -0
- {cloudtips-0.2.0 → cloudtips-0.3.1}/README.md +0 -0
- {cloudtips-0.2.0 → cloudtips-0.3.1}/cloudtips/auth.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudtips
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Неофициальная Python-библиотека для CloudTips (получение донатов, поллинг, обновление токенов)
|
|
5
5
|
Project-URL: Repository, https://github.com/IRRatium/cloudtips-api
|
|
6
6
|
Project-URL: Issues, https://github.com/IRRatium/cloudtips-api/issues
|
|
@@ -4,9 +4,9 @@ cloudtips — неофициальная Python-библиотека для Clou
|
|
|
4
4
|
|
|
5
5
|
from .auth import CloudTipsAuth, CloudTipsAuthError
|
|
6
6
|
from .client import CloudTipsAPIError, CloudTipsClient
|
|
7
|
-
from .models import AccumulationSummary, Card, Donation, PayoutFeeInfo, TokenData
|
|
7
|
+
from .models import AccumulationSummary, Card, Donation, PayoutFeeInfo, ReceiverProfile, TokenData
|
|
8
8
|
|
|
9
|
-
__version__ = "0.
|
|
9
|
+
__version__ = "0.3.1"
|
|
10
10
|
__all__ = [
|
|
11
11
|
"CloudTipsAuth",
|
|
12
12
|
"CloudTipsAuthError",
|
|
@@ -16,5 +16,6 @@ __all__ = [
|
|
|
16
16
|
"Card",
|
|
17
17
|
"PayoutFeeInfo",
|
|
18
18
|
"AccumulationSummary",
|
|
19
|
+
"ReceiverProfile",
|
|
19
20
|
"TokenData",
|
|
20
21
|
]
|
|
@@ -8,7 +8,7 @@ from typing import Callable, Iterator, List, Optional
|
|
|
8
8
|
import requests
|
|
9
9
|
|
|
10
10
|
from .auth import CloudTipsAuth
|
|
11
|
-
from .models import Donation, Card, PayoutFeeInfo, AccumulationSummary
|
|
11
|
+
from .models import Donation, Card, PayoutFeeInfo, AccumulationSummary, ReceiverProfile
|
|
12
12
|
|
|
13
13
|
_BASE_URL = "https://api.cloudtips.ru/api"
|
|
14
14
|
_MSK = timezone(timedelta(hours=3))
|
|
@@ -164,6 +164,28 @@ class CloudTipsClient:
|
|
|
164
164
|
else:
|
|
165
165
|
yield donation
|
|
166
166
|
|
|
167
|
+
# ------------------------------------------------------------------
|
|
168
|
+
# Профиль
|
|
169
|
+
# ------------------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
def get_me(self) -> ReceiverProfile:
|
|
172
|
+
"""
|
|
173
|
+
Получить профиль текущего пользователя.
|
|
174
|
+
|
|
175
|
+
Содержит имя, телефон, метод выплат, лимиты сумм и другие данные.
|
|
176
|
+
|
|
177
|
+
:return: :class:`ReceiverProfile`
|
|
178
|
+
|
|
179
|
+
Пример::
|
|
180
|
+
|
|
181
|
+
me = client.get_me()
|
|
182
|
+
print(me.full_name) # IRRing
|
|
183
|
+
print(me.payout_method) # Accumulation
|
|
184
|
+
print(me.available_amount_min, me.available_amount_max) # 49.0 3000.0
|
|
185
|
+
"""
|
|
186
|
+
data = self._get("/receivers/me")
|
|
187
|
+
return ReceiverProfile.from_dict(data.get("data", {}))
|
|
188
|
+
|
|
167
189
|
# ------------------------------------------------------------------
|
|
168
190
|
# Карты
|
|
169
191
|
# ------------------------------------------------------------------
|
|
@@ -234,18 +256,22 @@ class CloudTipsClient:
|
|
|
234
256
|
data = self._get("/accumulations/summary")
|
|
235
257
|
return AccumulationSummary.from_dict(data.get("data", {}))
|
|
236
258
|
|
|
259
|
+
def get_payout_method(self) -> str:
|
|
260
|
+
"""
|
|
261
|
+
Получить текущий метод выплат.
|
|
262
|
+
|
|
263
|
+
:return: ``"Instant"`` или ``"Accumulation"``
|
|
264
|
+
"""
|
|
265
|
+
return self.get_me().payout_method
|
|
266
|
+
|
|
237
267
|
def set_payout_method(self, method: str = "Instant") -> bool:
|
|
238
268
|
"""
|
|
239
269
|
Установить метод выплат.
|
|
240
270
|
|
|
241
271
|
:param method: ``"Instant"`` (мгновенно) или ``"Accumulation"`` (накопительно)
|
|
242
272
|
:return: ``True`` если успешно
|
|
243
|
-
|
|
244
|
-
Пример::
|
|
245
|
-
|
|
246
|
-
client.set_payout_method("Instant")
|
|
247
273
|
"""
|
|
248
|
-
data = self.
|
|
274
|
+
data = self._post("/receivers/payout-method", json={"payoutMethod": method})
|
|
249
275
|
return data.get("succeed", False)
|
|
250
276
|
|
|
251
277
|
# ------------------------------------------------------------------
|
|
@@ -263,9 +289,9 @@ class CloudTipsClient:
|
|
|
263
289
|
_raise_for_status(response)
|
|
264
290
|
return response.json()
|
|
265
291
|
|
|
266
|
-
def
|
|
292
|
+
def _post(self, path: str, json: Optional[dict] = None) -> dict:
|
|
267
293
|
headers = {**HEADERS_BASE, **self._auth.headers()}
|
|
268
|
-
response = self._session.
|
|
294
|
+
response = self._session.post(
|
|
269
295
|
self._base_url + path,
|
|
270
296
|
headers=headers,
|
|
271
297
|
json=json,
|
|
@@ -274,9 +300,9 @@ class CloudTipsClient:
|
|
|
274
300
|
_raise_for_status(response)
|
|
275
301
|
return response.json()
|
|
276
302
|
|
|
277
|
-
def
|
|
303
|
+
def _delete(self, path: str, json: Optional[dict] = None) -> dict:
|
|
278
304
|
headers = {**HEADERS_BASE, **self._auth.headers()}
|
|
279
|
-
response = self._session.
|
|
305
|
+
response = self._session.delete(
|
|
280
306
|
self._base_url + path,
|
|
281
307
|
headers=headers,
|
|
282
308
|
json=json,
|
|
@@ -107,6 +107,54 @@ class AccumulationSummary:
|
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
@dataclass
|
|
111
|
+
class ReceiverProfile:
|
|
112
|
+
user_id: str
|
|
113
|
+
full_name: str
|
|
114
|
+
phone_number: str
|
|
115
|
+
photo_url: str
|
|
116
|
+
payout_method: str # "Instant" или "Accumulation"
|
|
117
|
+
instant_payout_enabled: bool
|
|
118
|
+
is_premium: bool
|
|
119
|
+
onboarding_passed: bool
|
|
120
|
+
gender: str
|
|
121
|
+
work_place: Optional[str]
|
|
122
|
+
work_position: Optional[str]
|
|
123
|
+
birthday: Optional[str]
|
|
124
|
+
created_date: str
|
|
125
|
+
available_amount_min: float
|
|
126
|
+
available_amount_max: float
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def from_dict(cls, data: dict) -> "ReceiverProfile":
|
|
130
|
+
available = data.get("availableAmount") or {}
|
|
131
|
+
return cls(
|
|
132
|
+
user_id=data.get("userId", ""),
|
|
133
|
+
full_name=data.get("fullName", ""),
|
|
134
|
+
phone_number=data.get("phoneNumber", ""),
|
|
135
|
+
photo_url=data.get("photoUrl", ""),
|
|
136
|
+
payout_method=data.get("payoutMethod", "Instant"),
|
|
137
|
+
instant_payout_enabled=data.get("instantPayoutEnabled", False),
|
|
138
|
+
is_premium=data.get("isPremium", False),
|
|
139
|
+
onboarding_passed=data.get("onboardingPassed", False),
|
|
140
|
+
gender=data.get("gender", "NotSpecified"),
|
|
141
|
+
work_place=data.get("workPlace"),
|
|
142
|
+
work_position=data.get("workPosition"),
|
|
143
|
+
birthday=data.get("birthday"),
|
|
144
|
+
created_date=data.get("createdDate", ""),
|
|
145
|
+
available_amount_min=available.get("minimal", 0.0),
|
|
146
|
+
available_amount_max=available.get("maximal", 0.0),
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def __str__(self) -> str:
|
|
150
|
+
return (
|
|
151
|
+
f"{self.full_name} ({self.phone_number})\n"
|
|
152
|
+
f"Метод выплат: {self.payout_method} | "
|
|
153
|
+
f"Премиум: {'да' if self.is_premium else 'нет'} | "
|
|
154
|
+
f"Лимиты: {self.available_amount_min}₽ — {self.available_amount_max}₽"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
110
158
|
@dataclass
|
|
111
159
|
class TokenData:
|
|
112
160
|
"""Новые токены, которые библиотека передаёт в on_token_refresh."""
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cloudtips"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.1"
|
|
8
8
|
description = "Неофициальная Python-библиотека для CloudTips (получение донатов, поллинг, обновление токенов)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|