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

MerchantShelf.get()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125
Metric Value
cc 1
dl 0
loc 5
ccs 1
cts 2
cp 0.5
crap 1.125
rs 9.4285
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