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 public function getId()
15 {
16 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 public function getUsername()
27 {
28 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 public function getFirstName()
37 {
38 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 public function getLastName()
47 {
48 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 public function getRealName()
57 {
58 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 public function getEmail()
67 {
68 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 public function getPhone()
77 {
78 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 public function getSkype()
87 {
88 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 public function isAdmin()
97 {
98 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 public function isOwner()
107 {
108 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 public function isPrimaryOwner()
117 {
118 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 public function getPresence()
137 {
138 return $this->client->apiCall('users.getPresence', [
139 'user' => $this->getId(),
140 ])->then(function (Payload $response) {
141 return $response['presence'];
142 });
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