Skip to content

Commit b5e7776

Browse files
committed
Update Room data model and module docstrings
Add docstrings to the Room data model and ensure all 'known' attributes return their value or `None`.
1 parent 3fe19f6 commit b5e7776

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

ciscosparkapi/api/rooms.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
44
Classes:
55
Room: Models a Spark 'room' JSON object as a native Python object.
6-
RoomsAPI: Wrappers the Cisco Spark Rooms-API and exposes the API calls as
7-
Python method calls that return native Python objects.
6+
RoomsAPI: Wraps the Cisco Spark Rooms-API and exposes the APIs as native
7+
Python methods that return native Python objects.
88
99
"""
1010

@@ -35,10 +35,10 @@ class Room(SparkData):
3535
"""Model a Spark 'room' JSON object as a native Python object."""
3636

3737
def __init__(self, json):
38-
"""Init a new Room data object from a JSON dictionary or string.
38+
"""Initialize a Room 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.
@@ -48,42 +48,43 @@ def __init__(self, json):
4848

4949
@property
5050
def id(self):
51-
return self._json['id']
51+
"""The rooms's unique ID."""
52+
return self._json.get('id')
5253

5354
@property
5455
def title(self):
55-
return self._json['title']
56+
"""A user-friendly name for the room."""
57+
return self._json.get('title')
5658

5759
@property
5860
def type(self):
59-
return self._json['type']
61+
"""The type of room (i.e. 'group', 'direct' etc.)."""
62+
return self._json.get('type')
6063

6164
@property
6265
def isLocked(self):
63-
return self._json['isLocked']
66+
"""Whether or not the room is locked and controled by moderator(s)."""
67+
return self._json.get('isLocked')
6468

6569
@property
6670
def lastActivity(self):
67-
return self._json['lastActivity']
71+
"""The date and time when the room was last active."""
72+
return self._json.get('lastActivity')
6873

6974
@property
7075
def created(self):
71-
return self._json['created']
76+
"""The date and time when the room was created."""
77+
return self._json.get('created')
7278

7379
@property
7480
def creatorId(self):
75-
return self._json['creatorId']
81+
"""The ID of the person who created the room."""
82+
return self._json.get('creatorId')
7683

7784
@property
7885
def teamId(self):
79-
"""Return the room teamId, if it exists, otherwise return None.
80-
81-
teamId is an 'optional' attribute that only exists for Spark rooms that
82-
are associated with a Spark Team. To simplify use, rather than
83-
requiring use of try/catch statements or hasattr() calls, we simply
84-
return None if a room does not have a teamId attribute.
85-
"""
86-
return self._json.get('teamId', None)
86+
"""The ID for the team with which this room is associated."""
87+
return self._json.get('teamId')
8788

8889

8990
class RoomsAPI(object):

0 commit comments

Comments
 (0)