{"version":3,"sources":["api/archive/document/document-api.ts"],"names":["checkExtendedApiError","DocumentApi","constructor","errorReporter","this","getUserFeedbackSummary","itemId","response","await","fetch","json","result","addUserFeedback","feedback","body","JSON","stringify","method","headers","Content-Type"],"mappings":"OAESA,qBAAuF,KAA1D,iEAIzBC,YAETC,YAAoBC,GAAAC,KAAAD,cAAAA,CAAqD,CAEzEE,6BAA6BC,GAEzB,IAAMC,EAAWC,MAAMC,uBAAuBH,oBAAyB,EAEvE,OAAKE,MAAMR,sBAAsBO,EAAU,CAAA,EAAMH,KAAKD,aAAa,GAI/CK,MAAMD,EAASG,KAAI,GAEpBC,OALR,IAMf,CAEAC,sBAAsBN,EAAgBO,GAElC,IAAMC,EAAOC,KAAKC,UAAUH,CAAQ,EAU9BN,EAAWC,MAAMC,uBAAuBH,aARb,CAC7BW,OAAQ,OACRC,QAAS,CACLC,eAAgB,kB,EAEpBL,KAAAA,C,CAGwE,EAE5EN,MAAMR,sBAAsBO,EAAU,CAAA,EAAMH,KAAKD,aAAa,CAClE,C,QAhCSF,W","file":"document-api.js","sourcesContent":["import { IExtendedApiError } from \"../../../../components-shared/api/base/i-extended-api-error.js\";\r\nimport { IExtendedApiResponse } from \"../../../../components-shared/api/base/i-extended-api-response.js\";\r\nimport { checkExtendedApiError } from \"../../../../components-shared/api/base/error-handling.js\";\r\nimport { IUserFeedbackSummary } from \"./user-feedback-summary.js\";\r\nimport { IUserFeedbackInput } from \"./user-feedback-input.js\";\r\n\r\nexport class DocumentApi {\r\n \r\n constructor(private errorReporter: (error: IExtendedApiError) => void) { }\r\n\r\n async getUserFeedbackSummary(itemId: number): Promise {\r\n\r\n const response = await fetch(`/api/document/${itemId}/feedback-summary`);\r\n\r\n if (!await checkExtendedApiError(response, true, this.errorReporter)) {\r\n return null;\r\n }\r\n\r\n const apiResponse = await response.json() as IExtendedApiResponse;\r\n\r\n return apiResponse.result;\r\n }\r\n\r\n async addUserFeedback(itemId: number, feedback: IUserFeedbackInput): Promise {\r\n \r\n const body = JSON.stringify(feedback);\r\n\r\n const requestInit: RequestInit = {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n },\r\n body\r\n };\r\n\r\n const response = await fetch(`/api/document/${itemId}/feedback`, requestInit);\r\n\r\n await checkExtendedApiError(response, true, this.errorReporter);\r\n }\r\n}"]}