class WeChatClient(BaseWeChatClient): API_BASE_URL = 'https://qyapi.weixin.qq.com/cgi-bin/' user = api.WeChatUser() department = api.WeChatDepartment() menu = api.WeChatMenu() message = api.WeChatMessage() tag = api.WeChatTag() media = api.WeChatMedia() misc = api.WeChatMisc() agent = api.WeChatAgent() batch = api.WeChatBatch() jsapi = api.WeChatJSAPI() material = api.WeChatMaterial() oauth = api.WeChatOAuth() def __init__(self, corp_id, secret, access_token=None, session=None): super(WeChatClient, self).__init__(access_token, session) self.corp_id = corp_id self.secret = secret def fetch_access_token(self): """ Fetch access token""" return self._fetch_access_token( url='https://qyapi.weixin.qq.com/cgi-bin/gettoken', params={ 'corpid': self.corp_id, 'corpsecret': self.secret })
class WeChatClient(BaseWeChatClient): API_BASE_URL = 'https://qyapi.weixin.qq.com/cgi-bin/' agent = api.WeChatAgent() appchat = api.WeChatAppChat() batch = api.WeChatBatch() calendar = api.WeChatCalendar() chat = api.WeChatChat() department = api.WeChatDepartment() external_contact = api.WeChatExternalContact() external_contact_group_chat = api.WeChatExternalContactGroupChat() jsapi = api.WeChatJSAPI() material = api.WeChatMaterial() media = api.WeChatMedia() menu = api.WeChatMenu() message = api.WeChatMessage() misc = api.WeChatMisc() oauth = api.WeChatOAuth() schedule = api.WeChatSchedule() service = api.WeChatService() shakearound = api.WeChatShakeAround() tag = api.WeChatTag() user = api.WeChatUser() OA = api.WeChatOA() def __init__(self, corp_id, secret, access_token=None, session=None, timeout=None, auto_retry=True): self.corp_id = corp_id self.secret = secret super(WeChatClient, self).__init__(corp_id, access_token, session, timeout, auto_retry) @property def access_token_key(self): return '{0}_{1}_access_token'.format(self.corp_id, self.secret[:10]) def fetch_access_token(self): """ Fetch access token""" return self._fetch_access_token( url='https://qyapi.weixin.qq.com/cgi-bin/gettoken', params={ 'corpid': self.corp_id, 'corpsecret': self.secret })
def __init__(self, corp_id, secret, access_token=None): self.corp_id = corp_id self.secret = secret self._access_token = access_token self.expires_at = None weak_self = weakref.proxy(self) # APIs self.user = api.WeChatUser(weak_self) self.department = api.WeChatDepartment(weak_self) self.menu = api.WeChatMenu(weak_self) self.message = api.WeChatMessage(weak_self) self.tag = api.WeChatTag(weak_self) self.media = api.WeChatMedia(weak_self) self.misc = api.WeChatMisc(weak_self) self.agent = api.WeChatAgent(weak_self) self.batch = api.WeChatBatch(weak_self)