clozly 0.0.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.
clozly-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: clozly
3
+ Version: 0.0.0
File without changes
clozly-0.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .main import Clozly, ClozlyResponse
@@ -0,0 +1,43 @@
1
+ import httpx
2
+
3
+ class ClozlyResponse:
4
+ def __init__(self, data):
5
+ self._url = data.get("generatedImageUrl")
6
+ self.id = data.get("id")
7
+ self.status = "succeeded"
8
+ self.raw = data
9
+
10
+ def url(self):
11
+ return self._url
12
+
13
+
14
+ class Clozly:
15
+ def __init__(self, api_key: str):
16
+ self.api_key = api_key
17
+ self.base_url = 'https://clozly.ru/api/module-VTON/tryon'
18
+
19
+ async def run(self, product_id: str, user_photo_url: str, use_back_view: bool = False):
20
+ headers = {
21
+ 'Authorization': f'Bearer {self.api_key}',
22
+ 'Content-Type': 'application/json'
23
+ }
24
+
25
+ payload = {
26
+ 'productId': product_id,
27
+ 'userPhotoUrl': user_photo_url,
28
+ 'useBackView': use_back_view
29
+ }
30
+
31
+ try:
32
+ async with httpx.AsyncClient() as client:
33
+ response = await client.post(self.base_url, headers=headers, json=payload)
34
+
35
+ if not response.is_success:
36
+ error_text = response.text
37
+ raise Exception(f"Ошибка сервера ({response.status_code}): {error_text[:50]}")
38
+
39
+ data = response.json()
40
+ return ClozlyResponse(data)
41
+
42
+ except Exception as err:
43
+ raise Exception(f"Сетевая ошибка: {err}")
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: clozly
3
+ Version: 0.0.0
@@ -0,0 +1,7 @@
1
+ pyproject.toml
2
+ src/clozly/__init__.py
3
+ src/clozly/main.py
4
+ src/clozly.egg-info/PKG-INFO
5
+ src/clozly.egg-info/SOURCES.txt
6
+ src/clozly.egg-info/dependency_links.txt
7
+ src/clozly.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ clozly