Switch to using an enum for API ID constants.

This commit is contained in:
Jennifer Taylor
2021-08-19 19:21:41 +00:00
parent 96dd9a865e
commit b92cd4f579
8 changed files with 24 additions and 19 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
from typing import List, Any, Dict
from bemani.api.exceptions import APIException
from bemani.common import GameConstants
from bemani.common import APIConstants, GameConstants
from bemani.data import Data
@@ -20,5 +20,5 @@ class BaseObject:
self.version = version
self.omnimix = omnimix
def fetch_v1(self, idtype: str, ids: List[str], params: Dict[str, Any]) -> Any:
def fetch_v1(self, idtype: APIConstants, ids: List[str], params: Dict[str, Any]) -> Any:
raise APIException('Object fetch not supported for this version!')
+1 -1
View File
@@ -192,7 +192,7 @@ class CatalogObject(BaseObject):
else:
return self.version
def fetch_v1(self, idtype: str, ids: List[str], params: Dict[str, Any]) -> Dict[str, List[Dict[str, Any]]]:
def fetch_v1(self, idtype: APIConstants, ids: List[str], params: Dict[str, Any]) -> Dict[str, List[Dict[str, Any]]]:
# Verify IDs
if idtype != APIConstants.ID_TYPE_SERVER:
raise APIException(
+1 -1
View File
@@ -73,7 +73,7 @@ class ProfileObject(BaseObject):
return base
def fetch_v1(self, idtype: str, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
def fetch_v1(self, idtype: APIConstants, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
# Fetch the profiles
profiles: List[Tuple[UserID, ValidatedDict]] = []
if idtype == APIConstants.ID_TYPE_SERVER:
+1 -1
View File
@@ -230,7 +230,7 @@ class RecordsObject(BaseObject):
else:
return self.version
def fetch_v1(self, idtype: str, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
def fetch_v1(self, idtype: APIConstants, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
since = params.get('since')
until = params.get('until')
+1 -1
View File
@@ -180,7 +180,7 @@ class StatisticsObject(BaseObject):
return retval
def fetch_v1(self, idtype: str, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
def fetch_v1(self, idtype: APIConstants, ids: List[str], params: Dict[str, Any]) -> List[Dict[str, Any]]:
retval: List[Dict[str, Any]] = []
# Fetch the attempts