Built motion from commit 2438401.|1.0.5
[motion.git] / server / config / integrations / freshdesk.js
1 var _0x5ff9=["\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"];_0x5ff9[0];var _=require(_0x5ff9[1]);var util=require(_0x5ff9[2]);var moment=require(_0x5ff9[3]);var rp=require(_0x5ff9[4]);var FreshdeskIntegration=require(_0x5ff9[6])[_0x5ff9[5]];var IntConfiguration=require(_0x5ff9[6])[_0x5ff9[7]];var ReportIntegration=require(_0x5ff9[6])[_0x5ff9[8]];var VoiceQueue=require(_0x5ff9[6])[_0x5ff9[9]];var VoiceExtension=require(_0x5ff9[6])[_0x5ff9[10]];var Agent=require(_0x5ff9[6])[_0x5ff9[11]];function Freshdesk(){console[_0x5ff9[13]](_0x5ff9[12])}Freshdesk[_0x5ff9[15]][_0x5ff9[14]]= function(_0x4905xc,_0x4905xd,_0x4905xe,_0x4905xf,_0x4905x10,_0x4905x11,_0x4905x12){var _0x4905x13={connection:undefined,configuration:undefined,agent:undefined,enduser:undefined,ticketId:undefined,recordEnable:false,serverUrl:undefined};if(!_0x4905xc||  !_0x4905xd){err_message(_0x5ff9[16]);return};IntConfiguration[_0x5ff9[19]]({where:{id:_0x4905xd,AccountId:_0x4905xc},include:[{all:true,include:[{all:true}]}]})[_0x5ff9[18]](handleEntityNotFound())[_0x5ff9[18]](handleConnection(_0x4905x13))[_0x5ff9[18]](searchMotionAgent(_0x4905xe,_0x4905x10))[_0x5ff9[18]](handleMotionAgent(_0x4905x13))[_0x5ff9[18]](searchQueue(_0x4905x10))[_0x5ff9[18]](handleQueueRecordings(_0x4905x13,_0x4905x10))[_0x5ff9[18]](searchRoute(_0x4905x10))[_0x5ff9[18]](handleOutboundRecordings(_0x4905x13,_0x4905x10))[_0x5ff9[18]](searchAgent(_0x4905x13))[_0x5ff9[18]](handleAgent(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](searchAdmin(_0x4905x13))[_0x5ff9[18]](handleAdmin(_0x4905x13))[_0x5ff9[18]](searchContact(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](searchContactMobile(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](handleContact(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](createContact(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](handleCreateContact(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf))[_0x5ff9[18]](ticketCreation(_0x4905x13,_0x4905x10,_0x4905x11,_0x4905xe,_0x4905xf))[_0x5ff9[18]](handleTicketDisplay(_0x4905x13))[_0x5ff9[18]](handleReportIntegration(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xc,_0x4905x12,_0x4905xf))[_0x5ff9[18]](handleEnd(_0x4905x13))[_0x5ff9[17]](handleError(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xc))};function handleEntityNotFound(){return function(_0x4905x15){return _0x4905x15?_0x4905x15:null}}function handleConnection(_0x4905x13){return function(_0x4905x17){var _0x4905x18=getAccountConfiguration(_0x4905x17.FreshdeskAccount);_0x4905x13[_0x5ff9[20]]= _0x4905x17;_0x4905x13[_0x5ff9[21]]= _0x4905x18[_0x5ff9[21]];_0x4905x13[_0x5ff9[22]]= _0x4905x18[_0x5ff9[22]];_0x4905x13[_0x5ff9[23]]= _0x4905x17[_0x5ff9[25]][_0x5ff9[24]][_0x5ff9[23]];_0x4905x13[_0x5ff9[26]]= _0x4905x17[_0x5ff9[24]][_0x5ff9[26]]}}function getAccountConfiguration(_0x4905x1a){var _0x4905x1b={uri:stripTrailingSlash(_0x4905x1a[_0x5ff9[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":_0x5ff9[28],"\x41\x63\x63\x65\x70\x74":_0x5ff9[28]}};_0x4905x1b[_0x5ff9[22]][_0x5ff9[29]]= _0x5ff9[30]+  new Buffer(_0x4905x1a[_0x5ff9[32]]+ _0x5ff9[33]).toString(_0x5ff9[31]);return _0x4905x1b}function searchMotionAgent(_0x4905xe,_0x4905x10){return function(){return Agent[_0x5ff9[37]](_0x5ff9[36])[_0x5ff9[35]]({where:{name:getValueFromPropertyName(_0x4905x10,getAgentSearchPropertyFromChannel(_0x4905xe))},attributes:[_0x5ff9[34]]})}}function handleMotionAgent(_0x4905x13){return function(_0x4905x1e){if(_0x4905x1e&& _0x4905x1e[_0x5ff9[34]]){_0x4905x13[_0x5ff9[38]]= _0x4905x1e[_0x5ff9[34]]};return}}function searchQueue(_0x4905x10){return function(){if(_0x4905x10[_0x5ff9[39]]){return VoiceQueue[_0x5ff9[35]]({where:{name:_0x4905x10[_0x5ff9[39]]},attributes:[_0x5ff9[40],_0x5ff9[41]]})}else {return}}}function handleQueueRecordings(_0x4905x13,_0x4905x10){return function(_0x4905x21){if(_0x4905x10[_0x5ff9[39]]){if(_0x4905x21&& _0x4905x21[_0x5ff9[41]]){log_message(_0x5ff9[42]+ _0x4905x21[_0x5ff9[40]]);_0x4905x13[_0x5ff9[43]]= true}else {_0x4905x13[_0x5ff9[43]]= false;log_message(_0x5ff9[44])}};return}}function searchRoute(_0x4905x10){return function(){if(_0x4905x10[_0x5ff9[45]]){return VoiceExtension[_0x5ff9[35]]({where:{id:_0x4905x10[_0x5ff9[45]]},attributes:[_0x5ff9[46],_0x5ff9[47]]})}else {return}}}function handleOutboundRecordings(_0x4905x13,_0x4905x10){return function(_0x4905x24){if(_0x4905x10[_0x5ff9[45]]){if(_0x4905x24&& _0x4905x24[_0x5ff9[47]]){log_message(_0x5ff9[48]+ _0x4905x24[_0x5ff9[46]]);_0x4905x13[_0x5ff9[43]]= true}else {_0x4905x13[_0x5ff9[43]]= false;log_message(_0x5ff9[49])}};return}}function searchAgent(_0x4905x13){return function(){return rp({uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[50]),headers:_0x4905x13[_0x5ff9[22]],json:true})}}function getAgentSearchPropertyFromChannel(_0x4905xe){var _0x4905x27=_0x5ff9[51];if(_0x4905xe){switch(_0x4905xe){case _0x5ff9[53]:_0x4905x27= _0x5ff9[52];break;default:_0x4905x27= _0x5ff9[52];err_message(_0x5ff9[54]+ _0x4905xe)}};return _0x4905x27}function getValueFromPropertyName(_0x4905x10,_0x4905x27,_0x4905x13){if(_0x4905x27=== _0x5ff9[55]){if(_0x4905x13&& _0x4905x13[_0x5ff9[43]]&& _0x4905x13[_0x5ff9[23]]){return util[_0x5ff9[58]](_0x5ff9[56],stripTrailingSlash(_0x4905x13[_0x5ff9[23]]),_0x4905x10[_0x5ff9[57]])}else {return null}}else {return _[_0x5ff9[59]](_0x4905x10,_0x4905x27)}}function handleAgent(_0x4905x13,_0x4905xe,_0x4905x2a,_0x4905xf){return function(_0x4905x10){if(_0x4905x10&& _0x4905x10[_0x5ff9[60]]> 0){log_message(_0x5ff9[61]+ _0x4905x10[_0x5ff9[60]]+ _0x5ff9[62]+ _0x4905x13[_0x5ff9[38]]);_0x4905x13[_0x5ff9[36]]= getMatchObject(_0x4905x10,_0x5ff9[40],_0x4905x13[_0x5ff9[38]]);return _0x4905x13[_0x5ff9[36]]}else {log_message(_0x5ff9[63]);return}}}function getMatchObject(_0x4905x2c,_0x4905x27,_0x4905x2d){var _0x4905x2e=_[_0x5ff9[19]](_0x4905x2c,function(_0x4905x2f){if(_0x4905x2f[_0x5ff9[64]][_0x4905x27]=== _0x4905x2d){return _0x4905x2f}});return _0x4905x2e}function searchAdmin(_0x4905x13){return function(){if(_0x4905x13[_0x5ff9[36]]){return};log_message(_0x5ff9[65]+ _0x4905x13[_0x5ff9[38]]+ _0x5ff9[66]);return rp({uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[67]),headers:_0x4905x13[_0x5ff9[22]],json:true})}}function handleAdmin(_0x4905x13){return function(_0x4905x10){if(!_0x4905x10){return};_0x4905x13[_0x5ff9[36]]= _0x4905x10;return _0x4905x13[_0x5ff9[36]]}}function searchContact(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xf){return function(){var _0x4905x33=getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf),_0x4905x13);log_message(_0x5ff9[68]+ _0x4905x33);return rp({uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[69]+ _0x4905x33),headers:_0x4905x13[_0x5ff9[22]],json:true})}}function searchContactMobile(_0x4905x13,_0x4905xe,_0x4905x2a,_0x4905xf){return function(_0x4905x10){if(_0x4905x10&& _0x4905x10[_0x5ff9[60]]> 0){return _0x4905x10};var _0x4905x35=getValueFromPropertyName(_0x4905x2a,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf),_0x4905x13);log_message(_0x5ff9[70]+ _0x4905x35);return rp({uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[71]+ _0x4905x35),headers:_0x4905x13[_0x5ff9[22]],json:true})}}function getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf){var _0x4905x27=_0x5ff9[51];if(_0x4905xe){switch(_0x4905xe){case _0x5ff9[53]:if(_0x4905xf=== _0x5ff9[72]){_0x4905x27= _0x5ff9[73]}else {if(_0x4905xf=== _0x5ff9[39]){_0x4905x27= _0x5ff9[74]}};break;default:_0x4905x27= _0x5ff9[74];err_message(_0x5ff9[54]+ _0x4905xe)}};return _0x4905x27}function getEndUserNamePropertyFromChannel(_0x4905xe,_0x4905xf){var _0x4905x27=_0x5ff9[51];if(_0x4905xe){switch(_0x4905xe){case _0x5ff9[53]:if(_0x4905xf=== _0x5ff9[72]){_0x4905x27= _0x5ff9[75]}else {if(_0x4905xf=== _0x5ff9[39]){_0x4905x27= _0x5ff9[76]}};break;default:_0x4905x27= _0x5ff9[76];err_message(_0x5ff9[54]+ _0x4905xe)}};return _0x4905x27}function handleContact(_0x4905x13,_0x4905xe,_0x4905x2a,_0x4905xf){return function(_0x4905x10){if(!_0x4905x10){return};var _0x4905x39=getValueFromPropertyName(_0x4905x2a,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf));if(_0x4905x10[_0x5ff9[60]]> 0){log_message(_0x5ff9[77]+ _0x4905x39);_0x4905x13[_0x5ff9[78]]= _0x4905x10[0];return _0x4905x13[_0x5ff9[78]]};log_message(_0x5ff9[79]+ _0x4905x39);return}}function createContact(_0x4905x13,_0x4905xe,_0x4905x2a,_0x4905xf){return function(_0x4905x10){if(!_0x4905x10){log_message(_0x5ff9[80]+ getValueFromPropertyName(_0x4905x2a,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf)));log_message(getJsonForContactCreation(_0x4905xe,_0x4905x2a,_0x4905xf));var _0x4905x3b={method:_0x5ff9[81],uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[82]),headers:_0x4905x13[_0x5ff9[22]],body:getJsonForContactCreation(_0x4905xe,_0x4905x2a,_0x4905xf),json:true};return rp(_0x4905x3b)};return}}function getJsonForContactCreation(_0x4905xe,_0x4905x10,_0x4905xf){var _0x4905x3d={};switch(_0x4905xe){case _0x5ff9[53]:if(_0x4905xf=== _0x5ff9[39]){if(isValidName(_0x4905x10[_0x5ff9[76]])){_0x4905x3d[_0x5ff9[40]]= getValueFromPropertyName(_0x4905x10,getEndUserNamePropertyFromChannel(_0x4905xe,_0x4905xf))}else {_0x4905x3d[_0x5ff9[40]]= util[_0x5ff9[58]](_0x5ff9[83],getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf)))}}else {if(_0x4905xf=== _0x5ff9[72]){if(isValidName(_0x4905x10[_0x5ff9[75]])){_0x4905x3d[_0x5ff9[40]]= getValueFromPropertyName(_0x4905x10,getEndUserNamePropertyFromChannel(_0x4905xe,_0x4905xf))}else {_0x4905x3d[_0x5ff9[40]]= util[_0x5ff9[58]](_0x5ff9[83],getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf)))}}};_0x4905x3d[_0x5ff9[84]]= getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf));_0x4905x3d[_0x5ff9[85]]= getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf));_0x4905x3d[_0x5ff9[86]]= util[_0x5ff9[58]](_0x5ff9[87],getValueFromPropertyName(_0x4905x10,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf)));_0x4905x3d[_0x5ff9[88]]= util[_0x5ff9[58]](_0x5ff9[89],getValueFromPropertyName(_0x4905x10,_0x5ff9[57]));break;default:console[_0x5ff9[91]](_0x5ff9[90],_0x4905xe)};return _0x4905x3d}function isValidName(_0x4905x3f){return _0x4905x3f&& _0x4905x3f!== _0x5ff9[92]}function handleCreateContact(_0x4905x13,_0x4905xe,_0x4905x2a,_0x4905xf){return function(_0x4905x10){if(_0x4905x10){_0x4905x13[_0x5ff9[78]]= _0x4905x10};return}}function ticketCreation(_0x4905x13,_0x4905x2a,_0x4905x11,_0x4905xe,_0x4905xf){return function(){log_message(_0x5ff9[93]+ _0x4905x13[_0x5ff9[78]][_0x5ff9[46]]);var _0x4905x3f=util[_0x5ff9[58]](_0x5ff9[83],getValueFromPropertyName(_0x4905x2a,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf)));var _0x4905x33=getValueFromPropertyName(_0x4905x2a,getEndUserSearchPropertyFromChannel(_0x4905xe,_0x4905xf));var _0x4905x42={};_0x4905x42[_0x5ff9[94]]= _0x4905x13[_0x5ff9[36]][_0x5ff9[46]];_0x4905x42[_0x5ff9[95]]= _0x4905x13[_0x5ff9[78]][_0x5ff9[46]];_0x4905x42[_0x5ff9[40]]= (_0x4905x3f|| _0x4905x33);_0x4905x42[_0x5ff9[84]]= (_0x4905x33|| _0x4905x3f);_0x4905x42[_0x5ff9[96]]= 3;_0x4905x42[_0x5ff9[97]]= 1;_0x4905x42[_0x5ff9[98]]= 2;_0x4905x42[_0x5ff9[99]]= createSubjectFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11);if(!_0x4905x42[_0x5ff9[99]]){_0x4905x42[_0x5ff9[99]]= _0x5ff9[100]+ (_0x4905x33|| _0x4905x3f)};_0x4905x42[_0x5ff9[86]]= createDescriptionFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11);if(!_0x4905x42[_0x5ff9[86]]){_0x4905x42[_0x5ff9[86]]= _0x5ff9[100]+ (_0x4905x33|| _0x4905x3f)};var _0x4905x43=createFieldsFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11);if(_0x4905x43[_0x5ff9[60]]> 0){_[_0x5ff9[102]](_0x4905x43,function(_0x4905x44){_0x4905x42[_0x4905x44[_0x5ff9[46]]]= _0x4905x44[_0x5ff9[101]]})};var _0x4905x45=createCustomFieldsFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11);if(_0x4905x45[_0x5ff9[60]]> 0){_0x4905x42[_0x5ff9[103]]= {};_[_0x5ff9[102]](_0x4905x45,function(_0x4905x44){var _0x4905x46=_0x4905x44[_0x5ff9[46]];_0x4905x42[_0x5ff9[103]][_0x4905x46]= _0x4905x44[_0x5ff9[101]]})};var _0x4905x47=createTagsFromConfiguration(_0x4905x13);if(_0x4905x47[_0x5ff9[60]]> 0){_0x4905x42[_0x5ff9[104]]= _0x4905x47};log_message(_0x4905x42);var _0x4905x3b={method:_0x5ff9[81],uri:join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[105]),headers:_0x4905x13[_0x5ff9[22]],body:_0x4905x42,json:true};return rp(_0x4905x3b)}}function createSubjectFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11){var _0x4905x49=_0x5ff9[51];var _0x4905x4a=[];if(_0x4905x13[_0x5ff9[20]][_0x5ff9[106]][_0x5ff9[60]]> 0){var _0x4905x4b=_[_0x5ff9[107]](_0x4905x13[_0x5ff9[20]].Subject,[_0x5ff9[46]]);_[_0x5ff9[102]](_0x4905x4b,function(_0x4905x4c){if(_0x4905x4c[_0x5ff9[108]]=== _0x5ff9[109]){_0x4905x4a[_0x5ff9[111]](_0x4905x4c[_0x5ff9[110]])}else {if(_0x4905x4c[_0x5ff9[108]]=== _0x5ff9[112]&& _0x4905x4c[_0x5ff9[113]]){var _0x4905x39=getValueFromPropertyName(_0x4905x2a,_0x4905x4c[_0x5ff9[113]],_0x4905x13);if(_0x4905x39){_0x4905x4a[_0x5ff9[111]](_0x4905x39.toString())}}else {if(_0x4905x4c[_0x5ff9[108]]=== _0x5ff9[114]&& _0x4905x4c[_0x5ff9[115]]&& _0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]){_0x4905x11[_0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]]&& _0x4905x4a[_0x5ff9[111]](_0x4905x11[_0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]].toString())}}}});_0x4905x49= _0x4905x4a[_0x5ff9[117]](_0x5ff9[116])};return _0x4905x49}function createDescriptionFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11){var _0x4905x4e=_0x5ff9[51];var _0x4905x4a=[];if(_0x4905x13[_0x5ff9[20]][_0x5ff9[118]][_0x5ff9[60]]> 0){var _0x4905x4f=_[_0x5ff9[107]](_0x4905x13[_0x5ff9[20]].Description,[_0x5ff9[46]]);_[_0x5ff9[102]](_0x4905x4f,function(_0x4905x4c){if(_0x4905x4c[_0x5ff9[108]]=== _0x5ff9[109]){_0x4905x4a[_0x5ff9[111]](_0x4905x4c[_0x5ff9[110]])}else {if(_0x4905x4c[_0x5ff9[108]]=== _0x5ff9[119]){if(_0x4905x4c[_0x5ff9[120]]=== _0x5ff9[109]&& _0x4905x4c[_0x5ff9[121]]){_0x4905x4a[_0x5ff9[111]](util[_0x5ff9[58]](_0x5ff9[122],_0x4905x4c[_0x5ff9[121]],_0x4905x4c[_0x5ff9[123]]))}else {if(_0x4905x4c[_0x5ff9[120]]=== _0x5ff9[112]&& _0x4905x4c[_0x5ff9[113]]&& _0x4905x4c[_0x5ff9[121]]){var _0x4905x39=getValueFromPropertyName(_0x4905x2a,_0x4905x4c[_0x5ff9[113]],_0x4905x13);if(_0x4905x39){_0x4905x4a[_0x5ff9[111]](util[_0x5ff9[58]](_0x5ff9[122],_0x4905x4c[_0x5ff9[121]],_0x4905x39.toString()))}}else {if(_0x4905x4c[_0x5ff9[120]]=== _0x5ff9[114]&& _0x4905x4c[_0x5ff9[115]]&& _0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]&& _0x4905x4c[_0x5ff9[121]]){_0x4905x11[_0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]]&& _0x4905x4a[_0x5ff9[111]](util[_0x5ff9[58]](_0x5ff9[122],_0x4905x4c[_0x5ff9[121]],_0x4905x11[_0x4905x4c[_0x5ff9[115]][_0x5ff9[40]]]))}}}}}});_0x4905x4e= _0x4905x4a[_0x5ff9[117]](_0x5ff9[124])};return _0x4905x4e}function createFieldsFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11){var _0x4905x43=[];var _0x4905x51=[];if(_0x4905x13[_0x5ff9[20]][_0x5ff9[125]][_0x5ff9[60]]> 0){_0x4905x43= _[_0x5ff9[126]](_0x4905x13[_0x5ff9[20]].Field,{"\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64":false});_[_0x5ff9[102]](_0x4905x43,function(_0x4905x44){if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[109]&& _0x4905x44[_0x5ff9[127]]){_0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x44[_0x5ff9[110]]})}else {if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[112]&& _0x4905x44[_0x5ff9[113]]&& _0x4905x44[_0x5ff9[127]]){var _0x4905x39=getValueFromPropertyName(_0x4905x2a,_0x4905x44[_0x5ff9[113]],_0x4905x13);if(_0x4905x39){_0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x39.toString()})}}else {if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[114]&& _0x4905x44[_0x5ff9[127]]&& _0x4905x44[_0x5ff9[115]]&& _0x4905x44[_0x5ff9[115]][_0x5ff9[40]]){_0x4905x11[_0x4905x44[_0x5ff9[115]][_0x5ff9[40]]]&& _0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x11[_0x4905x44[_0x5ff9[115]][_0x5ff9[40]]].toString()})}}}})};return _0x4905x51}function createCustomFieldsFromConfiguration(_0x4905x13,_0x4905x2a,_0x4905x11){var _0x4905x45=[];var _0x4905x51=[];if(_0x4905x13[_0x5ff9[20]][_0x5ff9[125]][_0x5ff9[60]]> 0){_0x4905x45= _[_0x5ff9[126]](_0x4905x13[_0x5ff9[20]].Field,{"\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64":true});_[_0x5ff9[102]](_0x4905x45,function(_0x4905x44){if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[109]&& _0x4905x44[_0x5ff9[127]]){_0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x44[_0x5ff9[110]]})}else {if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[112]&& _0x4905x44[_0x5ff9[113]]&& _0x4905x44[_0x5ff9[127]]){var _0x4905x39=getValueFromPropertyName(_0x4905x2a,_0x4905x44[_0x5ff9[113]],_0x4905x13);if(_0x4905x39){_0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x39.toString()})}}else {if(_0x4905x44[_0x5ff9[108]]=== _0x5ff9[114]&& _0x4905x44[_0x5ff9[127]]&& _0x4905x44[_0x5ff9[115]]&& _0x4905x44[_0x5ff9[115]][_0x5ff9[40]]){_0x4905x11[_0x4905x44[_0x5ff9[115]][_0x5ff9[40]]]&& _0x4905x51[_0x5ff9[111]]({id:_0x4905x44[_0x5ff9[127]],value:_0x4905x11[_0x4905x44[_0x5ff9[115]][_0x5ff9[40]]].toString()})}}}})};return _0x4905x51}function createTagsFromConfiguration(_0x4905x13){var _0x4905x47=[];if(_0x4905x13[_0x5ff9[20]][_0x5ff9[128]][_0x5ff9[60]]> 0){_0x4905x47= _[_0x5ff9[129]](_0x4905x13[_0x5ff9[20]].Tags,_0x5ff9[40])};return _0x4905x47}function handleTicketDisplay(_0x4905x13){return function(_0x4905x10){if(_0x4905x10&& _0x4905x10[_0x5ff9[46]]){log_message(_0x5ff9[130]+ _0x4905x10[_0x5ff9[46]]);_0x4905x13[_0x5ff9[131]]= _0x4905x10[_0x5ff9[46]];return};return}}function handleReportIntegration(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xc,_0x4905x12,_0x4905xf){return function(){delete _0x4905x10[_0x5ff9[46]];_0x4905x10[_0x5ff9[132]]= _0x5ff9[133];_0x4905x10[_0x5ff9[134]]= _0x4905xe;_0x4905x10[_0x5ff9[135]]= _0x5ff9[136];_0x4905x10[_0x5ff9[131]]= _0x4905x13[_0x5ff9[131]];_0x4905x10[_0x5ff9[137]]= _0x4905xc;_0x4905x10[_0x5ff9[138]]= _0x4905xf;_0x4905x10[_0x5ff9[139]]= join_url(_0x4905x13[_0x5ff9[21]],_0x5ff9[140]+ _0x4905x13[_0x5ff9[131]]);_0x4905x12[_0x5ff9[144]](util[_0x5ff9[58]](_0x5ff9[143],_0x4905x10[_0x5ff9[52]]))[_0x5ff9[142]](_0x5ff9[141],_0x4905x10);return ReportIntegration[_0x5ff9[145]](_0x4905x10)}}function handleEnd(_0x4905x13,_0x4905x10,_0x4905xe){return function(){log_message(util[_0x5ff9[58]](_0x5ff9[146],_0x4905x13[_0x5ff9[131]],_0x4905x13[_0x5ff9[36]][_0x5ff9[64]][_0x5ff9[40]]));_0x4905x13= undefined;return}}function handleDebug(_0x4905x13){return function(){log_message(_0x4905x13);return}}function handleError(_0x4905x13,_0x4905xe,_0x4905x10,_0x4905xc){return function(_0x4905x59){err_message(_0x5ff9[147]);err_message(_0x5ff9[148]+ _0x4905x59[_0x5ff9[149]]);err_message(_0x5ff9[150]+ _0x4905x59[_0x5ff9[151]]);_0x4905x13= undefined;delete _0x4905x10[_0x5ff9[46]];_0x4905x10[_0x5ff9[132]]= _0x5ff9[133];_0x4905x10[_0x5ff9[134]]= _0x4905xe;_0x4905x10[_0x5ff9[135]]= _0x5ff9[152];_0x4905x10[_0x5ff9[137]]= _0x4905xc;ReportIntegration[_0x5ff9[145]](_0x4905x10)[_0x5ff9[18]](function(){return})[_0x5ff9[17]](function(_0x4905x59){err_message(_0x5ff9[153]);return})}}function err_message(_0x4905x4c){console[_0x5ff9[91]](_0x5ff9[154]+ _0x4905x4c)}function log_message(_0x4905x4c){console[_0x5ff9[13]](_0x5ff9[154]+ JSON[_0x5ff9[155]](_0x4905x4c))}function stripTrailingSlash(_0x4905x5d){if(_0x4905x5d[_0x5ff9[156]](-1) === _0x5ff9[157]){return _0x4905x5d[_0x5ff9[156]](0,_0x4905x5d[_0x5ff9[60]]- 1)};return _0x4905x5d}function join_url(){var _0x4905x5f= new RegExp(_0x5ff9[158],_0x5ff9[159]);var _0x4905x60=Array[_0x5ff9[15]][_0x5ff9[161]][_0x5ff9[160]](arguments);return _0x4905x60[_0x5ff9[129]](function(_0x4905x61){return _0x4905x61[_0x5ff9[162]](_0x4905x5f,_0x5ff9[51])})[_0x5ff9[117]](_0x5ff9[157])}module[_0x5ff9[163]]= Freshdesk