Skip to content

Commit

Permalink
Fix datetime properties
Browse files Browse the repository at this point in the history
Object properties should either return their value or `None` if no value is present.
  • Loading branch information
cmlccie committed Sep 14, 2018
1 parent c591d53 commit fc112f1
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 11 deletions.
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ def actorId(self):
@property
def created(self):
"""The date and time the event was performed."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ def isMonitor(self):
@property
def created(self):
"""The date and time the membership was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ def mentionedPeople(self):
@property
def created(self):
"""The date and time the message was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ def displayName(self):
@property
def created(self):
"""Creation date and time in ISO8601 format."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None
12 changes: 10 additions & 2 deletions webexteamssdk/models/mixins/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def licenses(self):
@property
def created(self):
"""The date and time the person was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None

@property
def status(self):
Expand All @@ -106,7 +110,11 @@ def status(self):
@property
def lastActivity(self):
"""The date and time of the person's last activity."""
return WebexTeamsDateTime.strptime(self._json_data.get('lastActivity'))
last_activity = self._json_data.get('lastActivity')
if last_activity:
return WebexTeamsDateTime.strptime(last_activity)
else:
return None

@property
def invitePending(self):
Expand Down
12 changes: 10 additions & 2 deletions webexteamssdk/models/mixins/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,20 @@ def isLocked(self):
@property
def lastActivity(self):
"""The date and time when the room was last active."""
return WebexTeamsDateTime.strptime(self._json_data.get('lastActivity'))
last_activity = self._json_data.get('lastActivity')
if last_activity:
return WebexTeamsDateTime.strptime(last_activity)
else:
return None

@property
def created(self):
"""The date and time when the room was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None

@property
def creatorId(self):
Expand Down
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ def name(self):
@property
def created(self):
"""The date and time the team was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None

@property
def creatorId(self):
Expand Down
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/team_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ def isModerator(self):
@property
def created(self):
"""The date and time the team membership was created."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None
6 changes: 5 additions & 1 deletion webexteamssdk/models/mixins/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ def status(self):
@property
def created(self):
"""Creation date and time in ISO8601 format."""
return WebexTeamsDateTime.strptime(self._json_data.get('created'))
created = self._json_data.get('created')
if created:
return WebexTeamsDateTime.strptime(created)
else:
return None

0 comments on commit fc112f1

Please sign in to comment.