Passed
Pull Request — master (#1174)
by
unknown
02:26
created

Client::updateStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\OfficialAccount\Store;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author bigface <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * Get WXA supported categories.
25
     *
26
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
27
     */
28
    public function categories()
29
    {
30
        return $this->httpGet('wxa/get_merchant_category');
31
    }
32
33
    /**
34
     * Get district from tencent map .
35
     *
36
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
37
     */
38
    public function district()
39
    {
40
        return $this->httpGet('wxa/get_district');
41
    }
42
43
    /**
44
     * Search store from tencent map.
45
     *
46
     * @param int $id district's id
47
     * @param string $keyword
48
     *
49
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
50
     */
51
    public function searchFormMap(int $id, string $keyword)
52
    {
53
        $params = [
54
            'districtid' => $id,
55
            'keyword'    => $keyword
56
        ];
57
58
        return $this->httpPostJson('wxa/search_map_poi', $params);
59
    }
60
61
    /**
62
     * Get store check status.
63
     *
64
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
65
     */
66
    public function getStatus()
67
    {
68
        return $this->httpPostJson('wxa/get_merchant_audit_info');
69
    }
70
71
    /**
72
     * Create a merchant.
73
     *
74
     * @param array $baseInfo
75
     *
76
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
77
     */
78
    public function createMerchant(array $baseInfo)
79
    {
80
        return $this->httpPostJson('wxa/apply_merchant', $baseInfo);
81
    }
82
83
    /**
84
     * Update a merchant.
85
     *
86
     * @param array $params
87
     *
88
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
89
     */
90
    public function updateMerchant(array $params)
91
    {
92
        return $this->httpPostJson('wxa/modify_merchant', $params);
93
    }
94
95
    /**
96
     * Create a store form tencent map.
97
     *
98
     * @param array $baseInfo
99
     *
100
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
101
     */
102
    public function createFormMap(array $baseInfo)
103
    {
104
        return $this->httpPostJson('wxa/create_map_poi', $baseInfo);
105
    }
106
107
    /**
108
     * Create a store.
109
     *
110
     * @param array $baseInfo
111
     *
112
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
113
     */
114
    public function createStore(array $baseInfo)
115
    {
116
        return $this->httpPostJson('wxa/add_store', $baseInfo);
117
    }
118
119
    /**
120
     * Update a store.
121
     *
122
     * @param int   $poiId
123
     * @param array $baseInfo
124
     *
125
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
126
     */
127
    public function updateStore(int $poiId, array $baseInfo)
128
    {
129
        $params = [
130
            'base_info' => array_merge($baseInfo, ['poi_id' => $poiId]),
131
        ];
132
133
        return $this->httpPostJson('wxa/update_store', $params);
134
    }
135
136
    /**
137
     * Get store by ID.
138
     *
139
     * @param int $poiId
140
     *
141
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
142
     */
143
    public function get(int $poiId)
144
    {
145
        return $this->httpPostJson('wxa/get_store_info', ['poi_id' => $poiId]);
146
    }
147
148
    /**
149
     * List store.
150
     *
151
     * @param int $offset
152
     * @param int $limit
153
     *
154
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
155
     */
156
    public function list(int $offset = 0, int $limit = 10)
157
    {
158
        $params = [
159
            'begin' => $offset,
160
            'limit' => $limit
161
        ];
162
163
        return $this->httpPostJson('wxa/get_store_list', $params);
164
    }
165
166
    /**
167
     * Delete a store.
168
     *
169
     * @param int $poiId
170
     *
171
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
172
     */
173
    public function delete(int $poiId)
174
    {
175
        return $this->httpPostJson('wxa/del_store', ['poi_id' => $poiId]);
176
    }
177
}
178