Initial code commit

This commit is contained in:
Alan Bridgeman 2024-10-14 14:41:44 -05:00
parent 88e75758af
commit 08f2127864
14 changed files with 1633 additions and 0 deletions

29
src/APIObject.ts Normal file
View file

@ -0,0 +1,29 @@
import { API, APICredentials } from "./API";
export abstract class APIObject {
/** The API instance to use for making requests. */
protected api: API;
/**
* Create a new API object.
*
* @param api The API instance to use for making requests. Defaults to a new API instance if not provided.
*/
protected constructor(credentials?: APICredentials) {
this.api = new API(credentials);
}
/**
* Convert the object to a JSON object.
*
* This is mostly used for API call. But also sometimes for code reuse purposes.
*/
abstract toJSON(): any;
/**
* Allows the object to be created from data.
*
* @param data The data to create the object from.
*/
abstract fromData<T>(data: T): APIObject | Promise<APIObject>;
}