Completed
Push — master ( 062592...735bc8 )
by Messense
02:39
created

get_all()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 3.1854
Metric Value
cc 2
dl 0
loc 6
ccs 1
cts 3
cp 0.3333
crap 3.1854
rs 9.4286
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