Skip to content

Commit 3b66234

Browse files
committed
Add new attributes to Person class & Update some DocStrings
Add the following new Spark attributes to the `Person` object class: type nickName invitePending loginEnabled Update any docstrings that don’t look right. ;-)
1 parent fac6308 commit 3b66234

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

ciscosparkapi/api/people.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,22 @@ class Person(SparkData):
3535
"""Model a Spark 'person' JSON object as a native Python object."""
3636

3737
def __init__(self, json):
38-
"""Init a new Person data object from a JSON dictionary or string.
38+
"""Initialize a Person data object from a dictionary or JSON string.
3939
4040
Args:
41-
json(dict, basestring): Input JSON object.
41+
json(dict, basestring): Input dictionary or JSON string.
4242
4343
Raises:
4444
TypeError: If the input object is not a dictionary or string.
4545
4646
"""
4747
super(Person, self).__init__(json)
4848

49+
@property
50+
def type(self):
51+
"""The type of object returned by Cisco Spark (should be `person`)."""
52+
return self._json.get('type')
53+
4954
@property
5055
def id(self):
5156
"""The person's unique ID."""
@@ -67,6 +72,11 @@ def displayName(self):
6772
"""Full name of the person."""
6873
return self._json.get('displayName')
6974

75+
@property
76+
def nickName(self):
77+
"""'Nick name' or preferred short name of the person."""
78+
return self._json.get('nickName')
79+
7080
@property
7181
def firstName(self):
7282
"""First name of the person."""
@@ -112,17 +122,27 @@ def lastActivity(self):
112122
"""The date and time of the person's last activity."""
113123
return self._json.get('lastActivity')
114124

125+
@property
126+
def invitePending(self):
127+
"""Person has been sent an invite, but hasn't responded."""
128+
return self._json.get('invitePending')
129+
130+
@property
131+
def loginEnabled(self):
132+
"""Person is allowed to login."""
133+
return self._json.get('loginEnabled')
134+
115135

116136
class PeopleAPI(object):
117137
"""Cisco Spark People-API wrapper class.
118138
119-
Wrappers the Cisco Spark People-API and exposes the API calls as Python
120-
method calls that return native Python objects.
139+
Wraps the Cisco Spark People-API and exposes the APIs as native Python
140+
methods that return native Python objects.
121141
122142
"""
123143

124144
def __init__(self, session):
125-
"""Init a new PeopleAPI object with the provided RestSession.
145+
"""Initialize a new PeopleAPI object with the provided RestSession.
126146
127147
Args:
128148
session(RestSession): The RESTful session object to be used for

0 commit comments

Comments
 (0)