50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
|
|
CORP_STATISTIC_URL = "/cgi-bin/kf/get_corp_statistic"
|
||
|
|
SERVICER_STATISTIC_URL = "/cgi-bin/kf/get_servicer_statistic"
|
||
|
|
|
||
|
|
|
||
|
|
class WeChatKFStatistics:
|
||
|
|
def __init__(self, gateway):
|
||
|
|
self._gateway = gateway
|
||
|
|
|
||
|
|
async def get_corp_statistic(
|
||
|
|
self,
|
||
|
|
open_kfid: str = "",
|
||
|
|
start_time: int = 0,
|
||
|
|
end_time: int = 0,
|
||
|
|
) -> dict:
|
||
|
|
payload = {}
|
||
|
|
if open_kfid:
|
||
|
|
payload["open_kfid"] = open_kfid
|
||
|
|
if start_time:
|
||
|
|
payload["start_time"] = start_time
|
||
|
|
if end_time:
|
||
|
|
payload["end_time"] = end_time
|
||
|
|
token = await self._gateway.get_access_token()
|
||
|
|
resp = await self._gateway._http.post(
|
||
|
|
CORP_STATISTIC_URL,
|
||
|
|
params={"access_token": token},
|
||
|
|
json=payload,
|
||
|
|
)
|
||
|
|
return resp.json()
|
||
|
|
|
||
|
|
async def get_servicer_statistic(
|
||
|
|
self,
|
||
|
|
servicer_userid: str = "",
|
||
|
|
start_time: int = 0,
|
||
|
|
end_time: int = 0,
|
||
|
|
) -> dict:
|
||
|
|
payload = {}
|
||
|
|
if servicer_userid:
|
||
|
|
payload["servicer_userid"] = servicer_userid
|
||
|
|
if start_time:
|
||
|
|
payload["start_time"] = start_time
|
||
|
|
if end_time:
|
||
|
|
payload["end_time"] = end_time
|
||
|
|
token = await self._gateway.get_access_token()
|
||
|
|
resp = await self._gateway._http.post(
|
||
|
|
SERVICER_STATISTIC_URL,
|
||
|
|
params={"access_token": token},
|
||
|
|
json=payload,
|
||
|
|
)
|
||
|
|
return resp.json()
|