234 lines
7.4 KiB
Python
234 lines
7.4 KiB
Python
from typing import List, Dict, Union
|
|
from datetime import datetime
|
|
|
|
|
|
class Embed:
|
|
def __init__(
|
|
self,
|
|
color: str,
|
|
title: str,
|
|
siteName: str,
|
|
description: str,
|
|
**kwargs
|
|
):
|
|
"""Embed object used for checking embeds
|
|
|
|
:param color: String of the embed's color
|
|
:param title: String of the embed's title
|
|
:param siteName: String of the embed's site name
|
|
:param description: String of the embed's description
|
|
"""
|
|
|
|
self.color = color
|
|
self.title = title
|
|
self.siteName = siteName
|
|
self.description = description
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
class File:
|
|
def __init__(
|
|
self,
|
|
createdAt: datetime,
|
|
id: int,
|
|
mimetype: str,
|
|
views: int,
|
|
name: str,
|
|
size: int,
|
|
favorite: bool,
|
|
originalName: str = None,
|
|
url: str = None,
|
|
maxViews: int = None,
|
|
expiredAt: Union[datetime, None] = None,
|
|
thumbnail: str = None,
|
|
folderId: int = None,
|
|
**kwargs
|
|
):
|
|
"""File object used for uploading files to Zipline
|
|
|
|
:param createdAt: Datetime object of when the file was created
|
|
:param id: Integer ID of the file
|
|
:param mimetype: String of the file's mimetype
|
|
:param views: Integer of the number of views the file has
|
|
:param name: String of the file's name
|
|
:param size: Integer of the file's size in bytes
|
|
:param favorite: Boolean of whether the file is favorited
|
|
:param originalName: (optional) String of the file's original name
|
|
:param url: (optional) String of the file's URL
|
|
:param maxViews: (optional) Integer of the file's maximum number of views
|
|
:param expiredAt: (optional) Datetime object of when the file will expire
|
|
:param thumbnail: (optional) String of the file's thumbnail URL
|
|
:param folderId: (optional) Integer of the file's folder ID
|
|
"""
|
|
|
|
self.createdAt = createdAt
|
|
self.id = id
|
|
self.mimetype = mimetype
|
|
self.views = views
|
|
self.name = name
|
|
self.size = size
|
|
self.favorite = favorite
|
|
self.originalName = originalName
|
|
self.url = url
|
|
self.maxViews = maxViews
|
|
self.expiredAt = expiredAt
|
|
self.thumbnail = thumbnail
|
|
self.folderId = folderId
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
class Result:
|
|
def __init__(self, status_code: int, message: str = '', data: List[Dict] = None):
|
|
"""Result returned from low-level RestAdapter
|
|
|
|
:param status_code: Standard HTTP Status code
|
|
:type status_code: int
|
|
:param message: Human readable result
|
|
:type message: str
|
|
:param data: Python List of Dictionaries (or maybe just a single Dictionary on error)
|
|
:type data: Union[List[Dict], Dict]
|
|
"""
|
|
|
|
self.status_code = int(status_code)
|
|
self.message = str(message)
|
|
self.data = data if data else []
|
|
|
|
|
|
class Invite:
|
|
def __init__(
|
|
self,
|
|
id: int,
|
|
code: str,
|
|
createdAt: datetime,
|
|
expiredAt: datetime,
|
|
used: bool,
|
|
createdById: int,
|
|
**kwargs
|
|
):
|
|
"""Invite object used for managing invites
|
|
|
|
:param id: Integer ID of the invite
|
|
:type id: int
|
|
:param code: String of the invite's code
|
|
:type code: str
|
|
:param createdAt: Datetime object of when the invite was created
|
|
:type createdAt: datetime
|
|
:param expiredAt: Datetime object of when the invite will expire
|
|
:type expiredAt: datetime
|
|
:param used: Boolean of whether the invite has been used
|
|
:type used: bool
|
|
:param createdById: Integer ID of the user who created the invite
|
|
:type createdById: int
|
|
"""
|
|
|
|
self.id = id
|
|
self.code = code
|
|
self.createdAt = createdAt
|
|
self.expiredAt = expiredAt
|
|
self.used = used
|
|
self.createdById = createdById
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
class OAuth:
|
|
def __init__(
|
|
self,
|
|
id: int,
|
|
provider: str,
|
|
userId: int,
|
|
providerId: str,
|
|
username: str,
|
|
token: str,
|
|
refresh: str,
|
|
**kwargs
|
|
):
|
|
"""OAuth object used for managing OAuth
|
|
|
|
:param id: Integer ID of the OAuth
|
|
:type id: int
|
|
:param provider: String of the OAuth's provider, one of 'DISCORD', 'GITHUB', 'GOOGLE'
|
|
:type provider: str
|
|
:param userId: Integer ID of the user who owns the OAuth
|
|
:type userId: int
|
|
:param providerId: String of the OAuth's provider ID
|
|
:type providerId: str
|
|
:param username: String of the OAuth's connected account's username
|
|
:type username: str
|
|
:param token: String of the OAuth's access token
|
|
:type token: str
|
|
:param refresh: String of the OAuth's refresh token
|
|
:type refresh: str
|
|
"""
|
|
|
|
self.id = id
|
|
self.provider = provider
|
|
self.userId = userId
|
|
self.providerId = providerId
|
|
self.username = username
|
|
self.token = token
|
|
self.refresh = refresh
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
class User:
|
|
def __init__(
|
|
self,
|
|
id: int,
|
|
uuid: str,
|
|
username: str,
|
|
avatar: str,
|
|
token: str,
|
|
administrator: bool,
|
|
superAdmin: bool,
|
|
systemTheme: str,
|
|
embed: Embed,
|
|
totpSecret: str,
|
|
domains: List[str],
|
|
oauth: Union[List['OAuth'], None] = None,
|
|
ratelimit: [datetime, None] = None,
|
|
**kwargs
|
|
):
|
|
"""User object used for managing users
|
|
|
|
:param id: Integer ID of the user
|
|
:type id: int
|
|
:param uuid: String of the user's UUID
|
|
:type uuid: str
|
|
:param username: String of the user's username
|
|
:type username: str
|
|
:param avatar: String of the user's avatar, base64 encoded
|
|
:type avatar: str
|
|
:param token: String of the user's token
|
|
:type token: str
|
|
:param administrator: Boolean of whether the user is an administrator
|
|
:type administrator: bool
|
|
:param superAdmin: Boolean of whether the user is a super administrator
|
|
:type superAdmin: bool
|
|
:param systemTheme: String of the user's system theme
|
|
:type systemTheme: str
|
|
:param embed: Embed object of the user's embed
|
|
:type embed: Embed
|
|
:param totpSecret: String of the user's TOTP secret
|
|
:type totpSecret: str
|
|
:param domains: List of Strings of the user's domains
|
|
:type domains: List[str]
|
|
:param oauth: (optional) List of OAuth objects
|
|
:type oauth: Union[List[OAuth], None]
|
|
:param ratelimit: (optional) Datetime object of when the user's ratelimit expires
|
|
:type ratelimit: Union[datetime, None]
|
|
"""
|
|
|
|
self.id = id
|
|
self.uuid = uuid
|
|
self.username = username
|
|
self.avatar = avatar
|
|
self.token = token
|
|
self.administrator = administrator
|
|
self.superAdmin = superAdmin
|
|
self.systemTheme = systemTheme
|
|
self.embed = embed
|
|
self.totpSecret = totpSecret
|
|
self.domains = domains
|
|
self.oauth = oauth
|
|
self.ratelimit = ratelimit
|
|
self.__dict__.update(kwargs)
|