{"version":3,"sources":["webpack:///./node_modules/@abaco/assets-module/src/modules/assets-module/api/DocumentApi.ts"],"names":["DocumentApi","http","rootPath","this","cancelTokenSource","pkCuaa","itemId","warehouseType","documentURLTypeString","getDocumentURLTypeString","documentURLTypeSubString","getDocumentURLTypeSubString","url","get","params","offset","count","res","data","records","documentId","delete","detailOut","post"],"mappings":"yMAMqBA,G,+BAMjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,EAChBC,KAAKC,kBAAoB,K,qHAGtB,WAA4BC,EAAgBC,EAAgBC,GAA5D,oGACGC,EAAwBL,KAAKM,yBAAyBF,GACtDG,EAA2BP,KAAKQ,4BAA4BJ,GAC9DK,EAHD,0CAG0CJ,EAH1C,qBAG4EH,EAH5E,YAGsFK,EAHtF,YAGkHJ,EAHlH,mCAIkB,SAAlBC,IACCK,EAAM,mCAAH,OAAsCJ,EAAtC,YAA+DE,EAA/D,YAA2FJ,EAA3F,oCALJ,SAOeH,KAAKF,KAAKY,IAAID,EAAK,CACjCE,OAAQ,CACJC,OAAQ,EACRC,MAAO,OAVZ,cAOGC,EAPH,yBAaIA,EAAIC,KAAKC,SAbb,gD,qJAeA,WAAuBd,EAAgBC,EAAgBC,GAAvD,oGACGC,EAAwBL,KAAKM,yBAAyBF,GACtDG,EAA2BP,KAAKQ,4BAA4BJ,GAC9DK,EAHD,0CAG0CJ,EAH1C,qBAG4EH,EAH5E,YAGsFK,EAHtF,YAGkHJ,EAHlH,8BAIkB,SAAlBC,IACCK,EAAM,mCAAH,OAAsCJ,EAAtC,YAA+DE,EAA/D,YAA2FJ,EAA3F,+BALJ,SAOeH,KAAKF,KAAKY,IAAID,EAAK,CACjCE,OAAQ,CACJC,OAAQ,EACRC,MAAO,OAVZ,cAOGC,EAPH,yBAaIA,EAAIC,KAAKC,SAbb,gD,iJAeA,WAAmBd,EAAgBC,EAAgBC,GAAnD,oGACGC,EAAwBL,KAAKM,yBAAyBF,GACtDG,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AjBA,GAGiB,eAAjBA,EALQ,YAQS,QAAjBA,EACQ,QAES,SAAjBA,EACQ,YAEJ,K,yCAEH,SAA4BA,GAChC,MAAoB,cAAjBA,EACQ,cAES,WAAjBA,EACQ,WAES,QAAjBA,EACQ,QAES,iBAAjBA,EACQ,iBAES,aAAjBA,EACQ,aAES,SAAjBA,EACQ,SAES,QAAjBA,EACQ,QAES,eAAjBA,EACQ,gBAES,QAAjBA,EACQ,QAES,SAAjBA,EACQ,SAEJ,O","file":"js/chunk-2d0aaf17.5f58d58f.js","sourcesContent":["import { HTTPClient, propsToDate, propsToDatePaged } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { DateHelper } from '@abaco/web-components/src/components/DateUtils';\nimport axios, { CancelTokenSource } from \"axios\";\nimport { Document, DocumentType, DocumentCategory, DocumentOut } from '../models/Document';\n\nexport default class DocumentApi {\n\n private http: HTTPClient;\n private rootPath: string;\n private cancelTokenSource: CancelTokenSource | null;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath;\n this.cancelTokenSource = null;\n }\n\n public async getDocumentCategories(pkCuaa: number, itemId: number, warehouseType: string): Promise {\n const documentURLTypeString = this.getDocumentURLTypeString(warehouseType);\n const documentURLTypeSubString = this.getDocumentURLTypeSubString(warehouseType);\n let url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/dictionary_document_categories`;\n if(warehouseType === \"PLOT\"){\n url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/${documentURLTypeSubString}/${itemId}/dictionary_document_categories`;\n }\n const res = await this.http.get(url, {\n params: {\n offset: 0,\n count: 300,\n }\n });\n return res.data.records;\n }\n public async getDocumentTypes(pkCuaa: number, itemId: number, warehouseType: string): Promise {\n const documentURLTypeString = this.getDocumentURLTypeString(warehouseType);\n const documentURLTypeSubString = this.getDocumentURLTypeSubString(warehouseType);\n let url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/dictionary_document_types`;\n if(warehouseType === \"PLOT\"){\n url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/${documentURLTypeSubString}/${itemId}/dictionary_document_types`;\n }\n const res = await this.http.get(url, {\n params: {\n offset: 0,\n count: 300,\n }\n });\n return res.data.records;\n }\n public async getDocuments(pkCuaa: number, itemId: number, warehouseType: string): Promise {\n const documentURLTypeString = this.getDocumentURLTypeString(warehouseType);\n const documentURLTypeSubString = this.getDocumentURLTypeSubString(warehouseType);\n let url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/documents`;\n if(warehouseType === \"PLOT\"){\n url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/${documentURLTypeSubString}/${itemId}/documents`;\n }\n const res = await this.http.get(url, {\n params: {\n offset: 0,\n count: 300,\n }\n });\n return res.data.records;\n }\n\n\n\n public async deleteDocument(pkCuaa: number, itemId: number, documentId: number, warehouseType: string): Promise {\n const documentURLTypeString = this.getDocumentURLTypeString(warehouseType);\n const documentURLTypeSubString = this.getDocumentURLTypeSubString(warehouseType);\n let url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/documents/${documentId}`;\n if(warehouseType === \"PLOT\"){\n url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/${documentURLTypeSubString}/${itemId}/documents/${documentId}`;\n }\n const res = await this.http.delete(url);\n return res.data;\n }\n public async insertDocument(pkCuaa: number, itemId: number, detailOut: DocumentOut, warehouseType: string): Promise {\n const documentURLTypeString = this.getDocumentURLTypeString(warehouseType);\n const documentURLTypeSubString = this.getDocumentURLTypeSubString(warehouseType);\n let url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/documents`;\n if(warehouseType === \"PLOT\"){\n url = `/sitiagri-rest-api/api_basic/v1/${documentURLTypeString}/subjects/${pkCuaa}/${documentURLTypeSubString}/${itemId}/documents`;\n }\n const res = await this.http.post(url, detailOut);\n return res.data;\n }\n\n\n private getDocumentURLTypeString(warehouseType: string): string{\n if(warehouseType == \"FERTILIZER\"){\n return \"warehouse\";\n }\n if(warehouseType == \"PRODUCT\"){\n return \"warehouse\";\n }\n if(warehouseType == \"SEED\"){\n return \"warehouse\";\n }\n if(warehouseType == \"PHYTOCHEMICAL\"){\n return \"warehouse\";\n }\n if(warehouseType == \"EQUIPMENT\"){\n return \"equipments\";\n }\n if(warehouseType == \"WATER\"){\n return \"warehouse\";\n }\n if(warehouseType == \"FUEL\"){\n return \"warehouse\";\n }\n if(warehouseType == \"ELECTRICITY\"){\n return \"warehouse\";\n }\n if(warehouseType == \"PLOT\"){\n return \"plots\";\n }\n if(warehouseType == \"STOCK\"){\n return \"warehouse\";\n }\n return \"\";\n }\n private getDocumentURLTypeSubString(warehouseType: string): string{\n if(warehouseType == \"FERTILIZER\"){\n return \"fertilizers\";\n }\n if(warehouseType == \"PRODUCT\"){\n return \"products\";\n }\n if(warehouseType == \"SEED\"){\n return \"seeds\";\n }\n if(warehouseType == \"PHYTOCHEMICAL\"){\n return \"phytochemicals\";\n }\n if(warehouseType == \"EQUIPMENT\"){\n return \"equipments\";\n }\n if(warehouseType == \"WATER\"){\n return \"waters\";\n }\n if(warehouseType == \"FUEL\"){\n return \"fuels\";\n }\n if(warehouseType == \"ELECTRICITY\"){\n return \"electricities\";\n }\n if(warehouseType == \"PLOT\"){\n return \"plots\";\n }\n if(warehouseType == \"STOCK\"){\n return \"stocks\";\n }\n return \"\";\n }\n\n}\n"],"sourceRoot":""}