Completed
Push — master ( 5a6f61...4723bf )
by mingyoung
16s
created

Client   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 9
dl 0
loc 77
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 3 1
A getGroups() 0 3 1
A get() 0 3 1
A create() 0 3 1
A update() 0 5 1
A delete() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the mingyoung/dingtalk.
5
 *
6
 * (c) 张铭阳 <[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 EasyDingTalk\Contact;
13
14
use EasyDingTalk\Kernel\BaseClient;
15
16
class Client extends BaseClient
17
{
18
    /**
19
     * 获取外部联系人标签列表
20
     *
21
     * @param int $offset
22
     * @param int $size
23
     *
24
     * @return mixed
25
     */
26
    public function getGroups($offset = 0, $size = 20)
27
    {
28
        return $this->client->postJson('topapi/extcontact/listlabelgroups', compact('offset', 'size'));
29
    }
30
31
    /**
32
     * 获取外部联系人列表
33
     *
34
     * @param int $offset
35
     * @param int $size
36
     *
37
     * @return mixed
38
     */
39
    public function list($offset = 0, $size = 20)
40
    {
41
        return $this->client->postJson('topapi/extcontact/list', compact('offset', 'size'));
42
    }
43
44
    /**
45
     * 获取企业外部联系人详情
46
     *
47
     * @param string $userId
48
     *
49
     * @return mixed
50
     */
51
    public function get($userId)
52
    {
53
        return $this->client->postJson('topapi/extcontact/get', ['user_id' => $userId]);
54
    }
55
56
    /**
57
     * 添加外部联系人
58
     *
59
     * @param array $contact
60
     *
61
     * @return mixed
62
     */
63
    public function create($contact)
64
    {
65
        return $this->client->postJson('topapi/extcontact/create', $contact);
66
    }
67
68
    /**
69
     * 更新外部联系人
70
     *
71
     * @param string $userId
72
     * @param array  $contact
73
     *
74
     * @return mixed
75
     */
76
    public function update($userId, $contact)
77
    {
78
        $contact = ['user_id' => $userId] + $contact;
79
80
        return $this->client->postJson('topapi/extcontact/update', compact('contact'));
81
    }
82
83
    /**
84
     * 删除外部联系人
85
     *
86
     * @param string $userId
87
     *
88
     * @return mixed
89
     */
90
    public function delete($userId)
91
    {
92
        return $this->client->postJson('topapi/extcontact/delete', ['user_id' => $userId]);
93
    }
94
}
95