1 | <?php |
||
2 | |||
3 | namespace EasyIM\TencentIM\Group; |
||
4 | |||
5 | use EasyIM\Kernel\BaseClient; |
||
6 | use EasyIM\Kernel\Exceptions\InvalidConfigException; |
||
7 | use EasyIM\Kernel\ParameterList; |
||
8 | use EasyIM\Kernel\Support\Arr; |
||
9 | use EasyIM\Kernel\Support\Collection; |
||
10 | use EasyIM\TencentIM\Kernel\Constant\GroupConstant; |
||
11 | use GuzzleHttp\Exception\GuzzleException; |
||
12 | use Psr\Http\Message\ResponseInterface; |
||
13 | |||
14 | /** |
||
15 | * Class Client |
||
16 | * |
||
17 | * @package EasyIM\TencentIM\Group |
||
18 | * @author yingzhan <[email protected]> |
||
19 | * |
||
20 | */ |
||
21 | class Client extends BaseClient |
||
22 | { |
||
23 | /** |
||
24 | * Create Group. |
||
25 | * |
||
26 | * @param string $name |
||
27 | * @param string|null $introduction |
||
28 | * @param string|null $notification |
||
29 | * @param string|null $faceUrl |
||
30 | * @param string $type |
||
31 | * @param string|null $ownerAccount |
||
32 | * @param string|null $groupId |
||
33 | * @param int|null $maxMemberCount |
||
34 | * @param string $applyJoinOption |
||
35 | * @param ParameterList|null $memberList ... MemberListParameter |
||
36 | * @param ParameterList|null $appDefinedData ...CommonParameter |
||
37 | * |
||
38 | * @return array|Collection|object|ResponseInterface|string |
||
39 | * @throws GuzzleException |
||
40 | * @throws InvalidConfigException |
||
41 | */ |
||
42 | public function create( |
||
43 | string $name, |
||
44 | string $introduction = null, |
||
45 | string $notification = null, |
||
46 | string $faceUrl = null, |
||
47 | string $type = GroupConstant::PUBLIC, |
||
48 | string $ownerAccount = null, |
||
49 | int $maxMemberCount = null, |
||
50 | ParameterList $memberList = null, |
||
51 | ParameterList $appDefinedData = null, |
||
52 | string $applyJoinOption = GroupConstant::FREE_ACCESS, |
||
53 | string $groupId = null |
||
54 | ) { |
||
55 | $params = [ |
||
56 | 'Type' => $type, |
||
57 | 'Name' => $name |
||
58 | ]; |
||
59 | Arr::setNotNullValue($params, 'Owner_Account', $ownerAccount); |
||
60 | Arr::setNotNullValue($params, 'MemberList', $memberList && $memberList()); |
||
61 | Arr::setNotNullValue($params, 'Notification', $notification); |
||
62 | Arr::setNotNullValue($params, 'Introduction', $introduction); |
||
63 | Arr::setNotNullValue($params, 'FaceUrl', $faceUrl); |
||
64 | Arr::setNotNullValue($params, 'GroupId', $groupId); |
||
65 | Arr::setNotNullValue($params, 'MaxMemberCount', $maxMemberCount); |
||
66 | Arr::setNotNullValue($params, 'ApplyJoinOption', $applyJoinOption); |
||
67 | Arr::setNotNullValue($params, 'AppDefinedData', $appDefinedData && $appDefinedData()); |
||
68 | |||
69 | return $this->httpPostJson('group_open_http_svc/create_group', $params); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Get group details. |
||
74 | * |
||
75 | * @param array $groupIds |
||
76 | * @param array|null $groupBaseInfoFilter |
||
77 | * @param array|null $memberInfoFilter |
||
78 | * @param array|null $appDefinedDataFilterGroup |
||
79 | * @param array|null $appDefinedDataFilterGroupMember |
||
80 | * |
||
81 | * @return array|Collection|object|ResponseInterface|string |
||
82 | * @throws GuzzleException |
||
83 | * @throws InvalidConfigException |
||
84 | */ |
||
85 | public function get( |
||
86 | array $groupIds, |
||
87 | array $groupBaseInfoFilter = null, |
||
88 | array $memberInfoFilter = null, |
||
89 | array $appDefinedDataFilterGroup = null, |
||
90 | array $appDefinedDataFilterGroupMember = null |
||
91 | ) { |
||
92 | $params['GroupIdList'] = $groupIds; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
93 | Arr::setNotNullValue($params, 'ResponseFilter.GroupBaseInfoFilter', $groupBaseInfoFilter); |
||
94 | Arr::setNotNullValue($params, 'ResponseFilter.MemberInfoFilter', $memberInfoFilter); |
||
95 | Arr::setNotNullValue($params, 'ResponseFilter.AppDefinedDataFilter_Group', $appDefinedDataFilterGroup); |
||
96 | Arr::setNotNullValue( |
||
97 | $params, |
||
98 | 'ResponseFilter.AppDefinedDataFilter_GroupMember', |
||
99 | $appDefinedDataFilterGroupMember |
||
100 | ); |
||
101 | |||
102 | return $this->httpPostJson('group_open_http_svc/get_group_info', $params); |
||
103 | } |
||
104 | |||
105 | |||
106 | /** |
||
107 | * Modify group basic data. |
||
108 | * |
||
109 | * @param string $groupId |
||
110 | * @param string|null $name |
||
111 | * @param string|null $introduction |
||
112 | * @param string|null $notification |
||
113 | * @param string|null $faceUrl |
||
114 | * @param int|null $maxMemberNum |
||
115 | * @param string $applyJoinOption |
||
116 | * @param ParameterList|null $appDefinedData ...CommonParameter |
||
117 | * @param string|null $shutUpAll |
||
118 | * |
||
119 | * @return array|Collection|object|ResponseInterface|string |
||
120 | * @throws GuzzleException |
||
121 | * @throws InvalidConfigException |
||
122 | */ |
||
123 | public function modify( |
||
124 | string $groupId, |
||
125 | string $name = null, |
||
126 | string $introduction = null, |
||
127 | string $notification = null, |
||
128 | string $faceUrl = null, |
||
129 | int $maxMemberNum = null, |
||
130 | string $shutUpAll = null, |
||
131 | string $applyJoinOption = GroupConstant::FREE_ACCESS, |
||
132 | ParameterList $appDefinedData = null |
||
133 | ) { |
||
134 | $params['GroupId'] = $groupId; |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
135 | Arr::setNotNullValue($params, 'Name', $name); |
||
136 | Arr::setNotNullValue($params, 'Introduction', $introduction); |
||
137 | Arr::setNotNullValue($params, 'Notification', $notification); |
||
138 | Arr::setNotNullValue($params, 'FaceUrl', $faceUrl); |
||
139 | Arr::setNotNullValue($params, 'MaxMemberNum', $maxMemberNum); |
||
140 | Arr::setNotNullValue($params, 'ApplyJoinOption', $applyJoinOption); |
||
141 | Arr::setNotNullValue($params, 'AppDefinedData', $appDefinedData && $appDefinedData()); |
||
142 | Arr::setNotNullValue($params, 'ShutUpAllMember', $shutUpAll); |
||
143 | |||
144 | return $this->httpPostJson('group_open_http_svc/modify_group_base_info', $params); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Disband group. |
||
149 | * |
||
150 | * @param string $groupId |
||
151 | * |
||
152 | * @return array|Collection|object|ResponseInterface|string |
||
153 | * @throws InvalidConfigException |
||
154 | * @throws GuzzleException |
||
155 | */ |
||
156 | public function destroy(string $groupId) |
||
157 | { |
||
158 | $params = [ |
||
159 | 'GroupId' => $groupId |
||
160 | ]; |
||
161 | |||
162 | return $this->httpPostJson('group_open_http_svc/destroy_group', $params); |
||
163 | } |
||
164 | } |
||
165 |