import { replace_all } from "@cocalc/util/misc";
import * as message from "@cocalc/util/message";
import { AsyncCall } from "./client";
export class SupportTickets {
private async_call: AsyncCall;
constructor(async_call: AsyncCall) {
this.async_call = async_call;
}
private async call(message: object): Promise<any> {
return await this.async_call({ message, timeout: 30 });
}
public async create(opts): Promise<string> {
if (opts.body != null) {
opts.body = replace_all(opts.body, "?session=", "?session=#");
}
return (await this.call(message.create_support_ticket(opts))).url;
}
public async get(): Promise<any> {
return (await this.call(message.get_support_tickets())).tickets;
}
}