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

MerchantShelf   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 50%
Metric Value
dl 0
loc 43
ccs 6
cts 12
cp 0.5
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 8 1
A get_all() 0 6 2
A add() 0 7 1
A delete() 0 5 1
A get() 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 MerchantShelf(BaseWeChatAPI):
7
8 10
    def add(self, name, banner, shelf_data):
9
        return self._post(
10
            'merchant/shelf/add',
11
            data={
12
                'shelf_name': name,
13
                'shelf_banner': banner,
14
                'shelf_data': shelf_data
15
            }
16
        )
17
18 10
    def delete(self, shelf_id):
19
        return self._post(
20
            'merchant/shelf/del',
21
            data={
22
                'shelf_id': shelf_id
23
            }
24
        )
25
26 10
    def update(self, shelf_id, name, banner, shelf_data):
27
        return self._post(
28
            'merchant/shelf/add',
29
            data={
30
                'shelf_id': shelf_id,
31
                'shelf_name': name,
32
                'shelf_banner': banner,
33
                'shelf_data': shelf_data
34
            }
35
        )
36
37 10
    def get_all(self):
38
        res = self._get(
39
            'merchant/shelf/getall',
40
            result_processor=lambda x: x['shelves']
41
        )
42
        return res
43
44 10
    def get(self, shelf_id):
45
        return self._post(
46
            'merchant/shelf/getbyid',
47
            data={
48
                'shelf_id': shelf_id
49
            }
50
        )
51