Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / ami / trigger / integration / salesforce.js
index dddc978..4a19be2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x563f=['ticketType','utc','endUserType','contact','lead','WhoId','account','WhatId','Case','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','isNil','validateEmail','User','find','execute','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','length','additionalSearchLead','account_contact_lead','Account','Lead','additionalSearchAccount','first','Phone','attributes','type','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','LastName','<unknown>','Caller\x20-\x20%s','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','Company','format','upperFirst','forEach','string','picklist','toString','variable','variableName','idField','customVariable','Variable','name','password','concat','securityToken','Connection','https://login.salesforce.com','clientSecret','username','Connection\x20established.','queue','serverUrl','stripTrailingSlash','remoteUri','monitor_format','[QUEUE]','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','calleridnum','integrationTab','user:%s','trigger:salesforce:display','newTab','trigger:browser:url','%s/%s/e','instanceUrl','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','error','outbound','recordingFormat','none','[OUTBOUND]','Recording\x20is\x20enabled!','destcalleridname','Fields','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','Salesforce\x20account\x20type\x20not\x20recognized','lastevent','toUpperCase',']\x20Ticket\x20%s\x20created.',']\x20Integration\x20account\x20type\x20%s.','lodash','request-promise','moment','bluebird','md5','jsforce','../../../../config/environment','../../../../config/logger','salesforce','redis','defaults','localhost','emit','assign','getString'];(function(_0x2bdfc4,_0x5551b7){var _0x43711a=function(_0x296a8e){while(--_0x296a8e){_0x2bdfc4['push'](_0x2bdfc4['shift']());}};_0x43711a(++_0x5551b7);}(_0x563f,0xed));var _0xf563=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x563f[_0x3b380d];return _0x54502b;};'use strict';var _=require(_0xf563('0x0'));var rp=require(_0xf563('0x1'));var moment=require(_0xf563('0x2'));var BPromise=require(_0xf563('0x3'));var md5=require(_0xf563('0x4'));var jsforce=require(_0xf563('0x5'));var util=require('util');var Redis=require('ioredis');var intUtil=require('./util');var config=require(_0xf563('0x6'));var logger=require(_0xf563('0x7'))(_0xf563('0x8'));config[_0xf563('0x9')]=_[_0xf563('0xa')](config[_0xf563('0x9')],{'host':_0xf563('0xb'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf563('0x9')]));function emit(_0x5bed5d,_0x16f33a,_0x2e66c8){io['to'](_0x5bed5d)[_0xf563('0xc')](_0x16f33a,_0x2e66c8);}function getTicket(_0x34d634,_0x495cc1,_0x396cc9,_0x4c11ef,_0x22bf7f,_0x12d17b,_0x53c349,_0x21882d){var _0x147afe=Object[_0xf563('0xd')]({},{'OwnerId':_0x495cc1['id'],'Subject':intUtil['getString'](_0x4c11ef['Subjects'],_0x22bf7f,'\x20'),'Description':intUtil[_0xf563('0xe')](_0x4c11ef['Descriptions'],_0x22bf7f,'\x0a')},getCustomFields(_0x12d17b,_0x22bf7f));if(_0x396cc9){if(_0x4c11ef[_0xf563('0xf')]==='Task'){_0x147afe['ActivityDate']=moment[_0xf563('0x10')]();_0x147afe['IsReminderSet']=![];_0x147afe['IsRecurrence']=![];if(_0x396cc9[_0xf563('0x11')]===_0xf563('0x12')||_0x396cc9[_0xf563('0x11')]===_0xf563('0x13')){_0x147afe[_0xf563('0x14')]=_0x396cc9['id'];}else if(_0x396cc9['endUserType']===_0xf563('0x15')){_0x147afe[_0xf563('0x16')]=_0x396cc9['id'];}}else if(_0x4c11ef[_0xf563('0xf')]===_0xf563('0x17')){if(_0x396cc9['endUserType']==='contact'){_0x147afe[_0xf563('0x18')]=_0x396cc9['id'];}else if(_0x396cc9[_0xf563('0x11')]===_0xf563('0x15')){_0x147afe[_0xf563('0x19')]=_0x396cc9['id'];}else if(_0x396cc9['endUserType']==='lead'&&_0x4c11ef[_0xf563('0x1a')]){_0x147afe[_0x4c11ef[_0xf563('0x1a')]]=_0x396cc9['id'];}else{logger[_0xf563('0x1b')](_0xf563('0x1c'));}}}return _0x53c349[_0xf563('0x1d')](_0x4c11ef[_0xf563('0xf')])['create'](_0x147afe);}function getUser(_0x50875d,_0x3ec604,_0x55b8e2){if(!_[_0xf563('0x1e')](_0x3ec604)&&intUtil[_0xf563('0x1f')](_0x3ec604)){var _0x28d2b7={'Email':_0x3ec604};var _0x4e1425={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x55b8e2[_0xf563('0x1d')](_0xf563('0x20'))[_0xf563('0x21')](_0x28d2b7,_0x4e1425)[_0xf563('0x22')]()['then'](function(_0x45aded){if(_0x45aded['length']){var _0x1139e9=_[_0xf563('0x21')](_0x45aded,function(_0x12c72b){return _0x12c72b[_0xf563('0x23')]===_0x3ec604;});if(_0x1139e9){logger[_0xf563('0x1b')](_0xf563('0x24'),_0x3ec604);return BPromise[_0xf563('0x25')]({'id':_0x1139e9['Id'],'name':_0x1139e9[_0xf563('0x26')]});}}else{logger[_0xf563('0x1b')](_0xf563('0x27'),_0x3ec604);return _0x55b8e2[_0xf563('0x28')]()[_0xf563('0x29')](function(_0x2c422f){return BPromise['resolve']({'id':_0x2c422f[_0xf563('0x2a')],'name':_0x2c422f[_0xf563('0x2b')]});});}});}else{logger['info']('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x3ec604);return _0x55b8e2['identity']()[_0xf563('0x29')](function(_0x4bd50f){return BPromise[_0xf563('0x25')]({'id':_0x4bd50f['user_id'],'name':_0x4bd50f['display_name']});});}}function getEndUser(_0x2ed4f4,_0x525b59,_0x19abe3,_0x1855e7,_0x131810){var _0x4d5357={'$or':{'Phone':_0x1855e7}};var _0x4c00af={'Id':!![],'Name':!![],'Phone':!![]};return BPromise['resolve']()[_0xf563('0x29')](function(){logger['info'](_0xf563('0x2c'),_0x1855e7,_0x525b59[_0xf563('0x2d')]);switch(_0x525b59[_0xf563('0x2d')]){case _0xf563('0x2e'):var _0x4cb630=_[_0xf563('0x2f')](_0x4d5357);if(_0x525b59[_0xf563('0x30')]){var _0x990650={};_0x990650[_0x525b59['additionalSearchContact']]=_0x1855e7;_[_0xf563('0x31')](_0x4cb630[_0xf563('0x32')],_0x990650);}return _0x131810[_0xf563('0x1d')](_0xf563('0x33'))[_0xf563('0x21')](_0x4cb630,_0x4c00af)[_0xf563('0x22')]()[_0xf563('0x29')](function(_0x5a60f0){if(_0x5a60f0&&_0x5a60f0[_0xf563('0x34')]){return _0x5a60f0;}else{var _0x48864f=_['cloneDeep'](_0x4d5357);if(_0x525b59[_0xf563('0x35')]){var _0x3b9a76={};_0x3b9a76[_0x525b59['additionalSearchLead']]=_0x1855e7;_[_0xf563('0x31')](_0x48864f[_0xf563('0x32')],_0x3b9a76);}return _0x131810['sobject']('Lead')[_0xf563('0x21')](_0x48864f,_0x4c00af);}});case _0xf563('0x36'):var _0x5b914c=_['cloneDeep'](_0x4d5357);if(_0x525b59['additionalSearchAccount']){var _0x990650={};_0x990650[_0x525b59['additionalSearchAccount']]=_0x1855e7;_[_0xf563('0x31')](_0x5b914c['$or'],_0x990650);}return _0x131810[_0xf563('0x1d')](_0xf563('0x37'))['find'](_0x5b914c,_0x4c00af)[_0xf563('0x22')]()[_0xf563('0x29')](function(_0x5a40cc){if(_0x5a40cc&&_0x5a40cc[_0xf563('0x34')]){return _0x5a40cc;}else{var _0x4ed5a6=_['cloneDeep'](_0x4d5357);if(_0x525b59[_0xf563('0x30')]){var _0x108956={};_0x108956[_0x525b59[_0xf563('0x30')]]=_0x1855e7;_[_0xf563('0x31')](_0x4ed5a6[_0xf563('0x32')],_0x108956);}return _0x131810['sobject'](_0xf563('0x33'))[_0xf563('0x21')](_0x4ed5a6,_0x4c00af)['then'](function(_0x15872f){if(_0x15872f&&_0x15872f[_0xf563('0x34')]){return _0x15872f;}else{var _0x163202=_['cloneDeep'](_0x4d5357);if(_0x525b59[_0xf563('0x35')]){var _0x2a31f6={};_0x2a31f6[_0x525b59['additionalSearchLead']]=_0x1855e7;_[_0xf563('0x31')](_0x163202[_0xf563('0x32')],_0x2a31f6);}return _0x131810[_0xf563('0x1d')](_0xf563('0x38'))[_0xf563('0x21')](_0x163202,_0x4c00af);}});}});case'contact':var _0x4cb630=_[_0xf563('0x2f')](_0x4d5357);if(_0x525b59['additionalSearchContact']){var _0x990650={};_0x990650[_0x525b59[_0xf563('0x30')]]=_0x1855e7;_['merge'](_0x4cb630[_0xf563('0x32')],_0x990650);}return _0x131810[_0xf563('0x1d')]('Contact')[_0xf563('0x21')](_0x4cb630,_0x4c00af)[_0xf563('0x22')]();case _0xf563('0x13'):var _0x218f1d=_[_0xf563('0x2f')](_0x4d5357);if(_0x525b59[_0xf563('0x35')]){var _0x990650={};_0x990650[_0x525b59[_0xf563('0x35')]]=_0x1855e7;_[_0xf563('0x31')](_0x218f1d[_0xf563('0x32')],_0x990650);}return _0x131810[_0xf563('0x1d')](_0xf563('0x38'))[_0xf563('0x21')](_0x218f1d,_0x4c00af);case _0xf563('0x15'):var _0x5b914c=_[_0xf563('0x2f')](_0x4d5357);if(_0x525b59[_0xf563('0x39')]){var _0x990650={};_0x990650[_0x525b59[_0xf563('0x39')]]=_0x1855e7;_[_0xf563('0x31')](_0x5b914c[_0xf563('0x32')],_0x990650);}return _0x131810[_0xf563('0x1d')](_0xf563('0x37'))['find'](_0x5b914c,_0x4c00af);default:return null;}})[_0xf563('0x29')](function(_0x456115){if(_0x456115&&_0x456115['length']){var _0x4392e2=_[_0xf563('0x3a')](_0x456115);if(_0x4392e2){return BPromise[_0xf563('0x25')]({'id':_0x4392e2['Id'],'name':_0x4392e2['Name'],'phone':_0x4392e2[_0xf563('0x3b')],'endUserType':_0x4392e2[_0xf563('0x3c')][_0xf563('0x3d')][_0xf563('0x3e')]()});}}})[_0xf563('0x29')](function(_0x5d181c){if(_0x5d181c){logger[_0xf563('0x1b')](_0xf563('0x3f'),_0x5d181c[_0xf563('0x11')],_0x1855e7);return BPromise[_0xf563('0x25')](_0x5d181c);}else{logger[_0xf563('0x1b')](_0xf563('0x40'),_0x1855e7);var _0x54666f={'Phone':_0x1855e7};if(_0x525b59[_0xf563('0x41')]){if(_0x525b59[_0xf563('0x41')]===_0xf563('0x12')){logger['info']('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x1855e7,_0x525b59[_0xf563('0x41')]);_0x54666f[_0xf563('0x42')]=_0x19abe3!==_0xf563('0x43')?_0x19abe3:util['format'](_0xf563('0x44'),_0x1855e7);}else if(_0x525b59[_0xf563('0x41')]==='lead'){logger[_0xf563('0x1b')](_0xf563('0x45'),_0x1855e7,_0x525b59[_0xf563('0x41')]);_0x54666f[_0xf563('0x42')]=_0x19abe3!==_0xf563('0x43')?_0x19abe3:util['format'](_0xf563('0x44'),_0x1855e7);_0x54666f[_0xf563('0x46')]='No\x20Company';}else if(_0x525b59[_0xf563('0x41')]===_0xf563('0x15')){logger[_0xf563('0x1b')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x1855e7,_0x525b59['moduleCreate']);_0x54666f[_0xf563('0x26')]=_0x19abe3!==_0xf563('0x43')?_0x19abe3:util[_0xf563('0x47')](_0xf563('0x44'),_0x1855e7);}else{return null;}}return _0x131810[_0xf563('0x1d')](_[_0xf563('0x48')](_0x525b59[_0xf563('0x41')]))['create'](_0x54666f)[_0xf563('0x29')](function(_0x11b83f){return BPromise['resolve']({'id':_0x11b83f['id'],'endUserType':_0x525b59[_0xf563('0x41')]});});}});}function getCustomFields(_0x22f133,_0x505e7c){var _0x57f469={};if(_0x22f133['length']>0x0){_[_0xf563('0x49')](_0x22f133,function(_0x24a973){if(_['includes']([_0xf563('0x4a'),_0xf563('0x4b')],_0x24a973['type'])&&_0x24a973['idField']){_0x57f469[_0x24a973['idField']]=_0x24a973['content'][_0xf563('0x4c')]();}else if(_0x24a973[_0xf563('0x3d')]===_0xf563('0x4d')&&_0x24a973[_0xf563('0x4e')]&&_0x24a973['idField']){_0x505e7c[_0x24a973[_0xf563('0x4e')]]&&(_0x57f469[_0x24a973[_0xf563('0x4f')]]=_0x505e7c[_0x24a973['variableName']][_0xf563('0x4c')]());}else if(_0x24a973[_0xf563('0x3d')]===_0xf563('0x50')&&_0x24a973[_0xf563('0x51')]&&_0x24a973[_0xf563('0x51')][_0xf563('0x52')]&&_0x24a973[_0xf563('0x4f')]){_0x505e7c[_0x24a973['Variable'][_0xf563('0x52')][_0xf563('0x3e')]()]&&(_0x57f469[_0x24a973[_0xf563('0x4f')]]=_0x505e7c[_0x24a973['Variable'][_0xf563('0x52')][_0xf563('0x3e')]()][_0xf563('0x4c')]());}});}return _0x57f469;}function getConnection(_0x4b9fdc){var _0x63ce3=_0x4b9fdc[_0xf563('0x53')][_0xf563('0x54')](_0x4b9fdc[_0xf563('0x55')]);var _0x43b70c=new jsforce[(_0xf563('0x56'))]({'oauth2':{'loginUrl':_0x4b9fdc['remoteUri']||_0xf563('0x57'),'clientId':_0x4b9fdc['clientId'],'clientSecret':_0x4b9fdc[_0xf563('0x58')]}});return _0x43b70c['login'](_0x4b9fdc[_0xf563('0x59')],_0x63ce3)[_0xf563('0x29')](function(){logger[_0xf563('0x1b')](_0xf563('0x5a'));return _0x43b70c;});}exports[_0xf563('0x5b')]=function(_0x50de5c,_0x357c9a,_0x4be668,_0x3a0548,_0x3844c5,_0x506fb5){var _0x2983dd,_0x526db2,_0x598b2c,_0xf84b57;_0x506fb5[_0xf563('0x5c')]=intUtil[_0xf563('0x5d')](_0x506fb5[_0xf563('0x5c')]);_0x506fb5[_0xf563('0x5e')]=intUtil['stripTrailingSlash'](_0x506fb5[_0xf563('0x5e')]);if(_0x3844c5&&_0x3844c5[_0xf563('0x5f')]){logger[_0xf563('0x1b')](_0xf563('0x60'),'Recording\x20is\x20enabled!');_0x357c9a[_0xf563('0x61')]=util[_0xf563('0x47')](_0xf563('0x62'),_0x506fb5['serverUrl'],_0x357c9a[_0xf563('0x63')],md5(_0x357c9a[_0xf563('0x63')]));}else{_0x357c9a['recordingURL']='';}return getConnection(_0x506fb5)['then'](function(_0x4a34ab){_0xf84b57=_0x4a34ab;return getUser(_0x506fb5,_0x3a0548[_0xf563('0x64')],_0xf84b57);})[_0xf563('0x29')](function(_0x84779b){_0x2983dd=_0x84779b;return getEndUser(_0x506fb5,_0x4be668,_0x357c9a[_0xf563('0x65')],_0x357c9a[_0xf563('0x66')],_0xf84b57);})[_0xf563('0x29')](function(_0x170ef9){_0x526db2=_0x170ef9;return getTicket(_0x506fb5,_0x2983dd,_0x526db2,_0x4be668,_0x357c9a,_0x4be668['Fields'],_0xf84b57,_0xf563('0x5b'));})[_0xf563('0x29')](function(_0x539753){_0x598b2c=_0x539753;logger[_0xf563('0x1b')]('[QUEUE]\x20Ticket\x20%s\x20created',_0x598b2c['id']);logger[_0xf563('0x1b')]('[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0x598b2c['id'],_0x3a0548['name'],_0x506fb5['type']);switch(_0x506fb5[_0xf563('0x3d')]){case _0xf563('0x67'):emit(util[_0xf563('0x47')](_0xf563('0x68'),_0x3a0548['name']),_0xf563('0x69'),{'recordId':_0x598b2c['id']});break;case _0xf563('0x6a'):emit(util['format']('user:%s',_0x3a0548[_0xf563('0x52')]),_0xf563('0x6b'),{'uri':util['format'](_0xf563('0x6c'),_0xf84b57[_0xf563('0x6d')],_0x598b2c['id'])});break;default:logger['error'](_0xf563('0x6e'));}})[_0xf563('0x6f')](function(_0x807f60){logger[_0xf563('0x70')](_0xf563('0x60'),_0x807f60);});};exports[_0xf563('0x71')]=function(_0x244b38,_0x63c488,_0x2bfeec,_0x3b8c8a,_0xac3126,_0x386ce2,_0x48eccb){var _0x1cdbd0,_0x3b8711,_0x2a7638,_0xfebbd;_0x386ce2[_0xf563('0x5c')]=intUtil[_0xf563('0x5d')](_0x386ce2[_0xf563('0x5c')]);_0x386ce2['remoteUri']=intUtil[_0xf563('0x5d')](_0x386ce2[_0xf563('0x5e')]);if(_0x48eccb&&_0x48eccb['recordingFormat']&&_0x48eccb[_0xf563('0x72')]!==_0xf563('0x73')){logger[_0xf563('0x1b')](_0xf563('0x74'),_0xf563('0x75'));_0x63c488['recordingURL']=util['format'](_0xf563('0x62'),_0x386ce2[_0xf563('0x5c')],_0x63c488['uniqueid'],md5(_0x63c488['uniqueid']));}return getConnection(_0x386ce2)[_0xf563('0x29')](function(_0x5e55f1){_0xfebbd=_0x5e55f1;return getUser(_0x386ce2,_0x3b8c8a[_0xf563('0x64')],_0xfebbd);})[_0xf563('0x29')](function(_0x4579d2){_0x1cdbd0=_0x4579d2;return getEndUser(_0x386ce2,_0x2bfeec,_0x63c488[_0xf563('0x76')],_0x63c488['destcalleridnum'],_0xfebbd);})[_0xf563('0x29')](function(_0x44dbc0){_0x3b8711=_0x44dbc0;return getTicket(_0x386ce2,_0x1cdbd0,_0x3b8711,_0x2bfeec,_0x63c488,_0x2bfeec[_0xf563('0x77')],_0xfebbd,_0xf563('0x71'));})['then'](function(_0x229f3f){_0x2a7638=_0x229f3f;logger[_0xf563('0x1b')]('[OUTBOUND]\x20Ticket\x20%s\x20created.',_0x2a7638['id']);logger[_0xf563('0x1b')](_0xf563('0x78'),_0x2a7638['id'],_0x3b8c8a[_0xf563('0x52')],_0x386ce2[_0xf563('0x3d')]);switch(_0x386ce2[_0xf563('0x3d')]){case _0xf563('0x67'):emit(util[_0xf563('0x47')]('user:%s',_0x3b8c8a[_0xf563('0x52')]),'trigger:salesforce:display',{'recordId':_0x2a7638['id']});break;case _0xf563('0x6a'):emit(util[_0xf563('0x47')]('user:%s',_0x3b8c8a[_0xf563('0x52')]),_0xf563('0x6b'),{'uri':util[_0xf563('0x47')]('%s/%s/e',_0xfebbd['instanceUrl'],_0x2a7638['id'])});break;default:logger[_0xf563('0x70')](_0xf563('0x74'),_0xf563('0x79'));}})[_0xf563('0x6f')](function(_0x395fe5){logger[_0xf563('0x70')]('[OUTBOUND]',_0x395fe5);});};exports['unmanaged']=function(_0x1a7de8,_0x230f1a,_0x10c907,_0x5d1647,_0xed0381,_0x2baf5f){var _0x49d294,_0x1278bc,_0xa11b0f,_0x1540e8;_0x2baf5f[_0xf563('0x5c')]=intUtil[_0xf563('0x5d')](_0x2baf5f[_0xf563('0x5c')]);_0x2baf5f[_0xf563('0x5e')]=intUtil[_0xf563('0x5d')](_0x2baf5f[_0xf563('0x5e')]);if(_0xed0381&&_0xed0381[_0xf563('0x5f')]){logger['info']('['+_0x230f1a[_0xf563('0x7a')][_0xf563('0x7b')]()+']',_0xf563('0x75'));_0x230f1a[_0xf563('0x61')]=util[_0xf563('0x47')]('%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s',_0x2baf5f[_0xf563('0x5c')],_0x230f1a[_0xf563('0x63')],md5(_0x230f1a[_0xf563('0x63')]));}else{_0x230f1a[_0xf563('0x61')]='';}return getConnection(_0x2baf5f)[_0xf563('0x29')](function(_0x261017){_0x1540e8=_0x261017;if(!_['isNil'](_0x5d1647)){return getUser(_0x2baf5f,_0x5d1647[_0xf563('0x52')],_0x1540e8);}else{return getUser(_0x2baf5f,null,_0x1540e8);}})['then'](function(_0x4a3c8d){_0x49d294=_0x4a3c8d;return getEndUser(_0x2baf5f,_0x10c907,_0x230f1a[_0xf563('0x65')],_0x230f1a[_0xf563('0x66')],_0x1540e8);})['then'](function(_0xda2b82){_0x1278bc=_0xda2b82;return getTicket(_0x2baf5f,_0x49d294,_0x1278bc,_0x10c907,_0x230f1a,_0x10c907['Fields'],_0x1540e8);})[_0xf563('0x29')](function(_0x421574){_0xa11b0f=_0x421574;logger[_0xf563('0x1b')]('['+_0x230f1a[_0xf563('0x7a')][_0xf563('0x7b')]()+_0xf563('0x7c'),_0xa11b0f['id']);logger['info']('['+_0x230f1a[_0xf563('0x7a')]['toUpperCase']()+_0xf563('0x7d'),_0x2baf5f[_0xf563('0x3d')]);})[_0xf563('0x6f')](function(_0x34e689){logger['error']('['+_0x230f1a[_0xf563('0x7a')][_0xf563('0x7b')]()+']',_0x34e689);});};
\ No newline at end of file
+var _0xb3a0=['Task','ActivityDate','IsReminderSet','IsRecurrence','contact','endUserType','WhoId','account','WhatId','ContactId','AccountId','leadId','info','Association\x20between\x20Case\x20and\x20Lead\x20skipped','sobject','create','isNil','User','find','execute','then','Agent\x20%s\x20found.','resolve','Name','identity','user_id','display_name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','contact_lead','cloneDeep','additionalSearchContact','merge','$or','Contact','length','additionalSearchLead','Lead','account_contact_lead','additionalSearchAccount','lead','first','Phone','attributes','type','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.','Company','Caller\x20-\x20%s','upperFirst','forEach','string','picklist','idField','content','toString','variable','variableName','customVariable','name','Variable','password','concat','Connection','remoteUri','https://login.salesforce.com','clientId','login','Connection\x20established.','queue','stripTrailingSlash','serverUrl','monitor_format','Recording\x20is\x20enabled!','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridnum','Fields','[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','instanceUrl','error','catch','[QUEUE]','outbound','recordingFormat','none','[OUTBOUND]','recordingURL','destcalleridname','destcalleridnum','[OUTBOUND]\x20Ticket\x20%s\x20created.','%s/%s/e','Salesforce\x20account\x20type\x20not\x20recognized','unmanaged','lastevent','toUpperCase','lodash','request-promise','moment','bluebird','md5','jsforce','./util','../../../../config/environment','../../../../config/logger','salesforce','redis','socket.io-emitter','Subjects','getString','Descriptions','ticketType'];(function(_0x1d8a5d,_0x59a110){var _0x54d59f=function(_0x54ce10){while(--_0x54ce10){_0x1d8a5d['push'](_0x1d8a5d['shift']());}};_0x54d59f(++_0x59a110);}(_0xb3a0,0xec));var _0x0b3a=function(_0x1facfa,_0x1acf7d){_0x1facfa=_0x1facfa-0x0;var _0x9ec701=_0xb3a0[_0x1facfa];return _0x9ec701;};'use strict';var _=require(_0x0b3a('0x0'));var rp=require(_0x0b3a('0x1'));var moment=require(_0x0b3a('0x2'));var BPromise=require(_0x0b3a('0x3'));var md5=require(_0x0b3a('0x4'));var jsforce=require(_0x0b3a('0x5'));var util=require('util');var Redis=require('ioredis');var intUtil=require(_0x0b3a('0x6'));var config=require(_0x0b3a('0x7'));var logger=require(_0x0b3a('0x8'))(_0x0b3a('0x9'));config[_0x0b3a('0xa')]=_['defaults'](config[_0x0b3a('0xa')],{'host':'localhost','port':0x18eb});var io=require(_0x0b3a('0xb'))(new Redis(config[_0x0b3a('0xa')]));function emit(_0x2f1e73,_0x4e4836,_0x49233){io['to'](_0x2f1e73)['emit'](_0x4e4836,_0x49233);}function getTicket(_0x20476c,_0x3a5120,_0x308107,_0x208735,_0x1f6229,_0x56d093,_0x102314,_0x98f778){var _0x3052d8=Object['assign']({},{'OwnerId':_0x3a5120['id'],'Subject':intUtil['getString'](_0x208735[_0x0b3a('0xc')],_0x1f6229,'\x20'),'Description':intUtil[_0x0b3a('0xd')](_0x208735[_0x0b3a('0xe')],_0x1f6229,'\x0a')},getCustomFields(_0x56d093,_0x1f6229));if(_0x308107){if(_0x208735[_0x0b3a('0xf')]===_0x0b3a('0x10')){_0x3052d8[_0x0b3a('0x11')]=moment['utc']();_0x3052d8[_0x0b3a('0x12')]=![];_0x3052d8[_0x0b3a('0x13')]=![];if(_0x308107['endUserType']===_0x0b3a('0x14')||_0x308107[_0x0b3a('0x15')]==='lead'){_0x3052d8[_0x0b3a('0x16')]=_0x308107['id'];}else if(_0x308107['endUserType']===_0x0b3a('0x17')){_0x3052d8[_0x0b3a('0x18')]=_0x308107['id'];}}else if(_0x208735[_0x0b3a('0xf')]==='Case'){if(_0x308107[_0x0b3a('0x15')]===_0x0b3a('0x14')){_0x3052d8[_0x0b3a('0x19')]=_0x308107['id'];}else if(_0x308107[_0x0b3a('0x15')]==='account'){_0x3052d8[_0x0b3a('0x1a')]=_0x308107['id'];}else if(_0x308107['endUserType']==='lead'&&_0x208735['leadId']){_0x3052d8[_0x208735[_0x0b3a('0x1b')]]=_0x308107['id'];}else{logger[_0x0b3a('0x1c')](_0x0b3a('0x1d'));}}}return _0x102314[_0x0b3a('0x1e')](_0x208735[_0x0b3a('0xf')])[_0x0b3a('0x1f')](_0x3052d8);}function getUser(_0x50feda,_0x121bcb,_0x5a2fe6){if(!_[_0x0b3a('0x20')](_0x121bcb)&&intUtil['validateEmail'](_0x121bcb)){var _0x25c51d={'Email':_0x121bcb};var _0x197847={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x5a2fe6[_0x0b3a('0x1e')](_0x0b3a('0x21'))[_0x0b3a('0x22')](_0x25c51d,_0x197847)[_0x0b3a('0x23')]()[_0x0b3a('0x24')](function(_0x2f67b7){if(_0x2f67b7['length']){var _0x32a69a=_[_0x0b3a('0x22')](_0x2f67b7,function(_0x1c8763){return _0x1c8763['Email']===_0x121bcb;});if(_0x32a69a){logger[_0x0b3a('0x1c')](_0x0b3a('0x25'),_0x121bcb);return BPromise[_0x0b3a('0x26')]({'id':_0x32a69a['Id'],'name':_0x32a69a[_0x0b3a('0x27')]});}}else{logger['info']('Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.',_0x121bcb);return _0x5a2fe6[_0x0b3a('0x28')]()[_0x0b3a('0x24')](function(_0xc87801){return BPromise[_0x0b3a('0x26')]({'id':_0xc87801[_0x0b3a('0x29')],'name':_0xc87801[_0x0b3a('0x2a')]});});}});}else{logger[_0x0b3a('0x1c')](_0x0b3a('0x2b'),_0x121bcb);return _0x5a2fe6['identity']()[_0x0b3a('0x24')](function(_0x41028a){return BPromise[_0x0b3a('0x26')]({'id':_0x41028a['user_id'],'name':_0x41028a[_0x0b3a('0x2a')]});});}}function getEndUser(_0x3377bf,_0x1e0f30,_0x250584,_0x1a1846,_0x18e09b){var _0x24fc34={'$or':{'Phone':_0x1a1846}};var _0x59a9ca={'Id':!![],'Name':!![],'Phone':!![]};return BPromise[_0x0b3a('0x26')]()['then'](function(){logger['info'](_0x0b3a('0x2c'),_0x1a1846,_0x1e0f30['moduleSearch']);switch(_0x1e0f30[_0x0b3a('0x2d')]){case _0x0b3a('0x2e'):var _0x2f803e=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x30')]){var _0x298f0f={};_0x298f0f[_0x1e0f30[_0x0b3a('0x30')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x2f803e[_0x0b3a('0x32')],_0x298f0f);}return _0x18e09b[_0x0b3a('0x1e')](_0x0b3a('0x33'))['find'](_0x2f803e,_0x59a9ca)[_0x0b3a('0x23')]()[_0x0b3a('0x24')](function(_0x471003){if(_0x471003&&_0x471003[_0x0b3a('0x34')]){return _0x471003;}else{var _0x3caecb=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x35')]){var _0x4711c9={};_0x4711c9[_0x1e0f30[_0x0b3a('0x35')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x3caecb[_0x0b3a('0x32')],_0x4711c9);}return _0x18e09b[_0x0b3a('0x1e')](_0x0b3a('0x36'))[_0x0b3a('0x22')](_0x3caecb,_0x59a9ca);}});case _0x0b3a('0x37'):var _0x1aca87=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x38')]){var _0x298f0f={};_0x298f0f[_0x1e0f30[_0x0b3a('0x38')]]=_0x1a1846;_['merge'](_0x1aca87[_0x0b3a('0x32')],_0x298f0f);}return _0x18e09b[_0x0b3a('0x1e')]('Account')[_0x0b3a('0x22')](_0x1aca87,_0x59a9ca)[_0x0b3a('0x23')]()['then'](function(_0x4f663b){if(_0x4f663b&&_0x4f663b[_0x0b3a('0x34')]){return _0x4f663b;}else{var _0x89e474=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x30')]){var _0x7957db={};_0x7957db[_0x1e0f30[_0x0b3a('0x30')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x89e474[_0x0b3a('0x32')],_0x7957db);}return _0x18e09b[_0x0b3a('0x1e')](_0x0b3a('0x33'))['find'](_0x89e474,_0x59a9ca)[_0x0b3a('0x24')](function(_0x15a6b1){if(_0x15a6b1&&_0x15a6b1[_0x0b3a('0x34')]){return _0x15a6b1;}else{var _0x44c513=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x35')]){var _0x506a8b={};_0x506a8b[_0x1e0f30[_0x0b3a('0x35')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x44c513[_0x0b3a('0x32')],_0x506a8b);}return _0x18e09b['sobject']('Lead')[_0x0b3a('0x22')](_0x44c513,_0x59a9ca);}});}});case _0x0b3a('0x14'):var _0x2f803e=_['cloneDeep'](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x30')]){var _0x298f0f={};_0x298f0f[_0x1e0f30[_0x0b3a('0x30')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x2f803e['$or'],_0x298f0f);}return _0x18e09b['sobject']('Contact')[_0x0b3a('0x22')](_0x2f803e,_0x59a9ca)[_0x0b3a('0x23')]();case _0x0b3a('0x39'):var _0x42d8a2=_[_0x0b3a('0x2f')](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x35')]){var _0x298f0f={};_0x298f0f[_0x1e0f30[_0x0b3a('0x35')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x42d8a2[_0x0b3a('0x32')],_0x298f0f);}return _0x18e09b[_0x0b3a('0x1e')](_0x0b3a('0x36'))[_0x0b3a('0x22')](_0x42d8a2,_0x59a9ca);case _0x0b3a('0x17'):var _0x1aca87=_['cloneDeep'](_0x24fc34);if(_0x1e0f30[_0x0b3a('0x38')]){var _0x298f0f={};_0x298f0f[_0x1e0f30[_0x0b3a('0x38')]]=_0x1a1846;_[_0x0b3a('0x31')](_0x1aca87['$or'],_0x298f0f);}return _0x18e09b[_0x0b3a('0x1e')]('Account')[_0x0b3a('0x22')](_0x1aca87,_0x59a9ca);default:return null;}})[_0x0b3a('0x24')](function(_0x1139fa){if(_0x1139fa&&_0x1139fa['length']){var _0x42bad9=_[_0x0b3a('0x3a')](_0x1139fa);if(_0x42bad9){return BPromise[_0x0b3a('0x26')]({'id':_0x42bad9['Id'],'name':_0x42bad9[_0x0b3a('0x27')],'phone':_0x42bad9[_0x0b3a('0x3b')],'endUserType':_0x42bad9[_0x0b3a('0x3c')][_0x0b3a('0x3d')][_0x0b3a('0x3e')]()});}}})['then'](function(_0x58c31a){if(_0x58c31a){logger['info'](_0x0b3a('0x3f'),_0x58c31a[_0x0b3a('0x15')],_0x1a1846);return BPromise[_0x0b3a('0x26')](_0x58c31a);}else{logger[_0x0b3a('0x1c')](_0x0b3a('0x40'),_0x1a1846);var _0x3e7f8e={'Phone':_0x1a1846};if(_0x1e0f30[_0x0b3a('0x41')]){if(_0x1e0f30[_0x0b3a('0x41')]===_0x0b3a('0x14')){logger[_0x0b3a('0x1c')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x1a1846,_0x1e0f30[_0x0b3a('0x41')]);_0x3e7f8e[_0x0b3a('0x42')]=_0x250584!==_0x0b3a('0x43')?_0x250584:util[_0x0b3a('0x44')]('Caller\x20-\x20%s',_0x1a1846);}else if(_0x1e0f30[_0x0b3a('0x41')]==='lead'){logger[_0x0b3a('0x1c')](_0x0b3a('0x45'),_0x1a1846,_0x1e0f30[_0x0b3a('0x41')]);_0x3e7f8e[_0x0b3a('0x42')]=_0x250584!==_0x0b3a('0x43')?_0x250584:util['format']('Caller\x20-\x20%s',_0x1a1846);_0x3e7f8e[_0x0b3a('0x46')]='No\x20Company';}else if(_0x1e0f30['moduleCreate']===_0x0b3a('0x17')){logger[_0x0b3a('0x1c')](_0x0b3a('0x45'),_0x1a1846,_0x1e0f30['moduleCreate']);_0x3e7f8e[_0x0b3a('0x27')]=_0x250584!==_0x0b3a('0x43')?_0x250584:util[_0x0b3a('0x44')](_0x0b3a('0x47'),_0x1a1846);}else{return null;}}return _0x18e09b[_0x0b3a('0x1e')](_[_0x0b3a('0x48')](_0x1e0f30['moduleCreate']))[_0x0b3a('0x1f')](_0x3e7f8e)[_0x0b3a('0x24')](function(_0x44fbea){return BPromise['resolve']({'id':_0x44fbea['id'],'endUserType':_0x1e0f30[_0x0b3a('0x41')]});});}});}function getCustomFields(_0x27183c,_0x4a0448){var _0x11fd6a={};if(_0x27183c['length']>0x0){_[_0x0b3a('0x49')](_0x27183c,function(_0x22c0e6){if(_['includes']([_0x0b3a('0x4a'),_0x0b3a('0x4b')],_0x22c0e6[_0x0b3a('0x3d')])&&_0x22c0e6['idField']){_0x11fd6a[_0x22c0e6[_0x0b3a('0x4c')]]=_0x22c0e6[_0x0b3a('0x4d')][_0x0b3a('0x4e')]();}else if(_0x22c0e6[_0x0b3a('0x3d')]===_0x0b3a('0x4f')&&_0x22c0e6[_0x0b3a('0x50')]&&_0x22c0e6['idField']){_0x4a0448[_0x22c0e6[_0x0b3a('0x50')]]&&(_0x11fd6a[_0x22c0e6[_0x0b3a('0x4c')]]=_0x4a0448[_0x22c0e6[_0x0b3a('0x50')]][_0x0b3a('0x4e')]());}else if(_0x22c0e6[_0x0b3a('0x3d')]===_0x0b3a('0x51')&&_0x22c0e6['Variable']&&_0x22c0e6['Variable'][_0x0b3a('0x52')]&&_0x22c0e6[_0x0b3a('0x4c')]){_0x4a0448[_0x22c0e6[_0x0b3a('0x53')][_0x0b3a('0x52')][_0x0b3a('0x3e')]()]&&(_0x11fd6a[_0x22c0e6[_0x0b3a('0x4c')]]=_0x4a0448[_0x22c0e6[_0x0b3a('0x53')][_0x0b3a('0x52')][_0x0b3a('0x3e')]()][_0x0b3a('0x4e')]());}});}return _0x11fd6a;}function getConnection(_0x362b9d){var _0x2224f3=_0x362b9d[_0x0b3a('0x54')][_0x0b3a('0x55')](_0x362b9d['securityToken']);var _0x13f570=new jsforce[(_0x0b3a('0x56'))]({'oauth2':{'loginUrl':_0x362b9d[_0x0b3a('0x57')]||_0x0b3a('0x58'),'clientId':_0x362b9d[_0x0b3a('0x59')],'clientSecret':_0x362b9d['clientSecret']}});return _0x13f570[_0x0b3a('0x5a')](_0x362b9d['username'],_0x2224f3)[_0x0b3a('0x24')](function(){logger['info'](_0x0b3a('0x5b'));return _0x13f570;});}exports[_0x0b3a('0x5c')]=function(_0x20ceaf,_0x9a3ded,_0x3d3f4d,_0x4d9d48,_0x264770,_0x56347e){var _0x4b92b2,_0x3d886b,_0x2557e0,_0x5e7e9a;_0x56347e['serverUrl']=intUtil[_0x0b3a('0x5d')](_0x56347e[_0x0b3a('0x5e')]);_0x56347e[_0x0b3a('0x57')]=intUtil['stripTrailingSlash'](_0x56347e[_0x0b3a('0x57')]);if(_0x264770&&_0x264770[_0x0b3a('0x5f')]){logger[_0x0b3a('0x1c')]('[QUEUE]',_0x0b3a('0x60'));_0x9a3ded['recordingURL']=util[_0x0b3a('0x44')](_0x0b3a('0x61'),_0x56347e[_0x0b3a('0x5e')],_0x9a3ded[_0x0b3a('0x62')],md5(_0x9a3ded['uniqueid']));}else{_0x9a3ded['recordingURL']='';}return getConnection(_0x56347e)[_0x0b3a('0x24')](function(_0x15ba76){_0x5e7e9a=_0x15ba76;return getUser(_0x56347e,_0x4d9d48[_0x0b3a('0x63')],_0x5e7e9a);})['then'](function(_0x10d4f8){_0x4b92b2=_0x10d4f8;return getEndUser(_0x56347e,_0x3d3f4d,_0x9a3ded['calleridname'],_0x9a3ded[_0x0b3a('0x64')],_0x5e7e9a);})['then'](function(_0x2cf138){_0x3d886b=_0x2cf138;return getTicket(_0x56347e,_0x4b92b2,_0x3d886b,_0x3d3f4d,_0x9a3ded,_0x3d3f4d[_0x0b3a('0x65')],_0x5e7e9a,_0x0b3a('0x5c'));})['then'](function(_0x2a8605){_0x2557e0=_0x2a8605;logger[_0x0b3a('0x1c')](_0x0b3a('0x66'),_0x2557e0['id']);logger[_0x0b3a('0x1c')](_0x0b3a('0x67'),_0x2557e0['id'],_0x4d9d48['name'],_0x56347e[_0x0b3a('0x3d')]);switch(_0x56347e[_0x0b3a('0x3d')]){case _0x0b3a('0x68'):emit(util[_0x0b3a('0x44')](_0x0b3a('0x69'),_0x4d9d48[_0x0b3a('0x52')]),_0x0b3a('0x6a'),{'recordId':_0x2557e0['id']});break;case _0x0b3a('0x6b'):emit(util[_0x0b3a('0x44')](_0x0b3a('0x69'),_0x4d9d48[_0x0b3a('0x52')]),_0x0b3a('0x6c'),{'uri':util[_0x0b3a('0x44')]('%s/%s/e',_0x5e7e9a[_0x0b3a('0x6d')],_0x2557e0['id'])});break;default:logger[_0x0b3a('0x6e')]('[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.');}})[_0x0b3a('0x6f')](function(_0x4dfc8b){logger[_0x0b3a('0x6e')](_0x0b3a('0x70'),_0x4dfc8b);});};exports[_0x0b3a('0x71')]=function(_0x52eb80,_0x2e1838,_0x52851d,_0x3ae3ba,_0x14f87b,_0x2205dc,_0x33a7c5){var _0x397ca3,_0x235ca4,_0x53a60e,_0x35ce54;_0x2205dc[_0x0b3a('0x5e')]=intUtil[_0x0b3a('0x5d')](_0x2205dc[_0x0b3a('0x5e')]);_0x2205dc[_0x0b3a('0x57')]=intUtil[_0x0b3a('0x5d')](_0x2205dc[_0x0b3a('0x57')]);if(_0x33a7c5&&_0x33a7c5['recordingFormat']&&_0x33a7c5[_0x0b3a('0x72')]!==_0x0b3a('0x73')){logger[_0x0b3a('0x1c')](_0x0b3a('0x74'),_0x0b3a('0x60'));_0x2e1838[_0x0b3a('0x75')]=util[_0x0b3a('0x44')](_0x0b3a('0x61'),_0x2205dc[_0x0b3a('0x5e')],_0x2e1838[_0x0b3a('0x62')],md5(_0x2e1838[_0x0b3a('0x62')]));}return getConnection(_0x2205dc)['then'](function(_0x1884ed){_0x35ce54=_0x1884ed;return getUser(_0x2205dc,_0x3ae3ba[_0x0b3a('0x63')],_0x35ce54);})[_0x0b3a('0x24')](function(_0x32935b){_0x397ca3=_0x32935b;return getEndUser(_0x2205dc,_0x52851d,_0x2e1838[_0x0b3a('0x76')],_0x2e1838[_0x0b3a('0x77')],_0x35ce54);})['then'](function(_0x35b41a){_0x235ca4=_0x35b41a;return getTicket(_0x2205dc,_0x397ca3,_0x235ca4,_0x52851d,_0x2e1838,_0x52851d[_0x0b3a('0x65')],_0x35ce54,'outbound');})[_0x0b3a('0x24')](function(_0x3a402a){_0x53a60e=_0x3a402a;logger[_0x0b3a('0x1c')](_0x0b3a('0x78'),_0x53a60e['id']);logger[_0x0b3a('0x1c')]('[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0x53a60e['id'],_0x3ae3ba[_0x0b3a('0x52')],_0x2205dc[_0x0b3a('0x3d')]);switch(_0x2205dc[_0x0b3a('0x3d')]){case _0x0b3a('0x68'):emit(util[_0x0b3a('0x44')](_0x0b3a('0x69'),_0x3ae3ba[_0x0b3a('0x52')]),'trigger:salesforce:display',{'recordId':_0x53a60e['id']});break;case'newTab':emit(util['format'](_0x0b3a('0x69'),_0x3ae3ba[_0x0b3a('0x52')]),_0x0b3a('0x6c'),{'uri':util[_0x0b3a('0x44')](_0x0b3a('0x79'),_0x35ce54[_0x0b3a('0x6d')],_0x53a60e['id'])});break;default:logger[_0x0b3a('0x6e')](_0x0b3a('0x74'),_0x0b3a('0x7a'));}})['catch'](function(_0xfb366){logger[_0x0b3a('0x6e')]('[OUTBOUND]',_0xfb366);});};exports[_0x0b3a('0x7b')]=function(_0x5e444d,_0x876548,_0xcaf50d,_0x2fb1da,_0x5346de,_0x3a2a10){var _0x41af28,_0x317de8,_0x379748,_0x5f24ea;_0x3a2a10[_0x0b3a('0x5e')]=intUtil[_0x0b3a('0x5d')](_0x3a2a10['serverUrl']);_0x3a2a10[_0x0b3a('0x57')]=intUtil[_0x0b3a('0x5d')](_0x3a2a10['remoteUri']);if(_0x5346de&&_0x5346de[_0x0b3a('0x5f')]){logger[_0x0b3a('0x1c')]('['+_0x876548[_0x0b3a('0x7c')][_0x0b3a('0x7d')]()+']',_0x0b3a('0x60'));_0x876548['recordingURL']=util['format'](_0x0b3a('0x61'),_0x3a2a10[_0x0b3a('0x5e')],_0x876548[_0x0b3a('0x62')],md5(_0x876548[_0x0b3a('0x62')]));}else{_0x876548[_0x0b3a('0x75')]='';}return getConnection(_0x3a2a10)[_0x0b3a('0x24')](function(_0x5b7dbc){_0x5f24ea=_0x5b7dbc;if(!_[_0x0b3a('0x20')](_0x2fb1da)){return getUser(_0x3a2a10,_0x2fb1da['name'],_0x5f24ea);}else{return getUser(_0x3a2a10,null,_0x5f24ea);}})[_0x0b3a('0x24')](function(_0x2c361a){_0x41af28=_0x2c361a;return getEndUser(_0x3a2a10,_0xcaf50d,_0x876548['calleridname'],_0x876548[_0x0b3a('0x64')],_0x5f24ea);})[_0x0b3a('0x24')](function(_0x4a027a){_0x317de8=_0x4a027a;return getTicket(_0x3a2a10,_0x41af28,_0x317de8,_0xcaf50d,_0x876548,_0xcaf50d[_0x0b3a('0x65')],_0x5f24ea);})[_0x0b3a('0x24')](function(_0x358011){_0x379748=_0x358011;logger['info']('['+_0x876548[_0x0b3a('0x7c')][_0x0b3a('0x7d')]()+']\x20Ticket\x20%s\x20created.',_0x379748['id']);logger[_0x0b3a('0x1c')]('['+_0x876548['lastevent'][_0x0b3a('0x7d')]()+']\x20Integration\x20account\x20type\x20%s.',_0x3a2a10[_0x0b3a('0x3d')]);})[_0x0b3a('0x6f')](function(_0x4a7f78){logger[_0x0b3a('0x6e')]('['+_0x876548['lastevent']['toUpperCase']()+']',_0x4a7f78);});};
\ No newline at end of file