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

MerchantGroup   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 46.67%
Metric Value
dl 0
loc 55
ccs 7
cts 15
cp 0.4667
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 6 1
A add() 0 7 1
A update_product() 0 6 1
A get_all() 0 6 2
A delete() 0 5 1
A get() 0 9 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 MerchantGroup(BaseWeChatAPI):
7
8 10
    def add(self, name, product_list):
9
        return self._post(
10
            'merchant/group/add',
11
            data={
12
                'group_detail': {
13
                    'group_name': name,
14
                    'product_list': product_list
15
                }
16
            }
17
        )
18
19 10
    def delete(self, group_id):
20
        return self._post(
21
            'merchant/group/del',
22
            data={
23
                'group_id': group_id
24
            }
25
        )
26
27 10
    def update(self, group_id, name):
28
        return self._post(
29
            'merchant/group/propertymod',
30
            data={
31
                'group_id': group_id,
32
                'group_name': name
33
            }
34
        )
35
36 10
    def update_product(self, group_id, product):
37
        return self._post(
38
            'merchant/group/productmod',
39
            data={
40
                'group_id': group_id,
41
                'product': product
42
            }
43
        )
44
45 10
    def get_all(self):
46
        res = self._get(
47
            'merchant/group/getall',
48
            result_processor=lambda x: x['group_detail']
49
        )
50
        return res
51
52 10
    def get(self, group_id):
53
        res = self._post(
54
            'merchant/group/getbyid',
55
            data={
56
                'group_id': group_id
57
            },
58
            result_processor=lambda x: x['group_detail']
59
        )
60
        return res
61