{"version":3,"sources":["webpack:///./node_modules/@abaco/protocol-module/src/modules/protocol/api/FertilizerPlanApi.ts"],"names":["FertilizerPlanApi","http","this","cancelTokenSource","get","res","data","pkCuaa","campaign","fp_header_id","search","filter","toUpperCase","push","params","length","undefined","pkid","paging","cancel","axios","CancelToken","source","offset","count","cancelToken","token","code","detailOut","post","delete","fert_crop_code","put","plot_id"],"mappings":"oPAKqBA,E,WAKjB,WAAYC,GAAgB,uBACxBC,KAAKD,KAAOA,EACZC,KAAKC,kBAAoB,K,6HAGtB,oHACeD,KAAKD,KAAKG,IAAV,yEADf,cACGC,EADH,yBAEIA,EAAIC,MAFR,gD,iJAKA,WAAwBC,EAAgBC,EAAkBC,GAA1D,uGACeP,KAAKD,KAAKG,IAAV,8DAAqEG,EAArE,sBAAyFC,EAAzF,6BAAsHC,IADrI,cACGJ,EADH,yBAEIA,EAAIC,MAFR,gD,uJAIA,WAAyBC,EAAgBC,EAAkBE,GAA3D,gGACGC,EAAS,GACZD,GAAoB,IAAVA,IACTA,EAASA,EAAOE,cAChBD,EAAOE,KAAP,4BAAiCH,KAJlC,SAMeR,KAAKD,KAAKG,IAAV,8DAAqEG,EAArE,sBAAyFC,EAAzF,qBAAsH,CACpIM,OAAQ,CACJH,OAAQA,EAAOI,OAASJ,OAASK,KARtC,cAMGX,EANH,yBAWIA,EAAIC,MAXR,gD,2JAaA,WAA6BW,EAAcC,EAAsBR,GAAjE,kGACCR,KAAKC,mBACLD,KAAKC,kBAAkBgB,SAE3BjB,KAAKC,kBAAoBiB,IAAMC,YAAYC,SACrCX,EAAS,GACZD,GAAoB,IAAVA,IACTA,EAASA,EAAOE,cAChBD,EAAOE,KAAP,2BAAgCH,KARjC,SAUeR,KAAKD,KAAKG,IAAV,wEAA+Ea,EAA/E,UAA6F,CAC3GH,OAAQ,CACJH,OAAQA,EAAOI,OAASJ,OAASK,EACjCO,OAAQL,EAAOK,OACfC,MAAON,EAAOM,OAElBC,YAAW,UAAEvB,KAAKC,yBAAP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7.js","sourcesContent":["import { FertilizerPlan, FertilizerPlanOut, FertilizerPlanCrop, FertilizerPlanDictionaries, FertilizerPlanPlot } from '../models/FertilizerPlan';\nimport { PagingParams, PagedResults } from '@abaco/web-common/src/Paging';\nimport { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport axios, { CancelTokenSource } from \"axios\";\n\nexport default class FertilizerPlanApi {\n\n private http: HTTPClient;\n private cancelTokenSource: CancelTokenSource | null;\n\n constructor(http: HTTPClient){\n this.http = http;\n this.cancelTokenSource = null;\n }\n\n public async getFertilizerPlanDictionaries(): Promise{\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots_plus/fertilizer_plan/dictionary`)\n return res.data;\n }\n\n public async getFertilizerPlan(pkCuaa: number, campaign: number, fp_header_id: number): Promise{\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots_plus/subjects/${pkCuaa}/campaigns/${campaign}/fertilizer_plans/${fp_header_id}`);\n return res.data;\n }\n public async getFertilizerPlans(pkCuaa: number, campaign: number, search?: string | null): Promise{\n const filter = [];\n if(search && search != \"\"){\n search = search.toUpperCase();\n filter.push(`^description like ${search}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots_plus/subjects/${pkCuaa}/campaigns/${campaign}/fertilizer_plans`, {\n params: {\n filter: filter.length ? filter : undefined,\n },\n })\n return res.data;\n }\n public async getFertilizerPlanPlots(pkid: number, paging: PagingParams, search?: string | null): Promise>{\n if (this.cancelTokenSource) {\n this.cancelTokenSource.cancel();\n }\n this.cancelTokenSource = axios.CancelToken.source();\n const filter = [];\n if(search && search != \"\"){\n search = search.toUpperCase();\n filter.push(`^crop_label like ${search}`);\n }\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_crop_filters/${pkid}/crops`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: paging.offset,\n count: paging.count\n },\n cancelToken: this.cancelTokenSource?.token\n })\n return res.data;\n }\n public async getFertilizerPlanCropByCode(pkid: number, code: string): Promise>{\n const filter = [];\n filter.push(`crop_code eq ${code}`);\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/plots/dictionary_crop_filters/${pkid}/crops`, {\n params: {\n filter: filter.length ? filter : undefined,\n offset: 0,\n count: 1\n },\n })\n return res.data;\n }\n public async insertFertilizerPlan(pkCuaa: number, campaign: number, detailOut: FertilizerPlanOut): Promise {\n const res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/plots_plus/subjects/${pkCuaa}/campaigns/${campaign}/fertilizer_plans`, detailOut);\n return res.data;\n }\n public async deleteFertilizerPlan(pkCuaa: number, campaign: number, fp_header_id: number): Promise {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots_plus/subjects/${pkCuaa}/campaigns/${campaign}/fertilizer_plans/${fp_header_id}`);\n return res.data;\n }\n public async updateFertilizerPlan(pkCuaa: number, campaign: number, fp_header_id: number, detailOut: FertilizerPlanOut): Promise {\n // remove field fert_crop_code from detailOut\n delete detailOut.fert_crop_code;\n const res = await this.http.put(`/sitiagri-rest-api/api_basic/v1/plots_plus/subjects/${pkCuaa}/campaigns/${campaign}/fertilizer_plans/${fp_header_id}`, detailOut);\n return res.data;\n }\n\n public async insertFertilizerPlanPlot(fp_header_id: number, plot_id: number): Promise {\n const res = await this.http.post(`/sitiagri-rest-api/api_basic/v1/plots_plus/fertilizer_plans/${fp_header_id}/plots/${plot_id}`, {});\n return res.data;\n }\n public async deleteFertilizerPlanPlot(fp_header_id: number, plot_id: number): Promise {\n const res = await this.http.delete(`/sitiagri-rest-api/api_basic/v1/plots_plus/fertilizer_plans/${fp_header_id}/plots/${plot_id}`);\n return res.data;\n }\n\n public async getCurrentCampaign(): Promise {\n const res = await this.http.get(\"/sitiagri-rest-api/api_basic/v1/land_uses/current_campaign\");\n return res.data.campaign\n }\n\n}\n"],"sourceRoot":""}