39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { Observable } from "rxjs";
|
|
|
|
import { WildDuckBaseService } from "./wildduck-base.service";
|
|
import { ExportCreateResponse, ExportDetailsResponse, ExportDownloadResponse } from "../interfaces/export-response.interface";
|
|
import { CreateExportData } from "../interfaces/export.interface";
|
|
import { WildDuckSuccessResponse } from "../interfaces/wildduck-response.interface";
|
|
|
|
@Injectable()
|
|
export class WildDuckExportService extends WildDuckBaseService {
|
|
/**
|
|
* Create export job for user data
|
|
*/
|
|
createExport(userId: string, data?: CreateExportData): Observable<ExportCreateResponse> {
|
|
return this.post<ExportCreateResponse>(`/users/${userId}/export`, data);
|
|
}
|
|
|
|
/**
|
|
* Get export job status
|
|
*/
|
|
getExportStatus(userId: string, exportId: string): Observable<ExportDetailsResponse> {
|
|
return this.get<ExportDetailsResponse>(`/users/${userId}/export/${exportId}`);
|
|
}
|
|
|
|
/**
|
|
* Download export file
|
|
*/
|
|
downloadExport(userId: string, exportId: string): Observable<ExportDownloadResponse> {
|
|
return this.get<ExportDownloadResponse>(`/users/${userId}/export/${exportId}/download`);
|
|
}
|
|
|
|
/**
|
|
* Delete export job
|
|
*/
|
|
deleteExport(userId: string, exportId: string): Observable<WildDuckSuccessResponse> {
|
|
return this.delete<WildDuckSuccessResponse>(`/users/${userId}/export/${exportId}`);
|
|
}
|
|
}
|