1 <?php
2 namespace Slack;
3
4 5 6
7 class Group extends Channel
8 {
9 10 11 12 13 14 15
16 public function rename($name)
17 {
18 return $this->client->apiCall('groups.rename', [
19 'channel' => $this->getId(),
20 'name' => $name,
21 ])->then(function () use ($name) {
22 $this->data['name'] = $name;
23 return $name;
24 });
25 }
26
27 28 29 30 31 32 33
34 public function setPurpose($text)
35 {
36 return $this->client->apiCall('groups.setPurpose', [
37 'channel' => $this->getId(),
38 'purpose' => $text,
39 ])->then(function () use ($text) {
40 $this->data['purpose']['value'] = $text;
41 return $text;
42 });
43 }
44
45 46 47 48 49 50 51
52 public function setTopic($text)
53 {
54 return $this->client->apiCall('groups.setTopic', [
55 'channel' => $this->getId(),
56 'topic' => $text,
57 ])->then(function () use ($text) {
58 $this->data['topic']['value'] = $text;
59 return $text;
60 });
61 }
62
63 64 65 66 67
68 public function archive()
69 {
70 return $this->client->apiCall('groups.archive', [
71 'channel' => $this->getId(),
72 ])->then(function () {
73 $this->data['is_archived'] = true;
74 });
75 }
76
77 78 79 80 81
82 public function unarchive()
83 {
84 return $this->client->apiCall('groups.unarchive', [
85 'channel' => $this->getId(),
86 ])->then(function () {
87 $this->data['is_archived'] = false;
88 });
89 }
90
91 92 93 94 95 96 97
98 public function inviteUser(User $user)
99 {
100 return $this->client->apiCall('groups.invite', [
101 'channel' => $this->getId(),
102 'user' => $user->getId(),
103 ])->then(function () use ($user) {
104 $this->data['members'][] = $user->getId();
105 });
106 }
107
108 109 110 111 112 113 114
115 public function kickUser(User $user)
116 {
117 return $this->client->apiCall('groups.kick', [
118 'channel' => $this->getId(),
119 'user' => $user->getId(),
120 ])->then(function () use ($user) {
121 unset($this->data['members'][$user->getId()]);
122 });
123 }
124
125 126 127 128 129
130 public function open()
131 {
132 return $this->client->apiCall('groups.open', [
133 'channel' => $this->getId(),
134 ])->then(function ($response) {
135 return !isset($response['no_op']);
136 });
137 }
138
139 140 141
142 public function close()
143 {
144 return $this->client->apiCall('groups.close', [
145 'channel' => $this->getId(),
146 ])->then(function ($response) {
147 return !isset($response['no_op']);
148 });
149 }
150 }
151