import ApiCall from "./ApiCall"; import Collections from "./Collections"; import Documents, { DeleteQuery, 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(options?: DeleteQuery): Promise { return this.apiCall.delete(this.endpointPath(), options); } async update( partialDocument: Partial, options: DocumentWriteParameters = {} ): Promise { return this.apiCall.patch(this.endpointPath(), partialDocument, options); } private endpointPath(): string { return `${Collections.RESOURCEPATH}/${encodeURIComponent(this.collectionName)}${Documents.RESOURCEPATH}/${encodeURIComponent(this.documentId)}`; } }