def list(self, offset, limit, **kwargs): """获取客户群列表,对应接口/cgi-bin/externalcontact/groupchat/list""" url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/list' params = {'access_token': self.token} json = {'offset': offset, 'limit': limit} return_response = requests.post(url, params=params, json=json) BaseApi.print_json(return_response.json()) logging.info(return_response.json()) return return_response.json()
def get(self, chat_id, **kwargs): """获取客户群详情,对应接口/cgi-bin/externalcontact/groupchat/get""" url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/groupchat/get' params = {'access_token': self.token} json = {'chat_id': chat_id} return_response = requests.post(url, params=params, json=json) BaseApi.print_json(return_response.json()) logging.info(return_response.json()) return return_response.json()
def list(self, **kwargs): """获取部门列表,对应接口/cgi-bin/department/list""" url = 'https://qyapi.weixin.qq.com/cgi-bin/department/list' return_response = self.session.get(url, params=kwargs) if self.is_debug: BaseApi.print_json(return_response.json()) print(Tools.errcode_translate(return_response.json()['errcode'])) logging.info(return_response.json()) return return_response.json()
def request_token(cls, corpsecret): """向服务器发送请求获取token""" return_response = requests.get(cls._token_url, params={ 'corpid': cls._corpid, 'corpsecret': corpsecret }) BaseApi.print_json(return_response.json()) logging.info(return_response.json()) assert return_response.json()['errcode'] == 0 return return_response.json()['access_token']
def update(self, access_token=None, **kwargs): """更新部门,对应接口/cgi-bin/department/update""" url = 'https://qyapi.weixin.qq.com/cgi-bin/department/update' if access_token is not None: return_response = self.session.post(url, json=kwargs, params={'access_token': access_token}) else: return_response = self.session.post(url, json=kwargs) if self.is_debug: BaseApi.print_json(return_response.json()) print(Tools.errcode_translate(return_response.json()['errcode'])) logging.info(return_response.json()) return return_response.json()
def get_tag(self): url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_corp_tag_list' request_json = {'tag_id': []} return_response = requests.post( url, params={'access_token': self.token}, json=request_json, ) if self.is_debug: BaseApi.print_json(return_response.json()) print(Tools.errcode_translate(return_response.json()['errcode'])) logging.info(return_response.json()) return return_response.json()
def __init__(self): BaseApi.__init__(self)