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 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