Completed
Pull Request — master (#138)
by
unknown
20:13
created

MerchantExpress.add()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125
Metric Value
cc 1
dl 0
loc 5
ccs 1
cts 2
cp 0.5
crap 1.125
rs 9.4285
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 MerchantExpress(BaseWeChatAPI):
7
8 10
    def add(self, delivery_template):
9
        return self._post(
10
            'merchant/express/add',
11
            data={
12
                'delivery_template': delivery_template
13
            }
14
        )
15
16 10
    def delete(self, template_id):
17
        return self._post(
18
            'merchant/express/del',
19
            data={
20
                'template_id': template_id
21
            }
22
        )
23
24 10
    def update(self, template_id, delivery_template):
25
        return self._post(
26
            'merchant/express/update',
27
            data={
28
                'template_id': template_id,
29
                'delivery_template': delivery_template
30
            }
31
        )
32
33 10
    def get(self, template_id):
34
        res = self._post(
35
            'merchant/express/getbyid',
36
            data={
37
                'template_id': template_id
38
            },
39
            result_processor=lambda x: x['template_info']
40
        )
41
        return res
42
43 10
    def get_all(self):
44
        res = self._get(
45
            'merchant/express/getall',
46
            result_processor=lambda x: x['template_info']
47
        )
48
        return res
49