import { Api } from "./api.class"; export class Command { constructor(private api: Api) {} async create( projectToken: string, source: string, isTypescript: number = 0, isPublic: number = 0 ): Promise { const response = await this.api.createRequestWithAuthHeaders( `${this.api.getUrl()}/command/create`, "POST", { source, isTypescript, isPublic, projectToken, } ); return response.data; } async update( id: string, updateData: Partial<{ source: string; isTypescript?: number; isPublic?: number; }> ): Promise { const response = await this.api.createRequestWithAuthHeaders( `${this.api.getUrl()}/command/update/${id}`, "POST", updateData ); return response.data; } async run( id: string, query: Record, headers: Record = {}, isPublic: boolean = false ): Promise { const response = await this.api.createRequestWithAuthHeaders( `${this.api.getUrl()}/command/${isPublic ? "run-public" : "run"}/${id}`, "POST", query, headers ); return response.data; } runPublic( id: string, query: Record, headers: Record = {} ): Promise { return this.run(id, query, headers, true); } async delete(id: string): Promise { const response = await this.api.createRequestWithAuthHeaders( `${this.api.getUrl()}/command/delete/${id}`, "DELETE" ); return response.data; } }