Skip to content

Commit

Permalink
add properties to VehicleLockUnlockStatusResponse
Browse files Browse the repository at this point in the history
adds is_success, is_error, is_in_progress to the status response
which makes it easier to act on request actions
  • Loading branch information
apmechev committed Nov 5, 2022
1 parent 01cb048 commit f1d0a0b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mytoyota/models/lock_unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,25 @@ def request_timestamp(self) -> datetime:
"""Request Timestamp."""
raw_datetime = self._data.get("requestTimestamp")
return datetime.strptime(raw_datetime, UNLOCK_TIMESTAMP_FORMAT)

@property
def error_code(self) -> str:
"""Request Error code"""
if self.status != "error":
return None
return self._data.get("errorCode", "")

@property
def is_success(self) -> bool:
"""Request was successful."""
return self.status == "completed"

@property
def is_error(self) -> bool:
"""Request failed."""
return self.status == "error"

@property
def is_in_progress(self) -> bool:
"""Request is processing."""
return self.status == "inprogress"

0 comments on commit f1d0a0b

Please sign in to comment.