Completed
Pull Request — master (#1477)
by
unknown
03:28
created

Client::list()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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