import * as Api from "../api/index"; type Info = { id: number; tts_args: object; backgroundInfo?: BackgroundArgs; }; export type BackgroundArgs = { rgb: string; id: number; } | string export class Project { id?: number; token: string | undefined; info?: Info; setToken(token: string) { this.token = token; } async getProject() { if (!this.token) { throw new Error("token is undefined"); } return Api.getCardInfo(this.token).then((res) => { this.info = res; this.id = this.info!.id; }); } static async create(token: string) { let project = new Project(); project.setToken(token); await project.getProject(); return project; } }