diarama-api 0.1.13__py3-none-any.whl → 0.1.19__py3-none-any.whl
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.
- diarama_api/__init__.py +4 -0
- diarama_api/client.py +11 -3
- diarama_api/files.py +17 -0
- diarama_api/games.py +1 -1
- diarama_api/media.py +7 -1
- diarama_api/platforms.py +26 -0
- {diarama_api-0.1.13.dist-info → diarama_api-0.1.19.dist-info}/METADATA +1 -1
- diarama_api-0.1.19.dist-info/RECORD +13 -0
- diarama_api-0.1.13.dist-info/RECORD +0 -11
- {diarama_api-0.1.13.dist-info → diarama_api-0.1.19.dist-info}/WHEEL +0 -0
- {diarama_api-0.1.13.dist-info → diarama_api-0.1.19.dist-info}/top_level.txt +0 -0
diarama_api/__init__.py
CHANGED
|
@@ -4,6 +4,8 @@ from .players import Players
|
|
|
4
4
|
from .games import Games
|
|
5
5
|
from .payments import Payments
|
|
6
6
|
from .media import Media
|
|
7
|
+
from .platforms import Platforms
|
|
8
|
+
from .files import Files
|
|
7
9
|
|
|
8
10
|
class DiaramaAPI:
|
|
9
11
|
def __init__(self, api_key):
|
|
@@ -13,3 +15,5 @@ class DiaramaAPI:
|
|
|
13
15
|
self.games = Games(self.client)
|
|
14
16
|
self.payments = Payments(self.client)
|
|
15
17
|
self.media = Media(self.client)
|
|
18
|
+
self.platforms = Platforms(self.client)
|
|
19
|
+
self.files = Files(self.client)
|
diarama_api/client.py
CHANGED
|
@@ -15,9 +15,17 @@ class DiaramaAPIClient:
|
|
|
15
15
|
r.raise_for_status()
|
|
16
16
|
return r.json()
|
|
17
17
|
|
|
18
|
-
def _post(self, endpoint, data=None):
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def _post(self, endpoint, data=None, files=None):
|
|
19
|
+
url = f"{self.base_url}{endpoint}"
|
|
20
|
+
headers = self.headers.copy()
|
|
21
|
+
|
|
22
|
+
if files:
|
|
23
|
+
headers.pop("Content-Type", None)
|
|
24
|
+
r = requests.post(url, headers=headers, files=files)
|
|
25
|
+
else:
|
|
26
|
+
json_data = json.dumps(data, ensure_ascii=False).encode('utf-8') if data else None
|
|
27
|
+
r = requests.post(url, headers=headers, data=json_data)
|
|
28
|
+
|
|
21
29
|
r.raise_for_status()
|
|
22
30
|
return r.json()
|
|
23
31
|
|
diarama_api/files.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Files:
|
|
2
|
+
def __init__(self, client):
|
|
3
|
+
self.client = client
|
|
4
|
+
|
|
5
|
+
def list(self):
|
|
6
|
+
return self.client._get("/files")
|
|
7
|
+
|
|
8
|
+
def download(self, filename):
|
|
9
|
+
return self.client._get(f"/files/{filename}")
|
|
10
|
+
|
|
11
|
+
def upload(self, file_obj, filename):
|
|
12
|
+
files = {'file': (filename, file_obj)}
|
|
13
|
+
return self.client._post("/files", files=files)
|
|
14
|
+
|
|
15
|
+
def edit(self, filename, content):
|
|
16
|
+
data = {"content": content}
|
|
17
|
+
return self.client._put(f"/files/{filename}", json=data)
|
diarama_api/games.py
CHANGED
|
@@ -20,7 +20,7 @@ class Games:
|
|
|
20
20
|
return self.client._post("/games/", data)
|
|
21
21
|
|
|
22
22
|
def update(self, game_id, **kwargs):
|
|
23
|
-
allowed = ["name", "version", "author"]
|
|
23
|
+
allowed = ["name", "version", "author", "description", "platforms", "media_id"]
|
|
24
24
|
data = {k: v for k, v in kwargs.items() if k in allowed}
|
|
25
25
|
return self.client._put(f"/games/{game_id}", data)
|
|
26
26
|
|
diarama_api/media.py
CHANGED
|
@@ -4,7 +4,8 @@ class Media:
|
|
|
4
4
|
|
|
5
5
|
def create_image(self, url, alt_text=None):
|
|
6
6
|
data = {"url": url}
|
|
7
|
-
if alt_text:
|
|
7
|
+
if alt_text:
|
|
8
|
+
data["alt_text"] = alt_text
|
|
8
9
|
return self.client._post("/media/images", data)
|
|
9
10
|
|
|
10
11
|
def create_avatar(self, image_id):
|
|
@@ -12,3 +13,8 @@ class Media:
|
|
|
12
13
|
|
|
13
14
|
def create_banner(self, image_id):
|
|
14
15
|
return self.client._post("/media/banners", {"image_id": image_id})
|
|
16
|
+
|
|
17
|
+
def upload(self, file_obj):
|
|
18
|
+
"""Загрузить файл как медиа"""
|
|
19
|
+
files = {'file': file_obj}
|
|
20
|
+
return self.client._post("/media/upload", files=files)
|
diarama_api/platforms.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# api/platforms.py
|
|
2
|
+
class Platforms:
|
|
3
|
+
def __init__(self, client):
|
|
4
|
+
self.client = client
|
|
5
|
+
|
|
6
|
+
def list(self):
|
|
7
|
+
"""Получить список всех платформ"""
|
|
8
|
+
return self.client._get("/platforms/")
|
|
9
|
+
|
|
10
|
+
def get(self, platform_id):
|
|
11
|
+
"""Получить платформу по ID"""
|
|
12
|
+
return self.client._get(f"/platforms/{platform_id}")
|
|
13
|
+
|
|
14
|
+
def create(self, name):
|
|
15
|
+
"""Создать новую платформу"""
|
|
16
|
+
data = {"name": name}
|
|
17
|
+
return self.client._post("/platforms/", data)
|
|
18
|
+
|
|
19
|
+
def update(self, platform_id, name):
|
|
20
|
+
"""Обновить платформу"""
|
|
21
|
+
data = {"name": name}
|
|
22
|
+
return self.client._put(f"/platforms/{platform_id}", data)
|
|
23
|
+
|
|
24
|
+
def delete(self, platform_id):
|
|
25
|
+
"""Удалить платформу"""
|
|
26
|
+
return self.client._delete(f"/platforms/{platform_id}")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diarama_api/__init__.py,sha256=5vRMtDZp2LSs0IH1SoMZwS7bWtBUWeYufZAUyeGFZAQ,643
|
|
2
|
+
diarama_api/auth.py,sha256=y5PkFDqMyD2FXQ0fepEzlS_XDAguLcS1fqq7lKkwV_Y,358
|
|
3
|
+
diarama_api/client.py,sha256=7VseMp0Zssd4DWmWJxWbzO0fFrCdorQF5WsAth9DfXc,1489
|
|
4
|
+
diarama_api/files.py,sha256=MYkViq0tT3B-mM2khoZPwTOfVA_rfD56cSOFLXDCsnk,530
|
|
5
|
+
diarama_api/games.py,sha256=4Bls55VmOIXEbLw0HVIffa-dAZBVyze4Ii4UD3pSITE,950
|
|
6
|
+
diarama_api/media.py,sha256=jregTsjacX0C2Mj4OEkETz1G3nCZR3ix_8s93mkNz0c,709
|
|
7
|
+
diarama_api/payments.py,sha256=kA9jTsJsSf2e0D3T517Xchmy-WNGtQdAOcDpbbvXkAM,738
|
|
8
|
+
diarama_api/platforms.py,sha256=Rdb_kSROFDJ0qQTfc57DgoifC0nqRh6xfdn30zNEjw0,922
|
|
9
|
+
diarama_api/players.py,sha256=9ThcJKsQNhvBMvT6DI-rdxwfw4xa3C-9nTFEoNFFuLk,892
|
|
10
|
+
diarama_api-0.1.19.dist-info/METADATA,sha256=Zx4uZitwWyMQzMnznolYffhmEMPn1svy6SpQODZ2uRQ,324
|
|
11
|
+
diarama_api-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
diarama_api-0.1.19.dist-info/top_level.txt,sha256=OcL6tQomtjFhzrraJ9GouJCWoc668jQEsqbUGxM8E7E,12
|
|
13
|
+
diarama_api-0.1.19.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
diarama_api/__init__.py,sha256=cJmhN50DnymYRMg3aLptA7UsbEoXswRQoV8S8AlpphY,493
|
|
2
|
-
diarama_api/auth.py,sha256=y5PkFDqMyD2FXQ0fepEzlS_XDAguLcS1fqq7lKkwV_Y,358
|
|
3
|
-
diarama_api/client.py,sha256=lru2OnwZ0U8RzqfzmN8jiP9OTrstlc2tM6Lol-j4NPE,1247
|
|
4
|
-
diarama_api/games.py,sha256=kYkkX0jHYftF6OZ2pSDns2eSenTyNu299CIgElNerAo,910
|
|
5
|
-
diarama_api/media.py,sha256=rwiOX2QSt5grZpj25639t4w8oyeV0Xtu72h_FF_d4WU,500
|
|
6
|
-
diarama_api/payments.py,sha256=kA9jTsJsSf2e0D3T517Xchmy-WNGtQdAOcDpbbvXkAM,738
|
|
7
|
-
diarama_api/players.py,sha256=9ThcJKsQNhvBMvT6DI-rdxwfw4xa3C-9nTFEoNFFuLk,892
|
|
8
|
-
diarama_api-0.1.13.dist-info/METADATA,sha256=7k9kzhB2zMxX8h5nleOl5f3FhfuGnmXRGpTyRxYagwc,324
|
|
9
|
-
diarama_api-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
diarama_api-0.1.13.dist-info/top_level.txt,sha256=OcL6tQomtjFhzrraJ9GouJCWoc668jQEsqbUGxM8E7E,12
|
|
11
|
-
diarama_api-0.1.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|