2023-08-18 13:10:16 +00:00
|
|
|
import { APIClient } from "./ApiClient";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data management api client
|
|
|
|
*/
|
|
|
|
export class DataApi {
|
|
|
|
/**
|
|
|
|
* Export the data of a family
|
|
|
|
*/
|
|
|
|
static async ExportData(family_id: number): Promise<Blob> {
|
|
|
|
const res = await APIClient.exec({
|
|
|
|
uri: `/family/${family_id}/data/export`,
|
|
|
|
method: "GET",
|
|
|
|
});
|
|
|
|
return res.data;
|
|
|
|
}
|
2023-08-18 13:27:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Import the data of a family
|
|
|
|
*/
|
|
|
|
static async ImportData(family_id: number, archive: Blob): Promise<Blob> {
|
|
|
|
const fd = new FormData();
|
|
|
|
fd.append("archive", archive);
|
|
|
|
const res = await APIClient.exec({
|
|
|
|
uri: `/family/${family_id}/data/import`,
|
|
|
|
method: "PUT",
|
|
|
|
formData: fd,
|
|
|
|
});
|
|
|
|
return res.data;
|
|
|
|
}
|
2023-08-18 13:10:16 +00:00
|
|
|
}
|