Merge pull request #1 from Sarsoo/lite

added return self for ease of code when refreshing access token
This commit is contained in:
andy 2019-12-21 10:47:32 +00:00 committed by GitHub
commit 2ef5e9c1c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
from __future__ import annotations
import requests import requests
from spotframework.model.user import User from spotframework.model.user import User
from spotframework.util.console import Color from spotframework.util.console import Color
@ -32,7 +33,7 @@ class NetworkUser(User):
return Color.RED + Color.BOLD + 'NetworkUser' + Color.END + \ return Color.RED + Color.BOLD + 'NetworkUser' + Color.END + \
f': {self.username}, {self.display_name}, {self.uri}' f': {self.username}, {self.display_name}, {self.uri}'
def refresh_access_token(self) -> None: def refresh_access_token(self) -> NetworkUser:
if self.refresh_token is None: if self.refresh_token is None:
raise NameError('no refresh token to query') raise NameError('no refresh token to query')
@ -78,6 +79,8 @@ class NetworkUser(User):
error_description = req.json().get('error_description', 'n/a') error_description = req.json().get('error_description', 'n/a')
logger.error(f'get {req.status_code} {error_text} - {error_description}') logger.error(f'get {req.status_code} {error_text} - {error_description}')
return self
def refresh_info(self) -> None: def refresh_info(self) -> None:
info = self.get_info() info = self.get_info()