Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / services / ami / trigger / integration / salesforce.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc487=['Company','No\x20Company','Name','upperFirst','forEach','includes','picklist','idField','content','toString','variable','variableName','customVariable','Variable','name','securityToken','Connection','remoteUri','https://login.salesforce.com','clientSecret','login','Connection\x20established.','stripTrailingSlash','serverUrl','[QUEUE]','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','calleridnum','Fields','queue','user:%s','trigger:salesforce:display','newTab','trigger:browser:url','%s/%s/e','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','recordingFormat','[OUTBOUND]','destcalleridname','outbound','[OUTBOUND]\x20Ticket\x20%s\x20created.','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','integrationTab','unmanaged','monitor_format','lastevent','toUpperCase','Recording\x20is\x20enabled!',']\x20Ticket\x20%s\x20created.','lodash','request-promise','moment','md5','jsforce','util','ioredis','./util','../../../../config/environment','../../../../config/logger','salesforce','redis','socket.io-emitter','getString','Subjects','Descriptions','Task','ActivityDate','utc','IsReminderSet','IsRecurrence','endUserType','contact','lead','account','WhatId','ticketType','Case','ContactId','AccountId','leadId','info','create','isNil','validateEmail','sobject','User','find','execute','then','length','Email','Agent\x20%s\x20found.','resolve','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','user_id','display_name','identity','Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.','moduleSearch','cloneDeep','additionalSearchContact','$or','Contact','additionalSearchLead','merge','Lead','account_contact_lead','additionalSearchAccount','Account','first','Phone','attributes','type','toLowerCase','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','Caller\x20-\x20%s','<unknown>','format'];(function(_0x52991d,_0x429d72){var _0x5b9004=function(_0x4bfe0d){while(--_0x4bfe0d){_0x52991d['push'](_0x52991d['shift']());}};_0x5b9004(++_0x429d72);}(_0xc487,0x134));var _0x7c48=function(_0x416a0a,_0x24f91f){_0x416a0a=_0x416a0a-0x0;var _0x574c9f=_0xc487[_0x416a0a];return _0x574c9f;};'use strict';var _=require(_0x7c48('0x0'));var rp=require(_0x7c48('0x1'));var moment=require(_0x7c48('0x2'));var BPromise=require('bluebird');var md5=require(_0x7c48('0x3'));var jsforce=require(_0x7c48('0x4'));var util=require(_0x7c48('0x5'));var Redis=require(_0x7c48('0x6'));var intUtil=require(_0x7c48('0x7'));var config=require(_0x7c48('0x8'));var logger=require(_0x7c48('0x9'))(_0x7c48('0xa'));config[_0x7c48('0xb')]=_['defaults'](config[_0x7c48('0xb')],{'host':'localhost','port':0x18eb});var io=require(_0x7c48('0xc'))(new Redis(config[_0x7c48('0xb')]));function emit(_0x4cadc,_0x218153,_0x526a24){io['to'](_0x4cadc)['emit'](_0x218153,_0x526a24);}function getTicket(_0x4c60f1,_0x18555f,_0x1deea4,_0x2d308e,_0x3ae8ef,_0x2a7c09,_0x46c60f,_0x188b38){var _0x52ede3=Object['assign']({},{'OwnerId':_0x18555f['id'],'Subject':intUtil[_0x7c48('0xd')](_0x2d308e[_0x7c48('0xe')],_0x3ae8ef,'\x20'),'Description':intUtil[_0x7c48('0xd')](_0x2d308e[_0x7c48('0xf')],_0x3ae8ef,'\x0a')},getCustomFields(_0x2a7c09,_0x3ae8ef));if(_0x1deea4){if(_0x2d308e['ticketType']===_0x7c48('0x10')){_0x52ede3[_0x7c48('0x11')]=moment[_0x7c48('0x12')]();_0x52ede3[_0x7c48('0x13')]=![];_0x52ede3[_0x7c48('0x14')]=![];if(_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x16')||_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x17')){_0x52ede3['WhoId']=_0x1deea4['id'];}else if(_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x18')){_0x52ede3[_0x7c48('0x19')]=_0x1deea4['id'];}}else if(_0x2d308e[_0x7c48('0x1a')]===_0x7c48('0x1b')){if(_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x16')){_0x52ede3[_0x7c48('0x1c')]=_0x1deea4['id'];}else if(_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x18')){_0x52ede3[_0x7c48('0x1d')]=_0x1deea4['id'];}else if(_0x1deea4[_0x7c48('0x15')]===_0x7c48('0x17')&&_0x2d308e[_0x7c48('0x1e')]){_0x52ede3[_0x2d308e['leadId']]=_0x1deea4['id'];}else{logger[_0x7c48('0x1f')]('Association\x20between\x20Case\x20and\x20Lead\x20skipped');}}}return _0x46c60f['sobject'](_0x2d308e[_0x7c48('0x1a')])[_0x7c48('0x20')](_0x52ede3);}function getUser(_0x50fdb1,_0x5ab7f7,_0x45370f){if(!_[_0x7c48('0x21')](_0x5ab7f7)&&intUtil[_0x7c48('0x22')](_0x5ab7f7)){var _0x4d53db={'Email':_0x5ab7f7};var _0x20bc59={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x45370f[_0x7c48('0x23')](_0x7c48('0x24'))[_0x7c48('0x25')](_0x4d53db,_0x20bc59)[_0x7c48('0x26')]()[_0x7c48('0x27')](function(_0x579637){if(_0x579637[_0x7c48('0x28')]){var _0x17ffa3=_['find'](_0x579637,function(_0x36abcf){return _0x36abcf[_0x7c48('0x29')]===_0x5ab7f7;});if(_0x17ffa3){logger[_0x7c48('0x1f')](_0x7c48('0x2a'),_0x5ab7f7);return BPromise[_0x7c48('0x2b')]({'id':_0x17ffa3['Id'],'name':_0x17ffa3['Name']});}}else{logger['info'](_0x7c48('0x2c'),_0x5ab7f7);return _0x45370f['identity']()['then'](function(_0x4cb84b){return BPromise[_0x7c48('0x2b')]({'id':_0x4cb84b[_0x7c48('0x2d')],'name':_0x4cb84b[_0x7c48('0x2e')]});});}});}else{logger[_0x7c48('0x1f')](_0x7c48('0x2c'),_0x5ab7f7);return _0x45370f[_0x7c48('0x2f')]()[_0x7c48('0x27')](function(_0x4d283a){return BPromise[_0x7c48('0x2b')]({'id':_0x4d283a[_0x7c48('0x2d')],'name':_0x4d283a['display_name']});});}}function getEndUser(_0x504f00,_0x25f0a6,_0x16339d,_0x21f7f6,_0x363f67){var _0x3fd447={'$or':{'Phone':_0x21f7f6}};var _0x5ce565={'Id':!![],'Name':!![],'Phone':!![]};return BPromise['resolve']()[_0x7c48('0x27')](function(){logger[_0x7c48('0x1f')](_0x7c48('0x30'),_0x21f7f6,_0x25f0a6[_0x7c48('0x31')]);switch(_0x25f0a6['moduleSearch']){case'contact_lead':var _0x24644f=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6[_0x7c48('0x33')]){var _0x16aff5={};_0x16aff5[_0x25f0a6[_0x7c48('0x33')]]=_0x21f7f6;_['merge'](_0x24644f[_0x7c48('0x34')],_0x16aff5);}return _0x363f67[_0x7c48('0x23')](_0x7c48('0x35'))[_0x7c48('0x25')](_0x24644f,_0x5ce565)[_0x7c48('0x26')]()[_0x7c48('0x27')](function(_0x5c5392){if(_0x5c5392&&_0x5c5392['length']){return _0x5c5392;}else{var _0x5eaeb4=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6['additionalSearchLead']){var _0xf1e185={};_0xf1e185[_0x25f0a6[_0x7c48('0x36')]]=_0x21f7f6;_[_0x7c48('0x37')](_0x5eaeb4['$or'],_0xf1e185);}return _0x363f67[_0x7c48('0x23')](_0x7c48('0x38'))[_0x7c48('0x25')](_0x5eaeb4,_0x5ce565);}});case _0x7c48('0x39'):var _0x1366b2=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6['additionalSearchAccount']){var _0x16aff5={};_0x16aff5[_0x25f0a6[_0x7c48('0x3a')]]=_0x21f7f6;_[_0x7c48('0x37')](_0x1366b2[_0x7c48('0x34')],_0x16aff5);}return _0x363f67[_0x7c48('0x23')](_0x7c48('0x3b'))[_0x7c48('0x25')](_0x1366b2,_0x5ce565)[_0x7c48('0x26')]()[_0x7c48('0x27')](function(_0x426e2d){if(_0x426e2d&&_0x426e2d[_0x7c48('0x28')]){return _0x426e2d;}else{var _0x42982e=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6[_0x7c48('0x33')]){var _0x794916={};_0x794916[_0x25f0a6[_0x7c48('0x33')]]=_0x21f7f6;_[_0x7c48('0x37')](_0x42982e[_0x7c48('0x34')],_0x794916);}return _0x363f67['sobject'](_0x7c48('0x35'))[_0x7c48('0x25')](_0x42982e,_0x5ce565)[_0x7c48('0x27')](function(_0x2e2e1b){if(_0x2e2e1b&&_0x2e2e1b[_0x7c48('0x28')]){return _0x2e2e1b;}else{var _0x1eb525=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6['additionalSearchLead']){var _0x3eebd9={};_0x3eebd9[_0x25f0a6['additionalSearchLead']]=_0x21f7f6;_[_0x7c48('0x37')](_0x1eb525[_0x7c48('0x34')],_0x3eebd9);}return _0x363f67[_0x7c48('0x23')](_0x7c48('0x38'))[_0x7c48('0x25')](_0x1eb525,_0x5ce565);}});}});case _0x7c48('0x16'):var _0x24644f=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6['additionalSearchContact']){var _0x16aff5={};_0x16aff5[_0x25f0a6[_0x7c48('0x33')]]=_0x21f7f6;_['merge'](_0x24644f[_0x7c48('0x34')],_0x16aff5);}return _0x363f67[_0x7c48('0x23')]('Contact')[_0x7c48('0x25')](_0x24644f,_0x5ce565)[_0x7c48('0x26')]();case _0x7c48('0x17'):var _0x423c68=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6[_0x7c48('0x36')]){var _0x16aff5={};_0x16aff5[_0x25f0a6[_0x7c48('0x36')]]=_0x21f7f6;_['merge'](_0x423c68[_0x7c48('0x34')],_0x16aff5);}return _0x363f67['sobject'](_0x7c48('0x38'))[_0x7c48('0x25')](_0x423c68,_0x5ce565);case _0x7c48('0x18'):var _0x1366b2=_[_0x7c48('0x32')](_0x3fd447);if(_0x25f0a6[_0x7c48('0x3a')]){var _0x16aff5={};_0x16aff5[_0x25f0a6[_0x7c48('0x3a')]]=_0x21f7f6;_['merge'](_0x1366b2[_0x7c48('0x34')],_0x16aff5);}return _0x363f67[_0x7c48('0x23')]('Account')[_0x7c48('0x25')](_0x1366b2,_0x5ce565);default:return null;}})[_0x7c48('0x27')](function(_0x2a67b2){if(_0x2a67b2&&_0x2a67b2[_0x7c48('0x28')]){var _0x564db1=_[_0x7c48('0x3c')](_0x2a67b2);if(_0x564db1){return BPromise[_0x7c48('0x2b')]({'id':_0x564db1['Id'],'name':_0x564db1['Name'],'phone':_0x564db1[_0x7c48('0x3d')],'endUserType':_0x564db1[_0x7c48('0x3e')][_0x7c48('0x3f')][_0x7c48('0x40')]()});}}})[_0x7c48('0x27')](function(_0xc99e6f){if(_0xc99e6f){logger[_0x7c48('0x1f')](_0x7c48('0x41'),_0xc99e6f[_0x7c48('0x15')],_0x21f7f6);return BPromise[_0x7c48('0x2b')](_0xc99e6f);}else{logger[_0x7c48('0x1f')](_0x7c48('0x42'),_0x21f7f6);var _0x52cfda={'Phone':_0x21f7f6};if(_0x25f0a6[_0x7c48('0x43')]){if(_0x25f0a6[_0x7c48('0x43')]===_0x7c48('0x16')){logger[_0x7c48('0x1f')](_0x7c48('0x44'),_0x21f7f6,_0x25f0a6['moduleCreate']);_0x52cfda[_0x7c48('0x45')]=_0x16339d!=='<unknown>'?_0x16339d:util['format'](_0x7c48('0x46'),_0x21f7f6);}else if(_0x25f0a6['moduleCreate']===_0x7c48('0x17')){logger[_0x7c48('0x1f')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x21f7f6,_0x25f0a6[_0x7c48('0x43')]);_0x52cfda[_0x7c48('0x45')]=_0x16339d!==_0x7c48('0x47')?_0x16339d:util[_0x7c48('0x48')](_0x7c48('0x46'),_0x21f7f6);_0x52cfda[_0x7c48('0x49')]=_0x7c48('0x4a');}else if(_0x25f0a6[_0x7c48('0x43')]===_0x7c48('0x18')){logger[_0x7c48('0x1f')](_0x7c48('0x44'),_0x21f7f6,_0x25f0a6[_0x7c48('0x43')]);_0x52cfda[_0x7c48('0x4b')]=_0x16339d!==_0x7c48('0x47')?_0x16339d:util[_0x7c48('0x48')](_0x7c48('0x46'),_0x21f7f6);}else{return null;}}return _0x363f67[_0x7c48('0x23')](_[_0x7c48('0x4c')](_0x25f0a6[_0x7c48('0x43')]))[_0x7c48('0x20')](_0x52cfda)['then'](function(_0x327a8c){return BPromise[_0x7c48('0x2b')]({'id':_0x327a8c['id'],'endUserType':_0x25f0a6[_0x7c48('0x43')]});});}});}function getCustomFields(_0x2b011e,_0x423b9a){var _0x379975={};if(_0x2b011e[_0x7c48('0x28')]>0x0){_[_0x7c48('0x4d')](_0x2b011e,function(_0x314009){if(_[_0x7c48('0x4e')](['string',_0x7c48('0x4f')],_0x314009['type'])&&_0x314009[_0x7c48('0x50')]){_0x379975[_0x314009['idField']]=_0x314009[_0x7c48('0x51')][_0x7c48('0x52')]();}else if(_0x314009[_0x7c48('0x3f')]===_0x7c48('0x53')&&_0x314009['variableName']&&_0x314009['idField']){_0x423b9a[_0x314009[_0x7c48('0x54')]]&&(_0x379975[_0x314009[_0x7c48('0x50')]]=_0x423b9a[_0x314009[_0x7c48('0x54')]]['toString']());}else if(_0x314009[_0x7c48('0x3f')]===_0x7c48('0x55')&&_0x314009[_0x7c48('0x56')]&&_0x314009[_0x7c48('0x56')][_0x7c48('0x57')]&&_0x314009['idField']){_0x423b9a[_0x314009[_0x7c48('0x56')][_0x7c48('0x57')]['toLowerCase']()]&&(_0x379975[_0x314009[_0x7c48('0x50')]]=_0x423b9a[_0x314009[_0x7c48('0x56')]['name'][_0x7c48('0x40')]()][_0x7c48('0x52')]());}});}return _0x379975;}function getConnection(_0x23fa8d){var _0x4ca13b=_0x23fa8d['password']['concat'](_0x23fa8d[_0x7c48('0x58')]);var _0x181f2f=new jsforce[(_0x7c48('0x59'))]({'oauth2':{'loginUrl':_0x23fa8d[_0x7c48('0x5a')]||_0x7c48('0x5b'),'clientId':_0x23fa8d['clientId'],'clientSecret':_0x23fa8d[_0x7c48('0x5c')]}});return _0x181f2f[_0x7c48('0x5d')](_0x23fa8d['username'],_0x4ca13b)['then'](function(){logger[_0x7c48('0x1f')](_0x7c48('0x5e'));return _0x181f2f;});}exports['queue']=function(_0x9f0fcc,_0x340575,_0x151abb,_0x369ad7,_0x4ed3c7,_0xbf6eaa){var _0x2062a0,_0x3b1d14,_0x30e1f0,_0x2e0915;_0xbf6eaa['serverUrl']=intUtil[_0x7c48('0x5f')](_0xbf6eaa[_0x7c48('0x60')]);_0xbf6eaa[_0x7c48('0x5a')]=intUtil[_0x7c48('0x5f')](_0xbf6eaa['remoteUri']);if(_0x4ed3c7&&_0x4ed3c7['monitor_format']){logger['info'](_0x7c48('0x61'),'Recording\x20is\x20enabled!');_0x340575[_0x7c48('0x62')]=util['format'](_0x7c48('0x63'),_0xbf6eaa[_0x7c48('0x60')],_0x340575[_0x7c48('0x64')],md5(_0x340575[_0x7c48('0x64')]));}else{_0x340575[_0x7c48('0x62')]='';}return getConnection(_0xbf6eaa)[_0x7c48('0x27')](function(_0x50d19c){_0x2e0915=_0x50d19c;return getUser(_0xbf6eaa,_0x369ad7[_0x7c48('0x65')],_0x2e0915);})['then'](function(_0x1c64f0){_0x2062a0=_0x1c64f0;return getEndUser(_0xbf6eaa,_0x151abb,_0x340575[_0x7c48('0x66')],_0x340575[_0x7c48('0x67')],_0x2e0915);})['then'](function(_0x201102){_0x3b1d14=_0x201102;return getTicket(_0xbf6eaa,_0x2062a0,_0x3b1d14,_0x151abb,_0x340575,_0x151abb[_0x7c48('0x68')],_0x2e0915,_0x7c48('0x69'));})[_0x7c48('0x27')](function(_0x385873){_0x30e1f0=_0x385873;logger[_0x7c48('0x1f')]('[QUEUE]\x20Ticket\x20%s\x20created',_0x30e1f0['id']);logger[_0x7c48('0x1f')]('[QUEUE]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.',_0x30e1f0['id'],_0x369ad7[_0x7c48('0x57')],_0xbf6eaa[_0x7c48('0x3f')]);switch(_0xbf6eaa[_0x7c48('0x3f')]){case'integrationTab':emit(util[_0x7c48('0x48')](_0x7c48('0x6a'),_0x369ad7['name']),_0x7c48('0x6b'),{'recordId':_0x30e1f0['id']});break;case _0x7c48('0x6c'):emit(util[_0x7c48('0x48')](_0x7c48('0x6a'),_0x369ad7[_0x7c48('0x57')]),_0x7c48('0x6d'),{'uri':util[_0x7c48('0x48')](_0x7c48('0x6e'),_0x2e0915['instanceUrl'],_0x30e1f0['id'])});break;default:logger[_0x7c48('0x6f')](_0x7c48('0x70'));}})[_0x7c48('0x71')](function(_0x2bb905){logger['error'](_0x7c48('0x61'),_0x2bb905);});};exports['outbound']=function(_0x361cf5,_0x356f44,_0x313127,_0x15cc6e,_0x2e9ed5,_0x3d6e32,_0x11b167){var _0x160459,_0x1aa49c,_0x52ae2c,_0x1193cf;_0x3d6e32[_0x7c48('0x60')]=intUtil[_0x7c48('0x5f')](_0x3d6e32[_0x7c48('0x60')]);_0x3d6e32[_0x7c48('0x5a')]=intUtil[_0x7c48('0x5f')](_0x3d6e32[_0x7c48('0x5a')]);if(_0x11b167&&_0x11b167[_0x7c48('0x72')]&&_0x11b167[_0x7c48('0x72')]!=='none'){logger[_0x7c48('0x1f')](_0x7c48('0x73'),'Recording\x20is\x20enabled!');_0x356f44[_0x7c48('0x62')]=util[_0x7c48('0x48')](_0x7c48('0x63'),_0x3d6e32[_0x7c48('0x60')],_0x356f44[_0x7c48('0x64')],md5(_0x356f44[_0x7c48('0x64')]));}return getConnection(_0x3d6e32)[_0x7c48('0x27')](function(_0x29141b){_0x1193cf=_0x29141b;return getUser(_0x3d6e32,_0x15cc6e[_0x7c48('0x65')],_0x1193cf);})[_0x7c48('0x27')](function(_0x5eae31){_0x160459=_0x5eae31;return getEndUser(_0x3d6e32,_0x313127,_0x356f44[_0x7c48('0x74')],_0x356f44['destcalleridnum'],_0x1193cf);})['then'](function(_0x303ce8){_0x1aa49c=_0x303ce8;return getTicket(_0x3d6e32,_0x160459,_0x1aa49c,_0x313127,_0x356f44,_0x313127[_0x7c48('0x68')],_0x1193cf,_0x7c48('0x75'));})[_0x7c48('0x27')](function(_0x3afd9f){_0x52ae2c=_0x3afd9f;logger['info'](_0x7c48('0x76'),_0x52ae2c['id']);logger['info'](_0x7c48('0x77'),_0x52ae2c['id'],_0x15cc6e[_0x7c48('0x57')],_0x3d6e32[_0x7c48('0x3f')]);switch(_0x3d6e32[_0x7c48('0x3f')]){case _0x7c48('0x78'):emit(util[_0x7c48('0x48')]('user:%s',_0x15cc6e[_0x7c48('0x57')]),_0x7c48('0x6b'),{'recordId':_0x52ae2c['id']});break;case _0x7c48('0x6c'):emit(util[_0x7c48('0x48')]('user:%s',_0x15cc6e[_0x7c48('0x57')]),_0x7c48('0x6d'),{'uri':util[_0x7c48('0x48')]('%s/%s/e',_0x1193cf['instanceUrl'],_0x52ae2c['id'])});break;default:logger[_0x7c48('0x6f')](_0x7c48('0x73'),'Salesforce\x20account\x20type\x20not\x20recognized');}})[_0x7c48('0x71')](function(_0x4ebc01){logger[_0x7c48('0x6f')](_0x7c48('0x73'),_0x4ebc01);});};exports[_0x7c48('0x79')]=function(_0x3f847e,_0x5a093c,_0x1fc168,_0x498373,_0x1a4c96,_0x505f0d){var _0xc92a89,_0x2061aa,_0x2b90ce,_0xf50fd6;_0x505f0d[_0x7c48('0x60')]=intUtil[_0x7c48('0x5f')](_0x505f0d['serverUrl']);_0x505f0d[_0x7c48('0x5a')]=intUtil[_0x7c48('0x5f')](_0x505f0d['remoteUri']);if(_0x1a4c96&&_0x1a4c96[_0x7c48('0x7a')]){logger[_0x7c48('0x1f')]('['+_0x5a093c[_0x7c48('0x7b')][_0x7c48('0x7c')]()+']',_0x7c48('0x7d'));_0x5a093c[_0x7c48('0x62')]=util[_0x7c48('0x48')](_0x7c48('0x63'),_0x505f0d[_0x7c48('0x60')],_0x5a093c['uniqueid'],md5(_0x5a093c['uniqueid']));}else{_0x5a093c[_0x7c48('0x62')]='';}return getConnection(_0x505f0d)[_0x7c48('0x27')](function(_0x30c1ac){_0xf50fd6=_0x30c1ac;if(!_[_0x7c48('0x21')](_0x498373)){return getUser(_0x505f0d,_0x498373[_0x7c48('0x57')],_0xf50fd6);}else{return getUser(_0x505f0d,null,_0xf50fd6);}})[_0x7c48('0x27')](function(_0x311eda){_0xc92a89=_0x311eda;return getEndUser(_0x505f0d,_0x1fc168,_0x5a093c[_0x7c48('0x66')],_0x5a093c[_0x7c48('0x67')],_0xf50fd6);})[_0x7c48('0x27')](function(_0x6498e9){_0x2061aa=_0x6498e9;return getTicket(_0x505f0d,_0xc92a89,_0x2061aa,_0x1fc168,_0x5a093c,_0x1fc168[_0x7c48('0x68')],_0xf50fd6);})[_0x7c48('0x27')](function(_0x3d06b9){_0x2b90ce=_0x3d06b9;logger['info']('['+_0x5a093c[_0x7c48('0x7b')][_0x7c48('0x7c')]()+_0x7c48('0x7e'),_0x2b90ce['id']);logger['info']('['+_0x5a093c['lastevent'][_0x7c48('0x7c')]()+']\x20Integration\x20account\x20type\x20%s.',_0x505f0d[_0x7c48('0x3f')]);})[_0x7c48('0x71')](function(_0x1c8b3a){logger[_0x7c48('0x6f')]('['+_0x5a093c[_0x7c48('0x7b')]['toUpperCase']()+']',_0x1c8b3a);});};