Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / services / ami / trigger / integration / salesforce.js
index b889a86..1a87f6e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8998=['jsforce','ioredis','./util','../../../../config/environment','../../../../config/logger','salesforce','redis','defaults','localhost','socket.io-emitter','emit','assign','getString','Subjects','ticketType','Task','utc','IsRecurrence','endUserType','contact','lead','WhoId','account','WhatId','Case','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','create','validateEmail','find','execute','length','Email','Name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','identity','then','resolve','user_id','display_name','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','additionalSearchLead','Lead','account_contact_lead','additionalSearchAccount','$or','Contact','Account','first','Phone','attributes','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','moduleCreate','<unknown>','format','Caller\x20-\x20%s','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','LastName','No\x20Company','forEach','includes','picklist','idField','content','toString','type','variableName','Variable','name','password','securityToken','Connection','remoteUri','https://login.salesforce.com','clientId','clientSecret','login','username','Connection\x20established.','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','calleridnum','queue','[QUEUE]\x20Ticket\x20%s\x20created','[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','user:%s','trigger:salesforce:display','newTab','trigger:browser:url','%s/%s/e','instanceUrl','error','catch','outbound','recordingFormat','none','destcalleridnum','Fields','[OUTBOUND]','Salesforce\x20account\x20type\x20not\x20recognized','toUpperCase','lastevent','lodash','moment','bluebird','md5'];(function(_0x37eb28,_0x57b951){var _0x3a11c3=function(_0x12f6d5){while(--_0x12f6d5){_0x37eb28['push'](_0x37eb28['shift']());}};_0x3a11c3(++_0x57b951);}(_0x8998,0x79));var _0x8899=function(_0x2c369d,_0x4a9c03){_0x2c369d=_0x2c369d-0x0;var _0x348412=_0x8998[_0x2c369d];return _0x348412;};'use strict';var _=require(_0x8899('0x0'));var rp=require('request-promise');var moment=require(_0x8899('0x1'));var BPromise=require(_0x8899('0x2'));var md5=require(_0x8899('0x3'));var jsforce=require(_0x8899('0x4'));var util=require('util');var Redis=require(_0x8899('0x5'));var intUtil=require(_0x8899('0x6'));var config=require(_0x8899('0x7'));var logger=require(_0x8899('0x8'))(_0x8899('0x9'));config[_0x8899('0xa')]=_[_0x8899('0xb')](config[_0x8899('0xa')],{'host':_0x8899('0xc'),'port':0x18eb});var io=require(_0x8899('0xd'))(new Redis(config[_0x8899('0xa')]));function emit(_0xe941,_0x2b7fe7,_0x33087e){io['to'](_0xe941)[_0x8899('0xe')](_0x2b7fe7,_0x33087e);}function getTicket(_0x10062e,_0x2ed536,_0x3fed32,_0x212e87,_0x11f2e7,_0x491f69,_0x268c20,_0xca5ad1){var _0x4f20e6=Object[_0x8899('0xf')]({},{'OwnerId':_0x2ed536['id'],'Subject':intUtil[_0x8899('0x10')](_0x212e87[_0x8899('0x11')],_0x11f2e7,'\x20'),'Description':intUtil[_0x8899('0x10')](_0x212e87['Descriptions'],_0x11f2e7,'\x0a')},getCustomFields(_0x491f69,_0x11f2e7));if(_0x3fed32){if(_0x212e87[_0x8899('0x12')]===_0x8899('0x13')){_0x4f20e6['ActivityDate']=moment[_0x8899('0x14')]();_0x4f20e6['IsReminderSet']=![];_0x4f20e6[_0x8899('0x15')]=![];if(_0x3fed32[_0x8899('0x16')]===_0x8899('0x17')||_0x3fed32[_0x8899('0x16')]===_0x8899('0x18')){_0x4f20e6[_0x8899('0x19')]=_0x3fed32['id'];}else if(_0x3fed32['endUserType']===_0x8899('0x1a')){_0x4f20e6[_0x8899('0x1b')]=_0x3fed32['id'];}}else if(_0x212e87[_0x8899('0x12')]===_0x8899('0x1c')){if(_0x3fed32[_0x8899('0x16')]===_0x8899('0x17')){_0x4f20e6[_0x8899('0x1d')]=_0x3fed32['id'];}else if(_0x3fed32[_0x8899('0x16')]===_0x8899('0x1a')){_0x4f20e6[_0x8899('0x1e')]=_0x3fed32['id'];}else if(_0x3fed32[_0x8899('0x16')]===_0x8899('0x18')&&_0x212e87[_0x8899('0x1f')]){_0x4f20e6[_0x212e87[_0x8899('0x1f')]]=_0x3fed32['id'];}else{logger[_0x8899('0x20')](_0x8899('0x21'));}}}return _0x268c20[_0x8899('0x22')](_0x212e87['ticketType'])[_0x8899('0x23')](_0x4f20e6);}function getUser(_0xf87975,_0x1b7206,_0xcf2465){if(!_['isNil'](_0x1b7206)&&intUtil[_0x8899('0x24')](_0x1b7206)){var _0x269d1e={'Email':_0x1b7206};var _0x2b53b9={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0xcf2465[_0x8899('0x22')]('User')[_0x8899('0x25')](_0x269d1e,_0x2b53b9)[_0x8899('0x26')]()['then'](function(_0x34497e){if(_0x34497e[_0x8899('0x27')]){var _0x33942c=_['find'](_0x34497e,function(_0x56fa1d){return _0x56fa1d[_0x8899('0x28')]===_0x1b7206;});if(_0x33942c){logger['info']('Agent\x20%s\x20found.',_0x1b7206);return BPromise['resolve']({'id':_0x33942c['Id'],'name':_0x33942c[_0x8899('0x29')]});}}else{logger[_0x8899('0x20')](_0x8899('0x2a'),_0x1b7206);return _0xcf2465[_0x8899('0x2b')]()[_0x8899('0x2c')](function(_0x4c5bd8){return BPromise[_0x8899('0x2d')]({'id':_0x4c5bd8[_0x8899('0x2e')],'name':_0x4c5bd8[_0x8899('0x2f')]});});}});}else{logger[_0x8899('0x20')](_0x8899('0x2a'),_0x1b7206);return _0xcf2465[_0x8899('0x2b')]()['then'](function(_0x3f03be){return BPromise[_0x8899('0x2d')]({'id':_0x3f03be[_0x8899('0x2e')],'name':_0x3f03be['display_name']});});}}function getEndUser(_0x5bab06,_0x17122b,_0x216359,_0x195472,_0x29c037){var _0x1d51d8={'$or':{'Phone':_0x195472}};var _0x5df7f2={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x8899('0x2d')]()[_0x8899('0x2c')](function(){logger[_0x8899('0x20')](_0x8899('0x30'),_0x195472,_0x17122b[_0x8899('0x31')]);switch(_0x17122b[_0x8899('0x31')]){case _0x8899('0x32'):var _0x1af91f=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x34')]){var _0x167594={};_0x167594[_0x17122b[_0x8899('0x34')]]=_0x195472;_[_0x8899('0x35')](_0x1af91f['$or'],_0x167594);}return _0x29c037[_0x8899('0x22')]('Contact')['find'](_0x1af91f,_0x5df7f2)['execute']()[_0x8899('0x2c')](function(_0x117c2f){if(_0x117c2f&&_0x117c2f['length']){return _0x117c2f;}else{var _0x3fd9d=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b['additionalSearchLead']){var _0x46c87e={};_0x46c87e[_0x17122b[_0x8899('0x36')]]=_0x195472;_[_0x8899('0x35')](_0x3fd9d['$or'],_0x46c87e);}return _0x29c037[_0x8899('0x22')](_0x8899('0x37'))[_0x8899('0x25')](_0x3fd9d,_0x5df7f2);}});case _0x8899('0x38'):var _0x3a4fe0=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x39')]){var _0x167594={};_0x167594[_0x17122b['additionalSearchAccount']]=_0x195472;_[_0x8899('0x35')](_0x3a4fe0[_0x8899('0x3a')],_0x167594);}return _0x29c037[_0x8899('0x22')]('Account')[_0x8899('0x25')](_0x3a4fe0,_0x5df7f2)[_0x8899('0x26')]()[_0x8899('0x2c')](function(_0x492486){if(_0x492486&&_0x492486[_0x8899('0x27')]){return _0x492486;}else{var _0x512332=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x34')]){var _0xb6bac5={};_0xb6bac5[_0x17122b[_0x8899('0x34')]]=_0x195472;_['merge'](_0x512332[_0x8899('0x3a')],_0xb6bac5);}return _0x29c037[_0x8899('0x22')](_0x8899('0x3b'))[_0x8899('0x25')](_0x512332,_0x5df7f2)[_0x8899('0x2c')](function(_0x5c463f){if(_0x5c463f&&_0x5c463f['length']){return _0x5c463f;}else{var _0x3d8149=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x36')]){var _0xe2211d={};_0xe2211d[_0x17122b[_0x8899('0x36')]]=_0x195472;_['merge'](_0x3d8149['$or'],_0xe2211d);}return _0x29c037['sobject'](_0x8899('0x37'))[_0x8899('0x25')](_0x3d8149,_0x5df7f2);}});}});case _0x8899('0x17'):var _0x1af91f=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x34')]){var _0x167594={};_0x167594[_0x17122b[_0x8899('0x34')]]=_0x195472;_[_0x8899('0x35')](_0x1af91f[_0x8899('0x3a')],_0x167594);}return _0x29c037[_0x8899('0x22')](_0x8899('0x3b'))['find'](_0x1af91f,_0x5df7f2)['execute']();case _0x8899('0x18'):var _0x40b0ec=_['cloneDeep'](_0x1d51d8);if(_0x17122b[_0x8899('0x36')]){var _0x167594={};_0x167594[_0x17122b[_0x8899('0x36')]]=_0x195472;_[_0x8899('0x35')](_0x40b0ec[_0x8899('0x3a')],_0x167594);}return _0x29c037[_0x8899('0x22')]('Lead')[_0x8899('0x25')](_0x40b0ec,_0x5df7f2);case _0x8899('0x1a'):var _0x3a4fe0=_[_0x8899('0x33')](_0x1d51d8);if(_0x17122b[_0x8899('0x39')]){var _0x167594={};_0x167594[_0x17122b[_0x8899('0x39')]]=_0x195472;_['merge'](_0x3a4fe0[_0x8899('0x3a')],_0x167594);}return _0x29c037[_0x8899('0x22')](_0x8899('0x3c'))['find'](_0x3a4fe0,_0x5df7f2);default:return null;}})[_0x8899('0x2c')](function(_0x5d86be){if(_0x5d86be&&_0x5d86be[_0x8899('0x27')]){var _0x267c06=_[_0x8899('0x3d')](_0x5d86be);if(_0x267c06){return BPromise['resolve']({'id':_0x267c06['Id'],'name':_0x267c06['Name'],'phone':_0x267c06[_0x8899('0x3e')],'endUserType':_0x267c06[_0x8899('0x3f')]['type'][_0x8899('0x40')]()});}}})['then'](function(_0x151079){if(_0x151079){logger[_0x8899('0x20')](_0x8899('0x41'),_0x151079['endUserType'],_0x195472);return BPromise[_0x8899('0x2d')](_0x151079);}else{logger['info']('Enduser\x20with\x20phone\x20%s\x20not\x20found',_0x195472);var _0x508d44={'Phone':_0x195472};if(_0x17122b[_0x8899('0x42')]){if(_0x17122b[_0x8899('0x42')]===_0x8899('0x17')){logger[_0x8899('0x20')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x195472,_0x17122b[_0x8899('0x42')]);_0x508d44['LastName']=_0x216359!==_0x8899('0x43')?_0x216359:util[_0x8899('0x44')](_0x8899('0x45'),_0x195472);}else if(_0x17122b[_0x8899('0x42')]===_0x8899('0x18')){logger['info'](_0x8899('0x46'),_0x195472,_0x17122b['moduleCreate']);_0x508d44[_0x8899('0x47')]=_0x216359!=='<unknown>'?_0x216359:util[_0x8899('0x44')](_0x8899('0x45'),_0x195472);_0x508d44['Company']=_0x8899('0x48');}else if(_0x17122b[_0x8899('0x42')]===_0x8899('0x1a')){logger[_0x8899('0x20')](_0x8899('0x46'),_0x195472,_0x17122b[_0x8899('0x42')]);_0x508d44[_0x8899('0x29')]=_0x216359!==_0x8899('0x43')?_0x216359:util[_0x8899('0x44')](_0x8899('0x45'),_0x195472);}else{return null;}}return _0x29c037[_0x8899('0x22')](_['upperFirst'](_0x17122b[_0x8899('0x42')]))['create'](_0x508d44)[_0x8899('0x2c')](function(_0x23411d){return BPromise[_0x8899('0x2d')]({'id':_0x23411d['id'],'endUserType':_0x17122b[_0x8899('0x42')]});});}});}function getCustomFields(_0x2e7528,_0x586b74){var _0x388b93={};if(_0x2e7528['length']>0x0){_[_0x8899('0x49')](_0x2e7528,function(_0x3ffa9e){if(_[_0x8899('0x4a')](['string',_0x8899('0x4b')],_0x3ffa9e['type'])&&_0x3ffa9e[_0x8899('0x4c')]){_0x388b93[_0x3ffa9e[_0x8899('0x4c')]]=_0x3ffa9e[_0x8899('0x4d')][_0x8899('0x4e')]();}else if(_0x3ffa9e[_0x8899('0x4f')]==='variable'&&_0x3ffa9e['variableName']&&_0x3ffa9e[_0x8899('0x4c')]){_0x586b74[_0x3ffa9e['variableName']]&&(_0x388b93[_0x3ffa9e[_0x8899('0x4c')]]=_0x586b74[_0x3ffa9e[_0x8899('0x50')]]['toString']());}else if(_0x3ffa9e['type']==='customVariable'&&_0x3ffa9e['Variable']&&_0x3ffa9e[_0x8899('0x51')]['name']&&_0x3ffa9e[_0x8899('0x4c')]){_0x586b74[_0x3ffa9e[_0x8899('0x51')]['name'][_0x8899('0x40')]()]&&(_0x388b93[_0x3ffa9e[_0x8899('0x4c')]]=_0x586b74[_0x3ffa9e[_0x8899('0x51')][_0x8899('0x52')][_0x8899('0x40')]()][_0x8899('0x4e')]());}});}return _0x388b93;}function getConnection(_0x56a001){var _0x55abd5=_0x56a001[_0x8899('0x53')]['concat'](_0x56a001[_0x8899('0x54')]);var _0x998fac=new jsforce[(_0x8899('0x55'))]({'oauth2':{'loginUrl':_0x56a001[_0x8899('0x56')]||_0x8899('0x57'),'clientId':_0x56a001[_0x8899('0x58')],'clientSecret':_0x56a001[_0x8899('0x59')]}});return _0x998fac[_0x8899('0x5a')](_0x56a001[_0x8899('0x5b')],_0x55abd5)[_0x8899('0x2c')](function(){logger[_0x8899('0x20')](_0x8899('0x5c'));return _0x998fac;});}exports['queue']=function(_0x2854dd,_0xda6da,_0x467637,_0x1df1d1,_0x1fafc8,_0x3fa5e4){var _0x4c8998,_0x3c19bf,_0x41fb89,_0x2ea3;_0x3fa5e4[_0x8899('0x5d')]=intUtil['stripTrailingSlash'](_0x3fa5e4['serverUrl']);_0x3fa5e4['remoteUri']=intUtil[_0x8899('0x5e')](_0x3fa5e4[_0x8899('0x56')]);if(_0x1fafc8&&_0x1fafc8[_0x8899('0x5f')]){logger[_0x8899('0x20')](_0x8899('0x60'),_0x8899('0x61'));_0xda6da[_0x8899('0x62')]=util['format'](_0x8899('0x63'),_0x3fa5e4[_0x8899('0x5d')],_0xda6da['uniqueid'],md5(_0xda6da[_0x8899('0x64')]));}else{_0xda6da[_0x8899('0x62')]='';}return getConnection(_0x3fa5e4)[_0x8899('0x2c')](function(_0x3323bc){_0x2ea3=_0x3323bc;return getUser(_0x3fa5e4,_0x1df1d1[_0x8899('0x65')],_0x2ea3);})['then'](function(_0x23820b){_0x4c8998=_0x23820b;return getEndUser(_0x3fa5e4,_0x467637,_0xda6da[_0x8899('0x66')],_0xda6da[_0x8899('0x67')],_0x2ea3);})[_0x8899('0x2c')](function(_0x524a6c){_0x3c19bf=_0x524a6c;return getTicket(_0x3fa5e4,_0x4c8998,_0x3c19bf,_0x467637,_0xda6da,_0x467637['Fields'],_0x2ea3,_0x8899('0x68'));})[_0x8899('0x2c')](function(_0x5197dc){_0x41fb89=_0x5197dc;logger[_0x8899('0x20')](_0x8899('0x69'),_0x41fb89['id']);logger[_0x8899('0x20')](_0x8899('0x6a'),_0x41fb89['id'],_0x1df1d1['name'],_0x3fa5e4[_0x8899('0x4f')]);switch(_0x3fa5e4[_0x8899('0x4f')]){case _0x8899('0x6b'):emit(util[_0x8899('0x44')](_0x8899('0x6c'),_0x1df1d1['name']),_0x8899('0x6d'),{'recordId':_0x41fb89['id']});break;case _0x8899('0x6e'):emit(util['format'](_0x8899('0x6c'),_0x1df1d1[_0x8899('0x52')]),_0x8899('0x6f'),{'uri':util[_0x8899('0x44')](_0x8899('0x70'),_0x2ea3[_0x8899('0x71')],_0x41fb89['id'])});break;default:logger[_0x8899('0x72')]('[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.');}})[_0x8899('0x73')](function(_0x3044b2){logger['error'](_0x8899('0x60'),_0x3044b2);});};exports[_0x8899('0x74')]=function(_0x399275,_0x1c1749,_0x4a8aff,_0x208162,_0x22e4c7,_0x492761,_0x9bc854){var _0x1f2b78,_0x5cc4e4,_0x52f070,_0x2195e6;_0x492761[_0x8899('0x5d')]=intUtil[_0x8899('0x5e')](_0x492761['serverUrl']);_0x492761['remoteUri']=intUtil['stripTrailingSlash'](_0x492761['remoteUri']);if(_0x9bc854&&_0x9bc854['recordingFormat']&&_0x9bc854[_0x8899('0x75')]!==_0x8899('0x76')){logger[_0x8899('0x20')]('[OUTBOUND]','Recording\x20is\x20enabled!');_0x1c1749[_0x8899('0x62')]=util[_0x8899('0x44')](_0x8899('0x63'),_0x492761['serverUrl'],_0x1c1749[_0x8899('0x64')],md5(_0x1c1749[_0x8899('0x64')]));}return getConnection(_0x492761)[_0x8899('0x2c')](function(_0x374244){_0x2195e6=_0x374244;return getUser(_0x492761,_0x208162['email'],_0x2195e6);})[_0x8899('0x2c')](function(_0x13d31b){_0x1f2b78=_0x13d31b;return getEndUser(_0x492761,_0x4a8aff,_0x1c1749['destcalleridname'],_0x1c1749[_0x8899('0x77')],_0x2195e6);})[_0x8899('0x2c')](function(_0x5c3581){_0x5cc4e4=_0x5c3581;return getTicket(_0x492761,_0x1f2b78,_0x5cc4e4,_0x4a8aff,_0x1c1749,_0x4a8aff[_0x8899('0x78')],_0x2195e6,_0x8899('0x74'));})[_0x8899('0x2c')](function(_0x5cc944){_0x52f070=_0x5cc944;logger[_0x8899('0x20')]('[OUTBOUND]\x20Ticket\x20%s\x20created.',_0x52f070['id']);logger[_0x8899('0x20')]('[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0x52f070['id'],_0x208162[_0x8899('0x52')],_0x492761['type']);switch(_0x492761[_0x8899('0x4f')]){case _0x8899('0x6b'):emit(util[_0x8899('0x44')](_0x8899('0x6c'),_0x208162[_0x8899('0x52')]),_0x8899('0x6d'),{'recordId':_0x52f070['id']});break;case _0x8899('0x6e'):emit(util[_0x8899('0x44')](_0x8899('0x6c'),_0x208162[_0x8899('0x52')]),_0x8899('0x6f'),{'uri':util['format'](_0x8899('0x70'),_0x2195e6[_0x8899('0x71')],_0x52f070['id'])});break;default:logger[_0x8899('0x72')](_0x8899('0x79'),_0x8899('0x7a'));}})[_0x8899('0x73')](function(_0x5d7ecc){logger[_0x8899('0x72')](_0x8899('0x79'),_0x5d7ecc);});};exports['unmanaged']=function(_0x755095,_0x28b40e,_0x5449ef,_0x5957e7,_0x460f91,_0x31e605){var _0x3c9b4a,_0x2d00a7,_0x2b3f7b,_0x20b67a;_0x31e605[_0x8899('0x5d')]=intUtil[_0x8899('0x5e')](_0x31e605[_0x8899('0x5d')]);_0x31e605[_0x8899('0x56')]=intUtil[_0x8899('0x5e')](_0x31e605[_0x8899('0x56')]);if(_0x460f91&&_0x460f91[_0x8899('0x5f')]){logger[_0x8899('0x20')]('['+_0x28b40e['lastevent'][_0x8899('0x7b')]()+']',_0x8899('0x61'));_0x28b40e[_0x8899('0x62')]=util['format'](_0x8899('0x63'),_0x31e605[_0x8899('0x5d')],_0x28b40e['uniqueid'],md5(_0x28b40e[_0x8899('0x64')]));}else{_0x28b40e[_0x8899('0x62')]='';}return getConnection(_0x31e605)[_0x8899('0x2c')](function(_0x1b7ea5){_0x20b67a=_0x1b7ea5;if(!_['isNil'](_0x5957e7)){return getUser(_0x31e605,_0x5957e7['name'],_0x20b67a);}else{return getUser(_0x31e605,null,_0x20b67a);}})[_0x8899('0x2c')](function(_0xebd821){_0x3c9b4a=_0xebd821;return getEndUser(_0x31e605,_0x5449ef,_0x28b40e['calleridname'],_0x28b40e['calleridnum'],_0x20b67a);})['then'](function(_0xd08c5d){_0x2d00a7=_0xd08c5d;return getTicket(_0x31e605,_0x3c9b4a,_0x2d00a7,_0x5449ef,_0x28b40e,_0x5449ef[_0x8899('0x78')],_0x20b67a);})[_0x8899('0x2c')](function(_0x3ae5b4){_0x2b3f7b=_0x3ae5b4;logger[_0x8899('0x20')]('['+_0x28b40e['lastevent']['toUpperCase']()+']\x20Ticket\x20%s\x20created.',_0x2b3f7b['id']);logger[_0x8899('0x20')]('['+_0x28b40e[_0x8899('0x7c')][_0x8899('0x7b')]()+']\x20Integration\x20account\x20type\x20%s.',_0x31e605['type']);})['catch'](function(_0x455a69){logger['error']('['+_0x28b40e[_0x8899('0x7c')][_0x8899('0x7b')]()+']',_0x455a69);});};
\ No newline at end of file
+var _0x3b00=['[OUTBOUND]','destcalleridname','destcalleridnum','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','Salesforce\x20account\x20type\x20not\x20recognized','unmanaged','lastevent','isNil','Fields','toUpperCase',']\x20Ticket\x20%s\x20created.','lodash','bluebird','md5','util','./util','../../../../config/environment','../../../../config/logger','salesforce','defaults','redis','localhost','socket.io-emitter','assign','getString','Subjects','Descriptions','ticketType','ActivityDate','utc','endUserType','contact','lead','WhoId','account','Case','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','validateEmail','find','execute','length','Agent\x20%s\x20found.','Name','resolve','user_id','display_name','identity','then','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','additionalSearchLead','Lead','account_contact_lead','additionalSearchAccount','Account','Contact','first','attributes','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','LastName','<unknown>','format','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','Caller\x20-\x20%s','No\x20Company','upperFirst','includes','picklist','type','idField','content','variable','variableName','toString','Variable','name','securityToken','Connection','https://login.salesforce.com','clientId','clientSecret','login','username','Connection\x20established.','queue','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridnum','[QUEUE]\x20Ticket\x20%s\x20created','[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','user:%s','trigger:salesforce:display','newTab','trigger:browser:url','%s/%s/e','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','remoteUri','recordingFormat','none'];(function(_0x324dc5,_0x4bb728){var _0x302b9f=function(_0x594edd){while(--_0x594edd){_0x324dc5['push'](_0x324dc5['shift']());}};_0x302b9f(++_0x4bb728);}(_0x3b00,0x179));var _0x03b0=function(_0x355c98,_0x3d2d54){_0x355c98=_0x355c98-0x0;var _0x2b369c=_0x3b00[_0x355c98];return _0x2b369c;};'use strict';var _=require(_0x03b0('0x0'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x03b0('0x1'));var md5=require(_0x03b0('0x2'));var jsforce=require('jsforce');var util=require(_0x03b0('0x3'));var Redis=require('ioredis');var intUtil=require(_0x03b0('0x4'));var config=require(_0x03b0('0x5'));var logger=require(_0x03b0('0x6'))(_0x03b0('0x7'));config['redis']=_[_0x03b0('0x8')](config[_0x03b0('0x9')],{'host':_0x03b0('0xa'),'port':0x18eb});var io=require(_0x03b0('0xb'))(new Redis(config[_0x03b0('0x9')]));function emit(_0x220b46,_0x34afa0,_0x13fc21){io['to'](_0x220b46)['emit'](_0x34afa0,_0x13fc21);}function getTicket(_0x126511,_0x3b76e8,_0xbf6335,_0x5c51e4,_0x20cb0c,_0x58857d,_0xd793e6,_0x5b9a19){var _0x11230b=Object[_0x03b0('0xc')]({},{'OwnerId':_0x3b76e8['id'],'Subject':intUtil[_0x03b0('0xd')](_0x5c51e4[_0x03b0('0xe')],_0x20cb0c,'\x20'),'Description':intUtil[_0x03b0('0xd')](_0x5c51e4[_0x03b0('0xf')],_0x20cb0c,'\x0a')},getCustomFields(_0x58857d,_0x20cb0c));if(_0xbf6335){if(_0x5c51e4[_0x03b0('0x10')]==='Task'){_0x11230b[_0x03b0('0x11')]=moment[_0x03b0('0x12')]();_0x11230b['IsReminderSet']=![];_0x11230b['IsRecurrence']=![];if(_0xbf6335[_0x03b0('0x13')]===_0x03b0('0x14')||_0xbf6335[_0x03b0('0x13')]===_0x03b0('0x15')){_0x11230b[_0x03b0('0x16')]=_0xbf6335['id'];}else if(_0xbf6335[_0x03b0('0x13')]===_0x03b0('0x17')){_0x11230b['WhatId']=_0xbf6335['id'];}}else if(_0x5c51e4[_0x03b0('0x10')]===_0x03b0('0x18')){if(_0xbf6335[_0x03b0('0x13')]===_0x03b0('0x14')){_0x11230b[_0x03b0('0x19')]=_0xbf6335['id'];}else if(_0xbf6335['endUserType']===_0x03b0('0x17')){_0x11230b[_0x03b0('0x1a')]=_0xbf6335['id'];}else if(_0xbf6335[_0x03b0('0x13')]===_0x03b0('0x15')&&_0x5c51e4['leadId']){_0x11230b[_0x5c51e4[_0x03b0('0x1b')]]=_0xbf6335['id'];}else{logger[_0x03b0('0x1c')](_0x03b0('0x1d'));}}}return _0xd793e6[_0x03b0('0x1e')](_0x5c51e4[_0x03b0('0x10')])['create'](_0x11230b);}function getUser(_0xa890de,_0x5a3ea4,_0x4e489c){if(!_['isNil'](_0x5a3ea4)&&intUtil[_0x03b0('0x1f')](_0x5a3ea4)){var _0x3bdc51={'Email':_0x5a3ea4};var _0x17ffd3={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x4e489c[_0x03b0('0x1e')]('User')[_0x03b0('0x20')](_0x3bdc51,_0x17ffd3)[_0x03b0('0x21')]()['then'](function(_0x1beedb){if(_0x1beedb[_0x03b0('0x22')]){var _0x3c89d6=_[_0x03b0('0x20')](_0x1beedb,function(_0x2ce395){return _0x2ce395['Email']===_0x5a3ea4;});if(_0x3c89d6){logger[_0x03b0('0x1c')](_0x03b0('0x23'),_0x5a3ea4);return BPromise['resolve']({'id':_0x3c89d6['Id'],'name':_0x3c89d6[_0x03b0('0x24')]});}}else{logger[_0x03b0('0x1c')]('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x5a3ea4);return _0x4e489c['identity']()['then'](function(_0x344678){return BPromise[_0x03b0('0x25')]({'id':_0x344678[_0x03b0('0x26')],'name':_0x344678[_0x03b0('0x27')]});});}});}else{logger['info']('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x5a3ea4);return _0x4e489c[_0x03b0('0x28')]()[_0x03b0('0x29')](function(_0x781328){return BPromise[_0x03b0('0x25')]({'id':_0x781328['user_id'],'name':_0x781328[_0x03b0('0x27')]});});}}function getEndUser(_0x10940a,_0x2017fe,_0x29e2b8,_0x2ece90,_0x5f1a8e){var _0x1782b2={'$or':{'Phone':_0x2ece90}};var _0x2e8e40={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x03b0('0x25')]()[_0x03b0('0x29')](function(){logger[_0x03b0('0x1c')]('Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.',_0x2ece90,_0x2017fe[_0x03b0('0x2a')]);switch(_0x2017fe[_0x03b0('0x2a')]){case _0x03b0('0x2b'):var _0x4f81c3=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe[_0x03b0('0x2d')]){var _0x2c2ff9={};_0x2c2ff9[_0x2017fe['additionalSearchContact']]=_0x2ece90;_[_0x03b0('0x2e')](_0x4f81c3[_0x03b0('0x2f')],_0x2c2ff9);}return _0x5f1a8e[_0x03b0('0x1e')]('Contact')[_0x03b0('0x20')](_0x4f81c3,_0x2e8e40)['execute']()[_0x03b0('0x29')](function(_0xe836f6){if(_0xe836f6&&_0xe836f6[_0x03b0('0x22')]){return _0xe836f6;}else{var _0x5644c9=_['cloneDeep'](_0x1782b2);if(_0x2017fe[_0x03b0('0x30')]){var _0x1c797c={};_0x1c797c[_0x2017fe[_0x03b0('0x30')]]=_0x2ece90;_[_0x03b0('0x2e')](_0x5644c9[_0x03b0('0x2f')],_0x1c797c);}return _0x5f1a8e[_0x03b0('0x1e')](_0x03b0('0x31'))[_0x03b0('0x20')](_0x5644c9,_0x2e8e40);}});case _0x03b0('0x32'):var _0x2b319b=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe[_0x03b0('0x33')]){var _0x2c2ff9={};_0x2c2ff9[_0x2017fe[_0x03b0('0x33')]]=_0x2ece90;_[_0x03b0('0x2e')](_0x2b319b[_0x03b0('0x2f')],_0x2c2ff9);}return _0x5f1a8e[_0x03b0('0x1e')](_0x03b0('0x34'))[_0x03b0('0x20')](_0x2b319b,_0x2e8e40)[_0x03b0('0x21')]()['then'](function(_0x289892){if(_0x289892&&_0x289892[_0x03b0('0x22')]){return _0x289892;}else{var _0x11458c=_['cloneDeep'](_0x1782b2);if(_0x2017fe[_0x03b0('0x2d')]){var _0x563e57={};_0x563e57[_0x2017fe[_0x03b0('0x2d')]]=_0x2ece90;_['merge'](_0x11458c[_0x03b0('0x2f')],_0x563e57);}return _0x5f1a8e[_0x03b0('0x1e')](_0x03b0('0x35'))[_0x03b0('0x20')](_0x11458c,_0x2e8e40)['then'](function(_0xd436b3){if(_0xd436b3&&_0xd436b3[_0x03b0('0x22')]){return _0xd436b3;}else{var _0xedbe3f=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe[_0x03b0('0x30')]){var _0x324f91={};_0x324f91[_0x2017fe['additionalSearchLead']]=_0x2ece90;_[_0x03b0('0x2e')](_0xedbe3f[_0x03b0('0x2f')],_0x324f91);}return _0x5f1a8e['sobject'](_0x03b0('0x31'))[_0x03b0('0x20')](_0xedbe3f,_0x2e8e40);}});}});case _0x03b0('0x14'):var _0x4f81c3=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe[_0x03b0('0x2d')]){var _0x2c2ff9={};_0x2c2ff9[_0x2017fe[_0x03b0('0x2d')]]=_0x2ece90;_['merge'](_0x4f81c3[_0x03b0('0x2f')],_0x2c2ff9);}return _0x5f1a8e['sobject'](_0x03b0('0x35'))['find'](_0x4f81c3,_0x2e8e40)[_0x03b0('0x21')]();case _0x03b0('0x15'):var _0x8aff26=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe['additionalSearchLead']){var _0x2c2ff9={};_0x2c2ff9[_0x2017fe[_0x03b0('0x30')]]=_0x2ece90;_[_0x03b0('0x2e')](_0x8aff26['$or'],_0x2c2ff9);}return _0x5f1a8e['sobject']('Lead')[_0x03b0('0x20')](_0x8aff26,_0x2e8e40);case'account':var _0x2b319b=_[_0x03b0('0x2c')](_0x1782b2);if(_0x2017fe['additionalSearchAccount']){var _0x2c2ff9={};_0x2c2ff9[_0x2017fe[_0x03b0('0x33')]]=_0x2ece90;_[_0x03b0('0x2e')](_0x2b319b[_0x03b0('0x2f')],_0x2c2ff9);}return _0x5f1a8e[_0x03b0('0x1e')](_0x03b0('0x34'))['find'](_0x2b319b,_0x2e8e40);default:return null;}})[_0x03b0('0x29')](function(_0x4b0187){if(_0x4b0187&&_0x4b0187[_0x03b0('0x22')]){var _0xd5549e=_[_0x03b0('0x36')](_0x4b0187);if(_0xd5549e){return BPromise[_0x03b0('0x25')]({'id':_0xd5549e['Id'],'name':_0xd5549e[_0x03b0('0x24')],'phone':_0xd5549e['Phone'],'endUserType':_0xd5549e[_0x03b0('0x37')]['type'][_0x03b0('0x38')]()});}}})['then'](function(_0x30769d){if(_0x30769d){logger[_0x03b0('0x1c')](_0x03b0('0x39'),_0x30769d[_0x03b0('0x13')],_0x2ece90);return BPromise[_0x03b0('0x25')](_0x30769d);}else{logger[_0x03b0('0x1c')](_0x03b0('0x3a'),_0x2ece90);var _0x233148={'Phone':_0x2ece90};if(_0x2017fe[_0x03b0('0x3b')]){if(_0x2017fe[_0x03b0('0x3b')]===_0x03b0('0x14')){logger[_0x03b0('0x1c')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x2ece90,_0x2017fe[_0x03b0('0x3b')]);_0x233148[_0x03b0('0x3c')]=_0x29e2b8!==_0x03b0('0x3d')?_0x29e2b8:util[_0x03b0('0x3e')]('Caller\x20-\x20%s',_0x2ece90);}else if(_0x2017fe['moduleCreate']===_0x03b0('0x15')){logger[_0x03b0('0x1c')](_0x03b0('0x3f'),_0x2ece90,_0x2017fe[_0x03b0('0x3b')]);_0x233148[_0x03b0('0x3c')]=_0x29e2b8!==_0x03b0('0x3d')?_0x29e2b8:util['format'](_0x03b0('0x40'),_0x2ece90);_0x233148['Company']=_0x03b0('0x41');}else if(_0x2017fe[_0x03b0('0x3b')]===_0x03b0('0x17')){logger[_0x03b0('0x1c')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x2ece90,_0x2017fe['moduleCreate']);_0x233148[_0x03b0('0x24')]=_0x29e2b8!==_0x03b0('0x3d')?_0x29e2b8:util[_0x03b0('0x3e')](_0x03b0('0x40'),_0x2ece90);}else{return null;}}return _0x5f1a8e['sobject'](_[_0x03b0('0x42')](_0x2017fe['moduleCreate']))['create'](_0x233148)[_0x03b0('0x29')](function(_0x1f1dd3){return BPromise[_0x03b0('0x25')]({'id':_0x1f1dd3['id'],'endUserType':_0x2017fe[_0x03b0('0x3b')]});});}});}function getCustomFields(_0x28fd5e,_0x2c1b13){var _0x36d477={};if(_0x28fd5e[_0x03b0('0x22')]>0x0){_['forEach'](_0x28fd5e,function(_0x158f04){if(_[_0x03b0('0x43')](['string',_0x03b0('0x44')],_0x158f04[_0x03b0('0x45')])&&_0x158f04[_0x03b0('0x46')]){_0x36d477[_0x158f04['idField']]=_0x158f04[_0x03b0('0x47')]['toString']();}else if(_0x158f04[_0x03b0('0x45')]===_0x03b0('0x48')&&_0x158f04[_0x03b0('0x49')]&&_0x158f04[_0x03b0('0x46')]){_0x2c1b13[_0x158f04[_0x03b0('0x49')]]&&(_0x36d477[_0x158f04[_0x03b0('0x46')]]=_0x2c1b13[_0x158f04[_0x03b0('0x49')]][_0x03b0('0x4a')]());}else if(_0x158f04[_0x03b0('0x45')]==='customVariable'&&_0x158f04[_0x03b0('0x4b')]&&_0x158f04[_0x03b0('0x4b')]['name']&&_0x158f04[_0x03b0('0x46')]){_0x2c1b13[_0x158f04[_0x03b0('0x4b')]['name'][_0x03b0('0x38')]()]&&(_0x36d477[_0x158f04['idField']]=_0x2c1b13[_0x158f04['Variable'][_0x03b0('0x4c')][_0x03b0('0x38')]()]['toString']());}});}return _0x36d477;}function getConnection(_0x348f31){var _0x5a5849=_0x348f31['password']['concat'](_0x348f31[_0x03b0('0x4d')]);var _0x18f282=new jsforce[(_0x03b0('0x4e'))]({'oauth2':{'loginUrl':_0x348f31['remoteUri']||_0x03b0('0x4f'),'clientId':_0x348f31[_0x03b0('0x50')],'clientSecret':_0x348f31[_0x03b0('0x51')]}});return _0x18f282[_0x03b0('0x52')](_0x348f31[_0x03b0('0x53')],_0x5a5849)[_0x03b0('0x29')](function(){logger['info'](_0x03b0('0x54'));return _0x18f282;});}exports[_0x03b0('0x55')]=function(_0x5d6000,_0x2a45e5,_0x1c2d5f,_0x231f90,_0x58ea99,_0x1fb250){var _0xaf9e6f,_0x32addf,_0x3552a7,_0x277055;_0x1fb250[_0x03b0('0x56')]=intUtil[_0x03b0('0x57')](_0x1fb250[_0x03b0('0x56')]);_0x1fb250['remoteUri']=intUtil[_0x03b0('0x57')](_0x1fb250['remoteUri']);if(_0x58ea99&&_0x58ea99[_0x03b0('0x58')]){logger[_0x03b0('0x1c')](_0x03b0('0x59'),_0x03b0('0x5a'));_0x2a45e5[_0x03b0('0x5b')]=util['format'](_0x03b0('0x5c'),_0x1fb250['serverUrl'],_0x2a45e5[_0x03b0('0x5d')],md5(_0x2a45e5[_0x03b0('0x5d')]));}else{_0x2a45e5[_0x03b0('0x5b')]='';}return getConnection(_0x1fb250)['then'](function(_0x51c56b){_0x277055=_0x51c56b;return getUser(_0x1fb250,_0x231f90[_0x03b0('0x5e')],_0x277055);})['then'](function(_0x4b5b4f){_0xaf9e6f=_0x4b5b4f;return getEndUser(_0x1fb250,_0x1c2d5f,_0x2a45e5['calleridname'],_0x2a45e5[_0x03b0('0x5f')],_0x277055);})[_0x03b0('0x29')](function(_0x37455d){_0x32addf=_0x37455d;return getTicket(_0x1fb250,_0xaf9e6f,_0x32addf,_0x1c2d5f,_0x2a45e5,_0x1c2d5f['Fields'],_0x277055,'queue');})[_0x03b0('0x29')](function(_0x479fd3){_0x3552a7=_0x479fd3;logger[_0x03b0('0x1c')](_0x03b0('0x60'),_0x3552a7['id']);logger[_0x03b0('0x1c')](_0x03b0('0x61'),_0x3552a7['id'],_0x231f90[_0x03b0('0x4c')],_0x1fb250[_0x03b0('0x45')]);switch(_0x1fb250['type']){case _0x03b0('0x62'):emit(util[_0x03b0('0x3e')](_0x03b0('0x63'),_0x231f90[_0x03b0('0x4c')]),_0x03b0('0x64'),{'recordId':_0x3552a7['id']});break;case _0x03b0('0x65'):emit(util['format'](_0x03b0('0x63'),_0x231f90[_0x03b0('0x4c')]),_0x03b0('0x66'),{'uri':util[_0x03b0('0x3e')](_0x03b0('0x67'),_0x277055[_0x03b0('0x68')],_0x3552a7['id'])});break;default:logger[_0x03b0('0x69')](_0x03b0('0x6a'));}})[_0x03b0('0x6b')](function(_0x38c17f){logger[_0x03b0('0x69')](_0x03b0('0x59'),_0x38c17f);});};exports['outbound']=function(_0x39dd37,_0x1fa5b1,_0x2151ca,_0x213e3c,_0xb96d5d,_0x469965,_0x550c50){var _0x3976e9,_0x3d3d74,_0x348c1a,_0x374399;_0x469965[_0x03b0('0x56')]=intUtil[_0x03b0('0x57')](_0x469965['serverUrl']);_0x469965['remoteUri']=intUtil[_0x03b0('0x57')](_0x469965[_0x03b0('0x6c')]);if(_0x550c50&&_0x550c50[_0x03b0('0x6d')]&&_0x550c50[_0x03b0('0x6d')]!==_0x03b0('0x6e')){logger[_0x03b0('0x1c')](_0x03b0('0x6f'),_0x03b0('0x5a'));_0x1fa5b1[_0x03b0('0x5b')]=util[_0x03b0('0x3e')](_0x03b0('0x5c'),_0x469965[_0x03b0('0x56')],_0x1fa5b1[_0x03b0('0x5d')],md5(_0x1fa5b1['uniqueid']));}return getConnection(_0x469965)[_0x03b0('0x29')](function(_0xe352e){_0x374399=_0xe352e;return getUser(_0x469965,_0x213e3c[_0x03b0('0x5e')],_0x374399);})[_0x03b0('0x29')](function(_0x1a7356){_0x3976e9=_0x1a7356;return getEndUser(_0x469965,_0x2151ca,_0x1fa5b1[_0x03b0('0x70')],_0x1fa5b1[_0x03b0('0x71')],_0x374399);})[_0x03b0('0x29')](function(_0x2ad97b){_0x3d3d74=_0x2ad97b;return getTicket(_0x469965,_0x3976e9,_0x3d3d74,_0x2151ca,_0x1fa5b1,_0x2151ca['Fields'],_0x374399,'outbound');})[_0x03b0('0x29')](function(_0x169d81){_0x348c1a=_0x169d81;logger[_0x03b0('0x1c')]('[OUTBOUND]\x20Ticket\x20%s\x20created.',_0x348c1a['id']);logger[_0x03b0('0x1c')](_0x03b0('0x72'),_0x348c1a['id'],_0x213e3c[_0x03b0('0x4c')],_0x469965['type']);switch(_0x469965[_0x03b0('0x45')]){case _0x03b0('0x62'):emit(util[_0x03b0('0x3e')](_0x03b0('0x63'),_0x213e3c[_0x03b0('0x4c')]),_0x03b0('0x64'),{'recordId':_0x348c1a['id']});break;case _0x03b0('0x65'):emit(util['format']('user:%s',_0x213e3c[_0x03b0('0x4c')]),'trigger:browser:url',{'uri':util['format'](_0x03b0('0x67'),_0x374399[_0x03b0('0x68')],_0x348c1a['id'])});break;default:logger[_0x03b0('0x69')](_0x03b0('0x6f'),_0x03b0('0x73'));}})[_0x03b0('0x6b')](function(_0x240d07){logger[_0x03b0('0x69')](_0x03b0('0x6f'),_0x240d07);});};exports[_0x03b0('0x74')]=function(_0x580ce2,_0x13a11b,_0x117954,_0x5bed60,_0x50afc7,_0x474bd6){var _0x144562,_0x4ed236,_0xeadd9f,_0x4ec6d2;_0x474bd6[_0x03b0('0x56')]=intUtil[_0x03b0('0x57')](_0x474bd6[_0x03b0('0x56')]);_0x474bd6[_0x03b0('0x6c')]=intUtil[_0x03b0('0x57')](_0x474bd6['remoteUri']);if(_0x50afc7&&_0x50afc7[_0x03b0('0x58')]){logger[_0x03b0('0x1c')]('['+_0x13a11b[_0x03b0('0x75')]['toUpperCase']()+']','Recording\x20is\x20enabled!');_0x13a11b['recordingURL']=util[_0x03b0('0x3e')](_0x03b0('0x5c'),_0x474bd6[_0x03b0('0x56')],_0x13a11b['uniqueid'],md5(_0x13a11b[_0x03b0('0x5d')]));}else{_0x13a11b[_0x03b0('0x5b')]='';}return getConnection(_0x474bd6)[_0x03b0('0x29')](function(_0xf94c89){_0x4ec6d2=_0xf94c89;if(!_[_0x03b0('0x76')](_0x5bed60)){return getUser(_0x474bd6,_0x5bed60[_0x03b0('0x4c')],_0x4ec6d2);}else{return getUser(_0x474bd6,null,_0x4ec6d2);}})[_0x03b0('0x29')](function(_0x3aed99){_0x144562=_0x3aed99;return getEndUser(_0x474bd6,_0x117954,_0x13a11b['calleridname'],_0x13a11b[_0x03b0('0x5f')],_0x4ec6d2);})[_0x03b0('0x29')](function(_0x477c38){_0x4ed236=_0x477c38;return getTicket(_0x474bd6,_0x144562,_0x4ed236,_0x117954,_0x13a11b,_0x117954[_0x03b0('0x77')],_0x4ec6d2);})[_0x03b0('0x29')](function(_0x390ddd){_0xeadd9f=_0x390ddd;logger[_0x03b0('0x1c')]('['+_0x13a11b[_0x03b0('0x75')][_0x03b0('0x78')]()+_0x03b0('0x79'),_0xeadd9f['id']);logger[_0x03b0('0x1c')]('['+_0x13a11b['lastevent'][_0x03b0('0x78')]()+']\x20Integration\x20account\x20type\x20%s.',_0x474bd6['type']);})[_0x03b0('0x6b')](function(_0x145c53){logger[_0x03b0('0x69')]('['+_0x13a11b[_0x03b0('0x75')][_0x03b0('0x78')]()+']',_0x145c53);});};
\ No newline at end of file