{"version":3,"sources":["webpack:///./node_modules/@abaco/messages-module/src/modules/messages/api/MessagesApi.ts"],"names":["MessagesApi","http","rootPath","this","cancelTokenSource","conversation_id","delete","res","data","paging","filter","subjectId","datetime","isInfinite","get","params","offset","count","text_search","undefined","subject_id","sort","toUpperCase","message_id","headers","responseType","download","message","post","file","fileName","formData","FormData","append","put","detailOut","result"],"mappings":"uMAKqBA,G,+BAKjB,WAAYC,EAAkBC,GAAgB,uBAC1CC,KAAKF,KAAOA,EACZE,KAAKD,SAAWA,EAChBC,KAAKC,kBAAoB,K,gHAGtB,WAAuBC,GAAvB,uGACeF,KAAKF,KAAKK,OAAV,UAAoBH,KAAKD,SAAzB,sCAA+DG,IAD9E,cACGE,EADH,yBAEIA,EAAIC,MAFR,gD,iJAKA,WACHC,EACAC,EACAC,EACAC,EACAC,GALG,uGAWeV,KAAKF,KAAKa,IAAV,UAAiBX,KAAKD,SAAtB,8BAA4D,CAC1Ea,OAAQ,CACJC,OAAQP,EAAOO,OACfC,MAAOR,EAAOQ,MACdC,YAAaR,QAAkBS,EAC/BC,WAAYT,GAAwB,GACpCU,KAAM,kBAjBX,cAWGd,EAXH,yBAqBKM,EAAsDN,EAAIC,KAA7C,CAAEA,KAAMD,EAAIC,KAAMI,SAAUA,IArB9C,gD,oKAwBA,WAAkCP,GAAlC,uGACeF,KAAKF,KAAKa,IAAV,UAAiBX,KAAKD,SAAtB,8BAA4D,CAC1Ea,OAAQ,CACJV,qBAHL,cACGE,EADH,yBAMIA,EAAIC,MANR,gD,8JASA,WACHC,EACAJ,GAFG,uGAIeF,KAAKF,KAAKa,IAAV,UAAiBX,KAAKD,SAAtB,sCAA4DG,EAA5D,aAAwF,CACtGU,OAAQ,CACJC,OAAQP,EAAOO,OACfC,MAAOR,EAAOQ,MACdI,KAAM,mBARX,cAIGd,EAJH,yBAWIA,EAAIC,MAXR,gD,gJAcA,WAAoBC,EAAsBC,GAA1C,uGACeP,KAAKF,KAAKa,IAAV,UAAiBX,KAAKD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,WAAyB2B,GAAzB,uGACehC,KAAKF,KAAK2B,KAAV,UAAkBzB,KAAKD,SAAvB,8BAA6DiC,GAD5E,cACG5B,EADH,yBAEIA,EAAIC,MAFR,gD,wJAKA,oHACeL,KAAKF,KAAKa,IAAV,UACXX,KAAKD,SADM,uEADf,cACGK,EADH,yBAIIA,EAAIC,KAAK4B,QAJb,gD,qJAMA,oHACejC,KAAKF,KAAKa,IAAV,UACXX,KAAKD,SADM,sEADf,cACGK,EADH,yBAIIA,EAAIC,KAAK4B,QAJb,gD","file":"js/chunk-2d0dd489.2ce3b106.js","sourcesContent":["import { AxiosResponse, HTTPClient } from \"@abaco/web-common/src/HTTP\";\nimport { Conversation, Message, NewConversationDetail, Recipient, Tag } from \"../models/Message\";\nimport { PagedResults, PagingParams } from \"@abaco/web-common/src/Paging\";\nimport axios, { CancelTokenSource } from \"axios\";\n\nexport default class MessagesApi {\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 lockConversation(conversation_id: number): Promise {\n const res = await this.http.delete(`${this.rootPath}/v1/messages/conversations/${conversation_id}`);\n return res.data;\n }\n\n public async getConversations(\n paging: PagingParams,\n filter: string | null,\n subjectId: number | null,\n datetime: number,\n isInfinite: boolean\n ): Promise {\n // if (subjectId == null) {\n // await new Promise(resolve => setTimeout(resolve, 5000));\n // }\n\n const res = await this.http.get(`${this.rootPath}/v1/messages/conversations`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n text_search: filter ? filter : undefined,\n subject_id: subjectId ? subjectId : \"\",\n sort: `-date_update`\n }\n });\n\n return !isInfinite ? { data: res.data, datetime: datetime } : res.data;\n }\n\n public async getSingleConversationDetail(conversation_id: number): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/messages/conversations`, {\n params: {\n conversation_id\n }\n });\n return res.data;\n }\n\n public async getSingleConversationMessages(\n paging: PagingParams,\n conversation_id: number\n ): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/messages/conversations/${conversation_id}/messages`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n sort: `-prog_message`\n }\n });\n return res.data;\n }\n\n public async getRecipients(paging: PagingParams, filter: string | null): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/people_registry/subjects`, {\n params: {\n offset: paging.offset,\n count: paging.count,\n filter: filter ? `^full_name like ${filter.toUpperCase()}` : undefined\n }\n });\n\n return res.data;\n }\n public async getPhoto(conversation_id: number, message_id: number): Promise {\n const res = await this.http.get(\n `${this.rootPath}/v1/messages/conversations/${conversation_id}/messages/${message_id}/attachmentV2`,\n { headers: { responseType: \"blob\" } }\n );\n return res.data;\n }\n public async downloadAttachment(conversation_id: number, message_id: number): Promise> {\n const res = await this.http.get(\n `${this.rootPath}/v1/messages/conversations/${conversation_id}/messages/${message_id}/attachmentV2`,\n {\n params: {\n download: true\n },\n responseType: \"blob\"\n }\n );\n return res;\n }\n\n public getPhotoURL(conversation_id: number, message_id: number): string {\n return `${this.rootPath}/v1/messages/conversations/${conversation_id}/messages/${message_id}/attachment`;\n }\n\n // public async getRecipientSubject(): Promise> {\n // const res = await this.http.get(`${this.rootPath}/v1/people_registry/subjects`, {\n // params: {\n // offset: 0,\n // count: 20,\n // only_empowered: true\n // }\n // });\n // return res.data;\n // }\n\n public async getTagTypes(paging: PagingParams): Promise> {\n const res = await this.http.get(`${this.rootPath}/v1/messages/dictionary/tag_types`, {\n params: {\n offset: paging.offset,\n count: paging.count\n }\n });\n return res.data;\n }\n\n public async insertNewMessage(conversation_id: number, message: string): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/messages/conversations/${conversation_id}/messages`, {\n message: message\n });\n return res.data;\n }\n\n public async attachFile(\n conversation_id: number,\n message_id: number,\n file: Blob,\n fileName: string\n ): Promise {\n const formData = new FormData();\n formData.append(\"file\", file, fileName);\n const res = await this.http.put(\n `${this.rootPath}/v1/messages/conversations/${conversation_id}/messages/${message_id}/attachment`,\n formData\n );\n return res.data;\n }\n\n public async insertConversation(detailOut: NewConversationDetail): Promise {\n const res = await this.http.post(`${this.rootPath}/v1/messages/conversations`, detailOut);\n return res.data;\n }\n\n public async checkCreateConversation(): Promise {\n const res = await this.http.get(\n `${this.rootPath}/v1/user_registry/module_competencies/SERVIZI/MESSAGES_CREATE_CONV`\n );\n return res.data.result;\n }\n public async checkLockConversation(): Promise {\n const res = await this.http.get(\n `${this.rootPath}/v1/user_registry/module_competencies/SERVIZI/MESSAGES_CLOSE_CONV`\n );\n return res.data.result;\n }\n}\n"],"sourceRoot":""}