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\MiniProgram\NearbyPoi; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
15
|
|
|
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Client. |
19
|
|
|
* |
20
|
|
|
* @author joyeekk <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Client extends BaseClient |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Add nearby poi. |
26
|
|
|
* |
27
|
|
|
* @param array $params |
28
|
|
|
* |
29
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
30
|
|
|
* |
31
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
32
|
|
|
*/ |
33
|
1 |
|
public function add(array $params) |
34
|
|
|
{ |
35
|
1 |
|
$params = array_merge([ |
36
|
1 |
|
'is_comm_nearby' => '1', |
37
|
|
|
'poi_id' => '', |
38
|
|
|
], $params); |
39
|
|
|
|
40
|
1 |
|
return $this->httpPostJson('wxa/addnearbypoi', $params); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Update nearby poi. |
45
|
|
|
* |
46
|
|
|
* @param string $poiId |
47
|
|
|
* @param array $params |
48
|
|
|
* |
49
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
50
|
|
|
* |
51
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
52
|
|
|
*/ |
53
|
1 |
|
public function update(string $poiId, array $params) |
54
|
|
|
{ |
55
|
1 |
|
$params = array_merge([ |
56
|
1 |
|
'is_comm_nearby' => '1', |
57
|
1 |
|
'poi_id' => $poiId, |
58
|
|
|
], $params); |
59
|
|
|
|
60
|
1 |
|
return $this->httpPostJson('wxa/addnearbypoi', $params); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Delete nearby poi. |
65
|
|
|
* |
66
|
|
|
* @param string $poiId |
67
|
|
|
* |
68
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
69
|
|
|
*/ |
70
|
1 |
|
public function delete(string $poiId) |
71
|
|
|
{ |
72
|
1 |
|
return $this->httpPostJson('wxa/delnearbypoi', [ |
73
|
1 |
|
'poi_id' => $poiId, |
74
|
|
|
]); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get nearby poi list. |
79
|
|
|
* |
80
|
|
|
* @param int $page |
81
|
|
|
* @param int $pageRows |
82
|
|
|
* |
83
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
84
|
|
|
*/ |
85
|
1 |
|
public function list(int $page, int $pageRows) |
86
|
|
|
{ |
87
|
1 |
|
return $this->httpGet('wxa/getnearbypoilist', [ |
88
|
1 |
|
'page' => $page, |
89
|
1 |
|
'page_rows' => $pageRows, |
90
|
|
|
]); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Set nearby poi show status. |
95
|
|
|
* |
96
|
|
|
* @param string $poiId |
97
|
|
|
* @param int $status |
98
|
|
|
* |
99
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
100
|
|
|
*/ |
101
|
2 |
|
public function setVisibility(string $poiId, int $status) |
102
|
|
|
{ |
103
|
2 |
|
if (!in_array($status, [0, 1], true)) { |
104
|
1 |
|
throw new InvalidArgumentException('status should be 0 or 1.'); |
105
|
|
|
} |
106
|
|
|
|
107
|
1 |
|
return $this->httpPostJson('wxa/setnearbypoishowstatus', [ |
108
|
1 |
|
'poi_id' => $poiId, |
109
|
1 |
|
'status' => $status, |
110
|
|
|
]); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|