Test Failed
Pull Request — master (#1476)
by
unknown
05:58
created

Client::list()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 5
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\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
    /**
26
     * Add nearby poi.
27
     *
28
     * @param string $name
29
     * @param string $credential
30
     * @param string $address
31
     * @param string $proofMaterial
32
     *
33
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
34
     */
35
    public function add(string $name, string $credential, string $address, string $proofMaterial = null)
36
    {
37
        return $this->httpPostJson('wxa/addnearbypoi', [
38
            'related_name'           => $name,
39
            'related_credential'     => $credential,
40
            'related_address'        => $address,
41
            'related_proof_material' => $proofMaterial
42
        ]);   
43
    }
44
45
    /**
46
     * Delete nearby poi.
47
     *
48
     * @param string $poiId
49
     *
50
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
51
     */
52
    public function delete(string $poiId)
53
    {
54
        return $this->httpPostJson('wxa/delnearbypoi', [
55
            'poi_id' => $poiId
56
        ]);
57
    }
58
59
    /**
60
     * Get nearby poi list.
61
     *
62
     * @param int $page
63
     * @param int $pageRows
64
     * 
65
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
66
     */
67
    public function list(int $page, int $pageRows)
68
    {
69
        return $this->httpGet('wxa/getnearbypoilist', [
70
            'page'      => $page,
71
            'page_rows' => $pageRows
72
        ]);
73
    }
74
75
    /**
76
     * Set nearby poi show status.
77
     * 
78
     * @param string $poiId
79
     * @param int    $status
80
     *
81
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
82
     */
83
    public function setShowStatus(string $poiId, int $status)
84
    {
85
        if (!in_array($status, [0, 1], true)) {
86
            throw new InvalidArgumentException('status should be 0 or 1.');
87
        }
88
89
        return $this->httpPostJson('wxa/setnearbypoishowstatus', [
90
            'poi_id' => $poiId,
91
            'status' => $status
92
        ]);
93
    }
94
}
95