{"version":3,"sources":["webpack:///./node_modules/@abaco/iot-module/src/modules/iot/api/SensorApi.ts"],"names":["SensorApi","http","path","this","pkCuaa","stationId","get","res","data","results","forEach","el","propsToDate","granularity","from","to","params","getSingleValue","dates","map","dt","Date","physicalQuantity","curDate","formatted","toISOString","split"],"mappings":"2RAKqBA,E,WAIjB,WAAYC,EAAkBC,GAAY,uBACtCC,KAAKF,KAAOA,EACZE,KAAKD,KAAOA,E,+GAGT,WAAsBE,EAAgBC,GAAtC,uGACeF,KAAKF,KAAKK,IAAV,WAEVH,KAAKD,KAFK,oBAEWE,EAFX,qBAE8BC,EAF9B,YAEmD,IAHlE,cACGE,EADH,OAMHA,EAAIC,KAAKC,QAAQC,SAAQ,SAACC,GAAD,OAAQC,eAAYD,EAAI,CAAC,YAN/C,kBAQIJ,EAAIC,KAAKC,SARb,gD,0JAWA,WAA8BL,EAAgBC,EAAmBQ,EAA0BC,EAAYC,GAAvG,gGACGC,EAAS,CACXF,OACAC,KACAE,gBAAgB,GAJjB,SAMed,KAAKF,KAAKK,IAAV,WAAuDH,KAAKD,KAA5D,oBAA4EE,EAA5E,qBAA+FC,EAA/F,oBAAoHQ,GAAe,CAACG,WANnJ,cAMGT,EANH,OAOHA,EAAIC,KAAKC,QAAQC,SAAQ,SAACC,GAAD,OAAQA,EAAGO,MAAQP,EAAGO,MAAMC,KAAI,SAAAC,GAAE,OAAI,IAAIC,KAAKD,SAPrE,kBAQIb,EAAIC,KAAKC,SARb,gD,4JAWA,WAA0BL,EAAgBkB,GAA1C,kGACGC,EAAU,IAAIF,KACdG,EAFH,UAEkBD,EAAQE,cAAcC,MAAM,KAAK,GAFnD,cAIevB,KAAKF,KAAKK,IAAV,WACVH,KAAKD,KADK,oBACWE,EADX,8BACuCkB,EADvC,wCACuFE,GAAa,IALnH,cAIGjB,EAJH,yBAOIA,EAAIC,MAAQD,EAAIC,KAAKC,QAAUF,EAAIC,KAAKC,QAAU,IAPtD,gD","file":"js/chunk-2d0e448b.75d5588e.js","sourcesContent":["import { HTTPClient, propsToDate} from '@abaco/web-common/src/HTTP';\nimport { Granularity, SensorItem, SensorWithReadings } from '../models/SensorModel';\nimport { SensorXResponse } from '../models/StationModel';\nimport { SensorPosition, SensorReading } from '../models/SensorDataModel';\n\nexport default class SensorApi {\n private http: HTTPClient;\n private path: string;\n\n constructor(http: HTTPClient, path: string) {\n this.http = http;\n this.path = path;\n }\n\n public async getSensorsItems(pkCuaa: number, stationId: string) {\n const res = await this.http.get>(\n\n `/${this.path}/v1/farm/${pkCuaa}/stations/${stationId}/sensors`, {\n })\n\n res.data.results.forEach((el) => propsToDate(el, ['date']))\n // res.data.results.push({type: 'DEFAULT', stationId: res.data.results[0].stationId, id: 'image', name: 'Image', unit: null, dataType: 'S', date: new Date(), value: 'https://sp-ao.shortpixel.ai/client/to_webp,q_glossy,ret_img,w_735,h_490/https://www.omnesgroup.com/wp-content/uploads/2020/07/obscure-programming.jpg'})\n return res.data.results;\n }\n\n public async getSensorItemAggregated(pkCuaa: number, stationId: string, granularity: Granularity, from: Date, to: Date) {\n const params = {\n from,\n to,\n getSingleValue: false\n }\n const res = await this.http.get>(`/${this.path}/v1/farm/${pkCuaa}/stations/${stationId}/sensors/${granularity}`, {params})\n res.data.results.forEach((el) => el.dates = el.dates.map(dt => new Date(dt)))\n return res.data.results;\n }\n\n public async getSensorsPositions(pkCuaa: number, physicalQuantity: string): Promise {\n const curDate = new Date();\n const formatted = `${curDate.toISOString().split('.')[0]}Z`;\n //const formatted = `2023-05-01T00:00:00Z`;\n const res = await this.http.get(\n `/${this.path}/v1/farm/${pkCuaa}/physical-quantity/${physicalQuantity}/readings?crs=EPSG:4326&date=${formatted}`, {\n })\n return res.data && res.data.results ? res.data.results : [];\n }\n}\n"],"sourceRoot":""}