Built motion from commit 497d3d92.|2.5.43
[motion2.git] / server / services / ami / trigger / integration / salesforce.js
index 794c0a2..ff16b09 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf925=['content','toString','variableName','Variable','name','password','concat','securityToken','remoteUri','clientId','clientSecret','login','Connection\x20established.','queue','serverUrl','stripTrailingSlash','[QUEUE]','Recording\x20is\x20enabled!','uniqueid','email','calleridnum','Fields','[QUEUE]\x20Ticket\x20%s\x20created','integrationTab','user:%s','trigger:salesforce:display','trigger:browser:url','%s/%s/e','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','outbound','recordingFormat','[OUTBOUND]','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','destcalleridname','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','Salesforce\x20account\x20type\x20not\x20recognized','unmanaged','monitor_format','toUpperCase','calleridname','lastevent',']\x20Integration\x20account\x20type\x20%s.','lodash','request-promise','moment','bluebird','jsforce','./util','../../../../config/environment','../../../../config/logger','salesforce','redis','defaults','socket.io-emitter','emit','assign','getString','Descriptions','ticketType','Task','ActivityDate','utc','IsReminderSet','lead','WhoId','account','Case','endUserType','contact','ContactId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','isNil','validateEmail','User','find','Email','Agent\x20%s\x20found.','resolve','Name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','identity','then','user_id','display_name','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','Contact','execute','length','additionalSearchLead','Lead','account_contact_lead','additionalSearchAccount','Account','first','attributes','type','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','LastName','format','Caller\x20-\x20%s','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','<unknown>','upperFirst','create','includes','string','idField'];(function(_0x58f032,_0x1ce454){var _0x480cdf=function(_0x522bfc){while(--_0x522bfc){_0x58f032['push'](_0x58f032['shift']());}};_0x480cdf(++_0x1ce454);}(_0xf925,0x127));var _0x5f92=function(_0x4ece58,_0x50922a){_0x4ece58=_0x4ece58-0x0;var _0x20d209=_0xf925[_0x4ece58];return _0x20d209;};'use strict';var _=require(_0x5f92('0x0'));var rp=require(_0x5f92('0x1'));var moment=require(_0x5f92('0x2'));var BPromise=require(_0x5f92('0x3'));var md5=require('md5');var jsforce=require(_0x5f92('0x4'));var util=require('util');var Redis=require('ioredis');var intUtil=require(_0x5f92('0x5'));var config=require(_0x5f92('0x6'));var logger=require(_0x5f92('0x7'))(_0x5f92('0x8'));config[_0x5f92('0x9')]=_[_0x5f92('0xa')](config[_0x5f92('0x9')],{'host':'localhost','port':0x18eb});var io=require(_0x5f92('0xb'))(new Redis(config['redis']));function emit(_0x4e7251,_0x92d888,_0x370922){io['to'](_0x4e7251)[_0x5f92('0xc')](_0x92d888,_0x370922);}function getTicket(_0x141067,_0x330605,_0x45085d,_0x5b7da9,_0x154e44,_0x2b05b3,_0x42f700,_0x29ba49){var _0x286899=Object[_0x5f92('0xd')]({},{'OwnerId':_0x330605['id'],'Subject':intUtil[_0x5f92('0xe')](_0x5b7da9['Subjects'],_0x154e44,'\x20'),'Description':intUtil[_0x5f92('0xe')](_0x5b7da9[_0x5f92('0xf')],_0x154e44,'\x0a')},getCustomFields(_0x2b05b3,_0x154e44));if(_0x45085d){if(_0x5b7da9[_0x5f92('0x10')]===_0x5f92('0x11')){_0x286899[_0x5f92('0x12')]=moment[_0x5f92('0x13')]();_0x286899[_0x5f92('0x14')]=![];_0x286899['IsRecurrence']=![];if(_0x45085d['endUserType']==='contact'||_0x45085d['endUserType']===_0x5f92('0x15')){_0x286899[_0x5f92('0x16')]=_0x45085d['id'];}else if(_0x45085d['endUserType']===_0x5f92('0x17')){_0x286899['WhatId']=_0x45085d['id'];}}else if(_0x5b7da9[_0x5f92('0x10')]===_0x5f92('0x18')){if(_0x45085d[_0x5f92('0x19')]===_0x5f92('0x1a')){_0x286899[_0x5f92('0x1b')]=_0x45085d['id'];}else if(_0x45085d[_0x5f92('0x19')]==='account'){_0x286899['AccountId']=_0x45085d['id'];}else if(_0x45085d[_0x5f92('0x19')]===_0x5f92('0x15')&&_0x5b7da9[_0x5f92('0x1c')]){_0x286899[_0x5b7da9[_0x5f92('0x1c')]]=_0x45085d['id'];}else{logger[_0x5f92('0x1d')](_0x5f92('0x1e'));}}}return _0x42f700[_0x5f92('0x1f')](_0x5b7da9[_0x5f92('0x10')])['create'](_0x286899);}function getUser(_0x41ece5,_0x17beff,_0x534346){if(!_[_0x5f92('0x20')](_0x17beff)&&intUtil[_0x5f92('0x21')](_0x17beff)){var _0x1e9fc5={'Email':_0x17beff};var _0x4074f2={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x534346['sobject'](_0x5f92('0x22'))[_0x5f92('0x23')](_0x1e9fc5,_0x4074f2)['execute']()['then'](function(_0x30cca1){if(_0x30cca1['length']){var _0x175399=_[_0x5f92('0x23')](_0x30cca1,function(_0x1c6409){return _0x1c6409[_0x5f92('0x24')]===_0x17beff;});if(_0x175399){logger[_0x5f92('0x1d')](_0x5f92('0x25'),_0x17beff);return BPromise[_0x5f92('0x26')]({'id':_0x175399['Id'],'name':_0x175399[_0x5f92('0x27')]});}}else{logger[_0x5f92('0x1d')](_0x5f92('0x28'),_0x17beff);return _0x534346[_0x5f92('0x29')]()[_0x5f92('0x2a')](function(_0x5481bb){return BPromise[_0x5f92('0x26')]({'id':_0x5481bb[_0x5f92('0x2b')],'name':_0x5481bb[_0x5f92('0x2c')]});});}});}else{logger[_0x5f92('0x1d')](_0x5f92('0x28'),_0x17beff);return _0x534346[_0x5f92('0x29')]()[_0x5f92('0x2a')](function(_0x8513a4){return BPromise[_0x5f92('0x26')]({'id':_0x8513a4[_0x5f92('0x2b')],'name':_0x8513a4[_0x5f92('0x2c')]});});}}function getEndUser(_0x2648e6,_0x4e1d1c,_0xa4bcd1,_0x228659,_0x5c33d2){var _0x41e972={'$or':{'Phone':_0x228659}};var _0x2baa16={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x5f92('0x26')]()['then'](function(){logger['info'](_0x5f92('0x2d'),_0x228659,_0x4e1d1c['moduleSearch']);switch(_0x4e1d1c[_0x5f92('0x2e')]){case _0x5f92('0x2f'):var _0x138a59=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c[_0x5f92('0x31')]){var _0x244410={};_0x244410[_0x4e1d1c[_0x5f92('0x31')]]=_0x228659;_[_0x5f92('0x32')](_0x138a59[_0x5f92('0x33')],_0x244410);}return _0x5c33d2[_0x5f92('0x1f')](_0x5f92('0x34'))[_0x5f92('0x23')](_0x138a59,_0x2baa16)[_0x5f92('0x35')]()['then'](function(_0x56b97f){if(_0x56b97f&&_0x56b97f[_0x5f92('0x36')]){return _0x56b97f;}else{var _0x42dc31=_['cloneDeep'](_0x41e972);if(_0x4e1d1c[_0x5f92('0x37')]){var _0x94a480={};_0x94a480[_0x4e1d1c[_0x5f92('0x37')]]=_0x228659;_[_0x5f92('0x32')](_0x42dc31[_0x5f92('0x33')],_0x94a480);}return _0x5c33d2['sobject'](_0x5f92('0x38'))[_0x5f92('0x23')](_0x42dc31,_0x2baa16);}});case _0x5f92('0x39'):var _0x4ee326=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c[_0x5f92('0x3a')]){var _0x244410={};_0x244410[_0x4e1d1c['additionalSearchAccount']]=_0x228659;_[_0x5f92('0x32')](_0x4ee326[_0x5f92('0x33')],_0x244410);}return _0x5c33d2[_0x5f92('0x1f')](_0x5f92('0x3b'))[_0x5f92('0x23')](_0x4ee326,_0x2baa16)[_0x5f92('0x35')]()[_0x5f92('0x2a')](function(_0x31dd57){if(_0x31dd57&&_0x31dd57[_0x5f92('0x36')]){return _0x31dd57;}else{var _0x7a595d=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c[_0x5f92('0x31')]){var _0x591383={};_0x591383[_0x4e1d1c[_0x5f92('0x31')]]=_0x228659;_[_0x5f92('0x32')](_0x7a595d[_0x5f92('0x33')],_0x591383);}return _0x5c33d2[_0x5f92('0x1f')]('Contact')[_0x5f92('0x23')](_0x7a595d,_0x2baa16)['then'](function(_0x1bf378){if(_0x1bf378&&_0x1bf378['length']){return _0x1bf378;}else{var _0x3acff1=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c['additionalSearchLead']){var _0x49963e={};_0x49963e[_0x4e1d1c[_0x5f92('0x37')]]=_0x228659;_[_0x5f92('0x32')](_0x3acff1[_0x5f92('0x33')],_0x49963e);}return _0x5c33d2[_0x5f92('0x1f')]('Lead')[_0x5f92('0x23')](_0x3acff1,_0x2baa16);}});}});case _0x5f92('0x1a'):var _0x138a59=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c[_0x5f92('0x31')]){var _0x244410={};_0x244410[_0x4e1d1c['additionalSearchContact']]=_0x228659;_[_0x5f92('0x32')](_0x138a59[_0x5f92('0x33')],_0x244410);}return _0x5c33d2[_0x5f92('0x1f')](_0x5f92('0x34'))[_0x5f92('0x23')](_0x138a59,_0x2baa16)[_0x5f92('0x35')]();case _0x5f92('0x15'):var _0x2a43a8=_[_0x5f92('0x30')](_0x41e972);if(_0x4e1d1c[_0x5f92('0x37')]){var _0x244410={};_0x244410[_0x4e1d1c['additionalSearchLead']]=_0x228659;_[_0x5f92('0x32')](_0x2a43a8['$or'],_0x244410);}return _0x5c33d2[_0x5f92('0x1f')](_0x5f92('0x38'))[_0x5f92('0x23')](_0x2a43a8,_0x2baa16);case'account':var _0x4ee326=_['cloneDeep'](_0x41e972);if(_0x4e1d1c[_0x5f92('0x3a')]){var _0x244410={};_0x244410[_0x4e1d1c['additionalSearchAccount']]=_0x228659;_[_0x5f92('0x32')](_0x4ee326[_0x5f92('0x33')],_0x244410);}return _0x5c33d2[_0x5f92('0x1f')](_0x5f92('0x3b'))[_0x5f92('0x23')](_0x4ee326,_0x2baa16);default:return null;}})[_0x5f92('0x2a')](function(_0x3e5806){if(_0x3e5806&&_0x3e5806['length']){var _0x5a2160=_[_0x5f92('0x3c')](_0x3e5806);if(_0x5a2160){return BPromise[_0x5f92('0x26')]({'id':_0x5a2160['Id'],'name':_0x5a2160['Name'],'phone':_0x5a2160['Phone'],'endUserType':_0x5a2160[_0x5f92('0x3d')][_0x5f92('0x3e')][_0x5f92('0x3f')]()});}}})['then'](function(_0x594372){if(_0x594372){logger[_0x5f92('0x1d')](_0x5f92('0x40'),_0x594372[_0x5f92('0x19')],_0x228659);return BPromise[_0x5f92('0x26')](_0x594372);}else{logger['info'](_0x5f92('0x41'),_0x228659);var _0x253db4={'Phone':_0x228659};if(_0x4e1d1c['moduleCreate']){if(_0x4e1d1c[_0x5f92('0x42')]==='contact'){logger['info']('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x228659,_0x4e1d1c[_0x5f92('0x42')]);_0x253db4[_0x5f92('0x43')]=_0xa4bcd1!=='<unknown>'?_0xa4bcd1:util[_0x5f92('0x44')](_0x5f92('0x45'),_0x228659);}else if(_0x4e1d1c[_0x5f92('0x42')]==='lead'){logger['info'](_0x5f92('0x46'),_0x228659,_0x4e1d1c[_0x5f92('0x42')]);_0x253db4[_0x5f92('0x43')]=_0xa4bcd1!==_0x5f92('0x47')?_0xa4bcd1:util[_0x5f92('0x44')]('Caller\x20-\x20%s',_0x228659);_0x253db4['Company']='No\x20Company';}else if(_0x4e1d1c[_0x5f92('0x42')]==='account'){logger[_0x5f92('0x1d')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x228659,_0x4e1d1c[_0x5f92('0x42')]);_0x253db4[_0x5f92('0x27')]=_0xa4bcd1!==_0x5f92('0x47')?_0xa4bcd1:util[_0x5f92('0x44')](_0x5f92('0x45'),_0x228659);}else{return null;}}return _0x5c33d2[_0x5f92('0x1f')](_[_0x5f92('0x48')](_0x4e1d1c[_0x5f92('0x42')]))[_0x5f92('0x49')](_0x253db4)[_0x5f92('0x2a')](function(_0x2e5509){return BPromise['resolve']({'id':_0x2e5509['id'],'endUserType':_0x4e1d1c[_0x5f92('0x42')]});});}});}function getCustomFields(_0x5921f2,_0x11195b){var _0x2efa13={};if(_0x5921f2[_0x5f92('0x36')]>0x0){_['forEach'](_0x5921f2,function(_0x4ea712){if(_[_0x5f92('0x4a')]([_0x5f92('0x4b'),'picklist'],_0x4ea712[_0x5f92('0x3e')])&&_0x4ea712[_0x5f92('0x4c')]){_0x2efa13[_0x4ea712[_0x5f92('0x4c')]]=_0x4ea712[_0x5f92('0x4d')][_0x5f92('0x4e')]();}else if(_0x4ea712[_0x5f92('0x3e')]==='variable'&&_0x4ea712['variableName']&&_0x4ea712[_0x5f92('0x4c')]){_0x11195b[_0x4ea712[_0x5f92('0x4f')]]&&(_0x2efa13[_0x4ea712[_0x5f92('0x4c')]]=_0x11195b[_0x4ea712[_0x5f92('0x4f')]][_0x5f92('0x4e')]());}else if(_0x4ea712['type']==='customVariable'&&_0x4ea712['Variable']&&_0x4ea712[_0x5f92('0x50')][_0x5f92('0x51')]&&_0x4ea712[_0x5f92('0x4c')]){_0x11195b[_0x4ea712[_0x5f92('0x50')][_0x5f92('0x51')]['toLowerCase']()]&&(_0x2efa13[_0x4ea712[_0x5f92('0x4c')]]=_0x11195b[_0x4ea712[_0x5f92('0x50')][_0x5f92('0x51')][_0x5f92('0x3f')]()]['toString']());}});}return _0x2efa13;}function getConnection(_0x25ee1a){var _0x1a2f91=_0x25ee1a[_0x5f92('0x52')][_0x5f92('0x53')](_0x25ee1a[_0x5f92('0x54')]);var _0x1219fa=new jsforce['Connection']({'oauth2':{'loginUrl':_0x25ee1a[_0x5f92('0x55')]||'https://login.salesforce.com','clientId':_0x25ee1a[_0x5f92('0x56')],'clientSecret':_0x25ee1a[_0x5f92('0x57')]}});return _0x1219fa[_0x5f92('0x58')](_0x25ee1a['username'],_0x1a2f91)[_0x5f92('0x2a')](function(){logger[_0x5f92('0x1d')](_0x5f92('0x59'));return _0x1219fa;});}exports[_0x5f92('0x5a')]=function(_0x5e97fd,_0x6b2d34,_0x971a15,_0x490643,_0x12b47b,_0x124a7d){var _0x285798,_0x1d1f24,_0x268d87,_0x4a3e5c;_0x124a7d[_0x5f92('0x5b')]=intUtil['stripTrailingSlash'](_0x124a7d['serverUrl']);_0x124a7d[_0x5f92('0x55')]=intUtil[_0x5f92('0x5c')](_0x124a7d['remoteUri']);if(_0x12b47b&&_0x12b47b['monitor_format']){logger[_0x5f92('0x1d')](_0x5f92('0x5d'),_0x5f92('0x5e'));_0x6b2d34['recordingURL']=util[_0x5f92('0x44')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x124a7d[_0x5f92('0x5b')],_0x6b2d34[_0x5f92('0x5f')],md5(_0x6b2d34[_0x5f92('0x5f')]));}else{_0x6b2d34['recordingURL']='';}return getConnection(_0x124a7d)[_0x5f92('0x2a')](function(_0x336492){_0x4a3e5c=_0x336492;return getUser(_0x124a7d,_0x490643[_0x5f92('0x60')],_0x4a3e5c);})[_0x5f92('0x2a')](function(_0x2e430f){_0x285798=_0x2e430f;return getEndUser(_0x124a7d,_0x971a15,_0x6b2d34['calleridname'],_0x6b2d34[_0x5f92('0x61')],_0x4a3e5c);})[_0x5f92('0x2a')](function(_0x1ecd2c){_0x1d1f24=_0x1ecd2c;return getTicket(_0x124a7d,_0x285798,_0x1d1f24,_0x971a15,_0x6b2d34,_0x971a15[_0x5f92('0x62')],_0x4a3e5c,_0x5f92('0x5a'));})[_0x5f92('0x2a')](function(_0x291689){_0x268d87=_0x291689;logger[_0x5f92('0x1d')](_0x5f92('0x63'),_0x268d87['id']);logger[_0x5f92('0x1d')]('[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0x268d87['id'],_0x490643[_0x5f92('0x51')],_0x124a7d[_0x5f92('0x3e')]);switch(_0x124a7d['type']){case _0x5f92('0x64'):emit(util[_0x5f92('0x44')](_0x5f92('0x65'),_0x490643[_0x5f92('0x51')]),_0x5f92('0x66'),{'recordId':_0x268d87['id']});break;case'newTab':emit(util[_0x5f92('0x44')]('user:%s',_0x490643[_0x5f92('0x51')]),_0x5f92('0x67'),{'uri':util[_0x5f92('0x44')](_0x5f92('0x68'),_0x4a3e5c[_0x5f92('0x69')],_0x268d87['id'])});break;default:logger[_0x5f92('0x6a')](_0x5f92('0x6b'));}})[_0x5f92('0x6c')](function(_0x479453){logger[_0x5f92('0x6a')](_0x5f92('0x5d'),_0x479453);});};exports[_0x5f92('0x6d')]=function(_0x592bb0,_0x7eedde,_0x16bb1f,_0x458aeb,_0x4e2172,_0x233662,_0x34542d){var _0x593ca2,_0xe04949,_0x1f398f,_0x97564;_0x233662[_0x5f92('0x5b')]=intUtil[_0x5f92('0x5c')](_0x233662[_0x5f92('0x5b')]);_0x233662[_0x5f92('0x55')]=intUtil['stripTrailingSlash'](_0x233662[_0x5f92('0x55')]);if(_0x34542d&&_0x34542d[_0x5f92('0x6e')]&&_0x34542d['recordingFormat']!=='none'){logger[_0x5f92('0x1d')](_0x5f92('0x6f'),_0x5f92('0x5e'));_0x7eedde[_0x5f92('0x70')]=util[_0x5f92('0x44')](_0x5f92('0x71'),_0x233662['serverUrl'],_0x7eedde['uniqueid'],md5(_0x7eedde[_0x5f92('0x5f')]));}return getConnection(_0x233662)[_0x5f92('0x2a')](function(_0x223fb5){_0x97564=_0x223fb5;return getUser(_0x233662,_0x458aeb[_0x5f92('0x60')],_0x97564);})['then'](function(_0x4f9137){_0x593ca2=_0x4f9137;return getEndUser(_0x233662,_0x16bb1f,_0x7eedde[_0x5f92('0x72')],_0x7eedde['destcalleridnum'],_0x97564);})[_0x5f92('0x2a')](function(_0x1e4cfb){_0xe04949=_0x1e4cfb;return getTicket(_0x233662,_0x593ca2,_0xe04949,_0x16bb1f,_0x7eedde,_0x16bb1f[_0x5f92('0x62')],_0x97564,_0x5f92('0x6d'));})[_0x5f92('0x2a')](function(_0x122f66){_0x1f398f=_0x122f66;logger[_0x5f92('0x1d')](_0x5f92('0x73'),_0x1f398f['id']);logger[_0x5f92('0x1d')](_0x5f92('0x74'),_0x1f398f['id'],_0x458aeb['name'],_0x233662[_0x5f92('0x3e')]);switch(_0x233662['type']){case _0x5f92('0x64'):emit(util['format'](_0x5f92('0x65'),_0x458aeb[_0x5f92('0x51')]),_0x5f92('0x66'),{'recordId':_0x1f398f['id']});break;case'newTab':emit(util['format'](_0x5f92('0x65'),_0x458aeb[_0x5f92('0x51')]),_0x5f92('0x67'),{'uri':util[_0x5f92('0x44')](_0x5f92('0x68'),_0x97564[_0x5f92('0x69')],_0x1f398f['id'])});break;default:logger[_0x5f92('0x6a')]('[OUTBOUND]',_0x5f92('0x75'));}})[_0x5f92('0x6c')](function(_0x493e5e){logger[_0x5f92('0x6a')](_0x5f92('0x6f'),_0x493e5e);});};exports[_0x5f92('0x76')]=function(_0x3d5656,_0x243b7f,_0x4e443f,_0x235d18,_0x33a8da,_0x39119b){var _0x353d3a,_0x5a134d,_0x1030fd,_0x42f347;_0x39119b[_0x5f92('0x5b')]=intUtil[_0x5f92('0x5c')](_0x39119b[_0x5f92('0x5b')]);_0x39119b[_0x5f92('0x55')]=intUtil[_0x5f92('0x5c')](_0x39119b[_0x5f92('0x55')]);if(_0x33a8da&&_0x33a8da[_0x5f92('0x77')]){logger[_0x5f92('0x1d')]('['+_0x243b7f['lastevent'][_0x5f92('0x78')]()+']',_0x5f92('0x5e'));_0x243b7f[_0x5f92('0x70')]=util[_0x5f92('0x44')](_0x5f92('0x71'),_0x39119b['serverUrl'],_0x243b7f['uniqueid'],md5(_0x243b7f['uniqueid']));}else{_0x243b7f[_0x5f92('0x70')]='';}return getConnection(_0x39119b)['then'](function(_0x2cfcb1){_0x42f347=_0x2cfcb1;if(!_[_0x5f92('0x20')](_0x235d18)){return getUser(_0x39119b,_0x235d18[_0x5f92('0x51')],_0x42f347);}else{return getUser(_0x39119b,null,_0x42f347);}})[_0x5f92('0x2a')](function(_0x511f29){_0x353d3a=_0x511f29;return getEndUser(_0x39119b,_0x4e443f,_0x243b7f[_0x5f92('0x79')],_0x243b7f['calleridnum'],_0x42f347);})[_0x5f92('0x2a')](function(_0x5080dc){_0x5a134d=_0x5080dc;return getTicket(_0x39119b,_0x353d3a,_0x5a134d,_0x4e443f,_0x243b7f,_0x4e443f[_0x5f92('0x62')],_0x42f347);})[_0x5f92('0x2a')](function(_0x523980){_0x1030fd=_0x523980;logger[_0x5f92('0x1d')]('['+_0x243b7f[_0x5f92('0x7a')][_0x5f92('0x78')]()+']\x20Ticket\x20%s\x20created.',_0x1030fd['id']);logger[_0x5f92('0x1d')]('['+_0x243b7f[_0x5f92('0x7a')][_0x5f92('0x78')]()+_0x5f92('0x7b'),_0x39119b[_0x5f92('0x3e')]);})[_0x5f92('0x6c')](function(_0x2e872f){logger[_0x5f92('0x6a')]('['+_0x243b7f['lastevent'][_0x5f92('0x78')]()+']',_0x2e872f);});};
\ No newline at end of file
+var _0x58d1=['resolve','display_name','then','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','Contact','additionalSearchLead','Lead','additionalSearchAccount','Account','first','Phone','type','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','LastName','<unknown>','Caller\x20-\x20%s','Company','No\x20Company','create','forEach','includes','string','picklist','idField','content','toString','variable','variableName','customVariable','Variable','name','toLowerCase','password','concat','securityToken','Connection','remoteUri','clientSecret','Connection\x20established.','queue','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','format','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','calleridnum','Fields','integrationTab','newTab','user:%s','trigger:browser:url','%s/%s/e','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','recordingFormat','none','[OUTBOUND]','destcalleridnum','outbound','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','unmanaged','stripTrailingSlash','lastevent','toUpperCase','lodash','request-promise','moment','bluebird','md5','jsforce','util','./util','../../../../config/environment','../../../../config/logger','defaults','redis','socket.io-emitter','emit','assign','getString','Subjects','Descriptions','ticketType','Task','ActivityDate','IsReminderSet','IsRecurrence','endUserType','contact','lead','WhoId','account','WhatId','Case','ContactId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','isNil','sobject','User','execute','length','find','Email','Agent\x20%s\x20found.','Name','identity','user_id','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.'];(function(_0x4e6449,_0x12327b){var _0xe18bcb=function(_0x1dcc1a){while(--_0x1dcc1a){_0x4e6449['push'](_0x4e6449['shift']());}};_0xe18bcb(++_0x12327b);}(_0x58d1,0x14f));var _0x158d=function(_0x45cd35,_0x41147c){_0x45cd35=_0x45cd35-0x0;var _0x16db84=_0x58d1[_0x45cd35];return _0x16db84;};'use strict';var _=require(_0x158d('0x0'));var rp=require(_0x158d('0x1'));var moment=require(_0x158d('0x2'));var BPromise=require(_0x158d('0x3'));var md5=require(_0x158d('0x4'));var jsforce=require(_0x158d('0x5'));var util=require(_0x158d('0x6'));var Redis=require('ioredis');var intUtil=require(_0x158d('0x7'));var config=require(_0x158d('0x8'));var logger=require(_0x158d('0x9'))('salesforce');config['redis']=_[_0x158d('0xa')](config[_0x158d('0xb')],{'host':'localhost','port':0x18eb});var io=require(_0x158d('0xc'))(new Redis(config['redis']));function emit(_0x2ef504,_0x780cce,_0x4bafe2){io['to'](_0x2ef504)[_0x158d('0xd')](_0x780cce,_0x4bafe2);}function getTicket(_0x37b1f6,_0x1e0eea,_0x28e863,_0x5bd19b,_0x582278,_0xa6f4ef,_0x5a3011,_0x257af8){var _0x4d82cd=Object[_0x158d('0xe')]({},{'OwnerId':_0x1e0eea['id'],'Subject':intUtil[_0x158d('0xf')](_0x5bd19b[_0x158d('0x10')],_0x582278,'\x20'),'Description':intUtil[_0x158d('0xf')](_0x5bd19b[_0x158d('0x11')],_0x582278,'\x0a')},getCustomFields(_0xa6f4ef,_0x582278));if(_0x28e863){if(_0x5bd19b[_0x158d('0x12')]===_0x158d('0x13')){_0x4d82cd[_0x158d('0x14')]=moment['utc']();_0x4d82cd[_0x158d('0x15')]=![];_0x4d82cd[_0x158d('0x16')]=![];if(_0x28e863[_0x158d('0x17')]===_0x158d('0x18')||_0x28e863['endUserType']===_0x158d('0x19')){_0x4d82cd[_0x158d('0x1a')]=_0x28e863['id'];}else if(_0x28e863[_0x158d('0x17')]===_0x158d('0x1b')){_0x4d82cd[_0x158d('0x1c')]=_0x28e863['id'];}}else if(_0x5bd19b['ticketType']===_0x158d('0x1d')){if(_0x28e863['endUserType']===_0x158d('0x18')){_0x4d82cd[_0x158d('0x1e')]=_0x28e863['id'];}else if(_0x28e863[_0x158d('0x17')]===_0x158d('0x1b')){_0x4d82cd['AccountId']=_0x28e863['id'];}else if(_0x28e863[_0x158d('0x17')]===_0x158d('0x19')&&_0x5bd19b[_0x158d('0x1f')]){_0x4d82cd[_0x5bd19b[_0x158d('0x1f')]]=_0x28e863['id'];}else{logger[_0x158d('0x20')](_0x158d('0x21'));}}}return _0x5a3011['sobject'](_0x5bd19b[_0x158d('0x12')])['create'](_0x4d82cd);}function getUser(_0x39b92a,_0x440418,_0x4394e5){if(!_[_0x158d('0x22')](_0x440418)&&intUtil['validateEmail'](_0x440418)){var _0x51cbbc={'Email':_0x440418};var _0x3560f2={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x4394e5[_0x158d('0x23')](_0x158d('0x24'))['find'](_0x51cbbc,_0x3560f2)[_0x158d('0x25')]()['then'](function(_0x625cff){if(_0x625cff[_0x158d('0x26')]){var _0x2ae57f=_[_0x158d('0x27')](_0x625cff,function(_0x3fea2a){return _0x3fea2a[_0x158d('0x28')]===_0x440418;});if(_0x2ae57f){logger[_0x158d('0x20')](_0x158d('0x29'),_0x440418);return BPromise['resolve']({'id':_0x2ae57f['Id'],'name':_0x2ae57f[_0x158d('0x2a')]});}}else{logger['info']('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x440418);return _0x4394e5[_0x158d('0x2b')]()['then'](function(_0x38fde4){return BPromise['resolve']({'id':_0x38fde4[_0x158d('0x2c')],'name':_0x38fde4['display_name']});});}});}else{logger[_0x158d('0x20')](_0x158d('0x2d'),_0x440418);return _0x4394e5[_0x158d('0x2b')]()['then'](function(_0x2024a0){return BPromise[_0x158d('0x2e')]({'id':_0x2024a0[_0x158d('0x2c')],'name':_0x2024a0[_0x158d('0x2f')]});});}}function getEndUser(_0x1bd073,_0x49ae37,_0x2e01eb,_0x2db003,_0x53050d){var _0x4db512={'$or':{'Phone':_0x2db003}};var _0x149a61={'Id':!![],'Name':!![],'Phone':!![]};return BPromise['resolve']()[_0x158d('0x30')](function(){logger[_0x158d('0x20')](_0x158d('0x31'),_0x2db003,_0x49ae37[_0x158d('0x32')]);switch(_0x49ae37[_0x158d('0x32')]){case _0x158d('0x33'):var _0x367541=_[_0x158d('0x34')](_0x4db512);if(_0x49ae37[_0x158d('0x35')]){var _0x31975f={};_0x31975f[_0x49ae37[_0x158d('0x35')]]=_0x2db003;_[_0x158d('0x36')](_0x367541[_0x158d('0x37')],_0x31975f);}return _0x53050d['sobject'](_0x158d('0x38'))['find'](_0x367541,_0x149a61)[_0x158d('0x25')]()[_0x158d('0x30')](function(_0x38ae8c){if(_0x38ae8c&&_0x38ae8c['length']){return _0x38ae8c;}else{var _0x207e17=_['cloneDeep'](_0x4db512);if(_0x49ae37[_0x158d('0x39')]){var _0x4eba2e={};_0x4eba2e[_0x49ae37[_0x158d('0x39')]]=_0x2db003;_[_0x158d('0x36')](_0x207e17[_0x158d('0x37')],_0x4eba2e);}return _0x53050d[_0x158d('0x23')](_0x158d('0x3a'))[_0x158d('0x27')](_0x207e17,_0x149a61);}});case'account_contact_lead':var _0x2f6633=_[_0x158d('0x34')](_0x4db512);if(_0x49ae37[_0x158d('0x3b')]){var _0x31975f={};_0x31975f[_0x49ae37[_0x158d('0x3b')]]=_0x2db003;_[_0x158d('0x36')](_0x2f6633['$or'],_0x31975f);}return _0x53050d[_0x158d('0x23')]('Account')[_0x158d('0x27')](_0x2f6633,_0x149a61)[_0x158d('0x25')]()['then'](function(_0x3eb605){if(_0x3eb605&&_0x3eb605['length']){return _0x3eb605;}else{var _0x21645a=_['cloneDeep'](_0x4db512);if(_0x49ae37[_0x158d('0x35')]){var _0x27e392={};_0x27e392[_0x49ae37[_0x158d('0x35')]]=_0x2db003;_['merge'](_0x21645a[_0x158d('0x37')],_0x27e392);}return _0x53050d[_0x158d('0x23')]('Contact')[_0x158d('0x27')](_0x21645a,_0x149a61)['then'](function(_0x242042){if(_0x242042&&_0x242042[_0x158d('0x26')]){return _0x242042;}else{var _0x407fee=_['cloneDeep'](_0x4db512);if(_0x49ae37['additionalSearchLead']){var _0x3b7dc3={};_0x3b7dc3[_0x49ae37['additionalSearchLead']]=_0x2db003;_[_0x158d('0x36')](_0x407fee[_0x158d('0x37')],_0x3b7dc3);}return _0x53050d[_0x158d('0x23')](_0x158d('0x3a'))[_0x158d('0x27')](_0x407fee,_0x149a61);}});}});case _0x158d('0x18'):var _0x367541=_[_0x158d('0x34')](_0x4db512);if(_0x49ae37['additionalSearchContact']){var _0x31975f={};_0x31975f[_0x49ae37[_0x158d('0x35')]]=_0x2db003;_[_0x158d('0x36')](_0x367541[_0x158d('0x37')],_0x31975f);}return _0x53050d[_0x158d('0x23')]('Contact')[_0x158d('0x27')](_0x367541,_0x149a61)[_0x158d('0x25')]();case _0x158d('0x19'):var _0x4987e3=_[_0x158d('0x34')](_0x4db512);if(_0x49ae37[_0x158d('0x39')]){var _0x31975f={};_0x31975f[_0x49ae37['additionalSearchLead']]=_0x2db003;_[_0x158d('0x36')](_0x4987e3[_0x158d('0x37')],_0x31975f);}return _0x53050d[_0x158d('0x23')]('Lead')[_0x158d('0x27')](_0x4987e3,_0x149a61);case _0x158d('0x1b'):var _0x2f6633=_[_0x158d('0x34')](_0x4db512);if(_0x49ae37[_0x158d('0x3b')]){var _0x31975f={};_0x31975f[_0x49ae37[_0x158d('0x3b')]]=_0x2db003;_[_0x158d('0x36')](_0x2f6633['$or'],_0x31975f);}return _0x53050d[_0x158d('0x23')](_0x158d('0x3c'))[_0x158d('0x27')](_0x2f6633,_0x149a61);default:return null;}})[_0x158d('0x30')](function(_0xff723b){if(_0xff723b&&_0xff723b[_0x158d('0x26')]){var _0x48500d=_[_0x158d('0x3d')](_0xff723b);if(_0x48500d){return BPromise[_0x158d('0x2e')]({'id':_0x48500d['Id'],'name':_0x48500d[_0x158d('0x2a')],'phone':_0x48500d[_0x158d('0x3e')],'endUserType':_0x48500d['attributes'][_0x158d('0x3f')]['toLowerCase']()});}}})[_0x158d('0x30')](function(_0x40c48c){if(_0x40c48c){logger[_0x158d('0x20')](_0x158d('0x40'),_0x40c48c['endUserType'],_0x2db003);return BPromise[_0x158d('0x2e')](_0x40c48c);}else{logger[_0x158d('0x20')](_0x158d('0x41'),_0x2db003);var _0x36dafa={'Phone':_0x2db003};if(_0x49ae37['moduleCreate']){if(_0x49ae37[_0x158d('0x42')]==='contact'){logger['info'](_0x158d('0x43'),_0x2db003,_0x49ae37[_0x158d('0x42')]);_0x36dafa[_0x158d('0x44')]=_0x2e01eb!==_0x158d('0x45')?_0x2e01eb:util['format'](_0x158d('0x46'),_0x2db003);}else if(_0x49ae37[_0x158d('0x42')]==='lead'){logger[_0x158d('0x20')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x2db003,_0x49ae37[_0x158d('0x42')]);_0x36dafa['LastName']=_0x2e01eb!==_0x158d('0x45')?_0x2e01eb:util['format'](_0x158d('0x46'),_0x2db003);_0x36dafa[_0x158d('0x47')]=_0x158d('0x48');}else if(_0x49ae37[_0x158d('0x42')]===_0x158d('0x1b')){logger[_0x158d('0x20')](_0x158d('0x43'),_0x2db003,_0x49ae37[_0x158d('0x42')]);_0x36dafa['Name']=_0x2e01eb!=='<unknown>'?_0x2e01eb:util['format'](_0x158d('0x46'),_0x2db003);}else{return null;}}return _0x53050d[_0x158d('0x23')](_['upperFirst'](_0x49ae37[_0x158d('0x42')]))[_0x158d('0x49')](_0x36dafa)['then'](function(_0x2e829a){return BPromise[_0x158d('0x2e')]({'id':_0x2e829a['id'],'endUserType':_0x49ae37[_0x158d('0x42')]});});}});}function getCustomFields(_0x373e24,_0x4f2505){var _0x20fe75={};if(_0x373e24[_0x158d('0x26')]>0x0){_[_0x158d('0x4a')](_0x373e24,function(_0x1e2f88){if(_[_0x158d('0x4b')]([_0x158d('0x4c'),_0x158d('0x4d')],_0x1e2f88[_0x158d('0x3f')])&&_0x1e2f88[_0x158d('0x4e')]){_0x20fe75[_0x1e2f88[_0x158d('0x4e')]]=_0x1e2f88[_0x158d('0x4f')][_0x158d('0x50')]();}else if(_0x1e2f88[_0x158d('0x3f')]===_0x158d('0x51')&&_0x1e2f88[_0x158d('0x52')]&&_0x1e2f88[_0x158d('0x4e')]){_0x4f2505[_0x1e2f88[_0x158d('0x52')]]&&(_0x20fe75[_0x1e2f88[_0x158d('0x4e')]]=_0x4f2505[_0x1e2f88[_0x158d('0x52')]][_0x158d('0x50')]());}else if(_0x1e2f88[_0x158d('0x3f')]===_0x158d('0x53')&&_0x1e2f88[_0x158d('0x54')]&&_0x1e2f88['Variable'][_0x158d('0x55')]&&_0x1e2f88[_0x158d('0x4e')]){_0x4f2505[_0x1e2f88[_0x158d('0x54')]['name'][_0x158d('0x56')]()]&&(_0x20fe75[_0x1e2f88[_0x158d('0x4e')]]=_0x4f2505[_0x1e2f88[_0x158d('0x54')]['name']['toLowerCase']()]['toString']());}});}return _0x20fe75;}function getConnection(_0x510a8){var _0x552b5f=_0x510a8[_0x158d('0x57')][_0x158d('0x58')](_0x510a8[_0x158d('0x59')]);var _0x1ae6b9=new jsforce[(_0x158d('0x5a'))]({'oauth2':{'loginUrl':_0x510a8[_0x158d('0x5b')]||'https://login.salesforce.com','clientId':_0x510a8['clientId'],'clientSecret':_0x510a8[_0x158d('0x5c')]}});return _0x1ae6b9['login'](_0x510a8['username'],_0x552b5f)[_0x158d('0x30')](function(){logger[_0x158d('0x20')](_0x158d('0x5d'));return _0x1ae6b9;});}exports[_0x158d('0x5e')]=function(_0x2db91d,_0x2f3faf,_0x50baef,_0x189e58,_0x1bc70d,_0x66fb85){var _0x36bc31,_0x442673,_0xca93d8,_0x356314;_0x66fb85[_0x158d('0x5f')]=intUtil['stripTrailingSlash'](_0x66fb85[_0x158d('0x5f')]);_0x66fb85['remoteUri']=intUtil['stripTrailingSlash'](_0x66fb85[_0x158d('0x5b')]);if(_0x1bc70d&&_0x1bc70d[_0x158d('0x60')]){logger['info'](_0x158d('0x61'),_0x158d('0x62'));_0x2f3faf[_0x158d('0x63')]=util[_0x158d('0x64')](_0x158d('0x65'),_0x66fb85['serverUrl'],_0x2f3faf[_0x158d('0x66')],md5(_0x2f3faf[_0x158d('0x66')]));}else{_0x2f3faf[_0x158d('0x63')]='';}return getConnection(_0x66fb85)[_0x158d('0x30')](function(_0x2766eb){_0x356314=_0x2766eb;return getUser(_0x66fb85,_0x189e58[_0x158d('0x67')],_0x356314);})[_0x158d('0x30')](function(_0x2d7060){_0x36bc31=_0x2d7060;return getEndUser(_0x66fb85,_0x50baef,_0x2f3faf[_0x158d('0x68')],_0x2f3faf[_0x158d('0x69')],_0x356314);})['then'](function(_0x103a2d){_0x442673=_0x103a2d;return getTicket(_0x66fb85,_0x36bc31,_0x442673,_0x50baef,_0x2f3faf,_0x50baef[_0x158d('0x6a')],_0x356314,_0x158d('0x5e'));})['then'](function(_0x14cb28){_0xca93d8=_0x14cb28;logger[_0x158d('0x20')]('[QUEUE]\x20Ticket\x20%s\x20created',_0xca93d8['id']);logger[_0x158d('0x20')]('[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0xca93d8['id'],_0x189e58[_0x158d('0x55')],_0x66fb85['type']);switch(_0x66fb85[_0x158d('0x3f')]){case _0x158d('0x6b'):emit(util['format']('user:%s',_0x189e58[_0x158d('0x55')]),'trigger:salesforce:display',{'recordId':_0xca93d8['id']});break;case _0x158d('0x6c'):emit(util[_0x158d('0x64')](_0x158d('0x6d'),_0x189e58[_0x158d('0x55')]),_0x158d('0x6e'),{'uri':util[_0x158d('0x64')](_0x158d('0x6f'),_0x356314[_0x158d('0x70')],_0xca93d8['id'])});break;default:logger[_0x158d('0x71')](_0x158d('0x72'));}})[_0x158d('0x73')](function(_0xd0d70c){logger[_0x158d('0x71')](_0x158d('0x61'),_0xd0d70c);});};exports['outbound']=function(_0x349474,_0x4a2fc1,_0xc16f1d,_0x52226b,_0x4c0e90,_0x4f3b4d,_0x4cd79f){var _0x501154,_0x4f2464,_0x3fd462,_0x53e590;_0x4f3b4d[_0x158d('0x5f')]=intUtil['stripTrailingSlash'](_0x4f3b4d[_0x158d('0x5f')]);_0x4f3b4d['remoteUri']=intUtil['stripTrailingSlash'](_0x4f3b4d[_0x158d('0x5b')]);if(_0x4cd79f&&_0x4cd79f['recordingFormat']&&_0x4cd79f[_0x158d('0x74')]!==_0x158d('0x75')){logger[_0x158d('0x20')](_0x158d('0x76'),_0x158d('0x62'));_0x4a2fc1[_0x158d('0x63')]=util[_0x158d('0x64')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x4f3b4d['serverUrl'],_0x4a2fc1[_0x158d('0x66')],md5(_0x4a2fc1[_0x158d('0x66')]));}return getConnection(_0x4f3b4d)['then'](function(_0x39f70f){_0x53e590=_0x39f70f;return getUser(_0x4f3b4d,_0x52226b['email'],_0x53e590);})[_0x158d('0x30')](function(_0x4185ac){_0x501154=_0x4185ac;return getEndUser(_0x4f3b4d,_0xc16f1d,_0x4a2fc1['destcalleridname'],_0x4a2fc1[_0x158d('0x77')],_0x53e590);})[_0x158d('0x30')](function(_0x19ca9){_0x4f2464=_0x19ca9;return getTicket(_0x4f3b4d,_0x501154,_0x4f2464,_0xc16f1d,_0x4a2fc1,_0xc16f1d[_0x158d('0x6a')],_0x53e590,_0x158d('0x78'));})['then'](function(_0x906fac){_0x3fd462=_0x906fac;logger[_0x158d('0x20')](_0x158d('0x79'),_0x3fd462['id']);logger[_0x158d('0x20')](_0x158d('0x7a'),_0x3fd462['id'],_0x52226b[_0x158d('0x55')],_0x4f3b4d[_0x158d('0x3f')]);switch(_0x4f3b4d[_0x158d('0x3f')]){case _0x158d('0x6b'):emit(util[_0x158d('0x64')](_0x158d('0x6d'),_0x52226b['name']),'trigger:salesforce:display',{'recordId':_0x3fd462['id']});break;case'newTab':emit(util[_0x158d('0x64')](_0x158d('0x6d'),_0x52226b['name']),_0x158d('0x6e'),{'uri':util[_0x158d('0x64')](_0x158d('0x6f'),_0x53e590[_0x158d('0x70')],_0x3fd462['id'])});break;default:logger['error'](_0x158d('0x76'),'Salesforce\x20account\x20type\x20not\x20recognized');}})[_0x158d('0x73')](function(_0xe6c5e4){logger[_0x158d('0x71')](_0x158d('0x76'),_0xe6c5e4);});};exports[_0x158d('0x7b')]=function(_0x286792,_0x5bea3f,_0x43741b,_0x1d053e,_0xa371fe,_0x245fe6){var _0x47ea08,_0x2746bd,_0x45c6d4,_0x38dc68;_0x245fe6[_0x158d('0x5f')]=intUtil[_0x158d('0x7c')](_0x245fe6[_0x158d('0x5f')]);_0x245fe6[_0x158d('0x5b')]=intUtil[_0x158d('0x7c')](_0x245fe6['remoteUri']);if(_0xa371fe&&_0xa371fe['monitor_format']){logger['info']('['+_0x5bea3f[_0x158d('0x7d')][_0x158d('0x7e')]()+']','Recording\x20is\x20enabled!');_0x5bea3f['recordingURL']=util[_0x158d('0x64')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x245fe6[_0x158d('0x5f')],_0x5bea3f[_0x158d('0x66')],md5(_0x5bea3f['uniqueid']));}else{_0x5bea3f[_0x158d('0x63')]='';}return getConnection(_0x245fe6)[_0x158d('0x30')](function(_0x58543a){_0x38dc68=_0x58543a;if(!_['isNil'](_0x1d053e)){return getUser(_0x245fe6,_0x1d053e[_0x158d('0x55')],_0x38dc68);}else{return getUser(_0x245fe6,null,_0x38dc68);}})[_0x158d('0x30')](function(_0x17bd50){_0x47ea08=_0x17bd50;return getEndUser(_0x245fe6,_0x43741b,_0x5bea3f[_0x158d('0x68')],_0x5bea3f[_0x158d('0x69')],_0x38dc68);})[_0x158d('0x30')](function(_0x101ad8){_0x2746bd=_0x101ad8;return getTicket(_0x245fe6,_0x47ea08,_0x2746bd,_0x43741b,_0x5bea3f,_0x43741b['Fields'],_0x38dc68);})[_0x158d('0x30')](function(_0xf1439b){_0x45c6d4=_0xf1439b;logger[_0x158d('0x20')]('['+_0x5bea3f[_0x158d('0x7d')][_0x158d('0x7e')]()+']\x20Ticket\x20%s\x20created.',_0x45c6d4['id']);logger['info']('['+_0x5bea3f['lastevent'][_0x158d('0x7e')]()+']\x20Integration\x20account\x20type\x20%s.',_0x245fe6[_0x158d('0x3f')]);})[_0x158d('0x73')](function(_0xf174ea){logger[_0x158d('0x71')]('['+_0x5bea3f[_0x158d('0x7d')][_0x158d('0x7e')]()+']',_0xf174ea);});};
\ No newline at end of file