Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / services / ami / trigger / integration / zoho.js
index a0b9030..3842367 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2617=['What_Id','First_Name','$se_module','talktime','Call_Duration','utc','mm:ss','answertime','endtime','YYYY-MM-DDTHH:mm:ss','starttime','called','Call_Result','Called','complete','connect','rejected','Rejected','abandoned','timeout','Timeout','Call_Start_Time','agentcalledAt','Call_Type','merge','Fields','Call\x20created!','details','err','queue','host','stripTrailingSlash','serverUrl','monitor_format','Recording\x20is\x20enabled!','recordingURL','uniqueid','com','email','The\x20User\x20ID\x20is:','calleridname','The\x20Call\x20ID\x20is:','[QUEUE]','user:%s','trigger:browser:url','https://crm.','/crm/EntityInfo.do?module=Calls&id=','outbound','recordingFormat','[OUTBOUND]','/api/voice/recordings/','/downloads?type=uniqueid&token=','destcalleridname','destcalleridnum','Outbound','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...','lastevent','toUpperCase','zoho.eu','calleridnum','Inbound','lodash','md5','util','./util','moment','bluebird','../../../../config/environment','../../../../config/logger','zoho','redis','defaults','socket.io-emitter','emit','debug','[HTTP]','stringify','forEach','includes','picklist','type','variableName','idField','toString','customVariable','Variable','name','toLowerCase','indexOf','split','isNil','access_token','isBefore','expires_in','zone','https://accounts.zoho.com','https://accounts.zoho.eu','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','refreshToken','clientId','clientSecret','refresh_token','then','add','catch','error','Failing\x20creating\x20the\x20access_token','stack','info','Search\x20user','GET','format','https://www.zohoapis.%s/crm/v2/users','ActiveUsers','Zoho-oauthtoken\x20','isArrayLikeObject','users','findIndex','Agent\x20found!','Using\x20the\x20admin\x20account!','profile','Administrator','user','The\x20failing\x20result\x20is','/crm/v2/','startCase','role','first_name','last_name','code','SUCCESS','data','enduserType','moduleCreate','Error:\x20','log','moduleSearch','contact_lead','https://www.zohoapis.','/crm/v2/Contacts/search?criteria=((Phone:equals:','Contacts','uri','Leads','nothing','/crm/v2/Leads/search?criteria=((Phone:equals:','Creating\x20new\x20call...','Owner','administrator','getString','Subjects','Description','Descriptions','Full_Name','Last_Name'];(function(_0x468b0f,_0x408566){var _0x3e74d9=function(_0x27a545){while(--_0x27a545){_0x468b0f['push'](_0x468b0f['shift']());}};_0x3e74d9(++_0x408566);}(_0x2617,0x175));var _0x7261=function(_0x208ad9,_0x69c80c){_0x208ad9=_0x208ad9-0x0;var _0x18dd92=_0x2617[_0x208ad9];return _0x18dd92;};'use strict';var _=require(_0x7261('0x0'));var rp=require('request-promise');var md5=require(_0x7261('0x1'));var util=require(_0x7261('0x2'));var intUtil=require(_0x7261('0x3'));var moment=require(_0x7261('0x4'));var Redis=require('ioredis');var BPromise=require(_0x7261('0x5'));var config=require(_0x7261('0x6'));var logger=require(_0x7261('0x7'))(_0x7261('0x8'));config[_0x7261('0x9')]=_[_0x7261('0xa')](config[_0x7261('0x9')],{'host':'localhost','port':0x18eb});var io=require(_0x7261('0xb'))(new Redis(config[_0x7261('0x9')]));function emit(_0x38444d,_0x33be81,_0x548b65){io['to'](_0x38444d)[_0x7261('0xc')](_0x33be81,_0x548b65);}function request(_0x14f348){logger[_0x7261('0xd')](_0x7261('0xe'),JSON[_0x7261('0xf')](_0x14f348));return rp(_0x14f348);}function getCustomFields(_0x5f125f,_0x5a49f4){var _0x1d5f5b={};if(_0x5f125f['length']>0x0){_[_0x7261('0x10')](_0x5f125f,function(_0x54642d){if(_[_0x7261('0x11')](['string',_0x7261('0x12')],_0x54642d[_0x7261('0x13')])&&_0x54642d['idField']){_0x1d5f5b[_0x54642d['idField']]=_0x54642d['content']['toString']();}else if(_0x54642d[_0x7261('0x13')]==='variable'&&_0x54642d[_0x7261('0x14')]&&_0x54642d[_0x7261('0x15')]&&_0x5a49f4[_0x54642d[_0x7261('0x14')]]){_0x1d5f5b[_0x54642d['idField']]=_0x5a49f4[_0x54642d[_0x7261('0x14')]][_0x7261('0x16')]();}else if(_0x54642d[_0x7261('0x13')]===_0x7261('0x17')&&_0x54642d[_0x7261('0x18')]&&_0x54642d[_0x7261('0x18')][_0x7261('0x19')]&&_0x54642d[_0x7261('0x15')]&&_0x5a49f4[_0x54642d['Variable'][_0x7261('0x19')][_0x7261('0x1a')]()]){_0x1d5f5b[_0x54642d['idField']]=_0x5a49f4[_0x54642d[_0x7261('0x18')][_0x7261('0x19')][_0x7261('0x1a')]()][_0x7261('0x16')]();}});}return _0x1d5f5b;}function getName(_0x9346e){if(_0x9346e[_0x7261('0x1b')]('\x20')>0x0){var _0x1ca019=_0x9346e[_0x7261('0x1c')](/ (.+)/);if(_0x1ca019[0x1]){return _0x1ca019;}}return[_0x9346e,_0x9346e];}var accountsTokens={};function getAccessToken(_0x250fb4){return new Promise(function(_0x22ce40,_0x54f777){if(!_[_0x7261('0x1d')](accountsTokens[_0x250fb4['id']])&&!_['isNil'](accountsTokens[_0x250fb4['id']][_0x7261('0x1e')])){if(moment()[_0x7261('0x1f')](accountsTokens[_0x250fb4['id']][_0x7261('0x20')])){_0x22ce40(accountsTokens[_0x250fb4['id']]['access_token']);}}var _0x352d08;switch(_0x250fb4[_0x7261('0x21')]){case'US':_0x352d08=_0x7261('0x22');break;case'AU':_0x352d08='https://accounts.zoho.com.au';break;case'EU':_0x352d08=_0x7261('0x23');break;case'IN':_0x352d08=_0x7261('0x24');break;case'CN':_0x352d08=_0x7261('0x25');break;default:_0x352d08=_0x7261('0x23');break;}var _0x41902b={'method':_0x7261('0x26'),'uri':_0x352d08+'/oauth/v2/token','qs':{'refresh_token':_0x250fb4[_0x7261('0x27')],'client_id':_0x250fb4[_0x7261('0x28')],'client_secret':_0x250fb4[_0x7261('0x29')],'grant_type':_0x7261('0x2a')},'json':!![]};return rp(_0x41902b)[_0x7261('0x2b')](function(_0x2899e5){accountsTokens[_0x250fb4['id']]={'access_token':_0x2899e5['access_token'],'expires_in':moment()[_0x7261('0x2c')](_0x2899e5[_0x7261('0x20')],'seconds')};_0x22ce40(_0x2899e5[_0x7261('0x1e')]);})[_0x7261('0x2d')](function(_0x38ea99){logger[_0x7261('0x2e')](_0x7261('0x2f'),_0x38ea99[_0x7261('0x30')]);_0x54f777(_0x38ea99);});});}function getUser(_0x5acf91,_0x197ff3,_0xc2428c,_0x1f1637){logger[_0x7261('0x31')](_0x7261('0x32'));return request({'method':_0x7261('0x33'),'uri':util[_0x7261('0x34')](_0x7261('0x35'),_0x197ff3),'qs':{'type':_0x7261('0x36')},'headers':{'Authorization':_0x7261('0x37')+_0x5acf91},'json':!![]})[_0x7261('0x2b')](function(_0x245558){if(_0x245558['users']){var _0x317d20=-0x1;if(_[_0x7261('0x38')](_0x245558[_0x7261('0x39')])){if(!_[_0x7261('0x1d')](_0x1f1637)){_0x317d20=_[_0x7261('0x3a')](_0x245558['users'],function(_0x12c145){return _0x12c145['email']===_0x1f1637;});}if(_0x317d20>=0x0){logger[_0x7261('0x31')](_0x7261('0x3b'));}else{logger['info'](_0x7261('0x3c'));_0x317d20=_[_0x7261('0x3a')](_0x245558[_0x7261('0x39')],function(_0x584560){return _0x584560[_0x7261('0x3d')][_0x7261('0x19')]==='Administrator';});}return _0x245558[_0x7261('0x39')][_0x317d20];}else{if(_0x245558['user'][_0x7261('0x3d')]['name']===_0x7261('0x3e')){logger[_0x7261('0x31')](_0x7261('0x3c'));user=_0x245558[_0x7261('0x3f')];return user;}else{logger['error']('The\x20failing\x20result\x20is',JSON['stringify'](_0x245558));throw new Error('Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20'+JSON[_0x7261('0xf')](_0x245558));}}}else{logger[_0x7261('0x2e')](_0x7261('0x40'),JSON[_0x7261('0xf')](_0x245558));throw new Error('Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20'+JSON[_0x7261('0xf')](_0x245558));}})[_0x7261('0x2d')](function(_0x151f29){console[_0x7261('0x2e')](_0x151f29);});}function getZohoUser(_0x3cf499,_0x3d36f5){return new BPromise(function(_0x28971f,_0x30ce2f){request(_0x3cf499)[_0x7261('0x2b')](function(_0x16a288){var _0x4a7c1e=null;if(_0x16a288){_0x4a7c1e=_0x16a288['data'][0x0];_0x4a7c1e['enduserType']=_0x3d36f5;}_0x28971f(_0x4a7c1e);})[_0x7261('0x2d')](function(_0x5f50ab){_0x30ce2f(_0x5f50ab);});});}function createEndUser(_0x5dfe3e,_0x46ea16,_0x25a551,_0x4e2450,_0x2dd4ac,_0x63e940){var _0x25a551=getName(_0x25a551);return request({'method':_0x7261('0x26'),'uri':'https://www.zohoapis.'+_0x46ea16+_0x7261('0x41')+_[_0x7261('0x42')](_0x63e940['moduleCreate'])+'s','body':{'data':[{'Last_Name':_0x25a551[0x1],'First_Name':_0x25a551[0x0],'Phone':_0x4e2450,'Owner':{'name':!_[_0x7261('0x1d')](_0x2dd4ac[_0x7261('0x43')][_0x7261('0x19')])?_0x2dd4ac[_0x7261('0x43')]['name']:!_['isNil'](_0x2dd4ac[_0x7261('0x44')])?_0x2dd4ac[_0x7261('0x44')]+'\x20'+_0x2dd4ac[_0x7261('0x45')]:_0x2dd4ac['last_name'],'id':_0x2dd4ac['id']}}]},'headers':{'Authorization':_0x7261('0x37')+_0x5dfe3e},'json':!![]})[_0x7261('0x2b')](function(_0x50e18a){if(_0x50e18a&&_0x50e18a['data'][0x0][_0x7261('0x46')]===_0x7261('0x47')){var _0x39027d=_0x50e18a[_0x7261('0x48')][0x0]['details'];_0x39027d[_0x7261('0x49')]=_[_0x7261('0x42')](_0x63e940[_0x7261('0x4a')])+'s';return _0x39027d;}logger['error'](_0x7261('0x40'),JSON['stringify'](data));throw new Error(_0x7261('0x4b')+JSON[_0x7261('0xf')](data));})[_0x7261('0x2d')](function(_0x339f53){console[_0x7261('0x4c')]('CREATE\x20ERROR',_0x339f53);});}function getEndUser(_0x12f9b0,_0x250493,_0x59c9eb,_0x3ec6ec,_0x2e6148,_0x2d10cd,_0x49f60a){var _0x18ab3b={'method':_0x7261('0x33'),'uri':'','headers':{'Authorization':_0x7261('0x37')+_0x12f9b0},'json':!![]};switch(_0x49f60a[_0x7261('0x4d')]){case _0x7261('0x4e'):_0x18ab3b['uri']=_0x7261('0x4f')+_0x250493+_0x7261('0x50')+_0x2e6148+'))';return getZohoUser(_0x18ab3b,_0x7261('0x51'))[_0x7261('0x2b')](function(_0x154ca5){if(_0x154ca5)return _0x154ca5;_0x18ab3b[_0x7261('0x52')]=_0x7261('0x4f')+_0x250493+'/crm/v2/Leads/search?criteria=((Phone:equals:'+_0x2e6148+'))';return getZohoUser(_0x18ab3b,_0x7261('0x53'))[_0x7261('0x2b')](function(_0x1befa5){if(_0x1befa5)return _0x1befa5;if(_0x49f60a['moduleCreate']!=_0x7261('0x54')){return createEndUser(_0x12f9b0,_0x250493,_0x3ec6ec,_0x2e6148,_0x2d10cd,_0x49f60a);}else{return{};}});});break;case'contact':_0x18ab3b[_0x7261('0x52')]=_0x7261('0x4f')+_0x250493+'/crm/v2/Contacts/search?criteria=((Phone:equals:'+_0x2e6148+'))';return getZohoUser(_0x18ab3b,'Contacts')[_0x7261('0x2b')](function(_0x27cc1b){if(_0x27cc1b)return _0x27cc1b;if(_0x49f60a['moduleCreate']!=_0x7261('0x54')){return createEndUser(_0x12f9b0,_0x250493,_0x3ec6ec,_0x2e6148,_0x2d10cd,_0x49f60a);}else{return{};}});break;case'lead':_0x18ab3b[_0x7261('0x52')]=_0x7261('0x4f')+_0x250493+_0x7261('0x55')+_0x2e6148+'))';return getZohoUser(_0x18ab3b,'Leads')[_0x7261('0x2b')](function(_0x524b2e){if(_0x524b2e)return _0x524b2e;if(_0x49f60a['moduleCreate']!=_0x7261('0x54')){return createEndUser(_0x12f9b0,_0x250493,_0x3ec6ec,_0x2e6148,_0x2d10cd,_0x49f60a);}else{return{};}});break;}}function getCall(_0x47e2af,_0x524698,_0x52e012,_0xa1c87b,_0x2ee0e5,_0x138e3a,_0x518337,_0x4befea){logger['info'](_0x7261('0x56'));var _0x3d9293={};_0x3d9293[_0x7261('0x57')]={'name':!_['isNil'](_0xa1c87b[_0x7261('0x43')]['name'])&&!_[_0x7261('0x1d')](_0xa1c87b[_0x7261('0x3d')][_0x7261('0x19')])&&_0xa1c87b[_0x7261('0x3d')][_0x7261('0x19')]===_0x7261('0x58')?_0xa1c87b[_0x7261('0x43')]['name']:!_[_0x7261('0x1d')](_0xa1c87b[_0x7261('0x44')])?_0xa1c87b[_0x7261('0x44')]+'\x20'+_0xa1c87b['last_name']:_0xa1c87b[_0x7261('0x45')],'id':_0xa1c87b['id']};_0x3d9293['Subject']=intUtil[_0x7261('0x59')](_0x138e3a[_0x7261('0x5a')],_0x518337,'\x20');_0x3d9293[_0x7261('0x5b')]=intUtil[_0x7261('0x59')](_0x138e3a[_0x7261('0x5c')],_0x518337,'\x0a');if(_0x2ee0e5[_0x7261('0x49')]==='Contacts'){_0x3d9293['Who_Id']={'name':!_[_0x7261('0x1d')](_0x2ee0e5[_0x7261('0x5d')])?_0x2ee0e5[_0x7261('0x5d')]:!_[_0x7261('0x1d')](_0x2ee0e5['First_Name'])?_0x2ee0e5['First_Name']+'\x20'+_0x2ee0e5[_0x7261('0x5e')]:_0x2ee0e5[_0x7261('0x5e')],'id':_0x2ee0e5['id']};}if(_0x2ee0e5[_0x7261('0x49')]===_0x7261('0x53')){_0x3d9293[_0x7261('0x5f')]={'name':!_['isNil'](_0x2ee0e5[_0x7261('0x5d')])?_0x2ee0e5[_0x7261('0x5d')]:!_[_0x7261('0x1d')](_0x2ee0e5[_0x7261('0x60')])?_0x2ee0e5[_0x7261('0x60')]+'\x20'+_0x2ee0e5[_0x7261('0x5e')]:_0x2ee0e5[_0x7261('0x5e')],'id':_0x2ee0e5['id']};_0x3d9293[_0x7261('0x61')]=_[_0x7261('0x42')](_0x2ee0e5[_0x7261('0x49')]);}if(_0x518337[_0x7261('0x62')]){_0x3d9293[_0x7261('0x63')]=moment[_0x7261('0x64')](parseInt(_0x518337['talktime'])*0x3e8)[_0x7261('0x34')](_0x7261('0x65'));}else if(_0x518337[_0x7261('0x66')]&&_0x518337['endtime']){_0x3d9293['Call_Duration']=moment['utc'](moment(_0x518337[_0x7261('0x67')],_0x7261('0x68'))['diff'](moment(_0x518337[_0x7261('0x69')],_0x7261('0x68'))))['format']('mm:ss');}switch(_0x518337['lastevent']){case _0x7261('0x6a'):_0x3d9293[_0x7261('0x6b')]=_0x7261('0x6c');break;case _0x7261('0x6d'):case _0x7261('0x6e'):_0x3d9293[_0x7261('0x6b')]='Answered';break;case _0x7261('0x6f'):_0x3d9293[_0x7261('0x6b')]=_0x7261('0x70');break;case _0x7261('0x71'):_0x3d9293['Call_Result']='Abandoned';break;case _0x7261('0x72'):_0x3d9293[_0x7261('0x6b')]=_0x7261('0x73');default:}_0x3d9293[_0x7261('0x74')]=(_0x4befea==='outbound'?moment(_0x518337[_0x7261('0x69')])[_0x7261('0x34')]('YYYY-MM-DDTHH:mm:ss'):moment(_0x518337[_0x7261('0x75')])[_0x7261('0x34')](_0x7261('0x68')))||moment()['format'](_0x7261('0x68'));_0x3d9293[_0x7261('0x76')]=_0x4befea||'Inbound';_0x3d9293=_[_0x7261('0x77')](_0x3d9293,getCustomFields(_0x138e3a[_0x7261('0x78')],_0x518337));return request({'method':_0x7261('0x26'),'uri':_0x7261('0x4f')+_0x524698+'/crm/v2/Calls','headers':{'Authorization':_0x7261('0x37')+_0x47e2af},'body':{'data':[_0x3d9293]},'json':!![]})[_0x7261('0x2b')](function(_0x8316bc){if(_0x8316bc&&_0x8316bc[_0x7261('0x48')][0x0]['code']===_0x7261('0x47')){logger[_0x7261('0x31')](_0x7261('0x79'));return{'id':_0x8316bc[_0x7261('0x48')][0x0][_0x7261('0x7a')]['id']};}})[_0x7261('0x2d')](function(_0x8b2068){logger[_0x7261('0x31')]('err',_0x8b2068[_0x7261('0x30')]);console[_0x7261('0x4c')](_0x7261('0x7b'),_0x8b2068);});}exports[_0x7261('0x7c')]=function(_0x3ab700,_0x4c6eff,_0x5eada1,_0x3acda2,_0x3123b2,_0x273579){var _0xbc2ed0,_0x1e2a03,_0x34bccf;_0x273579[_0x7261('0x7d')]=intUtil[_0x7261('0x7e')](_0x273579[_0x7261('0x7d')]);_0x273579[_0x7261('0x7f')]=intUtil[_0x7261('0x7e')](_0x273579[_0x7261('0x7f')]);if(_0x3123b2&&_0x3123b2[_0x7261('0x80')]){logger['info']('[QUEUE]',_0x7261('0x81'));_0x4c6eff[_0x7261('0x82')]=_0x273579[_0x7261('0x7f')]+'/api/voice/recordings/'+_0x4c6eff[_0x7261('0x83')]+'/downloads?type=uniqueid&token='+md5(_0x4c6eff[_0x7261('0x83')]);}else{_0x4c6eff[_0x7261('0x82')]='';}var _0x1d55db=_0x273579[_0x7261('0x7d')]==='zoho.eu'?'eu':_0x7261('0x84');return getAccessToken(_0x273579)[_0x7261('0x2b')](function(_0x930214){_0x34bccf=_0x930214;return getUser(_0x34bccf,_0x1d55db,_0x273579,_0x3acda2[_0x7261('0x85')]);})[_0x7261('0x2b')](function(_0x4a1cc9){_0xbc2ed0=_0x4a1cc9;logger['info'](_0x7261('0x86'),_0xbc2ed0['id']);return getEndUser(_0x34bccf,_0x1d55db,_0x273579,_0x4c6eff[_0x7261('0x87')],_0x4c6eff['calleridnum'],_0xbc2ed0,_0x5eada1);})[_0x7261('0x2b')](function(_0x36f3db){_0x1e2a03=_0x36f3db;return getCall(_0x34bccf,_0x1d55db,_0x273579,_0xbc2ed0,_0x1e2a03,_0x5eada1,_0x4c6eff,'Inbound');})[_0x7261('0x2b')](function(_0x3b24af){if(_0x3b24af){logger[_0x7261('0x31')](_0x7261('0x88'),_0x3b24af['id']);logger[_0x7261('0x31')](_0x7261('0x89'),'Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util['format'](_0x7261('0x8a'),_0x3acda2[_0x7261('0x19')]),_0x7261('0x8b'),{'uri':_0x7261('0x8c')+_0x273579[_0x7261('0x7d')]+_0x7261('0x8d')+_0x3b24af['id']});}})[_0x7261('0x2d')](function(_0x62d2f2){logger[_0x7261('0x2e')]('[QUEUE]',JSON['stringify'](_0x62d2f2));});};exports[_0x7261('0x8e')]=function(_0x4c959b,_0x4abec1,_0x39a98e,_0x875061,_0x4f588a,_0x3cc8b6,_0x361385){var _0x5f0ede,_0x189bdb,_0x49be88;_0x3cc8b6['host']=intUtil[_0x7261('0x7e')](_0x3cc8b6['host']);_0x3cc8b6[_0x7261('0x7f')]=intUtil['stripTrailingSlash'](_0x3cc8b6[_0x7261('0x7f')]);if(_0x361385&&_0x361385[_0x7261('0x8f')]&&_0x361385[_0x7261('0x8f')]!=='none'){logger[_0x7261('0x31')](_0x7261('0x90'),_0x7261('0x81'));_0x4abec1[_0x7261('0x82')]=_0x3cc8b6['serverUrl']+_0x7261('0x91')+_0x4abec1[_0x7261('0x83')]+_0x7261('0x92')+md5(_0x4abec1['uniqueid']);}var _0x3d8d34=_0x3cc8b6[_0x7261('0x7d')]==='zoho.eu'?'eu':_0x7261('0x84');return getAccessToken(_0x3cc8b6)[_0x7261('0x2b')](function(_0x1c14ce){_0x49be88=_0x1c14ce;return getUser(_0x49be88,_0x3d8d34,_0x3cc8b6,_0x875061[_0x7261('0x85')]);})['then'](function(_0x53a131){_0x5f0ede=_0x53a131;logger[_0x7261('0x31')]('The\x20User\x20ID\x20is:',_0x5f0ede['id']);return getEndUser(_0x49be88,_0x3d8d34,_0x3cc8b6,_0x4abec1[_0x7261('0x93')],_0x4abec1[_0x7261('0x94')],_0x5f0ede,_0x39a98e);})[_0x7261('0x2b')](function(_0x63dcf0){_0x189bdb=_0x63dcf0;return getCall(_0x49be88,_0x3d8d34,_0x3cc8b6,_0x5f0ede,_0x189bdb,_0x39a98e,_0x4abec1,_0x7261('0x95'));})[_0x7261('0x2b')](function(_0x2b6287){if(_0x2b6287){logger[_0x7261('0x31')](_0x7261('0x88'),_0x2b6287['id']);logger['info'](_0x7261('0x90'),_0x7261('0x96'));emit(util['format'](_0x7261('0x8a'),_0x875061['name']),'trigger:browser:url',{'uri':_0x7261('0x8c')+_0x3cc8b6[_0x7261('0x7d')]+_0x7261('0x8d')+_0x2b6287['id']});}})[_0x7261('0x2d')](function(_0x36a034){logger[_0x7261('0x2e')](_0x7261('0x90'),JSON[_0x7261('0xf')](_0x36a034));});};exports['unmanaged']=function(_0x3249a5,_0x1bdd12,_0x5f16a2,_0x5b45f8,_0x5d95d0,_0x90220){var _0x38b262,_0x19e337,_0x53eefd;_0x90220[_0x7261('0x7d')]=intUtil['stripTrailingSlash'](_0x90220[_0x7261('0x7d')]);_0x90220['serverUrl']=intUtil['stripTrailingSlash'](_0x90220[_0x7261('0x7f')]);if(_0x5d95d0&&_0x5d95d0[_0x7261('0x80')]){logger[_0x7261('0x31')]('['+_0x1bdd12[_0x7261('0x97')][_0x7261('0x98')]()+']','Recording\x20is\x20enabled!');_0x1bdd12[_0x7261('0x82')]=_0x90220[_0x7261('0x7f')]+'/api/voice/recordings/'+_0x1bdd12[_0x7261('0x83')]+_0x7261('0x92')+md5(_0x1bdd12['uniqueid']);}else{_0x1bdd12[_0x7261('0x82')]='';}var _0x572712=_0x90220['host']===_0x7261('0x99')?'eu':_0x7261('0x84');return getAccessToken(_0x90220)['then'](function(_0x3687a0){_0x53eefd=_0x3687a0;return getUser(_0x53eefd,_0x572712,_0x90220);})[_0x7261('0x2b')](function(_0xaf541){_0x38b262=_0xaf541;logger[_0x7261('0x31')](_0x7261('0x86'),_0x38b262['id']);return getEndUser(_0x53eefd,_0x572712,_0x90220,_0x1bdd12[_0x7261('0x87')],_0x1bdd12[_0x7261('0x9a')],_0x38b262,_0x5f16a2);})['then'](function(_0x15a966){_0x19e337=_0x15a966;return getCall(_0x53eefd,_0x572712,_0x90220,_0x38b262,_0x19e337,_0x5f16a2,_0x1bdd12,_0x7261('0x9b'));})[_0x7261('0x2b')](function(_0x5c9945){if(_0x5c9945){logger[_0x7261('0x31')]('The\x20Call\x20ID\x20is:',_0x5c9945['id']);}})[_0x7261('0x2d')](function(_0x4cce9c){logger[_0x7261('0x2e')]('['+_0x1bdd12[_0x7261('0x97')][_0x7261('0x98')]()+']',JSON[_0x7261('0xf')](_0x4cce9c));});};
\ No newline at end of file
+var _0xf547=['variable','variableName','customVariable','Variable','name','toLowerCase','indexOf','split','isNil','access_token','isBefore','expires_in','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.eu','https://accounts.zoho.in','https://accounts.zoho.com.cn','/oauth/v2/token','refreshToken','clientId','clientSecret','refresh_token','add','catch','error','Failing\x20creating\x20the\x20access_token','info','Search\x20user','GET','ActiveUsers','Zoho-oauthtoken\x20','then','users','findIndex','email','Using\x20the\x20admin\x20account!','profile','Administrator','user','The\x20failing\x20result\x20is','Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20','data','enduserType','POST','startCase','role','first_name','last_name','code','SUCCESS','details','moduleCreate','Error:\x20','CREATE\x20ERROR','contact_lead','uri','https://www.zohoapis.','/crm/v2/Contacts/search?criteria=((Phone:equals:','Contacts','/crm/v2/Leads/search?criteria=((Phone:equals:','nothing','contact','Leads','Creating\x20new\x20call...','Owner','administrator','Subject','getString','Subjects','Description','Descriptions','Full_Name','First_Name','Last_Name','What_Id','$se_module','Call_Duration','utc','format','answertime','endtime','YYYY-MM-DDTHH:mm:ss','diff','starttime','lastevent','Called','complete','Answered','Call_Result','abandoned','Abandoned','timeout','Timeout','Call_Start_Time','Call_Type','Inbound','merge','Fields','/crm/v2/Calls','Call\x20created!','stack','log','host','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','/api/voice/recordings/','/downloads?type=uniqueid&token=','uniqueid','zoho.eu','com','The\x20User\x20ID\x20is:','calleridname','user:%s','trigger:browser:url','https://crm.','outbound','recordingFormat','[OUTBOUND]','destcalleridname','destcalleridnum','Outbound','The\x20Call\x20ID\x20is:','/crm/EntityInfo.do?module=Calls&id=','unmanaged','toUpperCase','calleridnum','lodash','request-promise','md5','./util','ioredis','bluebird','../../../../config/environment','../../../../config/logger','redis','defaults','localhost','socket.io-emitter','emit','debug','stringify','length','forEach','includes','string','picklist','type','idField','content'];(function(_0xefd519,_0xc62635){var _0x4bb882=function(_0x37e0a1){while(--_0x37e0a1){_0xefd519['push'](_0xefd519['shift']());}};_0x4bb882(++_0xc62635);}(_0xf547,0x1b7));var _0x7f54=function(_0x187ee1,_0x3fd1e6){_0x187ee1=_0x187ee1-0x0;var _0x388160=_0xf547[_0x187ee1];return _0x388160;};'use strict';var _=require(_0x7f54('0x0'));var rp=require(_0x7f54('0x1'));var md5=require(_0x7f54('0x2'));var util=require('util');var intUtil=require(_0x7f54('0x3'));var moment=require('moment');var Redis=require(_0x7f54('0x4'));var BPromise=require(_0x7f54('0x5'));var config=require(_0x7f54('0x6'));var logger=require(_0x7f54('0x7'))('zoho');config[_0x7f54('0x8')]=_[_0x7f54('0x9')](config['redis'],{'host':_0x7f54('0xa'),'port':0x18eb});var io=require(_0x7f54('0xb'))(new Redis(config[_0x7f54('0x8')]));function emit(_0x7f3055,_0x18c7a9,_0x2799ef){io['to'](_0x7f3055)[_0x7f54('0xc')](_0x18c7a9,_0x2799ef);}function request(_0x183c25){logger[_0x7f54('0xd')]('[HTTP]',JSON[_0x7f54('0xe')](_0x183c25));return rp(_0x183c25);}function getCustomFields(_0x323d3c,_0x5696fe){var _0x3f88e3={};if(_0x323d3c[_0x7f54('0xf')]>0x0){_[_0x7f54('0x10')](_0x323d3c,function(_0x284691){if(_[_0x7f54('0x11')]([_0x7f54('0x12'),_0x7f54('0x13')],_0x284691[_0x7f54('0x14')])&&_0x284691[_0x7f54('0x15')]){_0x3f88e3[_0x284691[_0x7f54('0x15')]]=_0x284691[_0x7f54('0x16')]['toString']();}else if(_0x284691['type']===_0x7f54('0x17')&&_0x284691[_0x7f54('0x18')]&&_0x284691[_0x7f54('0x15')]&&_0x5696fe[_0x284691[_0x7f54('0x18')]]){_0x3f88e3[_0x284691[_0x7f54('0x15')]]=_0x5696fe[_0x284691[_0x7f54('0x18')]]['toString']();}else if(_0x284691[_0x7f54('0x14')]===_0x7f54('0x19')&&_0x284691[_0x7f54('0x1a')]&&_0x284691[_0x7f54('0x1a')]['name']&&_0x284691['idField']&&_0x5696fe[_0x284691[_0x7f54('0x1a')][_0x7f54('0x1b')][_0x7f54('0x1c')]()]){_0x3f88e3[_0x284691['idField']]=_0x5696fe[_0x284691[_0x7f54('0x1a')]['name'][_0x7f54('0x1c')]()]['toString']();}});}return _0x3f88e3;}function getName(_0x429db1){if(_0x429db1[_0x7f54('0x1d')]('\x20')>0x0){var _0x59c83e=_0x429db1[_0x7f54('0x1e')](/ (.+)/);if(_0x59c83e[0x1]){return _0x59c83e;}}return[_0x429db1,_0x429db1];}var accountsTokens={};function getAccessToken(_0x27b462){return new Promise(function(_0x137360,_0x44a269){if(!_[_0x7f54('0x1f')](accountsTokens[_0x27b462['id']])&&!_[_0x7f54('0x1f')](accountsTokens[_0x27b462['id']][_0x7f54('0x20')])){if(moment()[_0x7f54('0x21')](accountsTokens[_0x27b462['id']][_0x7f54('0x22')])){_0x137360(accountsTokens[_0x27b462['id']][_0x7f54('0x20')]);}}var _0x4c7c0a;switch(_0x27b462[_0x7f54('0x23')]){case'US':_0x4c7c0a=_0x7f54('0x24');break;case'AU':_0x4c7c0a=_0x7f54('0x25');break;case'EU':_0x4c7c0a=_0x7f54('0x26');break;case'IN':_0x4c7c0a=_0x7f54('0x27');break;case'CN':_0x4c7c0a=_0x7f54('0x28');break;default:_0x4c7c0a=_0x7f54('0x26');break;}var _0x38e73d={'method':'POST','uri':_0x4c7c0a+_0x7f54('0x29'),'qs':{'refresh_token':_0x27b462[_0x7f54('0x2a')],'client_id':_0x27b462[_0x7f54('0x2b')],'client_secret':_0x27b462[_0x7f54('0x2c')],'grant_type':_0x7f54('0x2d')},'json':!![]};return rp(_0x38e73d)['then'](function(_0x1c8e4d){accountsTokens[_0x27b462['id']]={'access_token':_0x1c8e4d[_0x7f54('0x20')],'expires_in':moment()[_0x7f54('0x2e')](_0x1c8e4d[_0x7f54('0x22')],'seconds')};_0x137360(_0x1c8e4d[_0x7f54('0x20')]);})[_0x7f54('0x2f')](function(_0x47be17){logger[_0x7f54('0x30')](_0x7f54('0x31'),_0x47be17['stack']);_0x44a269(_0x47be17);});});}function getUser(_0x2fe61b,_0x3713b8,_0x2d5bdc,_0x16cfbf){logger[_0x7f54('0x32')](_0x7f54('0x33'));return request({'method':_0x7f54('0x34'),'uri':util['format']('https://www.zohoapis.%s/crm/v2/users',_0x3713b8),'qs':{'type':_0x7f54('0x35')},'headers':{'Authorization':_0x7f54('0x36')+_0x2fe61b},'json':!![]})[_0x7f54('0x37')](function(_0x1ab51d){if(_0x1ab51d['users']){var _0x317cef=-0x1;if(_['isArrayLikeObject'](_0x1ab51d[_0x7f54('0x38')])){if(!_[_0x7f54('0x1f')](_0x16cfbf)){_0x317cef=_[_0x7f54('0x39')](_0x1ab51d[_0x7f54('0x38')],function(_0xa37237){return _0xa37237[_0x7f54('0x3a')]===_0x16cfbf;});}if(_0x317cef>=0x0){logger[_0x7f54('0x32')]('Agent\x20found!');}else{logger[_0x7f54('0x32')](_0x7f54('0x3b'));_0x317cef=_['findIndex'](_0x1ab51d[_0x7f54('0x38')],function(_0x3ccaa4){return _0x3ccaa4[_0x7f54('0x3c')][_0x7f54('0x1b')]===_0x7f54('0x3d');});}return _0x1ab51d[_0x7f54('0x38')][_0x317cef];}else{if(_0x1ab51d[_0x7f54('0x3e')][_0x7f54('0x3c')][_0x7f54('0x1b')]===_0x7f54('0x3d')){logger['info'](_0x7f54('0x3b'));user=_0x1ab51d[_0x7f54('0x3e')];return user;}else{logger[_0x7f54('0x30')](_0x7f54('0x3f'),JSON[_0x7f54('0xe')](_0x1ab51d));throw new Error(_0x7f54('0x40')+JSON[_0x7f54('0xe')](_0x1ab51d));}}}else{logger[_0x7f54('0x30')]('The\x20failing\x20result\x20is',JSON[_0x7f54('0xe')](_0x1ab51d));throw new Error(_0x7f54('0x40')+JSON[_0x7f54('0xe')](_0x1ab51d));}})[_0x7f54('0x2f')](function(_0x3c3ae9){console[_0x7f54('0x30')](_0x3c3ae9);});}function getZohoUser(_0x3ce1b2,_0xcd1591){return new BPromise(function(_0x3df367,_0x2a5ae8){request(_0x3ce1b2)[_0x7f54('0x37')](function(_0x1f9de6){var _0x240b4d=null;if(_0x1f9de6){_0x240b4d=_0x1f9de6[_0x7f54('0x41')][0x0];_0x240b4d[_0x7f54('0x42')]=_0xcd1591;}_0x3df367(_0x240b4d);})[_0x7f54('0x2f')](function(_0x38ea48){_0x2a5ae8(_0x38ea48);});});}function createEndUser(_0x59b13f,_0xbe16d1,_0x4a3b5a,_0x427aee,_0x7f0afa,_0x40599f){var _0x4a3b5a=getName(_0x4a3b5a);return request({'method':_0x7f54('0x43'),'uri':'https://www.zohoapis.'+_0xbe16d1+'/crm/v2/'+_[_0x7f54('0x44')](_0x40599f['moduleCreate'])+'s','body':{'data':[{'Last_Name':_0x4a3b5a[0x1],'First_Name':_0x4a3b5a[0x0],'Phone':_0x427aee,'Owner':{'name':!_['isNil'](_0x7f0afa[_0x7f54('0x45')][_0x7f54('0x1b')])?_0x7f0afa[_0x7f54('0x45')][_0x7f54('0x1b')]:!_[_0x7f54('0x1f')](_0x7f0afa['first_name'])?_0x7f0afa[_0x7f54('0x46')]+'\x20'+_0x7f0afa[_0x7f54('0x47')]:_0x7f0afa[_0x7f54('0x47')],'id':_0x7f0afa['id']}}]},'headers':{'Authorization':_0x7f54('0x36')+_0x59b13f},'json':!![]})[_0x7f54('0x37')](function(_0x13ed05){if(_0x13ed05&&_0x13ed05[_0x7f54('0x41')][0x0][_0x7f54('0x48')]===_0x7f54('0x49')){var _0x1f209b=_0x13ed05[_0x7f54('0x41')][0x0][_0x7f54('0x4a')];_0x1f209b[_0x7f54('0x42')]=_['startCase'](_0x40599f[_0x7f54('0x4b')])+'s';return _0x1f209b;}logger['error']('The\x20failing\x20result\x20is',JSON[_0x7f54('0xe')](data));throw new Error(_0x7f54('0x4c')+JSON[_0x7f54('0xe')](data));})[_0x7f54('0x2f')](function(_0x38e33e){console['log'](_0x7f54('0x4d'),_0x38e33e);});}function getEndUser(_0x415f36,_0x4d00c2,_0x5ef375,_0x336c54,_0x477e25,_0x182ffc,_0x528a25){var _0x45d400={'method':_0x7f54('0x34'),'uri':'','headers':{'Authorization':_0x7f54('0x36')+_0x415f36},'json':!![]};switch(_0x528a25['moduleSearch']){case _0x7f54('0x4e'):_0x45d400[_0x7f54('0x4f')]=_0x7f54('0x50')+_0x4d00c2+_0x7f54('0x51')+_0x477e25+'))';return getZohoUser(_0x45d400,_0x7f54('0x52'))[_0x7f54('0x37')](function(_0xa8a304){if(_0xa8a304)return _0xa8a304;_0x45d400[_0x7f54('0x4f')]=_0x7f54('0x50')+_0x4d00c2+_0x7f54('0x53')+_0x477e25+'))';return getZohoUser(_0x45d400,'Leads')['then'](function(_0x51d76c){if(_0x51d76c)return _0x51d76c;if(_0x528a25[_0x7f54('0x4b')]!=_0x7f54('0x54')){return createEndUser(_0x415f36,_0x4d00c2,_0x336c54,_0x477e25,_0x182ffc,_0x528a25);}else{return{};}});});break;case _0x7f54('0x55'):_0x45d400[_0x7f54('0x4f')]=_0x7f54('0x50')+_0x4d00c2+_0x7f54('0x51')+_0x477e25+'))';return getZohoUser(_0x45d400,_0x7f54('0x52'))[_0x7f54('0x37')](function(_0x4fb8e7){if(_0x4fb8e7)return _0x4fb8e7;if(_0x528a25['moduleCreate']!=_0x7f54('0x54')){return createEndUser(_0x415f36,_0x4d00c2,_0x336c54,_0x477e25,_0x182ffc,_0x528a25);}else{return{};}});break;case'lead':_0x45d400[_0x7f54('0x4f')]='https://www.zohoapis.'+_0x4d00c2+'/crm/v2/Leads/search?criteria=((Phone:equals:'+_0x477e25+'))';return getZohoUser(_0x45d400,_0x7f54('0x56'))['then'](function(_0x2e7050){if(_0x2e7050)return _0x2e7050;if(_0x528a25[_0x7f54('0x4b')]!=_0x7f54('0x54')){return createEndUser(_0x415f36,_0x4d00c2,_0x336c54,_0x477e25,_0x182ffc,_0x528a25);}else{return{};}});break;}}function getCall(_0x4a1fc8,_0x22231e,_0x225ff9,_0x3ba0d2,_0x10b81a,_0x548400,_0x3d8452,_0x59864d){logger['info'](_0x7f54('0x57'));var _0x57e5da={};_0x57e5da[_0x7f54('0x58')]={'name':!_[_0x7f54('0x1f')](_0x3ba0d2[_0x7f54('0x45')][_0x7f54('0x1b')])&&!_[_0x7f54('0x1f')](_0x3ba0d2[_0x7f54('0x3c')][_0x7f54('0x1b')])&&_0x3ba0d2[_0x7f54('0x3c')][_0x7f54('0x1b')]===_0x7f54('0x59')?_0x3ba0d2[_0x7f54('0x45')]['name']:!_[_0x7f54('0x1f')](_0x3ba0d2[_0x7f54('0x46')])?_0x3ba0d2[_0x7f54('0x46')]+'\x20'+_0x3ba0d2[_0x7f54('0x47')]:_0x3ba0d2[_0x7f54('0x47')],'id':_0x3ba0d2['id']};_0x57e5da[_0x7f54('0x5a')]=intUtil[_0x7f54('0x5b')](_0x548400[_0x7f54('0x5c')],_0x3d8452,'\x20');_0x57e5da[_0x7f54('0x5d')]=intUtil[_0x7f54('0x5b')](_0x548400[_0x7f54('0x5e')],_0x3d8452,'\x0a');if(_0x10b81a[_0x7f54('0x42')]===_0x7f54('0x52')){_0x57e5da['Who_Id']={'name':!_[_0x7f54('0x1f')](_0x10b81a[_0x7f54('0x5f')])?_0x10b81a[_0x7f54('0x5f')]:!_['isNil'](_0x10b81a['First_Name'])?_0x10b81a[_0x7f54('0x60')]+'\x20'+_0x10b81a[_0x7f54('0x61')]:_0x10b81a[_0x7f54('0x61')],'id':_0x10b81a['id']};}if(_0x10b81a['enduserType']===_0x7f54('0x56')){_0x57e5da[_0x7f54('0x62')]={'name':!_[_0x7f54('0x1f')](_0x10b81a['Full_Name'])?_0x10b81a['Full_Name']:!_[_0x7f54('0x1f')](_0x10b81a['First_Name'])?_0x10b81a['First_Name']+'\x20'+_0x10b81a[_0x7f54('0x61')]:_0x10b81a[_0x7f54('0x61')],'id':_0x10b81a['id']};_0x57e5da[_0x7f54('0x63')]=_[_0x7f54('0x44')](_0x10b81a[_0x7f54('0x42')]);}if(_0x3d8452['talktime']){_0x57e5da[_0x7f54('0x64')]=moment[_0x7f54('0x65')](parseInt(_0x3d8452['talktime'])*0x3e8)[_0x7f54('0x66')]('mm:ss');}else if(_0x3d8452[_0x7f54('0x67')]&&_0x3d8452[_0x7f54('0x68')]){_0x57e5da[_0x7f54('0x64')]=moment[_0x7f54('0x65')](moment(_0x3d8452[_0x7f54('0x68')],_0x7f54('0x69'))[_0x7f54('0x6a')](moment(_0x3d8452[_0x7f54('0x6b')],'YYYY-MM-DDTHH:mm:ss')))['format']('mm:ss');}switch(_0x3d8452[_0x7f54('0x6c')]){case'called':_0x57e5da['Call_Result']=_0x7f54('0x6d');break;case _0x7f54('0x6e'):case'connect':_0x57e5da['Call_Result']=_0x7f54('0x6f');break;case'rejected':_0x57e5da[_0x7f54('0x70')]='Rejected';break;case _0x7f54('0x71'):_0x57e5da[_0x7f54('0x70')]=_0x7f54('0x72');break;case _0x7f54('0x73'):_0x57e5da['Call_Result']=_0x7f54('0x74');default:}_0x57e5da[_0x7f54('0x75')]=(_0x59864d==='outbound'?moment(_0x3d8452[_0x7f54('0x6b')])[_0x7f54('0x66')]('YYYY-MM-DDTHH:mm:ss'):moment(_0x3d8452['agentcalledAt'])[_0x7f54('0x66')](_0x7f54('0x69')))||moment()[_0x7f54('0x66')](_0x7f54('0x69'));_0x57e5da[_0x7f54('0x76')]=_0x59864d||_0x7f54('0x77');_0x57e5da=_[_0x7f54('0x78')](_0x57e5da,getCustomFields(_0x548400[_0x7f54('0x79')],_0x3d8452));return request({'method':'POST','uri':_0x7f54('0x50')+_0x22231e+_0x7f54('0x7a'),'headers':{'Authorization':_0x7f54('0x36')+_0x4a1fc8},'body':{'data':[_0x57e5da]},'json':!![]})['then'](function(_0xe511a6){if(_0xe511a6&&_0xe511a6[_0x7f54('0x41')][0x0][_0x7f54('0x48')]===_0x7f54('0x49')){logger['info'](_0x7f54('0x7b'));return{'id':_0xe511a6['data'][0x0][_0x7f54('0x4a')]['id']};}})[_0x7f54('0x2f')](function(_0x13675f){logger['info']('err',_0x13675f[_0x7f54('0x7c')]);console[_0x7f54('0x7d')]('err',_0x13675f);});}exports['queue']=function(_0x29240f,_0x5685df,_0x30ec2d,_0x5758aa,_0x7afe9b,_0x1cda56){var _0xf3352f,_0xf465d,_0xca0fa8;_0x1cda56[_0x7f54('0x7e')]=intUtil['stripTrailingSlash'](_0x1cda56['host']);_0x1cda56[_0x7f54('0x7f')]=intUtil[_0x7f54('0x80')](_0x1cda56[_0x7f54('0x7f')]);if(_0x7afe9b&&_0x7afe9b[_0x7f54('0x81')]){logger[_0x7f54('0x32')](_0x7f54('0x82'),_0x7f54('0x83'));_0x5685df[_0x7f54('0x84')]=_0x1cda56[_0x7f54('0x7f')]+_0x7f54('0x85')+_0x5685df['uniqueid']+_0x7f54('0x86')+md5(_0x5685df[_0x7f54('0x87')]);}else{_0x5685df[_0x7f54('0x84')]='';}var _0x4d677b=_0x1cda56[_0x7f54('0x7e')]===_0x7f54('0x88')?'eu':_0x7f54('0x89');return getAccessToken(_0x1cda56)[_0x7f54('0x37')](function(_0x1f9a70){_0xca0fa8=_0x1f9a70;return getUser(_0xca0fa8,_0x4d677b,_0x1cda56,_0x5758aa[_0x7f54('0x3a')]);})['then'](function(_0x3b3774){_0xf3352f=_0x3b3774;logger[_0x7f54('0x32')](_0x7f54('0x8a'),_0xf3352f['id']);return getEndUser(_0xca0fa8,_0x4d677b,_0x1cda56,_0x5685df[_0x7f54('0x8b')],_0x5685df['calleridnum'],_0xf3352f,_0x30ec2d);})[_0x7f54('0x37')](function(_0x3e4b81){_0xf465d=_0x3e4b81;return getCall(_0xca0fa8,_0x4d677b,_0x1cda56,_0xf3352f,_0xf465d,_0x30ec2d,_0x5685df,_0x7f54('0x77'));})[_0x7f54('0x37')](function(_0x21f9d4){if(_0x21f9d4){logger[_0x7f54('0x32')]('The\x20Call\x20ID\x20is:',_0x21f9d4['id']);logger[_0x7f54('0x32')](_0x7f54('0x82'),'Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x7f54('0x66')](_0x7f54('0x8c'),_0x5758aa[_0x7f54('0x1b')]),_0x7f54('0x8d'),{'uri':_0x7f54('0x8e')+_0x1cda56['host']+'/crm/EntityInfo.do?module=Calls&id='+_0x21f9d4['id']});}})['catch'](function(_0x42107e){logger[_0x7f54('0x30')]('[QUEUE]',JSON[_0x7f54('0xe')](_0x42107e));});};exports[_0x7f54('0x8f')]=function(_0x18fd82,_0x394c03,_0x335fca,_0x4ac588,_0x3ae50f,_0x49d0f2,_0x78b619){var _0x9677d6,_0x2590b2,_0xba1a36;_0x49d0f2[_0x7f54('0x7e')]=intUtil['stripTrailingSlash'](_0x49d0f2['host']);_0x49d0f2[_0x7f54('0x7f')]=intUtil[_0x7f54('0x80')](_0x49d0f2[_0x7f54('0x7f')]);if(_0x78b619&&_0x78b619['recordingFormat']&&_0x78b619[_0x7f54('0x90')]!=='none'){logger[_0x7f54('0x32')](_0x7f54('0x91'),_0x7f54('0x83'));_0x394c03['recordingURL']=_0x49d0f2['serverUrl']+_0x7f54('0x85')+_0x394c03[_0x7f54('0x87')]+'/downloads?type=uniqueid&token='+md5(_0x394c03[_0x7f54('0x87')]);}var _0x4132a1=_0x49d0f2[_0x7f54('0x7e')]===_0x7f54('0x88')?'eu':_0x7f54('0x89');return getAccessToken(_0x49d0f2)['then'](function(_0x4f390){_0xba1a36=_0x4f390;return getUser(_0xba1a36,_0x4132a1,_0x49d0f2,_0x4ac588[_0x7f54('0x3a')]);})['then'](function(_0x18a3cd){_0x9677d6=_0x18a3cd;logger[_0x7f54('0x32')](_0x7f54('0x8a'),_0x9677d6['id']);return getEndUser(_0xba1a36,_0x4132a1,_0x49d0f2,_0x394c03[_0x7f54('0x92')],_0x394c03[_0x7f54('0x93')],_0x9677d6,_0x335fca);})[_0x7f54('0x37')](function(_0x40607f){_0x2590b2=_0x40607f;return getCall(_0xba1a36,_0x4132a1,_0x49d0f2,_0x9677d6,_0x2590b2,_0x335fca,_0x394c03,_0x7f54('0x94'));})[_0x7f54('0x37')](function(_0x5ccc41){if(_0x5ccc41){logger['info'](_0x7f54('0x95'),_0x5ccc41['id']);logger[_0x7f54('0x32')](_0x7f54('0x91'),'Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...');emit(util[_0x7f54('0x66')](_0x7f54('0x8c'),_0x4ac588[_0x7f54('0x1b')]),'trigger:browser:url',{'uri':'https://crm.'+_0x49d0f2[_0x7f54('0x7e')]+_0x7f54('0x96')+_0x5ccc41['id']});}})['catch'](function(_0x5169d7){logger[_0x7f54('0x30')](_0x7f54('0x91'),JSON[_0x7f54('0xe')](_0x5169d7));});};exports[_0x7f54('0x97')]=function(_0x158187,_0x44a7fc,_0x352778,_0x47d02d,_0x54270a,_0x3d3ff6){var _0x11f42b,_0x365b8b,_0x267742;_0x3d3ff6['host']=intUtil[_0x7f54('0x80')](_0x3d3ff6[_0x7f54('0x7e')]);_0x3d3ff6['serverUrl']=intUtil['stripTrailingSlash'](_0x3d3ff6[_0x7f54('0x7f')]);if(_0x54270a&&_0x54270a[_0x7f54('0x81')]){logger['info']('['+_0x44a7fc[_0x7f54('0x6c')][_0x7f54('0x98')]()+']','Recording\x20is\x20enabled!');_0x44a7fc[_0x7f54('0x84')]=_0x3d3ff6['serverUrl']+'/api/voice/recordings/'+_0x44a7fc[_0x7f54('0x87')]+_0x7f54('0x86')+md5(_0x44a7fc[_0x7f54('0x87')]);}else{_0x44a7fc[_0x7f54('0x84')]='';}var _0x3f8065=_0x3d3ff6[_0x7f54('0x7e')]===_0x7f54('0x88')?'eu':_0x7f54('0x89');return getAccessToken(_0x3d3ff6)[_0x7f54('0x37')](function(_0x593eb7){_0x267742=_0x593eb7;return getUser(_0x267742,_0x3f8065,_0x3d3ff6);})[_0x7f54('0x37')](function(_0x1cf714){_0x11f42b=_0x1cf714;logger[_0x7f54('0x32')](_0x7f54('0x8a'),_0x11f42b['id']);return getEndUser(_0x267742,_0x3f8065,_0x3d3ff6,_0x44a7fc['calleridname'],_0x44a7fc[_0x7f54('0x99')],_0x11f42b,_0x352778);})[_0x7f54('0x37')](function(_0x14ed06){_0x365b8b=_0x14ed06;return getCall(_0x267742,_0x3f8065,_0x3d3ff6,_0x11f42b,_0x365b8b,_0x352778,_0x44a7fc,'Inbound');})[_0x7f54('0x37')](function(_0x41e4f1){if(_0x41e4f1){logger[_0x7f54('0x32')](_0x7f54('0x95'),_0x41e4f1['id']);}})[_0x7f54('0x2f')](function(_0x544280){logger[_0x7f54('0x30')]('['+_0x44a7fc[_0x7f54('0x6c')][_0x7f54('0x98')]()+']',JSON[_0x7f54('0xe')](_0x544280));});};
\ No newline at end of file