{"version":3,"sources":["webpack:///./node_modules/@abaco/grapes-dashboard-module/src/modules/grapes-dashboard-module/api/NotificationsApi.ts"],"names":["NotificationsApi","http","this","pkCuaa","date","paging","get","params","sort","filter","getTime","undefined","subject_id","offset","count","res","data","totalcount","getConversation","curPage","records","conversationId","getConversationMessages"],"mappings":"qNAIqBA,G,+BAIjB,WAAYC,GAAgB,uBACxBC,KAAKD,KAAOA,E,+GAGT,WAAsBE,EAAgBC,EAAmBC,GAAzD,uGACeH,KAAKD,KAAKK,IAAV,yDAAwE,CACtFC,OAAQ,CACJC,KAAM,eACNC,OAAQL,EAAO,kBAAH,OAAqBA,EAAKM,gBAAcC,EACpDC,WAAYT,EACZU,OAAQR,EAAOQ,OACfC,MAAOT,EAAOS,SAPnB,cACGC,EADH,yBAUIA,EAAIC,MAVR,gD,wJAaA,WAA0Bb,EAAgBC,GAA1C,6FACCU,EAAQ,EACRC,EAAsB,GACtBE,EAAa,EAHd,uBAKuBf,KAAKgB,gBAAgBf,EAAQC,EAAM,CAAES,OAAQC,EAAOA,MAAO,MALlF,OAKOK,EALP,OAMCL,GAASK,EAAQL,MACjBG,EAAaE,EAAQF,WACrBF,EAAM,GAAH,sBAAOA,GAAP,eAAeI,EAAQC,UAR3B,UASMN,EAAQG,EATd,iDAWIF,GAXJ,iD,0JAcA,WAA8BM,EAAwBjB,EAAmBC,GAAzE,uGACeH,KAAKD,KAAKK,IAAV,iEAAwEe,EAAxE,aAAmG,CACjHd,OAAQ,CACJC,KAAM,gBACNC,OAAQL,EAAO,gBAAH,OAAmBA,EAAKM,gBAAcC,EAClDE,OAAQR,EAAOQ,OACfC,MAAOT,EAAOS,SANnB,cACGC,EADH,yBASIA,EAAIC,MATR,gD,+JAYA,WAAiCK,EAAwBjB,GAAzD,6FACCU,EAAQ,EACRC,EAAiB,GACjBE,EAAa,EAHd,uBAKuBf,KAAKoB,wBAAwBD,EAAgBjB,EAAM,CAAES,OAAQC,EAAOA,MAAO,MALlG,OAKOK,EALP,OAMCL,GAASK,EAAQL,MACjBG,EAAaE,EAAQF,WACrBF,EAAM,GAAH,sBAAOA,GAAP,eAAeI,EAAQC,UAR3B,UASMN,EAAQG,EATd,iDAWIF,GAXJ,iD","file":"js/chunk-2d0a34cd.f21f250d.js","sourcesContent":["import { HTTPClient, propsToDate, propsToDatePaged } from \"@abaco/web-common/src/HTTP\";\nimport { dbGIStoStandardPage, PagedResults, PagingParams } from \"@abaco/web-common/src/Paging\";\nimport { Conversation, Message } from \"../models/Notification\";\n\nexport default class NotificationsApi {\n\n private http: HTTPClient;\n\n constructor(http: HTTPClient) {\n this.http = http;\n }\n\n public async getConversation(pkCuaa: number, date: Date | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/messages/conversations`, {\n params: {\n sort: \"-date_update\",\n filter: date ? `date_update ge ${date.getTime()}` : undefined,\n subject_id: pkCuaa,\n offset: paging.offset,\n count: paging.count,\n }\n });\n return res.data;\n }\n\n public async getAllConversations(pkCuaa: number, date: Date | null): Promise {\n let count = 0;\n let res: Conversation[] = [];\n let totalcount = 0;\n do {\n const curPage = await this.getConversation(pkCuaa, date, { offset: count, count: 300 });\n count += curPage.count;\n totalcount = curPage.totalcount;\n res = [...res, ...curPage.records];\n } while (count < totalcount)\n\n return res;\n }\n\n public async getConversationMessages(conversationId: number, date: Date | null, paging: PagingParams): Promise> {\n const res = await this.http.get(`/sitiagri-rest-api/api_basic/v1/messages/conversations/${conversationId}/messages`, {\n params: {\n sort: \"-prog_message\",\n filter: date ? `date_send ge ${date.getTime()}` : undefined,\n offset: paging.offset,\n count: paging.count,\n }\n });\n return res.data;\n }\n\n public async getAllConversationMessages(conversationId: number, date: Date | null): Promise {\n let count = 0;\n let res: Message[] = [];\n let totalcount = 0;\n do {\n const curPage = await this.getConversationMessages(conversationId, date, { offset: count, count: 300 });\n count += curPage.count;\n totalcount = curPage.totalcount;\n res = [...res, ...curPage.records];\n } while (count < totalcount)\n\n return res;\n }\n\n\n // public async getNotificationsByWeek(pkCuaa: number, startDate: Date, endDate: Date, paging: PagingParams): Promise> {\n // filter: filter ? `subject_full_name like ${filter.toUpperCase()}` : undefined,\n // const res = await this.http.get(`/sitiagri-rest-api/api_sso/v1/messages/conversations`, {\n // params: {\n // sort: \"-date_update\",\n // subject_id: pkCuaa,\n // offset: paging.offset,\n // count: paging.count,\n // }\n // });\n // return res.data;\n // }\n\n}\n"],"sourceRoot":""}