WeChatTemplate.del_private_template()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 2
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 1
cts 2
cp 0.5
crap 1.125
1
# -*- coding: utf-8 -*-
2 10
from __future__ import absolute_import, unicode_literals
3
4 10
from wechatpy.client.api.base import BaseWeChatAPI
5
6
7 10
class WeChatTemplate(BaseWeChatAPI):
8
9 10
    def set_industry(self, industry_id1, industry_id2):
10
        """
11
        设置所属行业
12
        详情请参考
13
        https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
14
15
        :param industry_id1: 公众号模板消息所属行业编号
16
        :param industry_id2: 公众号模板消息所属行业编号
17
        :return: 返回的 JSON 数据包
18
        """
19
        return self._post(
20
            'template/api_set_industry',
21
            data={
22
                'industry_id1': industry_id1,
23
                'industry_id2': industry_id2
24
            }
25
        )
26
27 10
    def get_industry(self):
28
        """
29
        获取设置的行业信息
30
        详情请参考
31
        https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
32
33
        :return: 返回的 JSON 数据包
34
        """
35
        return self._get(
36
            'template/get_industry'
37
        )
38
39 10
    def get(self, template_id_short):
40
        """
41
        获得模板ID
42
        详情请参考
43
        https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
44
45
        :param template_id_short: 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
46
        :return: 模板 ID
47
        """
48
        res = self._post(
49
            'template/api_add_template',
50
            data={
51
                'template_id_short': template_id_short
52
            },
53
            result_processor=lambda x: x['template_id']
54
        )
55
        return res
56
57 10
    add = get
58
59 10
    def get_all_private_template(self):
60
        """
61
        获取模板列表
62
        详情请参考
63
        https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
64
65
        :return: 返回的 JSON 数据包
66
        """
67
        return self._get(
68
            'template/get_all_private_template'
69
        )
70
71 10
    def del_private_template(self, template_id):
72
        """
73
        删除模板
74
        详情请参考
75
        https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
76
77
        :param template_id: 公众帐号下模板消息ID
78
        :return: 返回的 JSON 数据包
79
        """
80
        return self._post(
81
            'template/del_private_template',
82
            data={
83
                'template_id': template_id
84
            }
85
        )
86