import { APIClient } from "./ApiClient";

export class BackupApi {
  /**
   * FinancesManager export
   */
  static get FinancesManagerExportURL(): string {
    return APIClient.backendURL() + "/backup/finances_manager/export";
  }

  /**
   * FinancesManager import
   */
  static async FinancesManagerImport(file: File): Promise<void> {
    const fd = new FormData();
    fd.append("file", file);
    await APIClient.exec({
      method: "POST",
      uri: "/backup/finances_manager/import",
      formData: fd,
    });
  }

  /**
   * ZIP Export
   */
  static get ZIPExportURL(): string {
    return APIClient.backendURL() + "/backup/zip/export";
  }

  /**
   * ZIP import
   */
  static async ZIPImport(file: File): Promise<void> {
    const fd = new FormData();
    fd.append("file", file);
    await APIClient.exec({
      method: "POST",
      uri: "/backup/zip/import",
      formData: fd,
    });
  }

  /**
   * Excel export
   */
  static ExcelExportURL(): string {
    return APIClient.backendURL() + "/backup/xslx/export";
  }
}
