Skip to content

Commit eaa61ff

Browse files
committed
Update People API and Person model
Resolves include phone, extension and location fields on People #137
1 parent a746c3d commit eaa61ff

File tree

3 files changed

+116
-7
lines changed

3 files changed

+116
-7
lines changed

tests/api/test_people.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def inner_function():
8383
lastName="webexteamssdk",
8484
orgId=me.orgId,
8585
licenses=[licenses_dict["Advanced Messaging"].id],
86+
callingData=True,
87+
minResponse=False,
8688
)
8789
return person
8890

webexteamssdk/api/people.py

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
SOFTWARE.
2323
"""
2424

25-
2625
from __future__ import (
2726
absolute_import,
2827
division,
@@ -80,7 +79,7 @@ def list(
8079
id=None,
8180
orgId=None,
8281
max=None,
83-
**request_parameters
82+
**request_parameters,
8483
):
8584
"""List people in your organization.
8685
@@ -150,21 +149,35 @@ def list(
150149
def create(
151150
self,
152151
emails,
152+
phoneNumbers=None,
153+
extension=None,
154+
locationId=None,
153155
displayName=None,
154156
firstName=None,
155157
lastName=None,
156158
avatar=None,
157159
orgId=None,
158160
roles=None,
159161
licenses=None,
160-
**request_parameters
162+
department=None,
163+
manager=None,
164+
managerId=None,
165+
title=None,
166+
addresses=None,
167+
siteUrls=None,
168+
callingData=None,
169+
minResponse=None,
170+
**request_parameters,
161171
):
162172
"""Create a new user account for a given organization
163173
164174
Only an admin can create a new user account.
165175
166176
Args:
167177
emails(`list`): Email address(es) of the person (list of strings).
178+
phoneNumbers(`list`): Phone numbers for the person.
179+
extension(basestring): Webex Calling extension of the person.
180+
locationId(basestring): The ID of the location for this person.
168181
displayName(basestring): Full name of the person.
169182
firstName(basestring): First name of the person.
170183
lastName(basestring): Last name of the person.
@@ -176,6 +189,19 @@ def create(
176189
licenses(`list`): Licenses allocated to the person (list of
177190
strings - containing the license IDs to be allocated to the
178191
person).
192+
department(basestring): The business department the user belongs
193+
to.
194+
manager(basestring): A manager identifier.
195+
managerId(basestring): Person ID of the manager.
196+
title(basestring): The person's title.
197+
addresses(`list`): A person's addresses.
198+
siteUrls(`list`): One or several site names where this user has an
199+
attendee role.
200+
callingData(bool): Include Webex Calling user details in the
201+
response.
202+
minResponse(bool): Set to true to improve performance by omitting
203+
person details and returning only the ID in the response when
204+
successful.
179205
**request_parameters: Additional request parameters (provides
180206
support for parameters that may be added in the future).
181207
@@ -188,28 +214,55 @@ def create(
188214
189215
"""
190216
check_type(emails, list)
217+
check_type(phoneNumbers, list, optional=True)
218+
check_type(extension, basestring, optional=True)
219+
check_type(locationId, basestring, optional=True)
191220
check_type(displayName, basestring, optional=True)
192221
check_type(firstName, basestring, optional=True)
193222
check_type(lastName, basestring, optional=True)
194223
check_type(avatar, basestring, optional=True)
195224
check_type(orgId, basestring, optional=True)
196225
check_type(roles, list, optional=True)
197226
check_type(licenses, list, optional=True)
227+
check_type(department, basestring, optional=True)
228+
check_type(manager, basestring, optional=True)
229+
check_type(managerId, basestring, optional=True)
230+
check_type(title, basestring, optional=True)
231+
check_type(addresses, list, optional=True)
232+
check_type(siteUrls, list, optional=True)
233+
check_type(callingData, bool, optional=True)
234+
check_type(minResponse, bool, optional=True)
198235

199236
post_data = dict_from_items_with_values(
200237
request_parameters,
201238
emails=emails,
239+
phoneNumbers=phoneNumbers,
240+
extension=extension,
241+
locationId=locationId,
202242
displayName=displayName,
203243
firstName=firstName,
204244
lastName=lastName,
205245
avatar=avatar,
206246
orgId=orgId,
207247
roles=roles,
208248
licenses=licenses,
249+
department=department,
250+
manager=manager,
251+
managerId=managerId,
252+
title=title,
253+
addresses=addresses,
254+
siteUrls=siteUrls,
255+
)
256+
257+
params = dict_from_items_with_values(
258+
callingData=callingData,
259+
minResponse=minResponse,
209260
)
210261

211262
# API request
212-
json_data = self._session.post(API_ENDPOINT, json=post_data)
263+
json_data = self._session.post(
264+
API_ENDPOINT, params=params, json=post_data
265+
)
213266

214267
# Return a person object created from the returned JSON object
215268
return self._object_factory(OBJECT_TYPE, json_data)
@@ -247,7 +300,7 @@ def update(
247300
orgId=None,
248301
roles=None,
249302
licenses=None,
250-
**request_parameters
303+
**request_parameters,
251304
):
252305
"""Update details for a person, by ID.
253306

webexteamssdk/models/mixins/person.py

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
SOFTWARE.
2323
"""
2424

25-
2625
from __future__ import (
2726
absolute_import,
2827
division,
@@ -48,10 +47,21 @@ def emails(self):
4847
"""The email addresses of the person."""
4948
return self._json_data.get("emails")
5049

50+
@property
5151
def phoneNumbers(self):
5252
"""Phone numbers for the person."""
5353
return self._json_data.get("phoneNumbers")
5454

55+
@property
56+
def extension(self):
57+
"""The Webex Calling extension for the person."""
58+
return self._json_data.get("extension")
59+
60+
@property
61+
def locationId(self):
62+
"""The location ID for the person."""
63+
return self._json_data.get("locationId")
64+
5565
@property
5666
def displayName(self):
5767
"""The full name of the person."""
@@ -100,6 +110,31 @@ def licenses(self):
100110
"""An list of license strings allocated to this person."""
101111
return self._json_data.get("licenses")
102112

113+
@property
114+
def department(self):
115+
"""The business department the user belongs to."""
116+
return self._json_data.get("department")
117+
118+
@property
119+
def manager(self):
120+
"""A manager identifier."""
121+
return self._json_data.get("manager")
122+
123+
@property
124+
def managerId(self):
125+
"""Person ID of the manager."""
126+
return self._json_data.get("managerId")
127+
128+
@property
129+
def title(self):
130+
"""The person's title."""
131+
return self._json_data.get("title")
132+
133+
@property
134+
def addresses(self):
135+
"""A person's addresses."""
136+
return self._json_data.get("addresses")
137+
103138
@property
104139
def created(self):
105140
"""The date and time the person was created."""
@@ -137,6 +172,25 @@ def lastActivity(self):
137172
else:
138173
return None
139174

175+
@property
176+
def siteUrls(self):
177+
"""One or several site names where this user has a role."""
178+
return self._json_data.get("siteUrls")
179+
180+
@property
181+
def sipAddresses(self):
182+
"""The user's SIP addresses."""
183+
return self._json_data.get("sipAddresses")
184+
185+
@property
186+
def xmppFederationJid(self):
187+
"""XMPP federation identifier.
188+
189+
Identifier for intra-domain federation with other XMPP based messenger
190+
systems.
191+
"""
192+
return self._json_data.get("xmppFederationJid")
193+
140194
@property
141195
def status(self):
142196
"""The current presence status of the person.
@@ -161,7 +215,7 @@ def status(self):
161215
162216
`presenting`: The user is sharing content
163217
164-
`unknown`: The users status could not be determined
218+
`unknown`: The user's status could not be determined
165219
"""
166220
return self._json_data.get("status")
167221

0 commit comments

Comments
 (0)