Client::list()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
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
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
29
     */
30 1
    public function categories()
31
    {
32 1
        return $this->httpGet('wxa/get_merchant_category');
33
    }
34
35
    /**
36
     * Get district from tencent map .
37
     *
38
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
39
     *
40
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
41
     */
42 1
    public function districts()
43
    {
44 1
        return $this->httpGet('wxa/get_district');
45
    }
46
47
    /**
48
     * Search store from tencent map.
49
     *
50
     * @param int    $districtId
51
     * @param string $keyword
52
     *
53
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
54
     *
55
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
56
     * @throws \GuzzleHttp\Exception\GuzzleException
57
     */
58 1
    public function searchFromMap(int $districtId, string $keyword)
59
    {
60
        $params = [
61 1
            'districtid' => $districtId,
62 1
            'keyword' => $keyword,
63
        ];
64
65 1
        return $this->httpPostJson('wxa/search_map_poi', $params);
66
    }
67
68
    /**
69
     * Get store check status.
70
     *
71
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
72
     *
73
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
74
     * @throws \GuzzleHttp\Exception\GuzzleException
75
     */
76 1
    public function getStatus()
77
    {
78 1
        return $this->httpGet('wxa/get_merchant_audit_info');
79
    }
80
81
    /**
82
     * Create a merchant.
83
     *
84
     * @param array $baseInfo
85
     *
86
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
87
     *
88
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
89
     * @throws \GuzzleHttp\Exception\GuzzleException
90
     */
91 1
    public function createMerchant(array $baseInfo)
92
    {
93 1
        return $this->httpPostJson('wxa/apply_merchant', $baseInfo);
94
    }
95
96
    /**
97
     * Update a merchant.
98
     *
99
     * @param array $params
100
     *
101
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
102
     *
103
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
104
     * @throws \GuzzleHttp\Exception\GuzzleException
105
     */
106 1
    public function updateMerchant(array $params)
107
    {
108 1
        return $this->httpPostJson('wxa/modify_merchant', $params);
109
    }
110
111
    /**
112
     * Create a store from tencent map.
113
     *
114
     * @param array $baseInfo
115
     *
116
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
117
     *
118
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
119
     * @throws \GuzzleHttp\Exception\GuzzleException
120
     */
121 1
    public function createFromMap(array $baseInfo)
122
    {
123 1
        return $this->httpPostJson('wxa/create_map_poi', $baseInfo);
124
    }
125
126
    /**
127
     * Create a store.
128
     *
129
     * @param array $baseInfo
130
     *
131
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
132
     *
133
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
134
     * @throws \GuzzleHttp\Exception\GuzzleException
135
     */
136 1
    public function create(array $baseInfo)
137
    {
138 1
        return $this->httpPostJson('wxa/add_store', $baseInfo);
139
    }
140
141
    /**
142
     * Update a store.
143
     *
144
     * @param int   $poiId
145
     * @param array $baseInfo
146
     *
147
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
148
     *
149
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
150
     * @throws \GuzzleHttp\Exception\GuzzleException
151
     */
152 1
    public function update(int $poiId, array $baseInfo)
153
    {
154 1
        $params = array_merge($baseInfo, ['poi_id' => $poiId]);
155
156 1
        return $this->httpPostJson('wxa/update_store', $params);
157
    }
158
159
    /**
160
     * Get store by ID.
161
     *
162
     * @param int $poiId
163
     *
164
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
165
     *
166
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
167
     * @throws \GuzzleHttp\Exception\GuzzleException
168
     */
169 1
    public function get(int $poiId)
170
    {
171 1
        return $this->httpPostJson('wxa/get_store_info', ['poi_id' => $poiId]);
172
    }
173
174
    /**
175
     * List store.
176
     *
177
     * @param int $offset
178
     * @param int $limit
179
     *
180
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
181
     *
182
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
183
     * @throws \GuzzleHttp\Exception\GuzzleException
184
     */
185 1
    public function list(int $offset = 0, int $limit = 10)
186
    {
187
        $params = [
188 1
            'offset' => $offset,
189 1
            'limit' => $limit,
190
        ];
191
192 1
        return $this->httpPostJson('wxa/get_store_list', $params);
193
    }
194
195
    /**
196
     * Delete a store.
197
     *
198
     * @param int $poiId
199
     *
200
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
201
     *
202
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
203
     * @throws \GuzzleHttp\Exception\GuzzleException
204
     */
205 1
    public function delete(int $poiId)
206
    {
207 1
        return $this->httpPostJson('wxa/del_store', ['poi_id' => $poiId]);
208
    }
209
}
210