Dotory
This commit is contained in:
parent
40266cc6e5
commit
5f8600d9ae
3 changed files with 14 additions and 15 deletions
|
|
@ -7,27 +7,27 @@ class StoreService:
|
|||
|
||||
async def get_dotory_by_id(self, user_id: int):
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(f"{self.SERVER_URL}/")
|
||||
response = await client.get(f"{self.SERVER_URL}/api/dotory/{user_id}")
|
||||
response_json = response.json()
|
||||
return
|
||||
return response_json["dotory"]
|
||||
|
||||
async def register_user(self, user_id: int):
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.SERVER_URL}/", json={"user_id": user_id}
|
||||
f"{self.SERVER_URL}/api/dotory", json={"user_id": user_id}
|
||||
)
|
||||
return
|
||||
return response.json()
|
||||
|
||||
async def buy_product(self, product_id: int, user_id: int):
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.SERVER_URL}/", json={"user_id": user_id}
|
||||
f"{self.SERVER_URL}/api/buy/{product_id}", json={"user_id": user_id}
|
||||
)
|
||||
return
|
||||
return response.json()
|
||||
|
||||
async def update_user_dotory(self, user_id: int, dotoryNum: int):
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.put(
|
||||
f"{self.SERVER_URL}/", json={"num": dotoryNum}
|
||||
f"{self.SERVER_URL}/api/dotory/{user_id}", json={"num": dotoryNum}
|
||||
)
|
||||
return
|
||||
return response.json()["dotory"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue