|
1
|
|
|
<?php |
|
2
|
|
|
namespace Slack; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Contains information about a team member. |
|
6
|
|
|
*/ |
|
7
|
|
|
class User extends ClientObject |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Gets the user's ID. |
|
11
|
|
|
* |
|
12
|
|
|
* @return string The user's ID. |
|
13
|
|
|
*/ |
|
14
|
6 |
|
public function getId() |
|
15
|
|
|
{ |
|
16
|
6 |
|
return $this->data['id']; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Gets the user's username. |
|
21
|
|
|
* |
|
22
|
|
|
* Does not include the @ symbol at the beginning. |
|
23
|
|
|
* |
|
24
|
|
|
* @return string The user's username. |
|
25
|
|
|
*/ |
|
26
|
2 |
|
public function getUsername() |
|
27
|
|
|
{ |
|
28
|
2 |
|
return $this->data['name']; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Gets the user's first name if supplied. |
|
33
|
|
|
* |
|
34
|
|
|
* @return string The user's first name, or null if no name was given. |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function getFirstName() |
|
37
|
|
|
{ |
|
38
|
1 |
|
return isset($this->data['profile']['first_name']) ? $this->data['profile']['first_name'] : null; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Gets the user's last name if supplied. |
|
43
|
|
|
* |
|
44
|
|
|
* @return string The user's last name, or null if no name was given. |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public function getLastName() |
|
47
|
|
|
{ |
|
48
|
1 |
|
return isset($this->data['profile']['last_name']) ? $this->data['profile']['last_name'] : null; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Gets the user's real name if supplied. |
|
53
|
|
|
* |
|
54
|
|
|
* @return string The user's real name, or null if no name was given. |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function getRealName() |
|
57
|
|
|
{ |
|
58
|
1 |
|
return isset($this->data['profile']['real_name']) ? $this->data['profile']['real_name'] : null; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Gets the user's email address if supplied. |
|
63
|
|
|
* |
|
64
|
|
|
* @return string The user's email address, or null if no email was given. |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function getEmail() |
|
67
|
|
|
{ |
|
68
|
1 |
|
return isset($this->data['profile']['email']) ? $this->data['profile']['email'] : null; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Gets the user's phone number if supplied. |
|
73
|
|
|
* |
|
74
|
|
|
* @return string The user's phone number, or null if no number was given. |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function getPhone() |
|
77
|
|
|
{ |
|
78
|
1 |
|
return isset($this->data['profile']['phone']) ? $this->data['profile']['phone'] : null; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Gets the user's Skype name if supplied. |
|
83
|
|
|
* |
|
84
|
|
|
* @return string The user's Skype name, or null if no Skype name was given. |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function getSkype() |
|
87
|
|
|
{ |
|
88
|
1 |
|
return isset($this->data['profile']['skype']) ? $this->data['profile']['skype'] : null; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Checks if the user is a team administrator. |
|
93
|
|
|
* |
|
94
|
|
|
* @return bool True if the user is a team administrator. |
|
95
|
|
|
*/ |
|
96
|
1 |
|
public function isAdmin() |
|
97
|
|
|
{ |
|
98
|
1 |
|
return $this->data['is_admin']; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Checks if the user is a team owner. |
|
103
|
|
|
* |
|
104
|
|
|
* @return bool True if the user is a team owner. |
|
105
|
|
|
*/ |
|
106
|
1 |
|
public function isOwner() |
|
107
|
|
|
{ |
|
108
|
1 |
|
return $this->data['is_owner']; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Checks if the user is the team's primary owner. |
|
113
|
|
|
* |
|
114
|
|
|
* @return bool True if the user is the primary team owner. |
|
115
|
|
|
*/ |
|
116
|
1 |
|
public function isPrimaryOwner() |
|
117
|
|
|
{ |
|
118
|
1 |
|
return $this->data['is_primary_owner']; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Checks if the user has been deactivated. |
|
123
|
|
|
* |
|
124
|
|
|
* @return bool True if the user is deactivated. |
|
125
|
|
|
*/ |
|
126
|
|
|
public function isDeleted() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->data['deleted']; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Gets a user's presence. |
|
133
|
|
|
* |
|
134
|
|
|
* @return \React\Promise\PromiseInterface The current user's presence, either "active" or "away". |
|
135
|
|
|
*/ |
|
136
|
1 |
|
public function getPresence() |
|
137
|
|
|
{ |
|
138
|
1 |
|
return $this->client->apiCall('users.getPresence', [ |
|
139
|
1 |
|
'user' => $this->getId(), |
|
140
|
1 |
|
])->then(function (Payload $response) { |
|
141
|
1 |
|
return $response['presence']; |
|
142
|
1 |
|
}); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* User profile image URL 24x24px |
|
147
|
|
|
* |
|
148
|
|
|
* @return string URL of the 24x24px user profile image |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getProfileImage24() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->data['profile']['image_24']; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* User profile image URL 32x32px |
|
157
|
|
|
* |
|
158
|
|
|
* @return string URL of the 32x32px user profile image |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getProfileImage32() |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->data['profile']['image_32']; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* User profile image URL 48x48px |
|
167
|
|
|
* |
|
168
|
|
|
* @return string URL of the 48x48px user profile image |
|
169
|
|
|
*/ |
|
170
|
|
|
public function getProfileImage48() |
|
171
|
|
|
{ |
|
172
|
|
|
return $this->data['profile']['image_48']; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* User profile image URL 72x72px |
|
177
|
|
|
* |
|
178
|
|
|
* @return string URL of the 72x72px user profile image |
|
179
|
|
|
*/ |
|
180
|
|
|
public function getProfileImage72() |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->data['profile']['image_72']; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* User profile image URL 192x192px |
|
187
|
|
|
* |
|
188
|
|
|
* @return string URL of the 192x192px user profile image |
|
189
|
|
|
*/ |
|
190
|
|
|
public function getProfileImage192() |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->data['profile']['image_192']; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|