diarama-api 0.1.16__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 CHANGED
@@ -5,6 +5,7 @@ from .games import Games
5
5
  from .payments import Payments
6
6
  from .media import Media
7
7
  from .platforms import Platforms
8
+ from .files import Files
8
9
 
9
10
  class DiaramaAPI:
10
11
  def __init__(self, api_key):
@@ -15,3 +16,4 @@ class DiaramaAPI:
15
16
  self.payments = Payments(self.client)
16
17
  self.media = Media(self.client)
17
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
- json_data = json.dumps(data, ensure_ascii=False).encode('utf-8')
20
- r = requests.post(f"{self.base_url}{endpoint}", headers=self.headers, data=json_data)
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diarama-api
3
- Version: 0.1.16
3
+ Version: 0.1.19
4
4
  Summary: Python SDK для работы с API Diarama Studio
5
5
  Author-email: Haru <hello@chinoharu.ru>
6
6
  License: MIT
@@ -1,12 +1,13 @@
1
- diarama_api/__init__.py,sha256=EPszHsXnxfWYivzy6n2D9G9cP8YHCXqNd9BfMmDhDKc,576
1
+ diarama_api/__init__.py,sha256=5vRMtDZp2LSs0IH1SoMZwS7bWtBUWeYufZAUyeGFZAQ,643
2
2
  diarama_api/auth.py,sha256=y5PkFDqMyD2FXQ0fepEzlS_XDAguLcS1fqq7lKkwV_Y,358
3
- diarama_api/client.py,sha256=lru2OnwZ0U8RzqfzmN8jiP9OTrstlc2tM6Lol-j4NPE,1247
3
+ diarama_api/client.py,sha256=7VseMp0Zssd4DWmWJxWbzO0fFrCdorQF5WsAth9DfXc,1489
4
+ diarama_api/files.py,sha256=MYkViq0tT3B-mM2khoZPwTOfVA_rfD56cSOFLXDCsnk,530
4
5
  diarama_api/games.py,sha256=4Bls55VmOIXEbLw0HVIffa-dAZBVyze4Ii4UD3pSITE,950
5
6
  diarama_api/media.py,sha256=jregTsjacX0C2Mj4OEkETz1G3nCZR3ix_8s93mkNz0c,709
6
7
  diarama_api/payments.py,sha256=kA9jTsJsSf2e0D3T517Xchmy-WNGtQdAOcDpbbvXkAM,738
7
8
  diarama_api/platforms.py,sha256=Rdb_kSROFDJ0qQTfc57DgoifC0nqRh6xfdn30zNEjw0,922
8
9
  diarama_api/players.py,sha256=9ThcJKsQNhvBMvT6DI-rdxwfw4xa3C-9nTFEoNFFuLk,892
9
- diarama_api-0.1.16.dist-info/METADATA,sha256=nHYsWQ2yYnpOiUm4UQtYxs3bjCZgCEJk3nf072RD82s,324
10
- diarama_api-0.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- diarama_api-0.1.16.dist-info/top_level.txt,sha256=OcL6tQomtjFhzrraJ9GouJCWoc668jQEsqbUGxM8E7E,12
12
- diarama_api-0.1.16.dist-info/RECORD,,
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,,