RelationClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 65
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bindPages() 0 8 1
A listByPageId() 0 10 1
A listByDeviceId() 0 8 1
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\ShakeAround;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class RelationClient.
18
 *
19
 * @author allen05ren <[email protected]>
20
 */
21
class RelationClient extends BaseClient
22
{
23
    /**
24
     * Bind pages for device.
25
     *
26
     * @param array $deviceIdentifier
27
     * @param array $pageIds
28
     *
29
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
30
     *
31
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
32
     * @throws \GuzzleHttp\Exception\GuzzleException
33
     */
34 1
    public function bindPages(array $deviceIdentifier, array $pageIds)
35
    {
36
        $params = [
37 1
            'device_identifier' => $deviceIdentifier,
38 1
            'page_ids' => $pageIds,
39
        ];
40
41 1
        return $this->httpPostJson('shakearound/device/bindpage', $params);
42
    }
43
44
    /**
45
     * Get pageIds by deviceId.
46
     *
47
     * @param array $deviceIdentifier
48
     *
49
     * @return array|\EasyWeChat\Kernel\Support\Collection
50
     *
51
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
52
     * @throws \GuzzleHttp\Exception\GuzzleException
53
     */
54 1
    public function listByDeviceId(array $deviceIdentifier)
55
    {
56
        $params = [
57 1
            'type' => 1,
58 1
            'device_identifier' => $deviceIdentifier,
59
        ];
60
61 1
        return $this->httpPostJson('shakearound/relation/search', $params);
62
    }
63
64
    /**
65
     * Get devices by pageId.
66
     *
67
     * @param int $pageId
68
     * @param int $begin
69
     * @param int $count
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 listByPageId(int $pageId, int $begin, int $count)
77
    {
78
        $params = [
79 1
            'type' => 2,
80 1
            'page_id' => $pageId,
81 1
            'begin' => $begin,
82 1
            'count' => $count,
83
        ];
84
85 1
        return $this->httpPostJson('shakearound/relation/search', $params);
86
    }
87
}
88