Completed
Push — master ( e6b198...e30f90 )
by Messense
11:09 queued 10:06
created

WeChatClient.fetch_access_token()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
cc 1
dl 0
loc 7
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
1
# -*- coding: utf-8 -*-
2 10
from __future__ import absolute_import, unicode_literals
3
4 10
from wechatpy.client.base import BaseWeChatClient
5 10
from wechatpy.enterprise.client import api
6
7
8 10
class WeChatClient(BaseWeChatClient):
9
10 10
    API_BASE_URL = 'https://qyapi.weixin.qq.com/cgi-bin/'
11
12 10
    user = api.WeChatUser()
13 10
    department = api.WeChatDepartment()
14 10
    menu = api.WeChatMenu()
15 10
    message = api.WeChatMessage()
16 10
    tag = api.WeChatTag()
17 10
    media = api.WeChatMedia()
18 10
    misc = api.WeChatMisc()
19 10
    agent = api.WeChatAgent()
20 10
    batch = api.WeChatBatch()
21 10
    jsapi = api.WeChatJSAPI()
22 10
    material = api.WeChatMaterial()
23 10
    oauth = api.WeChatOAuth()
24 10
    shakearound = api.WeChatShakeAround()
25 10
    service = api.WeChatService()
26 10
    chat = api.WeChatChat()
27
28 10
    def __init__(self, corp_id, secret, access_token=None,
29
                 session=None, timeout=None):
30 10
        super(WeChatClient, self).__init__(
31
            corp_id, access_token, session, timeout
32
        )
33 10
        self.corp_id = corp_id
34 10
        self.secret = secret
35
36 10
    def fetch_access_token(self):
37
        """ Fetch access token"""
38 10
        return self._fetch_access_token(
39
            url='https://qyapi.weixin.qq.com/cgi-bin/gettoken',
40
            params={
41
                'corpid': self.corp_id,
42
                'corpsecret': self.secret
43
            }
44
        )
45