{"version":3,"sources":["webpack:///./node_modules/@abaco/prescription-module/src/modules/prescriptions/api/PrescriptionsApi.ts"],"names":["PrescriptionsApi","http","rootPath","this","filter","paging","get","params","count","offset","reg_id","undefined","activity_type","valid_from","Date","getTime","valid_to","res","data","toUpperCase","has_competence","records","prescription","post","id","put","delete"],"mappings":"uMAIqBA,G,+BAIjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,E,gHAGpB,WAAuBE,EAAoCC,GAA3D,uGACsBF,KAAKF,KAAKK,IAAV,UAAiBH,KAAKD,SAAtB,2BAAyD,CACvEK,OAAQ,CACJC,MAAOH,EAAOG,MACdC,OAAQJ,EAAOI,OACfC,OAAc,OAANN,QAAM,IAANA,KAAQM,OAASN,EAAOM,YAASC,EACzCC,cAAqB,OAANR,QAAM,IAANA,KAAQQ,cAAgBR,EAAOQ,mBAAgBD,EAC9DE,WAAkB,OAANT,QAAM,IAANA,KAAQS,WAAa,IAAIC,KAAKV,EAAOS,YAAYE,eAAYJ,EACzEK,SAAgB,OAANZ,QAAM,IAANA,KAAQY,SAAW,IAAIF,KAAKV,EAAOY,UAAUD,eAAYJ,KAR/E,cACUM,EADV,yBAWWA,EAAIC,MAXf,gD,wJAcA,uHAWW,CAAC,YAAY,YAXxB,2C,0IAcA,WAAiBb,EAAsBD,GAAvC,uGACsBD,KAAKF,KAAKK,IAAV,UAAiBH,KAAKD,SAAtB,0CAAwE,CACtFK,OAAQ,CACJC,MAAO,IACPJ,OAAQA,EAAS,sBAAH,OAAyBA,EAAOe,oBAAkBR,EAChES,gBAAgB,KAL5B,cACUH,EADV,yBAQWA,EAAIC,MARf,gD,iJAWA,oHACsBf,KAAKF,KAAKK,IAAV,UAAiBH,KAAKD,SAAtB,0CAAwE,CACtFK,OAAQ,CACJC,MAAO,IACPY,gBAAgB,KAJ5B,cACUH,EADV,yBAOWA,EAAIC,KAAKG,SAPpB,gD,gJAUA,WAAuBC,GAAvB,uGACsBnB,KAAKF,KAAKsB,KAAV,UAAkBpB,KAAKD,SAAvB,sBAAqDoB,GAD3E,cACUL,EADV,yBAEWA,EAAIC,MAFf,gD,iJAKA,WAAuBI,EAA+BE,GAAtD,uGACsBrB,KAAKF,KAAKwB,IAAV,UAAiBtB,KAAKD,SAAtB,8BAAoDsB,GAAMF,GADhF,cACUL,EADV,yBAEWA,EAAIC,MAFf,gD,qJAKA,WAAyBM,GAAzB,uGACsBrB,KAAKF,KAAKyB,OAAV,UAAoBvB,KAAKD,SAAzB,8BAAuDsB,IAD7E,cACUP,EADV,yBAEWA,EAAIC,MAFf,gD","file":"js/chunk-2d213aeb.aff90285.js","sourcesContent":["import { HTTPClient } from '@abaco/web-common/src/HTTP';\nimport { PagedResults, PagingParams } from '@abaco/web-common/src/Paging';\nimport { Prescription, PrescriptionFilter, PrescriptionOut, Regions } from \"../models/PrescriptionsModel\";\n\nexport default class PrescriptionsApi {\n private http: HTTPClient;\n private rootPath: string;\n\n constructor(http: HTTPClient, rootPath: string) {\n this.http = http;\n this.rootPath = rootPath;\n }\n\n async getPrescriptions(filter: PrescriptionFilter | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`${this.rootPath}/api/v1/exemptions/list`, {\n params: {\n count: paging.count,\n offset: paging.offset,\n reg_id: filter?.reg_id ? filter.reg_id : undefined,\n activity_type: filter?.activity_type ? filter.activity_type : undefined,\n valid_from: filter?.valid_from ? new Date(filter.valid_from).getTime() : undefined,\n valid_to: filter?.valid_to ? new Date(filter.valid_to).getTime() : undefined\n }\n });\n return res.data;\n }\n\n async getPrescriptionsTypes(): Promise {\n /*\n ALL TYPES:\n SEEDING,\n TREATMENT,\n FERTILIZATION,\n HARVESTING,\n IRRIGATION,\n GENERIC,\n UNKNOWN\n */\n return [\"TREATMENT\",\"GENERIC\"];\n }\n\n async getRegions(paging: PagingParams, filter: string | null): Promise> {\n const res = await this.http.get(`${this.rootPath}/api_basic/v1/plots/dictionary_regions`, {\n params: {\n count: 100,\n filter: filter ? `^region_label like ${filter.toUpperCase()}` : undefined,\n has_competence: true\n }\n });\n return res.data;\n }\n\n async getRegionsList(): Promise {\n const res = await this.http.get(`${this.rootPath}/api_basic/v1/plots/dictionary_regions`, {\n params: {\n count: 100,\n has_competence: true\n }\n });\n return res.data.records;\n }\n\n async savePrescription(prescription: PrescriptionOut): Promise {\n const res = await this.http.post(`${this.rootPath}/api/v1/exemptions`, prescription);\n return res.data;\n }\n\n async editPrescription(prescription: PrescriptionOut, id: number): Promise {\n const res = await this.http.put(`${this.rootPath}/api/v1/exemptions/${id}`, prescription);\n return res.data;\n }\n\n async deletePrescription(id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/api/v1/exemptions/${id}`);\n return res.data;\n }\n\n}\n"],"sourceRoot":""}