understanding commited on
Commit
2cc5f0e
·
verified ·
1 Parent(s): 76b253b

Create integrations/cf_worker1.py

Browse files
Files changed (1) hide show
  1. bot/integrations/cf_worker1.py +19 -0
bot/integrations/cf_worker1.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PATH: bot/integrations/cf_worker1.py
2
+ from bot.config import Workers
3
+ from bot.integrations.http import post_json
4
+
5
+ def _h():
6
+ return {"Authorization": f"Bearer {Workers.BOT_BACKEND_KEY}", "Content-Type": "application/json"}
7
+
8
+ async def profile_add(tg_id: int, client_id: str, client_secret: str, label: str = "main", ttl_sec: int = 600) -> dict:
9
+ return await post_json(
10
+ f"{Workers.WORKER1_URL}/api/profile/add",
11
+ _h(),
12
+ {"tg_id": str(tg_id), "client_id": client_id, "client_secret": client_secret, "label": label, "ttl_sec": ttl_sec},
13
+ )
14
+
15
+ async def profile_list(tg_id: int) -> dict:
16
+ return await post_json(f"{Workers.WORKER1_URL}/api/profile/list", _h(), {"tg_id": str(tg_id)})
17
+
18
+ async def profile_set_default(tg_id: int, profile_id: str) -> dict:
19
+ return await post_json(f"{Workers.WORKER1_URL}/api/profile/set_default", _h(), {"tg_id": str(tg_id), "profile_id": profile_id})