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\Group\Parameter\Import\ImportMemberParameter; |
11
|
|
|
use EasyIM\TencentIM\Group\Parameter\Import\ImportMsgListParameter; |
12
|
|
|
use EasyIM\TencentIM\Kernel\Constant\GroupConstant; |
13
|
|
|
use GuzzleHttp\Exception\GuzzleException; |
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class ImportClient |
18
|
|
|
* |
19
|
|
|
* @package EasyIM\TencentIM\Group |
20
|
|
|
* @author yingzhan <[email protected]> |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
class ImportClient extends BaseClient |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Import group basic data. |
27
|
|
|
* |
28
|
|
|
* @param string $name |
29
|
|
|
* @param string $type |
30
|
|
|
* @param string|null $ownerAccount |
31
|
|
|
* @param string|null $groupId |
32
|
|
|
* @param string|null $notification |
33
|
|
|
* @param string|null $introduction |
34
|
|
|
* @param string|null $faceUrl |
35
|
|
|
* @param int|null $maxMemberCount |
36
|
|
|
* @param string|null $applyJoinOption |
37
|
|
|
* @param ParameterList|null $appDefined |
38
|
|
|
* @param int|null $createTime |
39
|
|
|
* |
40
|
|
|
* @return array|Collection|object|ResponseInterface|string |
41
|
|
|
* @throws GuzzleException |
42
|
|
|
* @throws InvalidConfigException |
43
|
|
|
*/ |
44
|
|
|
public function importGroup( |
45
|
|
|
string $name, |
46
|
|
|
string $type = GroupConstant::PUBLIC, |
47
|
|
|
string $ownerAccount = null, |
48
|
|
|
string $groupId = null, |
49
|
|
|
string $notification = null, |
50
|
|
|
string $introduction = null, |
51
|
|
|
string $faceUrl = null, |
52
|
|
|
int $maxMemberCount = null, |
53
|
|
|
string $applyJoinOption = null, |
54
|
|
|
ParameterList $appDefined = null, |
55
|
|
|
int $createTime = null |
56
|
|
|
) { |
57
|
|
|
$params = [ |
58
|
|
|
'Name' => $name, |
59
|
|
|
'Type' => $type |
60
|
|
|
]; |
61
|
|
|
Arr::setNotNullValue($params, 'Owner_Account', $ownerAccount); |
62
|
|
|
Arr::setNotNullValue($params, 'GroupId', $groupId); |
63
|
|
|
Arr::setNotNullValue($params, 'Notification', $notification); |
64
|
|
|
Arr::setNotNullValue($params, 'Introduction', $introduction); |
65
|
|
|
Arr::setNotNullValue($params, 'FaceUrl', $faceUrl); |
66
|
|
|
Arr::setNotNullValue($params, 'MaxMemberCount', $maxMemberCount); |
67
|
|
|
Arr::setNotNullValue($params, 'ApplyJoinOption', $applyJoinOption); |
68
|
|
|
Arr::setNotNullValue($params, 'AppDefinedData', $appDefined && $appDefined()); |
69
|
|
|
Arr::setNotNullValue($params, 'CreateTime', $createTime); |
70
|
|
|
|
71
|
|
|
return $this->httpPostJson('group_open_http_svc/import_group', $params); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Import group message. |
76
|
|
|
* |
77
|
|
|
* @param string $groupId |
78
|
|
|
* @param ImportMsgListParameter ...$msgListParameters |
79
|
|
|
* |
80
|
|
|
* @return array|Collection|object|ResponseInterface|string |
81
|
|
|
* @throws InvalidConfigException |
82
|
|
|
* @throws GuzzleException |
83
|
|
|
*/ |
84
|
|
|
public function importGroupMsg(string $groupId, ImportMsgListParameter ...$msgListParameters) |
85
|
|
|
{ |
86
|
|
|
$params = [ |
87
|
|
|
'GroupId' => $groupId, |
88
|
|
|
'MsgList' => parameterList(...$msgListParameters)() |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
return $this->httpPostJson('group_open_http_svc/import_group_msg', $params); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Import group members. |
96
|
|
|
* |
97
|
|
|
* @param string $groupId |
98
|
|
|
* @param ImportMemberParameter ...$memberParameters |
99
|
|
|
* |
100
|
|
|
* @return array|Collection|object|ResponseInterface|string |
101
|
|
|
* @throws InvalidConfigException |
102
|
|
|
* @throws GuzzleException |
103
|
|
|
*/ |
104
|
|
|
public function importGroupMember(string $groupId, ImportMemberParameter ...$memberParameters) |
105
|
|
|
{ |
106
|
|
|
$params = [ |
107
|
|
|
'GroupId' => $groupId, |
108
|
|
|
'MemberList' => parameterList(...$memberParameters)() |
109
|
|
|
]; |
110
|
|
|
|
111
|
|
|
return $this->httpPostJson('group_open_http_svc/import_group_member', $params); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|