import ApiCall from "./ApiCall"; import Collections from "./Collections"; import Documents, { DocumentSchema, DocumentWriteParameters, } from "./Documents"; export class Document { constructor( private collectionName: string, private documentId: string, private apiCall: ApiCall ) {} async retrieve(): Promise { return this.apiCall.get(this.endpointPath()); } async delete(): Promise { return this.apiCall.delete(this.endpointPath()); } async update( partialDocument: Partial, options: DocumentWriteParameters = {} ): Promise { return this.apiCall.patch(this.endpointPath(), partialDocument, options); } private endpointPath(): string { return `${Collections.RESOURCEPATH}/${this.collectionName}${Documents.RESOURCEPATH}/${this.documentId}`; } }