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

MerchantExpress   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%
Metric Value
dl 0
loc 43
ccs 6
cts 13
cp 0.4615
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 6 1
A delete() 0 5 1
A get() 0 9 2
A get_all() 0 6 2
A add() 0 5 1
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