Files
2026-08-02 14:07:04 +08:00

49 lines
1.8 KiB
Python

import threading
import requests
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.viewsets import ViewSet
from sixGuoDjango import BaseResponse, ResData
from wechat_token.token工具包 import sixToken
class 客服账号管理接口ViewSets( ViewSet ):
lock = threading.Lock( )
@action( detail=False, methods=[ "post" ], url_path="添加客服账号" )
def 添加客服账号( self, request: Request ):
""""""
wecom_token = sixToken.get_wecom_token( )
phone_token = sixToken.get_weom_phone_token( )
uri = f"https://qyapi.weixin.qq.com/cgi-bin/kf/account/add?access_token={wecom_token}"
json_data = {
"name": "新建的客服账号",
"media_id": "294DpAog3YA5b9rTK4PjjfRfYLO0L5qpDHAJIzhhQ2jAEWjb9i661Q4lk8oFnPtmj"
}
print( "==============" )
postData = requests.post( url=uri, json=json_data )
print( postData.json( ) )
httpResData = BaseResponse( resData=ResData( listData=[ ], dictData=postData.json( ) ), ).model_dump( )
return Response( data=httpResData, status=status.HTTP_200_OK )
@action( detail=False, methods=[ "post" ], url_path="获取客服账号列表" )
def 获取客服账号列表( self, request: Request ):
""""""
wecom_token = sixToken.get_wecom_token( )
uri = f"https://qyapi.weixin.qq.com/cgi-bin/kf/account/list?access_token={wecom_token}"
postData = requests.post( url=uri, )
print( postData.json( ) )
httpResData = BaseResponse( resData=ResData( listData=[ ], dictData=postData.json( ) ), ).model_dump( )
return Response( data=httpResData, status=status.HTTP_200_OK )