1743c5567b0842f3adbc142eac64ec0cd13010b4
[motion.git] / server / config / integrations / freshdesk.js
1 var _0xa88e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x72\x65\x71\x75\x65\x73\x74\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x56\x6F\x69\x63\x65\x51\x75\x65\x75\x65","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x55\x73\x65\x72","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x20\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x20\x69\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x68\x61\x6E\x64\x6C\x65\x45\x76\x65\x6E\x74","\x70\x72\x6F\x74\x6F\x74\x79\x70\x65","\x50\x61\x73\x73\x65\x64\x20\x70\x61\x72\x61\x6D\x65\x74\x65\x72\x73\x20\x61\x72\x65\x20\x6E\x6F\x74\x20\x65\x6E\x6F\x75\x67\x68\x20\x74\x6F\x20\x63\x72\x65\x61\x74\x65\x20\x61\x20\x6E\x65\x77\x20\x74\x69\x63\x6B\x65\x74\x3A\x20\x6D\x69\x73\x73\x20\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x49\x64\x20\x6F\x72\x20\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E\x49\x64","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64","\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x75\x72\x69","\x68\x65\x61\x64\x65\x72\x73","\x73\x65\x72\x76\x65\x72\x55\x72\x6C","\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x2F\x6A\x73\x6F\x6E","\x41\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E","\x42\x61\x73\x69\x63\x20","\x62\x61\x73\x65\x36\x34","\x61\x70\x69\x4B\x65\x79","\x3A\x58","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x61\x67\x65\x6E\x74","\x73\x63\x6F\x70\x65","\x61\x67\x65\x6E\x74\x4E\x61\x6D\x65","\x71\x75\x65\x75\x65","\x6E\x61\x6D\x65","\x6D\x6F\x6E\x69\x74\x6F\x72\x5F\x66\x6F\x72\x6D\x61\x74","\x52\x65\x63\x6F\x72\x64\x69\x6E\x67\x20\x65\x6E\x61\x62\x6C\x65\x64\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x51\x75\x65\x75\x65\x20","\x72\x65\x63\x6F\x72\x64\x45\x6E\x61\x62\x6C\x65","\x51\x75\x65\x75\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x20\x6F\x72\x20\x52\x65\x63\x6F\x72\x64\x69\x6E\x67\x20\x6E\x6F\x74\x20\x65\x6E\x61\x62\x6C\x65\x64","\x72\x6F\x75\x74\x65\x49\x64","\x69\x64","\x72\x65\x63\x6F\x72\x64","\x52\x65\x63\x6F\x72\x64\x69\x6E\x67\x20\x65\x6E\x61\x62\x6C\x65\x64\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x52\x6F\x75\x74\x65\x20\x4F\x75\x74\x62\x6F\x75\x6E\x64\x20","\x52\x6F\x75\x74\x65\x20\x4F\x75\x74\x62\x6F\x75\x6E\x64\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x20\x6F\x72\x20\x52\x65\x63\x6F\x72\x64\x69\x6E\x67\x20\x6E\x6F\x74\x20\x65\x6E\x61\x62\x6C\x65\x64","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x61\x67\x65\x6E\x74\x73","","\x6D\x65\x6D\x62\x65\x72\x6E\x61\x6D\x65","\x76\x6F\x69\x63\x65","\x43\x68\x61\x6E\x6E\x65\x6C\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64\x3A\x20","\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x55\x52\x4C","\x25\x73\x2F\x61\x70\x69\x2F\x76\x6F\x69\x63\x65\x2F\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x73\x2F\x25\x73\x2F\x64\x6F\x77\x6E\x6C\x6F\x61\x64\x3F\x74\x79\x70\x65\x3D\x75\x6E\x69\x71\x75\x65\x69\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x66\x6F\x72\x6D\x61\x74","\x72\x65\x73\x75\x6C\x74","\x6C\x65\x6E\x67\x74\x68","\x41\x67\x65\x6E\x74\x73\x20\x66\x6F\x75\x6E\x64\x20\x28","\x29\x2E\x20\x46\x69\x6E\x64\x20\x77\x69\x74\x68\x20\x6E\x61\x6D\x65\x3A\x20","\x41\x67\x65\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x63\x6F\x6E\x74\x61\x63\x74","\x41\x67\x65\x6E\x74\x20","\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2E\x20\x55\x73\x65\x20\x74\x68\x65\x20\x61\x64\x6D\x69\x6E\x20\x61\x63\x63\x6F\x75\x6E\x74","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x61\x67\x65\x6E\x74\x73\x2F\x6D\x65","\x43\x6F\x6E\x74\x61\x63\x74\x20\x74\x6F\x20\x73\x65\x61\x72\x63\x68\x20\x77\x69\x74\x68\x20\x70\x68\x6F\x6E\x65\x20","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73\x3F\x70\x68\x6F\x6E\x65\x3D","\x43\x6F\x6E\x74\x61\x63\x74\x20\x74\x6F\x20\x73\x65\x61\x72\x63\x68\x20\x77\x69\x74\x68\x20\x6D\x6F\x62\x69\x6C\x65\x20","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73\x3F\x6D\x6F\x62\x69\x6C\x65\x3D","\x6F\x75\x74\x62\x6F\x75\x6E\x64","\x64\x65\x73\x74\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x64\x65\x73\x74\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x43\x6F\x6E\x74\x61\x63\x74\x20\x66\x6F\x75\x6E\x64\x20\x28\x70\x68\x6F\x6E\x65\x29\x3A\x20","\x65\x6E\x64\x75\x73\x65\x72","\x43\x6F\x6E\x74\x61\x63\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x20\x28\x70\x68\x6F\x6E\x65\x29\x3A\x20","\x43\x72\x65\x61\x74\x65\x20\x6E\x65\x77\x20\x63\x6F\x6E\x74\x61\x63\x74\x20\x77\x69\x74\x68\x20\x70\x68\x6F\x6E\x65\x20","\x50\x4F\x53\x54","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x63\x6F\x6E\x74\x61\x63\x74\x73","\x43\x61\x6C\x6C\x65\x72\x20\x2D\x20\x25\x73","\x70\x68\x6F\x6E\x65","\x6D\x6F\x62\x69\x6C\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x50\x68\x6F\x6E\x65\x20\x6E\x75\x6D\x62\x65\x72\x20\x25\x73\x2E\x20\x4F\x72\x69\x67\x69\x6E\x61\x74\x65\x20\x66\x72\x6F\x6D\x20\x4D\x6F\x74\x69\x6F\x6E\x2E","\x65\x6D\x61\x69\x6C","\x25\x73\x40\x63\x6F\x6D\x70\x61\x6E\x79\x2E\x63\x6F\x6D","\x43\x68\x61\x6E\x6E\x65\x6C\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64\x3A","\x65\x72\x72\x6F\x72","\x3C\x75\x6E\x6B\x6E\x6F\x77\x6E\x3E","\x43\x72\x65\x61\x74\x65\x20\x74\x69\x63\x6B\x65\x74\x20\x74\x6F\x20\x63\x6F\x6E\x74\x61\x63\x74\x20\x77\x69\x74\x68\x20\x69\x64\x20\x20","\x72\x65\x73\x70\x6F\x6E\x64\x65\x72\x5F\x69\x64","\x72\x65\x71\x75\x65\x73\x74\x65\x72\x5F\x69\x64","\x73\x6F\x75\x72\x63\x65","\x70\x72\x69\x6F\x72\x69\x74\x79","\x73\x74\x61\x74\x75\x73","\x73\x75\x62\x6A\x65\x63\x74","\x50\x68\x6F\x6E\x65\x20\x6E\x75\x6D\x62\x65\x72\x20","\x76\x61\x6C\x75\x65","\x66\x6F\x72\x45\x61\x63\x68","\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x74\x61\x67\x73","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x74\x69\x63\x6B\x65\x74\x73","\x53\x75\x62\x6A\x65\x63\x74","\x73\x6F\x72\x74\x42\x79","\x74\x79\x70\x65","\x73\x74\x72\x69\x6E\x67","\x63\x6F\x6E\x74\x65\x6E\x74","\x70\x75\x73\x68","\x76\x61\x72\x69\x61\x62\x6C\x65","\x76\x61\x72\x69\x61\x62\x6C\x65\x4E\x61\x6D\x65","\x63\x75\x73\x74\x6F\x6D\x56\x61\x72\x69\x61\x62\x6C\x65","\x56\x61\x72\x69\x61\x62\x6C\x65","\x20","\x6A\x6F\x69\x6E","\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6B\x65\x79\x56\x61\x6C\x75\x65","\x6B\x65\x79\x54\x79\x70\x65","\x6B\x65\x79","\x25\x73\x3A\x20\x25\x73","\x6B\x65\x79\x43\x6F\x6E\x74\x65\x6E\x74","\x3C\x62\x72\x3E","\x46\x69\x65\x6C\x64","\x66\x69\x6C\x74\x65\x72","\x69\x64\x46\x69\x65\x6C\x64","\x54\x61\x67\x73","\x6D\x61\x70","\x54\x69\x63\x6B\x65\x74\x20\x63\x72\x65\x61\x74\x65\x64\x20","\x74\x69\x63\x6B\x65\x74\x49\x64","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x66\x72\x65\x73\x68\x64\x65\x73\x6B","\x65\x76\x65\x6E\x74\x43\x68\x61\x6E\x6E\x65\x6C","\x65\x78\x69\x74\x53\x74\x61\x74\x75\x73","\x73\x75\x63\x63\x65\x73\x73","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x49\x64","\x73\x75\x62\x74\x79\x70\x65\x43\x68\x61\x6E\x6E\x65\x6C","\x75\x72\x6C","\x2F\x68\x65\x6C\x70\x64\x65\x73\x6B\x2F\x74\x69\x63\x6B\x65\x74\x73\x2F","\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x3A\x66\x72\x65\x73\x68\x64\x65\x73\x6B","\x65\x6D\x69\x74","\x61\x67\x65\x6E\x74\x3A\x25\x73","\x74\x6F","\x63\x72\x65\x61\x74\x65","\x54\x69\x63\x6B\x65\x74\x20\x25\x73\x20\x64\x69\x73\x70\x6C\x61\x79\x65\x64\x20\x74\x6F\x20\x61\x67\x65\x6E\x74\x20\x25\x73","\x45\x72\x72\x6F\x72\x20\x69\x6E\x20\x74\x69\x63\x6B\x65\x74\x20\x63\x72\x65\x61\x74\x69\x6F\x6E","\x4D\x65\x73\x73\x61\x67\x65\x3A\x20","\x6D\x65\x73\x73\x61\x67\x65","\x53\x74\x61\x63\x6B\x3A\x20","\x73\x74\x61\x63\x6B","\x66\x61\x69\x6C\x65\x64","\x45\x72\x72\x6F\x72\x20\x69\x6E\x20\x52\x65\x70\x6F\x72\x74\x20\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x20\x63\x72\x65\x61\x74\x65","\x5B\x46\x72\x65\x73\x68\x64\x65\x73\x6B\x5D\x20","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x73\x75\x62\x73\x74\x72","\x2F","\x5E\x5C\x2F\x7C\x5C\x2F\x24","\x67","\x63\x61\x6C\x6C","\x73\x6C\x69\x63\x65","\x72\x65\x70\x6C\x61\x63\x65","\x65\x78\x70\x6F\x72\x74\x73"];_0xa88e[0];var _=require(_0xa88e[1]);var util=require(_0xa88e[2]);var moment=require(_0xa88e[3]);var rp=require(_0xa88e[4]);var FreshdeskIntegration=require(_0xa88e[6])[_0xa88e[5]];var IntConfiguration=require(_0xa88e[6])[_0xa88e[7]];var ReportIntegration=require(_0xa88e[6])[_0xa88e[8]];var VoiceQueue=require(_0xa88e[6])[_0xa88e[9]];var VoiceExtension=require(_0xa88e[6])[_0xa88e[10]];var Agent=require(_0xa88e[6])[_0xa88e[11]];function Freshdesk(){console[_0xa88e[13]](_0xa88e[12])}Freshdesk[_0xa88e[15]][_0xa88e[14]]= function(_0x40f7xc,_0x40f7xd,_0x40f7xe,_0x40f7xf,_0x40f7x10,_0x40f7x11,_0x40f7x12){var _0x40f7x13={connection:undefined,configuration:undefined,agent:undefined,enduser:undefined,ticketId:undefined,recordEnable:false,serverUrl:undefined};if(!_0x40f7xc||  !_0x40f7xd){err_message(_0xa88e[16]);return};IntConfiguration[_0xa88e[19]]({where:{id:_0x40f7xd,AccountId:_0x40f7xc},include:[{all:true,include:[{all:true}]}]})[_0xa88e[18]](handleEntityNotFound())[_0xa88e[18]](handleConnection(_0x40f7x13))[_0xa88e[18]](searchMotionAgent(_0x40f7xe,_0x40f7x10))[_0xa88e[18]](handleMotionAgent(_0x40f7x13))[_0xa88e[18]](searchQueue(_0x40f7x10))[_0xa88e[18]](handleQueueRecordings(_0x40f7x13,_0x40f7x10))[_0xa88e[18]](searchRoute(_0x40f7x10))[_0xa88e[18]](handleOutboundRecordings(_0x40f7x13,_0x40f7x10))[_0xa88e[18]](searchAgent(_0x40f7x13))[_0xa88e[18]](handleAgent(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](searchAdmin(_0x40f7x13))[_0xa88e[18]](handleAdmin(_0x40f7x13))[_0xa88e[18]](searchContact(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](searchContactMobile(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](handleContact(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](createContact(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](handleCreateContact(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf))[_0xa88e[18]](ticketCreation(_0x40f7x13,_0x40f7x10,_0x40f7x11,_0x40f7xe,_0x40f7xf))[_0xa88e[18]](handleTicketDisplay(_0x40f7x13))[_0xa88e[18]](handleReportIntegration(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xc,_0x40f7x12,_0x40f7xf))[_0xa88e[18]](handleEnd(_0x40f7x13))[_0xa88e[17]](handleError(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xc))};function handleEntityNotFound(){return function(_0x40f7x15){return _0x40f7x15?_0x40f7x15:null}}function handleConnection(_0x40f7x13){return function(_0x40f7x17){var _0x40f7x18=getAccountConfiguration(_0x40f7x17.FreshdeskAccount);_0x40f7x13[_0xa88e[20]]= _0x40f7x17;_0x40f7x13[_0xa88e[21]]= _0x40f7x18[_0xa88e[21]];_0x40f7x13[_0xa88e[22]]= _0x40f7x18[_0xa88e[22]];_0x40f7x13[_0xa88e[23]]= _0x40f7x17[_0xa88e[25]][_0xa88e[24]][_0xa88e[23]];_0x40f7x13[_0xa88e[26]]= _0x40f7x17[_0xa88e[24]][_0xa88e[26]]}}function getAccountConfiguration(_0x40f7x1a){var _0x40f7x1b={uri:stripTrailingSlash(_0x40f7x1a[_0xa88e[27]]),headers:{"\x41\x75\x74\x68\x6F\x72\x69\x7A\x61\x74\x69\x6F\x6E":undefined,"\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x54\x79\x70\x65":_0xa88e[28],"\x41\x63\x63\x65\x70\x74":_0xa88e[28]}};_0x40f7x1b[_0xa88e[22]][_0xa88e[29]]= _0xa88e[30]+  new Buffer(_0x40f7x1a[_0xa88e[32]]+ _0xa88e[33]).toString(_0xa88e[31]);return _0x40f7x1b}function searchMotionAgent(_0x40f7xe,_0x40f7x10){return function(){return Agent[_0xa88e[37]](_0xa88e[36])[_0xa88e[35]]({where:{name:getValueFromPropertyName(_0x40f7x10,getAgentSearchPropertyFromChannel(_0x40f7xe))},attributes:[_0xa88e[34]]})}}function handleMotionAgent(_0x40f7x13){return function(_0x40f7x1e){if(_0x40f7x1e&& _0x40f7x1e[_0xa88e[34]]){_0x40f7x13[_0xa88e[38]]= _0x40f7x1e[_0xa88e[34]]};return}}function searchQueue(_0x40f7x10){return function(){if(_0x40f7x10[_0xa88e[39]]){return VoiceQueue[_0xa88e[35]]({where:{name:_0x40f7x10[_0xa88e[39]]},attributes:[_0xa88e[40],_0xa88e[41]]})}else {return}}}function handleQueueRecordings(_0x40f7x13,_0x40f7x10){return function(_0x40f7x21){if(_0x40f7x10[_0xa88e[39]]){if(_0x40f7x21&& _0x40f7x21[_0xa88e[41]]){log_message(_0xa88e[42]+ _0x40f7x21[_0xa88e[40]]);_0x40f7x13[_0xa88e[43]]= true}else {_0x40f7x13[_0xa88e[43]]= false;log_message(_0xa88e[44])}};return}}function searchRoute(_0x40f7x10){return function(){if(_0x40f7x10[_0xa88e[45]]){return VoiceExtension[_0xa88e[35]]({where:{id:_0x40f7x10[_0xa88e[45]]},attributes:[_0xa88e[46],_0xa88e[47]]})}else {return}}}function handleOutboundRecordings(_0x40f7x13,_0x40f7x10){return function(_0x40f7x24){if(_0x40f7x10[_0xa88e[45]]){if(_0x40f7x24&& _0x40f7x24[_0xa88e[47]]){log_message(_0xa88e[48]+ _0x40f7x24[_0xa88e[46]]);_0x40f7x13[_0xa88e[43]]= true}else {_0x40f7x13[_0xa88e[43]]= false;log_message(_0xa88e[49])}};return}}function searchAgent(_0x40f7x13){return function(){return rp({uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[50]),headers:_0x40f7x13[_0xa88e[22]],json:true})}}function getAgentSearchPropertyFromChannel(_0x40f7xe){var _0x40f7x27=_0xa88e[51];if(_0x40f7xe){switch(_0x40f7xe){case _0xa88e[53]:_0x40f7x27= _0xa88e[52];break;default:_0x40f7x27= _0xa88e[52];err_message(_0xa88e[54]+ _0x40f7xe)}};return _0x40f7x27}function getValueFromPropertyName(_0x40f7x10,_0x40f7x27,_0x40f7x13){if(_0x40f7x27=== _0xa88e[55]){if(_0x40f7x13&& _0x40f7x13[_0xa88e[43]]&& _0x40f7x13[_0xa88e[23]]){return util[_0xa88e[58]](_0xa88e[56],stripTrailingSlash(_0x40f7x13[_0xa88e[23]]),_0x40f7x10[_0xa88e[57]])}else {return null}}else {return _[_0xa88e[59]](_0x40f7x10,_0x40f7x27)}}function handleAgent(_0x40f7x13,_0x40f7xe,_0x40f7x2a,_0x40f7xf){return function(_0x40f7x10){if(_0x40f7x10&& _0x40f7x10[_0xa88e[60]]> 0){log_message(_0xa88e[61]+ _0x40f7x10[_0xa88e[60]]+ _0xa88e[62]+ _0x40f7x13[_0xa88e[38]]);_0x40f7x13[_0xa88e[36]]= getMatchObject(_0x40f7x10,_0xa88e[40],_0x40f7x13[_0xa88e[38]]);return _0x40f7x13[_0xa88e[36]]}else {log_message(_0xa88e[63]);return}}}function getMatchObject(_0x40f7x2c,_0x40f7x27,_0x40f7x2d){var _0x40f7x2e=_[_0xa88e[19]](_0x40f7x2c,function(_0x40f7x2f){if(_0x40f7x2f[_0xa88e[64]][_0x40f7x27]=== _0x40f7x2d){return _0x40f7x2f}});return _0x40f7x2e}function searchAdmin(_0x40f7x13){return function(){if(_0x40f7x13[_0xa88e[36]]){return};log_message(_0xa88e[65]+ _0x40f7x13[_0xa88e[38]]+ _0xa88e[66]);return rp({uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[67]),headers:_0x40f7x13[_0xa88e[22]],json:true})}}function handleAdmin(_0x40f7x13){return function(_0x40f7x10){if(!_0x40f7x10){return};_0x40f7x13[_0xa88e[36]]= _0x40f7x10;return _0x40f7x13[_0xa88e[36]]}}function searchContact(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xf){return function(){var _0x40f7x33=getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf),_0x40f7x13);log_message(_0xa88e[68]+ _0x40f7x33);return rp({uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[69]+ _0x40f7x33),headers:_0x40f7x13[_0xa88e[22]],json:true})}}function searchContactMobile(_0x40f7x13,_0x40f7xe,_0x40f7x2a,_0x40f7xf){return function(_0x40f7x10){if(_0x40f7x10&& _0x40f7x10[_0xa88e[60]]> 0){return _0x40f7x10};var _0x40f7x35=getValueFromPropertyName(_0x40f7x2a,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf),_0x40f7x13);log_message(_0xa88e[70]+ _0x40f7x35);return rp({uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[71]+ _0x40f7x35),headers:_0x40f7x13[_0xa88e[22]],json:true})}}function getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf){var _0x40f7x27=_0xa88e[51];if(_0x40f7xe){switch(_0x40f7xe){case _0xa88e[53]:if(_0x40f7xf=== _0xa88e[72]){_0x40f7x27= _0xa88e[73]}else {if(_0x40f7xf=== _0xa88e[39]){_0x40f7x27= _0xa88e[74]}};break;default:_0x40f7x27= _0xa88e[74];err_message(_0xa88e[54]+ _0x40f7xe)}};return _0x40f7x27}function getEndUserNamePropertyFromChannel(_0x40f7xe,_0x40f7xf){var _0x40f7x27=_0xa88e[51];if(_0x40f7xe){switch(_0x40f7xe){case _0xa88e[53]:if(_0x40f7xf=== _0xa88e[72]){_0x40f7x27= _0xa88e[75]}else {if(_0x40f7xf=== _0xa88e[39]){_0x40f7x27= _0xa88e[76]}};break;default:_0x40f7x27= _0xa88e[76];err_message(_0xa88e[54]+ _0x40f7xe)}};return _0x40f7x27}function handleContact(_0x40f7x13,_0x40f7xe,_0x40f7x2a,_0x40f7xf){return function(_0x40f7x10){if(!_0x40f7x10){return};var _0x40f7x39=getValueFromPropertyName(_0x40f7x2a,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf));if(_0x40f7x10[_0xa88e[60]]> 0){log_message(_0xa88e[77]+ _0x40f7x39);_0x40f7x13[_0xa88e[78]]= _0x40f7x10[0];return _0x40f7x13[_0xa88e[78]]};log_message(_0xa88e[79]+ _0x40f7x39);return}}function createContact(_0x40f7x13,_0x40f7xe,_0x40f7x2a,_0x40f7xf){return function(_0x40f7x10){if(!_0x40f7x10){log_message(_0xa88e[80]+ getValueFromPropertyName(_0x40f7x2a,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf)));log_message(getJsonForContactCreation(_0x40f7xe,_0x40f7x2a,_0x40f7xf));var _0x40f7x3b={method:_0xa88e[81],uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[82]),headers:_0x40f7x13[_0xa88e[22]],body:getJsonForContactCreation(_0x40f7xe,_0x40f7x2a,_0x40f7xf),json:true};return rp(_0x40f7x3b)};return}}function getJsonForContactCreation(_0x40f7xe,_0x40f7x10,_0x40f7xf){var _0x40f7x3d={};switch(_0x40f7xe){case _0xa88e[53]:if(_0x40f7xf=== _0xa88e[39]){if(isValidName(_0x40f7x10[_0xa88e[76]])){_0x40f7x3d[_0xa88e[40]]= getValueFromPropertyName(_0x40f7x10,getEndUserNamePropertyFromChannel(_0x40f7xe,_0x40f7xf))}else {_0x40f7x3d[_0xa88e[40]]= util[_0xa88e[58]](_0xa88e[83],getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf)))}}else {if(_0x40f7xf=== _0xa88e[72]){if(isValidName(_0x40f7x10[_0xa88e[75]])){_0x40f7x3d[_0xa88e[40]]= getValueFromPropertyName(_0x40f7x10,getEndUserNamePropertyFromChannel(_0x40f7xe,_0x40f7xf))}else {_0x40f7x3d[_0xa88e[40]]= util[_0xa88e[58]](_0xa88e[83],getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf)))}}};_0x40f7x3d[_0xa88e[84]]= getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf));_0x40f7x3d[_0xa88e[85]]= getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf));_0x40f7x3d[_0xa88e[86]]= util[_0xa88e[58]](_0xa88e[87],getValueFromPropertyName(_0x40f7x10,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf)));_0x40f7x3d[_0xa88e[88]]= util[_0xa88e[58]](_0xa88e[89],getValueFromPropertyName(_0x40f7x10,_0xa88e[57]));break;default:console[_0xa88e[91]](_0xa88e[90],_0x40f7xe)};return _0x40f7x3d}function isValidName(_0x40f7x3f){return _0x40f7x3f&& _0x40f7x3f!== _0xa88e[92]}function handleCreateContact(_0x40f7x13,_0x40f7xe,_0x40f7x2a,_0x40f7xf){return function(_0x40f7x10){if(_0x40f7x10){_0x40f7x13[_0xa88e[78]]= _0x40f7x10};return}}function ticketCreation(_0x40f7x13,_0x40f7x2a,_0x40f7x11,_0x40f7xe,_0x40f7xf){return function(){log_message(_0xa88e[93]+ _0x40f7x13[_0xa88e[78]][_0xa88e[46]]);var _0x40f7x3f=util[_0xa88e[58]](_0xa88e[83],getValueFromPropertyName(_0x40f7x2a,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf)));var _0x40f7x33=getValueFromPropertyName(_0x40f7x2a,getEndUserSearchPropertyFromChannel(_0x40f7xe,_0x40f7xf));var _0x40f7x42={};_0x40f7x42[_0xa88e[94]]= _0x40f7x13[_0xa88e[36]][_0xa88e[46]];_0x40f7x42[_0xa88e[95]]= _0x40f7x13[_0xa88e[78]][_0xa88e[46]];_0x40f7x42[_0xa88e[40]]= (_0x40f7x3f|| _0x40f7x33);_0x40f7x42[_0xa88e[84]]= (_0x40f7x33|| _0x40f7x3f);_0x40f7x42[_0xa88e[96]]= 3;_0x40f7x42[_0xa88e[97]]= 1;_0x40f7x42[_0xa88e[98]]= 2;_0x40f7x42[_0xa88e[99]]= createSubjectFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11);if(!_0x40f7x42[_0xa88e[99]]){_0x40f7x42[_0xa88e[99]]= _0xa88e[100]+ (_0x40f7x33|| _0x40f7x3f)};_0x40f7x42[_0xa88e[86]]= createDescriptionFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11);if(!_0x40f7x42[_0xa88e[86]]){_0x40f7x42[_0xa88e[86]]= _0xa88e[100]+ (_0x40f7x33|| _0x40f7x3f)};var _0x40f7x43=createFieldsFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11);if(_0x40f7x43[_0xa88e[60]]> 0){_[_0xa88e[102]](_0x40f7x43,function(_0x40f7x44){_0x40f7x42[_0x40f7x44[_0xa88e[46]]]= _0x40f7x44[_0xa88e[101]]})};var _0x40f7x45=createCustomFieldsFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11);if(_0x40f7x45[_0xa88e[60]]> 0){_0x40f7x42[_0xa88e[103]]= {};_[_0xa88e[102]](_0x40f7x45,function(_0x40f7x44){var _0x40f7x46=_0x40f7x44[_0xa88e[46]];_0x40f7x42[_0xa88e[103]][_0x40f7x46]= _0x40f7x44[_0xa88e[101]]})};var _0x40f7x47=createTagsFromConfiguration(_0x40f7x13);if(_0x40f7x47[_0xa88e[60]]> 0){_0x40f7x42[_0xa88e[104]]= _0x40f7x47};log_message(_0x40f7x42);var _0x40f7x3b={method:_0xa88e[81],uri:join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[105]),headers:_0x40f7x13[_0xa88e[22]],body:_0x40f7x42,json:true};return rp(_0x40f7x3b)}}function createSubjectFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11){var _0x40f7x49=_0xa88e[51];var _0x40f7x4a=[];if(_0x40f7x13[_0xa88e[20]][_0xa88e[106]][_0xa88e[60]]> 0){var _0x40f7x4b=_[_0xa88e[107]](_0x40f7x13[_0xa88e[20]].Subject,[_0xa88e[46]]);_[_0xa88e[102]](_0x40f7x4b,function(_0x40f7x4c){if(_0x40f7x4c[_0xa88e[108]]=== _0xa88e[109]){_0x40f7x4a[_0xa88e[111]](_0x40f7x4c[_0xa88e[110]])}else {if(_0x40f7x4c[_0xa88e[108]]=== _0xa88e[112]&& _0x40f7x4c[_0xa88e[113]]){var _0x40f7x39=getValueFromPropertyName(_0x40f7x2a,_0x40f7x4c[_0xa88e[113]],_0x40f7x13);if(_0x40f7x39){_0x40f7x4a[_0xa88e[111]](_0x40f7x39.toString())}}else {if(_0x40f7x4c[_0xa88e[108]]=== _0xa88e[114]&& _0x40f7x4c[_0xa88e[115]]&& _0x40f7x4c[_0xa88e[115]][_0xa88e[40]]){_0x40f7x11[_0x40f7x4c[_0xa88e[115]][_0xa88e[40]]]&& _0x40f7x4a[_0xa88e[111]](_0x40f7x11[_0x40f7x4c[_0xa88e[115]][_0xa88e[40]]].toString())}}}});_0x40f7x49= _0x40f7x4a[_0xa88e[117]](_0xa88e[116])};return _0x40f7x49}function createDescriptionFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11){var _0x40f7x4e=_0xa88e[51];var _0x40f7x4a=[];if(_0x40f7x13[_0xa88e[20]][_0xa88e[118]][_0xa88e[60]]> 0){var _0x40f7x4f=_[_0xa88e[107]](_0x40f7x13[_0xa88e[20]].Description,[_0xa88e[46]]);_[_0xa88e[102]](_0x40f7x4f,function(_0x40f7x4c){if(_0x40f7x4c[_0xa88e[108]]=== _0xa88e[109]){_0x40f7x4a[_0xa88e[111]](_0x40f7x4c[_0xa88e[110]])}else {if(_0x40f7x4c[_0xa88e[108]]=== _0xa88e[119]){if(_0x40f7x4c[_0xa88e[120]]=== _0xa88e[109]&& _0x40f7x4c[_0xa88e[121]]){_0x40f7x4a[_0xa88e[111]](util[_0xa88e[58]](_0xa88e[122],_0x40f7x4c[_0xa88e[121]],_0x40f7x4c[_0xa88e[123]]))}else {if(_0x40f7x4c[_0xa88e[120]]=== _0xa88e[112]&& _0x40f7x4c[_0xa88e[113]]&& _0x40f7x4c[_0xa88e[121]]){var _0x40f7x39=getValueFromPropertyName(_0x40f7x2a,_0x40f7x4c[_0xa88e[113]],_0x40f7x13);if(_0x40f7x39){_0x40f7x4a[_0xa88e[111]](util[_0xa88e[58]](_0xa88e[122],_0x40f7x4c[_0xa88e[121]],_0x40f7x39.toString()))}}else {if(_0x40f7x4c[_0xa88e[120]]=== _0xa88e[114]&& _0x40f7x4c[_0xa88e[115]]&& _0x40f7x4c[_0xa88e[115]][_0xa88e[40]]&& _0x40f7x4c[_0xa88e[121]]){_0x40f7x11[_0x40f7x4c[_0xa88e[115]][_0xa88e[40]]]&& _0x40f7x4a[_0xa88e[111]](util[_0xa88e[58]](_0xa88e[122],_0x40f7x4c[_0xa88e[121]],_0x40f7x11[_0x40f7x4c[_0xa88e[115]][_0xa88e[40]]]))}}}}}});_0x40f7x4e= _0x40f7x4a[_0xa88e[117]](_0xa88e[124])};return _0x40f7x4e}function createFieldsFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11){var _0x40f7x43=[];var _0x40f7x51=[];if(_0x40f7x13[_0xa88e[20]][_0xa88e[125]][_0xa88e[60]]> 0){_0x40f7x43= _[_0xa88e[126]](_0x40f7x13[_0xa88e[20]].Field,{"\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64":false});_[_0xa88e[102]](_0x40f7x43,function(_0x40f7x44){if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[109]&& _0x40f7x44[_0xa88e[127]]){_0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x44[_0xa88e[110]]})}else {if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[112]&& _0x40f7x44[_0xa88e[113]]&& _0x40f7x44[_0xa88e[127]]){var _0x40f7x39=getValueFromPropertyName(_0x40f7x2a,_0x40f7x44[_0xa88e[113]],_0x40f7x13);if(_0x40f7x39){_0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x39.toString()})}}else {if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[114]&& _0x40f7x44[_0xa88e[127]]&& _0x40f7x44[_0xa88e[115]]&& _0x40f7x44[_0xa88e[115]][_0xa88e[40]]){_0x40f7x11[_0x40f7x44[_0xa88e[115]][_0xa88e[40]]]&& _0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x11[_0x40f7x44[_0xa88e[115]][_0xa88e[40]]].toString()})}}}})};return _0x40f7x51}function createCustomFieldsFromConfiguration(_0x40f7x13,_0x40f7x2a,_0x40f7x11){var _0x40f7x45=[];var _0x40f7x51=[];if(_0x40f7x13[_0xa88e[20]][_0xa88e[125]][_0xa88e[60]]> 0){_0x40f7x45= _[_0xa88e[126]](_0x40f7x13[_0xa88e[20]].Field,{"\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64":true});_[_0xa88e[102]](_0x40f7x45,function(_0x40f7x44){if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[109]&& _0x40f7x44[_0xa88e[127]]){_0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x44[_0xa88e[110]]})}else {if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[112]&& _0x40f7x44[_0xa88e[113]]&& _0x40f7x44[_0xa88e[127]]){var _0x40f7x39=getValueFromPropertyName(_0x40f7x2a,_0x40f7x44[_0xa88e[113]],_0x40f7x13);if(_0x40f7x39){_0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x39.toString()})}}else {if(_0x40f7x44[_0xa88e[108]]=== _0xa88e[114]&& _0x40f7x44[_0xa88e[127]]&& _0x40f7x44[_0xa88e[115]]&& _0x40f7x44[_0xa88e[115]][_0xa88e[40]]){_0x40f7x11[_0x40f7x44[_0xa88e[115]][_0xa88e[40]]]&& _0x40f7x51[_0xa88e[111]]({id:_0x40f7x44[_0xa88e[127]],value:_0x40f7x11[_0x40f7x44[_0xa88e[115]][_0xa88e[40]]].toString()})}}}})};return _0x40f7x51}function createTagsFromConfiguration(_0x40f7x13){var _0x40f7x47=[];if(_0x40f7x13[_0xa88e[20]][_0xa88e[128]][_0xa88e[60]]> 0){_0x40f7x47= _[_0xa88e[129]](_0x40f7x13[_0xa88e[20]].Tags,_0xa88e[40])};return _0x40f7x47}function handleTicketDisplay(_0x40f7x13){return function(_0x40f7x10){if(_0x40f7x10&& _0x40f7x10[_0xa88e[46]]){log_message(_0xa88e[130]+ _0x40f7x10[_0xa88e[46]]);_0x40f7x13[_0xa88e[131]]= _0x40f7x10[_0xa88e[46]];return};return}}function handleReportIntegration(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xc,_0x40f7x12,_0x40f7xf){return function(){delete _0x40f7x10[_0xa88e[46]];_0x40f7x10[_0xa88e[132]]= _0xa88e[133];_0x40f7x10[_0xa88e[134]]= _0x40f7xe;_0x40f7x10[_0xa88e[135]]= _0xa88e[136];_0x40f7x10[_0xa88e[131]]= _0x40f7x13[_0xa88e[131]];_0x40f7x10[_0xa88e[137]]= _0x40f7xc;_0x40f7x10[_0xa88e[138]]= _0x40f7xf;_0x40f7x10[_0xa88e[139]]= join_url(_0x40f7x13[_0xa88e[21]],_0xa88e[140]+ _0x40f7x13[_0xa88e[131]]);_0x40f7x12[_0xa88e[144]](util[_0xa88e[58]](_0xa88e[143],_0x40f7x10[_0xa88e[52]]))[_0xa88e[142]](_0xa88e[141],_0x40f7x10);return ReportIntegration[_0xa88e[145]](_0x40f7x10)}}function handleEnd(_0x40f7x13,_0x40f7x10,_0x40f7xe){return function(){log_message(util[_0xa88e[58]](_0xa88e[146],_0x40f7x13[_0xa88e[131]],_0x40f7x13[_0xa88e[36]][_0xa88e[64]][_0xa88e[40]]));_0x40f7x13= undefined;return}}function handleDebug(_0x40f7x13){return function(){log_message(_0x40f7x13);return}}function handleError(_0x40f7x13,_0x40f7xe,_0x40f7x10,_0x40f7xc){return function(_0x40f7x59){err_message(_0xa88e[147]);err_message(_0xa88e[148]+ _0x40f7x59[_0xa88e[149]]);err_message(_0xa88e[150]+ _0x40f7x59[_0xa88e[151]]);_0x40f7x13= undefined;delete _0x40f7x10[_0xa88e[46]];_0x40f7x10[_0xa88e[132]]= _0xa88e[133];_0x40f7x10[_0xa88e[134]]= _0x40f7xe;_0x40f7x10[_0xa88e[135]]= _0xa88e[152];_0x40f7x10[_0xa88e[137]]= _0x40f7xc;ReportIntegration[_0xa88e[145]](_0x40f7x10)[_0xa88e[18]](function(){return})[_0xa88e[17]](function(_0x40f7x59){err_message(_0xa88e[153]);return})}}function err_message(_0x40f7x4c){console[_0xa88e[91]](_0xa88e[154]+ _0x40f7x4c)}function log_message(_0x40f7x4c){console[_0xa88e[13]](_0xa88e[154]+ JSON[_0xa88e[155]](_0x40f7x4c))}function stripTrailingSlash(_0x40f7x5d){if(_0x40f7x5d[_0xa88e[156]](-1) === _0xa88e[157]){return _0x40f7x5d[_0xa88e[156]](0,_0x40f7x5d[_0xa88e[60]]- 1)};return _0x40f7x5d}function join_url(){var _0x40f7x5f= new RegExp(_0xa88e[158],_0xa88e[159]);var _0x40f7x60=Array[_0xa88e[15]][_0xa88e[161]][_0xa88e[160]](arguments);return _0x40f7x60[_0xa88e[129]](function(_0x40f7x61){return _0x40f7x61[_0xa88e[162]](_0x40f7x5f,_0xa88e[51])})[_0xa88e[117]](_0xa88e[157])}module[_0xa88e[163]]= Freshdesk