-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
108 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from dataclasses import dataclass | ||
|
||
from Tami4EdgeAPI import device_metadata, water_quality | ||
from Tami4EdgeAPI.drink import Drink | ||
|
||
|
||
@dataclass | ||
class Device(object): | ||
id: int | ||
name: str | ||
connected: bool | ||
psn: str | ||
type: str | ||
device_firmware: str | ||
device_metadata: device_metadata.DeviceMetadata | ||
water_quality: water_quality.WaterQuality | ||
drinks: list[Drink] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class DeviceMetadata(object): | ||
id: int | ||
name: str | ||
connected: bool | ||
psn: str | ||
type: str | ||
device_firmware: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
from datetime import datetime, timedelta | ||
from typing import Optional | ||
|
||
|
||
class Token(object): | ||
access_token: str | ||
refresh_token: str | ||
expires_at: datetime | ||
access_token: str | ||
expires_at: Optional[datetime] | ||
|
||
def __init__( | ||
self, refresh_token: str, access_token: str = None, expires_in: int = None | ||
self, | ||
refresh_token: str, | ||
access_token: Optional[str] = None, | ||
expires_at: Optional[datetime] = None, | ||
): | ||
self.refresh_token = refresh_token | ||
self.access_token = access_token if access_token else None | ||
self.expires_at = ( | ||
datetime.now() + timedelta(seconds=expires_in) if expires_in else None | ||
) | ||
self.expires_at = expires_at | ||
|
||
@property | ||
def is_valid(self): | ||
return self.access_token is not None and self.expires_at > datetime.now() | ||
return ( | ||
self.access_token is not None | ||
and self.expires_at is not None | ||
and self.expires_at > datetime.now() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters