Completed
Push — master ( 8e978d...0648f6 )
by mingyoung
12s
created

Client::deleteUserRoles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Role;
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 list($offset = 0, $size = 20)
27
    {
28
        return $this->client->postJson('topapi/role/list', compact('offset', 'size'));
29
    }
30
31
    /**
32
     * 获取角色下的员工列表
33
     *
34
     * @param int $roleId
35
     * @param int $offset
36
     * @param int $size
37
     *
38
     * @return mixed
39
     */
40
    public function getUsers($roleId, $offset = 0, $size = 20)
41
    {
42
        return $this->client->postJson('topapi/role/simplelist', compact('offset', 'size') + ['role_id' => $roleId]);
43
    }
44
45
    /**
46
     * 获取角色组
47
     *
48
     * @param int $groupId
49
     *
50
     * @return mixed
51
     */
52
    public function getGroups($groupId)
53
    {
54
        return $this->client->postJson('topapi/role/getrolegroup', ['group_id' => $groupId]);
55
    }
56
57
    /**
58
     * 获取角色详情
59
     *
60
     * @param int $roleId
61
     *
62
     * @return mixed
63
     */
64
    public function get($roleId)
65
    {
66
        return $this->client->postJson('topapi/role/getrole', compact('roleId'));
67
    }
68
69
    /**
70
     * 创建角色
71
     *
72
     * @param int    $groupId
73
     * @param string $roleName
74
     *
75
     * @return mixed
76
     */
77
    public function create($groupId, $roleName)
78
    {
79
        return $this->client->postJson('role/add_role', compact('groupId', 'roleName'));
80
    }
81
82
    /**
83
     * 更新角色
84
     *
85
     * @param int    $roleId
86
     * @param string $roleName
87
     *
88
     * @return mixed
89
     */
90
    public function update($roleId, $roleName)
91
    {
92
        return $this->client->postJson('role/update_role', compact('roleId', 'roleName'));
93
    }
94
95
    /**
96
     * 删除角色
97
     *
98
     * @param int $roleId
99
     *
100
     * @return mixed
101
     */
102
    public function delete($roleId)
103
    {
104
        return $this->client->postJson('topapi/role/deleterole', ['role_id' => $roleId]);
105
    }
106
107
    /**
108
     * 创建角色组
109
     *
110
     * @param string $name
111
     *
112
     * @return mixed
113
     */
114
    public function createGroup($name)
115
    {
116
        return $this->client->postJson('role/add_role_group', compact('name'));
117
    }
118
119
    /**
120
     * 批量增加员工角色
121
     *
122
     * @param string $roleIds
123
     * @param string $userIds
124
     *
125
     * @return mixed
126
     */
127
    public function addUserRoles($roleIds, $userIds)
128
    {
129
        return $this->client->postJson('topapi/role/addrolesforemps', compact('roleIds', 'userIds'));
130
    }
131
132
    /**
133
     * 批量删除员工角色
134
     *
135
     * @param string $roleIds
136
     * @param string $userIds
137
     *
138
     * @return mixed
139
     */
140
    public function deleteUserRoles($roleIds, $userIds)
141
    {
142
        return $this->client->postJson('topapi/role/removerolesforemps', compact('roleIds', 'userIds'));
143
    }
144
}
145