WeChatMisc.get_wechat_ips()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 19
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 1
dl 0
loc 19
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 2
1
# -*- coding: utf-8 -*-
2 10
from __future__ import absolute_import, unicode_literals
3 10
from wechatpy.client.api.base import BaseWeChatAPI
4
5
6 10
class WeChatMisc(BaseWeChatAPI):
7
8 10
    def short_url(self, long_url):
9
        """
10
        将一条长链接转成短链接
11
        详情请参考
12
        http://mp.weixin.qq.com/wiki/10/165c9b15eddcfbd8699ac12b0bd89ae6.html
13
14
        :param long_url: 长链接地址
15
        :return: 返回的 JSON 数据包
16
17
        使用示例::
18
19
            from wechatpy import WeChatClient
20
21
            client = WeChatClient('appid', 'secret')
22
            res = client.misc.short_url('http://www.qq.com')
23
24
        """
25 10
        return self._post(
26
            'shorturl',
27
            data={
28
                'action': 'long2short',
29
                'long_url': long_url
30
            }
31
        )
32
33 10
    def get_wechat_ips(self):
34
        """
35
        获取微信服务器 IP 地址列表
36
37
        :return: IP 地址列表
38
39
        使用示例::
40
41
            from wechatpy import WeChatClient
42
43
            client = WeChatClient('appid', 'secret')
44
            ips = client.misc.get_wechat_ips()
45
46
        """
47 10
        res = self._get(
48
            'getcallbackip',
49
            result_processor=lambda x: x['ip_list']
50
        )
51
        return res
52