1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
from datetime import datetime
from httpx import AsyncClient, Headers
from wolf_comm import constants
from wolf_comm.constants import SESSION_ID, TIMESTAMP
from wolf_comm.helpers import bearer_header
async def create_session(client: AsyncClient, token: str):
data = {
TIMESTAMP: datetime.now().strftime("%Y-%m-%d %H:%M:%S")
}
resp = await client.post(constants.BASE_URL_PORTAL + "/api/portal/CreateSession2",
headers=Headers({**bearer_header(token),
**{"Content-Type": "application/json"}}),
json=data)
return resp.json()['BrowserSessionId']
async def update_session(client: AsyncClient, token: str, session_id: str):
data = {
SESSION_ID: session_id
}
await client.post(constants.BASE_URL_PORTAL + "/api/portal/UpdateSession",
headers=Headers({**bearer_header(token),
**{"Content-Type": "application/json"}}),
json=data)
|