f0808607c2569477d055f7c9cd0db67fa7cb6c6d
[motion.git] / server / config / integrations / salesforce.js
1 var _0x9ea7=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6A\x73\x66\x6F\x72\x63\x65","\x6D\x6F\x6D\x65\x6E\x74","\x6D\x6F\x74\x69\x6F\x6E","\x2E\x2E\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x43\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\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","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\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","\x69\x6E\x66\x6F","\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","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x74\x68\x65\x6E","\x66\x69\x6E\x64","\x63\x6F\x6E\x6E\x65\x63\x74\x69\x6F\x6E","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74","\x68\x74\x74\x70\x73\x3A\x2F\x2F\x6C\x6F\x67\x69\x6E\x2E\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x2E\x63\x6F\x6D","\x63\x6C\x69\x65\x6E\x74\x49\x64","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x73\x65\x63\x75\x72\x69\x74\x79\x54\x6F\x6B\x65\x6E","\x63\x6F\x6E\x63\x61\x74","\x70\x61\x73\x73\x77\x6F\x72\x64","\x63\x6F\x6E\x66\x69\x67\x75\x72\x61\x74\x69\x6F\x6E","\x73\x65\x72\x76\x65\x72\x55\x52\x4C","\x73\x65\x72\x76\x65\x72\x55\x72\x6C","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x6C\x6F\x67\x69\x6E","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\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","\x72\x65\x63\x6F\x72\x64\x45\x6E\x61\x62\x6C\x65","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x41\x67\x65\x6E\x74\x20\x74\x6F\x20\x73\x65\x61\x72\x63\x68\x3A","\x65\x78\x65\x63\x75\x74\x65","\x73\x6F\x62\x6A\x65\x63\x74","","\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","\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x41\x67\x65\x6E\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x4E\x61\x6D\x65","\x66\x69\x72\x73\x74","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x41\x67\x65\x6E\x74\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","\x69\x64\x65\x6E\x74\x69\x74\x79","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x41\x64\x6D\x69\x6E\x20\x73\x65\x6C\x65\x63\x74\x65\x64","\x75\x73\x65\x72\x5F\x69\x64","\x64\x69\x73\x70\x6C\x61\x79\x5F\x6E\x61\x6D\x65","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x43\x6F\x6E\x74\x61\x63\x74\x20\x74\x6F\x20\x73\x65\x61\x72\x63\x68\x3A","\x43\x6F\x6E\x74\x61\x63\x74","\x50\x68\x6F\x6E\x65","\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x43\x6F\x6E\x74\x61\x63\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x65\x6E\x64\x75\x73\x65\x72","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x43\x6F\x6E\x74\x61\x63\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x4C\x65\x61\x64\x20\x74\x6F\x20\x73\x65\x61\x72\x63\x68\x3A","\x4C\x65\x61\x64","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x4C\x65\x61\x64\x20\x66\x6F\x75\x6E\x64\x3A","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x43\x6F\x6E\x74\x61\x63\x74\x2F\x4C\x65\x61\x64\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x63\x72\x65\x61\x74\x65","\x4E\x6F\x20\x43\x6F\x6D\x70\x61\x6E\x79","\x4C\x61\x73\x74\x4E\x61\x6D\x65","\x43\x61\x6C\x6C\x65\x72\x20\x2D\x20\x25\x73","\x3C\x75\x6E\x6B\x6E\x6F\x77\x6E\x3E","\x73\x75\x63\x63\x65\x73\x73","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x4C\x65\x61\x64\x20\x63\x72\x65\x61\x74\x65\x64\x3A\x20","\x49\x64","\x75\x74\x63","\x76\x61\x6C\x75\x65","\x66\x6F\x72\x45\x61\x63\x68","\x54\x61\x73\x6B","\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","\x0A","\x46\x69\x65\x6C\x64","\x69\x64\x46\x69\x65\x6C\x64","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x54\x61\x73\x6B\x20\x63\x72\x65\x61\x74\x65\x64\x20","\x74\x61\x73\x6B\x49\x64","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65","\x65\x76\x65\x6E\x74\x43\x68\x61\x6E\x6E\x65\x6C","\x65\x78\x69\x74\x53\x74\x61\x74\x75\x73","\x74\x69\x63\x6B\x65\x74\x49\x64","\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","\x25\x73\x2F\x25\x73\x2F\x65","\x69\x6E\x73\x74\x61\x6E\x63\x65\x55\x72\x6C","\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x54\x79\x70\x65","\x65\x6D\x62\x65\x64\x64\x65\x64","\x72\x65\x70\x6F\x72\x74\x5F\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x3A\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65","\x65\x6D\x69\x74","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x54\x61\x73\x6B\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","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x45\x72\x72\x6F\x72\x20\x69\x6E\x20\x74\x61\x73\x6B\x20\x63\x72\x65\x61\x74\x69\x6F\x6E","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x3A","\x6D\x65\x73\x73\x61\x67\x65","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\x53\x74\x61\x63\x6B\x3A","\x73\x74\x61\x63\x6B","\x66\x61\x69\x6C\x65\x64","\x5B\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x5D\x20\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","\x73\x75\x62\x73\x74\x72","\x2F","\x65\x78\x70\x6F\x72\x74\x73"];_0x9ea7[0];var _=require(_0x9ea7[1]);var util=require(_0x9ea7[2]);var jsforce=require(_0x9ea7[3]);var moment=require(_0x9ea7[4]);var logger=require(_0x9ea7[6])(_0x9ea7[5]);var SalesforceConfiguration=require(_0x9ea7[8])[_0x9ea7[7]];var ReportIntegration=require(_0x9ea7[8])[_0x9ea7[9]];var VoiceQueue=require(_0x9ea7[8])[_0x9ea7[10]];var VoiceExtension=require(_0x9ea7[8])[_0x9ea7[11]];var Agent=require(_0x9ea7[8])[_0x9ea7[12]];function Salesforce(){logger[_0x9ea7[14]](_0x9ea7[13])}Salesforce[_0x9ea7[16]][_0x9ea7[15]]= function(_0xf037xc,_0xf037xd,_0xf037xe,_0xf037xf,_0xf037x10,_0xf037x11,_0xf037x12){var _0xf037x13={connection:undefined,configuration:undefined,agent:undefined,enduser:undefined,taskId:undefined,recordEnable:false,serverURL:undefined,agentName:undefined};if(!_0xf037xc||  !_0xf037xd){logger[_0x9ea7[18]](_0x9ea7[17]);return};SalesforceConfiguration[_0x9ea7[21]]({where:{id:_0xf037xd,AccountId:_0xf037xc},include:[{all:true,include:[{all:true}]}]})[_0x9ea7[20]](handleEntityNotFound())[_0x9ea7[20]](handleConnection(_0xf037x13))[_0x9ea7[20]](searchMotionAgent(_0xf037xe,_0xf037x10))[_0x9ea7[20]](handleMotionAgent(_0xf037x13))[_0x9ea7[20]](searchQueue(_0xf037x10))[_0x9ea7[20]](handleQueueRecordings(_0xf037x13,_0xf037x10))[_0x9ea7[20]](searchRoute(_0xf037x10))[_0x9ea7[20]](handleOutboundRecordings(_0xf037x13,_0xf037x10))[_0x9ea7[20]](searchAgent(_0xf037x13,_0xf037xe,_0xf037x10))[_0x9ea7[20]](handleAgent(_0xf037x13,_0xf037xe,_0xf037x10))[_0x9ea7[20]](searchAdmin(_0xf037x13))[_0x9ea7[20]](handleAdmin(_0xf037x13))[_0x9ea7[20]](searchContact(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](handleContact(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](searchLead(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](handleLead(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](leadCreation(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](handleLeadCreation(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf))[_0x9ea7[20]](taskCreation(_0xf037x13,_0xf037x10,_0xf037x11))[_0x9ea7[20]](handleTaskDisplay(_0xf037x13))[_0x9ea7[20]](handleReportIntegration(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xc,_0xf037x12,_0xf037xf))[_0x9ea7[20]](handleEnd(_0xf037x13))[_0x9ea7[19]](handleError(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xc))};function handleEntityNotFound(){return function(_0xf037x15){if(!_0xf037x15){return null};return _0xf037x15}}function handleConnection(_0xf037x13){return function(_0xf037x17){_0xf037x13[_0x9ea7[22]]=  new jsforce.Connection({oauth2:{loginUrl:_0xf037x17[_0x9ea7[24]][_0x9ea7[23]]?_0xf037x17[_0x9ea7[24]][_0x9ea7[23]]:_0x9ea7[25],clientId:_0xf037x17[_0x9ea7[24]][_0x9ea7[26]],clientSecret:_0xf037x17[_0x9ea7[24]][_0x9ea7[27]]}});var _0xf037x18=_0xf037x17[_0x9ea7[24]][_0x9ea7[30]][_0x9ea7[29]](_0xf037x17[_0x9ea7[24]][_0x9ea7[28]]);_0xf037x13[_0x9ea7[31]]= _0xf037x17;_0xf037x13[_0x9ea7[32]]= _0xf037x17[_0x9ea7[24]][_0x9ea7[33]];return _0xf037x13[_0x9ea7[22]][_0x9ea7[35]](_0xf037x17[_0x9ea7[24]][_0x9ea7[34]],_0xf037x18)}}function searchMotionAgent(_0xf037xe,_0xf037x10){return function(){var _0xf037x1a=getAgentSearchPropertyFromChannel(_0xf037xe);if(_0xf037x10[_0x9ea7[36]](_0xf037x1a)){return Agent[_0x9ea7[40]](_0x9ea7[39])[_0x9ea7[38]]({where:{name:getValueFromPropertyName(_0xf037x10,_0xf037x1a)},attributes:[_0x9ea7[37]]})};return}}function handleMotionAgent(_0xf037x13){return function(_0xf037x1c){if(_0xf037x1c&& _0xf037x1c[_0x9ea7[37]]){_0xf037x13[_0x9ea7[41]]= _0xf037x1c[_0x9ea7[37]]};return}}function searchQueue(_0xf037x10){return function(){if(_0xf037x10[_0x9ea7[42]]){return VoiceQueue[_0x9ea7[38]]({where:{name:_0xf037x10[_0x9ea7[42]]},attributes:[_0x9ea7[43],_0x9ea7[44]]})}else {return}}}function handleQueueRecordings(_0xf037x13,_0xf037x10){return function(_0xf037x1f){if(_0xf037x10[_0x9ea7[42]]){if(_0xf037x1f&& _0xf037x1f[_0x9ea7[44]]){logger[_0x9ea7[14]](_0x9ea7[45],_0xf037x1f[_0x9ea7[43]]);_0xf037x13[_0x9ea7[46]]= true}else {_0xf037x13[_0x9ea7[46]]= false;logger[_0x9ea7[14]](_0x9ea7[47])}};return}}function searchRoute(_0xf037x10){return function(){if(_0xf037x10[_0x9ea7[48]]){return VoiceExtension[_0x9ea7[38]]({where:{id:_0xf037x10[_0x9ea7[48]]},attributes:[_0x9ea7[49],_0x9ea7[50]]})}else {return}}}function handleOutboundRecordings(_0xf037x13,_0xf037x10){return function(_0xf037x22){if(_0xf037x10[_0x9ea7[48]]){if(_0xf037x22&& _0xf037x22[_0x9ea7[50]]){logger[_0x9ea7[14]](_0x9ea7[51],_0xf037x22[_0x9ea7[49]]);_0xf037x13[_0x9ea7[46]]= true}else {_0xf037x13[_0x9ea7[46]]= false;logger[_0x9ea7[14]](_0x9ea7[52])}};return}}function searchAgent(_0xf037x13,_0xf037xe,_0xf037x10){return function(){if(_0xf037x13[_0x9ea7[41]]){logger[_0x9ea7[14]](_0x9ea7[53],_0xf037x13[_0x9ea7[41]]);return _0xf037x13[_0x9ea7[22]][_0x9ea7[55]](_0x9ea7[12])[_0x9ea7[21]]({Name:_0xf037x13[_0x9ea7[41]]},{Id:1,Username:1,Name:1})[_0x9ea7[54]]()};return}}function getAgentSearchPropertyFromChannel(_0xf037xe){var _0xf037x25=_0x9ea7[56];if(_0xf037xe){switch(_0xf037xe){case _0x9ea7[58]:_0xf037x25= _0x9ea7[57];break;default:_0xf037x25= _0x9ea7[57];logger[_0x9ea7[18]](_0x9ea7[59],_0xf037xe)}};return _0xf037x25}function getValueFromPropertyName(_0xf037x10,_0xf037x25,_0xf037x13){if(_0xf037x25=== _0x9ea7[60]){if(_0xf037x13&& _0xf037x13[_0x9ea7[46]]&& _0xf037x13[_0x9ea7[32]]){return util[_0x9ea7[63]](_0x9ea7[61],stripTrailingSlash(_0xf037x13[_0x9ea7[32]]),_0xf037x10[_0x9ea7[62]])}else {return null}}else {return _[_0x9ea7[64]](_0xf037x10,_0xf037x25)}}function handleAgent(_0xf037x13,_0xf037xe,_0xf037x28){return function(_0xf037x10){if(_0xf037x10&& _0xf037x10[_0x9ea7[65]]> 0){logger[_0x9ea7[14]](_0x9ea7[66],_0xf037x13[_0x9ea7[41]]);_0xf037x13[_0x9ea7[39]]= getMatchObject(_0xf037x10,_0x9ea7[67],_0xf037x13[_0x9ea7[41]]);return _0xf037x13[_0x9ea7[39]]};return}}function getMatchObject(_0xf037x2a,_0xf037x25,_0xf037x2b){var _0xf037x2c=_[_0x9ea7[21]](_0xf037x2a,{property:_0xf037x2b});if(_0xf037x2c){return _0xf037x2c};return _[_0x9ea7[68]](_0xf037x2a)}function searchAdmin(_0xf037x13){return function(_0xf037x10){if(_0xf037x10){return};logger[_0x9ea7[14]](_0x9ea7[69]);return _0xf037x13[_0x9ea7[22]][_0x9ea7[70]]()}}function handleAdmin(_0xf037x13){return function(_0xf037x10){if(!_0xf037x10){return};if(_0xf037x10){logger[_0x9ea7[14]](_0x9ea7[71]);_0xf037x13[_0x9ea7[39]]= {Id:_0xf037x10[_0x9ea7[72]],Name:_0xf037x10[_0x9ea7[73]],Username:_0xf037x10[_0x9ea7[34]]}};return}}function searchContact(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xf){return function(){logger[_0x9ea7[14]](_0x9ea7[74],getValueFromPropertyName(_0xf037x10,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));var _0xf037x30={};_0xf037x30[getEndUserSearchQueryFromChannel(_0xf037xe)]= getValueFromPropertyName(_0xf037x10,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf));return _0xf037x13[_0x9ea7[22]][_0x9ea7[55]](_0x9ea7[75])[_0x9ea7[21]](_0xf037x30,{Id:1,Name:1})[_0x9ea7[54]]()}}function getEndUserSearchQueryFromChannel(_0xf037xe){var _0xf037x25=_0x9ea7[56];if(_0xf037xe){switch(_0xf037xe){case _0x9ea7[58]:_0xf037x25= _0x9ea7[76];break;default:_0xf037x25= _0x9ea7[76];logger[_0x9ea7[18]](_0x9ea7[59],_0xf037xe)}};return _0xf037x25}function getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf){var _0xf037x25=_0x9ea7[56];if(_0xf037xe){switch(_0xf037xe){case _0x9ea7[58]:if(_0xf037xf=== _0x9ea7[77]){_0xf037x25= _0x9ea7[78]}else {if(_0xf037xf=== _0x9ea7[42]){_0xf037x25= _0x9ea7[79]}};break;default:_0xf037x25= _0x9ea7[79];logger[_0x9ea7[18]](_0x9ea7[59],_0xf037xe)}};return _0xf037x25}function getEndUserNamePropertyFromChannel(_0xf037xe,_0xf037xf){var _0xf037x25=_0x9ea7[56];if(_0xf037xe){switch(_0xf037xe){case _0x9ea7[58]:if(_0xf037xf=== _0x9ea7[77]){_0xf037x25= _0x9ea7[80]}else {if(_0xf037xf=== _0x9ea7[42]){_0xf037x25= _0x9ea7[81]}};break;default:_0xf037x25= _0x9ea7[81];logger[_0x9ea7[18]](_0x9ea7[59],_0xf037xe)}};return _0xf037x25}function handleContact(_0xf037x13,_0xf037xe,_0xf037x28,_0xf037xf){return function(_0xf037x10){if(_0xf037x10[_0x9ea7[65]]> 0){logger[_0x9ea7[14]](_0x9ea7[82],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));_0xf037x13[_0x9ea7[83]]= _0xf037x10[0];return _0xf037x13[_0x9ea7[83]]};logger[_0x9ea7[14]](_0x9ea7[84],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));return}}function searchLead(_0xf037x13,_0xf037xe,_0xf037x28,_0xf037xf){return function(_0xf037x10){if(!_0xf037x10){logger[_0x9ea7[14]](_0x9ea7[85],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));var _0xf037x30={};_0xf037x30[getEndUserSearchQueryFromChannel(_0xf037xe)]= getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf));return _0xf037x13[_0x9ea7[22]][_0x9ea7[55]](_0x9ea7[86])[_0x9ea7[21]](_0xf037x30,{Id:1,Name:1})[_0x9ea7[54]]()};return}}function handleLead(_0xf037x13,_0xf037xe,_0xf037x28,_0xf037xf){return function(_0xf037x10){if(_0xf037x10&& _0xf037x10[_0x9ea7[65]]> 0){logger[_0x9ea7[14]](_0x9ea7[87],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));_0xf037x13[_0x9ea7[83]]= _0xf037x10[0];return _0xf037x13[_0x9ea7[83]]};return}}function leadCreation(_0xf037x13,_0xf037xe,_0xf037x28,_0xf037xf){return function(_0xf037x10){if(_0xf037x10|| _0xf037x13[_0x9ea7[83]]){return};logger[_0x9ea7[14]](_0x9ea7[88],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));return _0xf037x13[_0x9ea7[22]][_0x9ea7[55]](_0x9ea7[86])[_0x9ea7[89]](getJsonForEndUserCreation(_0xf037xe,_0xf037x28,_0xf037xf))}}function getJsonForEndUserCreation(_0xf037xe,_0xf037x10,_0xf037xf){var _0xf037x39={Company:_0x9ea7[90]};switch(_0xf037xe){case _0x9ea7[58]:if(_0xf037xf=== _0x9ea7[42]){if(isValidName(_0xf037x10[_0x9ea7[81]])){_0xf037x39[_0x9ea7[91]]= getValueFromPropertyName(_0xf037x10,getEndUserNamePropertyFromChannel(_0xf037xe,_0xf037xf))}else {_0xf037x39[_0x9ea7[91]]= util[_0x9ea7[63]](_0x9ea7[92],getValueFromPropertyName(_0xf037x10,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)))}}else {if(_0xf037xf=== _0x9ea7[77]){if(isValidName(_0xf037x10[_0x9ea7[80]])){_0xf037x39[_0x9ea7[91]]= getValueFromPropertyName(_0xf037x10,getEndUserNamePropertyFromChannel(_0xf037xe,_0xf037xf))}else {_0xf037x39[_0x9ea7[91]]= util[_0x9ea7[63]](_0x9ea7[92],getValueFromPropertyName(_0xf037x10,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)))}}};_0xf037x39[_0x9ea7[76]]= getValueFromPropertyName(_0xf037x10,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf));break;default:logger[_0x9ea7[18]](_0x9ea7[59],_0xf037xe)};return _0xf037x39}function isValidName(_0xf037x3b){return _0xf037x3b&& _0xf037x3b!== _0x9ea7[93]}function handleLeadCreation(_0xf037x13,_0xf037xe,_0xf037x28,_0xf037xf){return function(_0xf037x10){if(!_0xf037x10){return};if(_0xf037x10&& _0xf037x10[_0x9ea7[94]]){logger[_0x9ea7[14]](_0x9ea7[95],getValueFromPropertyName(_0xf037x28,getEndUserSearchPropertyFromChannel(_0xf037xe,_0xf037xf)));_0xf037x13[_0x9ea7[83]]= {Id:_0xf037x10[_0x9ea7[49]]}};return}}function taskCreation(_0xf037x13,_0xf037x28,_0xf037x11){return function(){var _0xf037x3e={WhoId:_0xf037x13[_0x9ea7[83]][_0x9ea7[96]],OwnerId:_0xf037x13[_0x9ea7[39]][_0x9ea7[96]],ActivityDate:moment[_0x9ea7[97]](),IsReminderSet:false,IsRecurrence:false,Subject:createSubjectFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11),Description:createDescriptionFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11)};var _0xf037x3f=createCustomFieldsFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11);if(_0xf037x3f[_0x9ea7[65]]> 0){_[_0x9ea7[99]](_0xf037x3f,function(_0xf037x40){_0xf037x3e[_0xf037x40[_0x9ea7[49]]]= _0xf037x40[_0x9ea7[98]]})};return _0xf037x13[_0x9ea7[22]][_0x9ea7[55]](_0x9ea7[100])[_0x9ea7[89]](_0xf037x3e)}}function createSubjectFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11){var _0xf037x42=_0x9ea7[56];var _0xf037x43=[];if(_0xf037x13[_0x9ea7[31]][_0x9ea7[101]][_0x9ea7[65]]> 0){var _0xf037x44=_[_0x9ea7[102]](_0xf037x13[_0x9ea7[31]].Subject,[_0x9ea7[49]]);_[_0x9ea7[99]](_0xf037x44,function(_0xf037x45){if(_0xf037x45[_0x9ea7[103]]=== _0x9ea7[104]){_0xf037x43[_0x9ea7[106]](_0xf037x45[_0x9ea7[105]])}else {if(_0xf037x45[_0x9ea7[103]]=== _0x9ea7[107]&& _0xf037x45[_0x9ea7[108]]){var _0xf037x46=getValueFromPropertyName(_0xf037x28,_0xf037x45[_0x9ea7[108]],_0xf037x13);if(_0xf037x46){_0xf037x43[_0x9ea7[106]](_0xf037x46.toString())}}else {if(_0xf037x45[_0x9ea7[103]]=== _0x9ea7[109]&& _0xf037x45[_0x9ea7[110]]&& _0xf037x45[_0x9ea7[110]][_0x9ea7[43]]){_0xf037x11[_0xf037x45[_0x9ea7[110]][_0x9ea7[43]]]&& _0xf037x43[_0x9ea7[106]](_0xf037x11[_0xf037x45[_0x9ea7[110]][_0x9ea7[43]]].toString())}}}});_0xf037x42= _0xf037x43[_0x9ea7[112]](_0x9ea7[111])};return _0xf037x42}function createDescriptionFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11){var _0xf037x48=_0x9ea7[56];var _0xf037x43=[];if(_0xf037x13[_0x9ea7[31]][_0x9ea7[113]][_0x9ea7[65]]> 0){var _0xf037x49=_[_0x9ea7[102]](_0xf037x13[_0x9ea7[31]].Description,[_0x9ea7[49]]);_[_0x9ea7[99]](_0xf037x49,function(_0xf037x45){if(_0xf037x45[_0x9ea7[103]]=== _0x9ea7[104]){_0xf037x43[_0x9ea7[106]](_0xf037x45[_0x9ea7[105]])}else {if(_0xf037x45[_0x9ea7[103]]=== _0x9ea7[114]){if(_0xf037x45[_0x9ea7[115]]=== _0x9ea7[104]&& _0xf037x45[_0x9ea7[116]]){_0xf037x43[_0x9ea7[106]](util[_0x9ea7[63]](_0x9ea7[117],_0xf037x45[_0x9ea7[116]],_0xf037x45[_0x9ea7[118]]))}else {if(_0xf037x45[_0x9ea7[115]]=== _0x9ea7[107]&& _0xf037x45[_0x9ea7[108]]&& _0xf037x45[_0x9ea7[116]]){var _0xf037x46=getValueFromPropertyName(_0xf037x28,_0xf037x45[_0x9ea7[108]],_0xf037x13);if(_0xf037x46){_0xf037x43[_0x9ea7[106]](util[_0x9ea7[63]](_0x9ea7[117],_0xf037x45[_0x9ea7[116]],_0xf037x46.toString()))}}else {if(_0xf037x45[_0x9ea7[115]]=== _0x9ea7[109]&& _0xf037x45[_0x9ea7[110]]&& _0xf037x45[_0x9ea7[110]][_0x9ea7[43]]&& _0xf037x45[_0x9ea7[116]]){_0xf037x11[_0xf037x45[_0x9ea7[110]][_0x9ea7[43]]]&& _0xf037x43[_0x9ea7[106]](util[_0x9ea7[63]](_0x9ea7[117],_0xf037x45[_0x9ea7[116]],_0xf037x11[_0xf037x45[_0x9ea7[110]][_0x9ea7[43]]]))}}}}}});_0xf037x48= _0xf037x43[_0x9ea7[112]](_0x9ea7[119])};return _0xf037x48}function createCustomFieldsFromConfiguration(_0xf037x13,_0xf037x28,_0xf037x11){var _0xf037x4b=[];var _0xf037x4c=[];if(_0xf037x13[_0x9ea7[31]][_0x9ea7[120]][_0x9ea7[65]]> 0){_0xf037x4b= _0xf037x13[_0x9ea7[31]][_0x9ea7[120]];_[_0x9ea7[99]](_0xf037x4b,function(_0xf037x40){if(_0xf037x40[_0x9ea7[103]]=== _0x9ea7[104]&& _0xf037x40[_0x9ea7[121]]){_0xf037x4c[_0x9ea7[106]]({id:_0xf037x40[_0x9ea7[121]],value:_0xf037x40[_0x9ea7[105]]})}else {if(_0xf037x40[_0x9ea7[103]]=== _0x9ea7[107]&& _0xf037x40[_0x9ea7[108]]&& _0xf037x40[_0x9ea7[121]]){var _0xf037x46=getValueFromPropertyName(_0xf037x28,_0xf037x40[_0x9ea7[108]],_0xf037x13);if(_0xf037x46){_0xf037x4c[_0x9ea7[106]]({id:_0xf037x40[_0x9ea7[121]],value:_0xf037x46.toString()})}}else {if(_0xf037x40[_0x9ea7[103]]=== _0x9ea7[109]&& _0xf037x40[_0x9ea7[121]]&& _0xf037x40[_0x9ea7[110]]&& _0xf037x40[_0x9ea7[110]][_0x9ea7[43]]){_0xf037x11[_0xf037x40[_0x9ea7[110]][_0x9ea7[43]]]&& _0xf037x4c[_0x9ea7[106]]({id:_0xf037x40[_0x9ea7[121]],value:_0xf037x11[_0xf037x40[_0x9ea7[110]][_0x9ea7[43]]].toString()})}}}})};return _0xf037x4c}function handleTaskDisplay(_0xf037x13){return function(_0xf037x10){if(_0xf037x10&& _0xf037x10[_0x9ea7[94]]){logger[_0x9ea7[14]](_0x9ea7[122],_0xf037x10[_0x9ea7[49]]);_0xf037x13[_0x9ea7[123]]= _0xf037x10[_0x9ea7[49]];return};return}}function handleReportIntegration(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xc,_0xf037x12,_0xf037xf){return function(){delete _0xf037x10[_0x9ea7[49]];delete _0xf037x10[_0x9ea7[124]];delete _0xf037x10[_0x9ea7[125]];_0xf037x10[_0x9ea7[126]]= _0x9ea7[127];_0xf037x10[_0x9ea7[128]]= _0xf037xe;_0xf037x10[_0x9ea7[129]]= _0x9ea7[94];_0xf037x10[_0x9ea7[130]]= _0xf037x13[_0x9ea7[123]];_0xf037x10[_0x9ea7[131]]= _0xf037xc;_0xf037x10[_0x9ea7[132]]= _0xf037xf;_0xf037x10[_0x9ea7[133]]= util[_0x9ea7[63]](_0x9ea7[134],_0xf037x13[_0x9ea7[22]][_0x9ea7[135]],_0xf037x13[_0x9ea7[123]]);_0xf037x10[_0x9ea7[136]]= _0xf037x13[_0x9ea7[31]][_0x9ea7[24]][_0x9ea7[136]]?_0xf037x13[_0x9ea7[31]][_0x9ea7[24]][_0x9ea7[136]]:_0x9ea7[137];_0xf037x12[_0x9ea7[139]](_0x9ea7[138],_0xf037x10);delete _0xf037x10[_0x9ea7[136]];return ReportIntegration[_0x9ea7[89]](_0xf037x10)}}function handleEnd(_0xf037x13,_0xf037x10,_0xf037xe){return function(){logger[_0x9ea7[14]](util[_0x9ea7[63]](_0x9ea7[140],_0xf037x13[_0x9ea7[123]],_0xf037x13[_0x9ea7[39]].Id));_0xf037x13= undefined;return}}function handleError(_0xf037x13,_0xf037xe,_0xf037x10,_0xf037xc){return function(_0xf037x51){logger[_0x9ea7[18]](_0x9ea7[141]);logger[_0x9ea7[18]](_0x9ea7[142],_0xf037x51[_0x9ea7[143]]);logger[_0x9ea7[18]](_0x9ea7[144],_0xf037x51[_0x9ea7[145]]);_0xf037x13= undefined;delete _0xf037x10[_0x9ea7[49]];delete _0xf037x10[_0x9ea7[124]];delete _0xf037x10[_0x9ea7[125]];_0xf037x10[_0x9ea7[126]]= _0x9ea7[127];_0xf037x10[_0x9ea7[128]]= _0xf037xe;_0xf037x10[_0x9ea7[129]]= _0x9ea7[146];_0xf037x10[_0x9ea7[131]]= _0xf037xc;ReportIntegration[_0x9ea7[89]](_0xf037x10)[_0x9ea7[20]](function(){return})[_0x9ea7[19]](function(_0xf037x51){logger[_0x9ea7[18]](_0x9ea7[147]);return})}}function stripTrailingSlash(_0xf037x53){if(_0xf037x53[_0x9ea7[148]](-1) === _0x9ea7[149]){return _0xf037x53[_0x9ea7[148]](0,_0xf037x53[_0x9ea7[65]]- 1)};return _0xf037x53}module[_0x9ea7[150]]= Salesforce