@bit-ui-libs/common
Version:
This library was generated with [Nx](https://nx.dev).
34 lines (26 loc) • 1.35 kB
text/typescript
import { BaseService, BaseServiceOptions } from '../../api/services/base-service';
import { BitDocument } from '../interfaces';
import { AddDocumentRequest, EditDocumentRequest, ListDocumentsRequest } from './documents.service.interfaces';
export type DocumentsServiceOptions = BaseServiceOptions & { profileApiUrl: string };
export class DocumentsService extends BaseService {
private profileApiUrl: string;
constructor(opts: DocumentsServiceOptions) {
super(opts);
this.profileApiUrl = opts.profileApiUrl;
}
listDocuments(profileId: string, req: ListDocumentsRequest) {
return this.get<BitDocument[]>(`${this.profileApiUrl}/${profileId}/documents`, req);
}
addDocument(profileId: string, req: AddDocumentRequest) {
return this.post<BitDocument, AddDocumentRequest>(`${this.profileApiUrl}/${profileId}/documents`, req);
}
getDocumentById(profileId: string, docId: string) {
return this.get<BitDocument>(`${this.profileApiUrl}/${profileId}/documents/${docId}`);
}
editDocument(profileId: string, docId: string, req: EditDocumentRequest) {
return this.put<BitDocument, EditDocumentRequest>(`${this.profileApiUrl}/${profileId}/documents/${docId}`, req);
}
removeDocument(profileId: string, docId: string) {
return this.delete<void>(`${this.profileApiUrl}/${profileId}/documents/${docId}`);
}
}