Staff::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EntWeChat\Staff;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Staff.
9
 */
10
class Staff extends AbstractAPI
11
{
12
    const API_LISTS = 'https://qyapi.weixin.qq.com/cgi-bin/kf/list';
13
    const API_MESSAGE_SEND = 'https://qyapi.weixin.qq.com/cgi-bin/kf/send';
14
15
    //用户类型
16
    const USER_TYPE_STAFF = 'kf';      // 客服
17
    const USER_TYPE_USERID = 'userid';  // 客户UserId
18
    const USER_TYPE_OPENID = 'openid';  // 客户OpenId
19
20
    //客服类型
21
    const STAFF_TYPE_INTERNAL = 'internal';  // 内部
22
    const STAFF_TYPE_EXTERNAL = 'external';  // 外部
23
24
    /**
25
     * List all staffs.
26
     *
27
     * @param string|null $type
28
     *
29
     * @return \EntWeChat\Support\Collection
30
     */
31 View Code Duplication
    public function lists($type = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $params = [
34
            'type' => $type,
35
        ];
36
37
        return $this->parseJSON('get', [self::API_LISTS, $params]);
38
    }
39
40
    /**
41
     * Get message builder.
42
     *
43
     * @param \EntWeChat\Message\AbstractMessage|string $message
44
     *
45
     * @throws \EntWeChat\Core\Exceptions\InvalidArgumentException
46
     *
47
     * @return \EntWeChat\Staff\MessageBuilder
48
     */
49
    public function message($message)
50
    {
51
        $messageBuilder = new MessageBuilder($this);
52
53
        return $messageBuilder->message($message);
54
    }
55
56
    /**
57
     * Send a message.
58
     *
59
     * @param string|array $message
60
     *
61
     * @return \EntWeChat\Support\Collection
62
     */
63
    public function send($message)
64
    {
65
        return $this->parseJSON('json', [self::API_MESSAGE_SEND, $message]);
66
    }
67
}
68