from typing import Optional, List from enum import Enum import uuid class DeviceAuthorization: """ Represents device authorization data. Attributes: deviceCode (str): The device code. userCode (str): The user code. verificationUri (str): The verification URI. verificationUriComplete (str): The complete verification URI. expiresIn (int): Expiration time in seconds. interval (int): Polling interval in seconds. """ def __init__(self, jsonData: dict): self.error: Optional[str] = jsonData.get("error") self.deviceCode: str = jsonData.get("device_code") self.userCode: str = jsonData.get("user_code") self.verificationUri: str = jsonData.get("verification_uri") self.verificationUriComplete: str = jsonData.get("verification_uri_complete") self.expiresIn: int = jsonData.get("expires_in") self.interval: int = jsonData.get("interval") class Login: """ Represents the login response data parsed from a JSON dictionary. Attributes: error (Optional[str]): Error message if login failed, otherwise None. idToken (str): The ID token issued by RecNet. accessToken (str): The access token for accessing protected resources. tokenType (str): The type of the token issued (e.g., "Bearer"). expiresIn (str): The duration in seconds until the token expires. refreshToken (int): The refresh token used to obtain new access tokens. scope (str): The scope of access granted by the token. Args: jsonData (dict): The JSON dictionary containing login response data. """ def __init__(self, jsonData: dict): self.error: Optional[str] = jsonData.get("error") self.idToken: str = jsonData.get("id_token") self.accessToken: str = jsonData.get("access_token") self.tokenType: str = jsonData.get("token_type") self.expiresIn: str = jsonData.get("expires_in") self.refreshToken: int = jsonData.get("refresh_token") self.scope: str = jsonData.get("scope") class Account: def __init__(self, jsonData: dict): self.accountId: int = jsonData.get("accountId") self.displayName: str = jsonData.get("displayName") self.username: str = jsonData.get("username") self.profileImage: str = jsonData.get("profileImage") class TagType(Enum): General = 0 Auto = 1 AGOnly = 2 class Tag: def __init__(self, jsonData: dict): self.Tag: str = jsonData.get("Tag") tagType = jsonData.get("Type") if tagType == 0: Type = TagType.General elif tagType == 1: Type = TagType.Auto elif tagType == 2: Type = TagType.AGOnly self.Type: TagType = Type class Upload: def __init__(self, jsonData: dict): self.Filename = jsonData.get("filename") self.Hash = jsonData.get("hash") self.OwnershipProof = jsonData.get("ownershipProof") class InventionCurrentVersion: def __init__(self, jsonData: dict): self.BlobName: str = jsonData.get("BlobName") self.HasBetaContent: bool = jsonData.get("HasBetaContent") self.HasDevContent: bool = jsonData.get("BlobName") self.HasImageFileReference: bool = jsonData.get("HasImageFileReference") self.ReferencedUnityAssetIds: List[str] = jsonData.get("ReferencedUnityAssetIds") self.InstantiationCost: int = jsonData.get("InstantiationCost") self.LightsCost: int = jsonData.get("LightsCost") self.ChipsCost: int = jsonData.get("ChipsCost") self.CloudVariablesCost: int = jsonData.get("CloudVariablesCost") class Invention: def __init__(self, jsonData: dict): self.InventionId: str = jsonData.get("InventionId") self.ReplicationId: uuid.UUID = jsonData.get("ReplicationId") self.CreatorPlayerId: int = jsonData.get("CreatorPlayerId") self.CurrentVersion: InventionCurrentVersion = InventionCurrentVersion(jsonData.get("CurrentVersion")) self.Description: str = jsonData.get("Description") self.LongDescription: str = jsonData.get("LongDescription") self.ImageName: str = jsonData.get("ImageName") self.UgcVersion: int = jsonData.get("UgcVersion") self.ForceCannotPublish: bool = jsonData.get("ForceCannotPublish") self.CurrentVersionNumber: int = jsonData.get("CurrentVersionNumber") self.LatestVersionNumber: int = jsonData.get("LatestVersionNumber") self.Name: str = jsonData.get("Name") self.Accessibility: int = jsonData.get("Accessibility") self.IsPublished: bool = jsonData.get("IsPublished") self.IsFeatured: bool = jsonData.get("IsFeatured") self.FirstPublishedAt: Optional[str] = jsonData.get("FirstPublishedAt") self.CreationRoomId: int = jsonData.get("CreationRoomId") self.NumPlayersHaveUsedInRoom: int = jsonData.get("NumPlayersHaveUsedInRoom") self.NumDownloads: int = jsonData.get("NumDownloads")