Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / ami / trigger / integration / zoho.js
index c1eee24..863a7ad 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcb4f=['isNil','access_token','isBefore','zone','https://accounts.zoho.com','https://accounts.zoho.com.au','https://accounts.zoho.eu','https://accounts.zoho.in','https://accounts.zoho.com.cn','POST','/oauth/v2/token','refreshToken','refresh_token','then','add','expires_in','seconds','catch','error','Failing\x20creating\x20the\x20access_token','stack','info','ActiveUsers','Zoho-oauthtoken\x20','users','isArrayLikeObject','findIndex','email','Agent\x20found!','Using\x20the\x20admin\x20account!','profile','Administrator','user','The\x20failing\x20result\x20is','Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20','data','enduserType','/crm/v2/','startCase','role','first_name','last_name','code','SUCCESS','Error:\x20','CREATE\x20ERROR','GET','moduleSearch','contact_lead','uri','https://www.zohoapis.','/crm/v2/Contacts/search?criteria=((Phone:equals:','Contacts','/crm/v2/Leads/search?criteria=((Phone:equals:','Leads','moduleCreate','nothing','contact','Creating\x20new\x20call...','Owner','administrator','getString','Subjects','Description','Descriptions','Who_Id','Full_Name','First_Name','Last_Name','What_Id','talktime','Call_Duration','utc','answertime','endtime','diff','starttime','YYYY-MM-DDTHH:mm:ss','lastevent','called','Called','complete','connect','Call_Result','Answered','rejected','Abandoned','Timeout','Call_Start_Time','format','agentcalledAt','merge','Fields','/crm/v2/Calls','err','log','stripTrailingSlash','host','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','/api/voice/recordings/','uniqueid','/downloads?type=uniqueid&token=','recordingURL','zoho.eu','com','The\x20User\x20ID\x20is:','calleridname','calleridnum','Inbound','The\x20Call\x20ID\x20is:','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','/crm/EntityInfo.do?module=Calls&id=','outbound','recordingFormat','none','[OUTBOUND]','destcalleridname','destcalleridnum','Outbound','https://crm.','unmanaged','toUpperCase','request-promise','util','moment','ioredis','bluebird','../../../../config/logger','defaults','localhost','emit','debug','[HTTP]','stringify','length','forEach','string','picklist','type','idField','content','variable','variableName','toString','customVariable','name','Variable','split'];(function(_0x55821d,_0x27a22e){var _0x58ea8a=function(_0x5bdd3d){while(--_0x5bdd3d){_0x55821d['push'](_0x55821d['shift']());}};_0x58ea8a(++_0x27a22e);}(_0xcb4f,0x1b1));var _0xfcb4=function(_0x273c39,_0x1052e6){_0x273c39=_0x273c39-0x0;var _0x46d6b5=_0xcb4f[_0x273c39];return _0x46d6b5;};'use strict';var _=require('lodash');var rp=require(_0xfcb4('0x0'));var md5=require('md5');var util=require(_0xfcb4('0x1'));var intUtil=require('./util');var moment=require(_0xfcb4('0x2'));var Redis=require(_0xfcb4('0x3'));var BPromise=require(_0xfcb4('0x4'));var config=require('../../../../config/environment');var logger=require(_0xfcb4('0x5'))('zoho');config['redis']=_[_0xfcb4('0x6')](config['redis'],{'host':_0xfcb4('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function emit(_0x5d9069,_0x565b1c,_0x145a53){io['to'](_0x5d9069)[_0xfcb4('0x8')](_0x565b1c,_0x145a53);}function request(_0x68e07f){logger[_0xfcb4('0x9')](_0xfcb4('0xa'),JSON[_0xfcb4('0xb')](_0x68e07f));return rp(_0x68e07f);}function getCustomFields(_0x1fb27a,_0x58bc41){var _0x48b677={};if(_0x1fb27a[_0xfcb4('0xc')]>0x0){_[_0xfcb4('0xd')](_0x1fb27a,function(_0x18ff02){if(_['includes']([_0xfcb4('0xe'),_0xfcb4('0xf')],_0x18ff02[_0xfcb4('0x10')])&&_0x18ff02[_0xfcb4('0x11')]){_0x48b677[_0x18ff02['idField']]=_0x18ff02[_0xfcb4('0x12')]['toString']();}else if(_0x18ff02[_0xfcb4('0x10')]===_0xfcb4('0x13')&&_0x18ff02[_0xfcb4('0x14')]&&_0x18ff02[_0xfcb4('0x11')]&&_0x58bc41[_0x18ff02[_0xfcb4('0x14')]]){_0x48b677[_0x18ff02['idField']]=_0x58bc41[_0x18ff02['variableName']][_0xfcb4('0x15')]();}else if(_0x18ff02[_0xfcb4('0x10')]===_0xfcb4('0x16')&&_0x18ff02['Variable']&&_0x18ff02['Variable'][_0xfcb4('0x17')]&&_0x18ff02[_0xfcb4('0x11')]&&_0x58bc41[_0x18ff02['Variable'][_0xfcb4('0x17')]['toLowerCase']()]){_0x48b677[_0x18ff02[_0xfcb4('0x11')]]=_0x58bc41[_0x18ff02[_0xfcb4('0x18')][_0xfcb4('0x17')]['toLowerCase']()][_0xfcb4('0x15')]();}});}return _0x48b677;}function getName(_0x572b45){if(_0x572b45['indexOf']('\x20')>0x0){var _0x3867ad=_0x572b45[_0xfcb4('0x19')](/ (.+)/);if(_0x3867ad[0x1]){return _0x3867ad;}}return[_0x572b45,_0x572b45];}var accountsTokens={};function getAccessToken(_0x3f9103){return new Promise(function(_0x5b8ba7,_0x20d54d){if(!_[_0xfcb4('0x1a')](accountsTokens[_0x3f9103['id']])&&!_['isNil'](accountsTokens[_0x3f9103['id']][_0xfcb4('0x1b')])){if(moment()[_0xfcb4('0x1c')](accountsTokens[_0x3f9103['id']]['expires_in'])){_0x5b8ba7(accountsTokens[_0x3f9103['id']][_0xfcb4('0x1b')]);}}var _0x2f0752;switch(_0x3f9103[_0xfcb4('0x1d')]){case'US':_0x2f0752=_0xfcb4('0x1e');break;case'AU':_0x2f0752=_0xfcb4('0x1f');break;case'EU':_0x2f0752=_0xfcb4('0x20');break;case'IN':_0x2f0752=_0xfcb4('0x21');break;case'CN':_0x2f0752=_0xfcb4('0x22');break;default:_0x2f0752=_0xfcb4('0x20');break;}var _0x280662={'method':_0xfcb4('0x23'),'uri':_0x2f0752+_0xfcb4('0x24'),'qs':{'refresh_token':_0x3f9103[_0xfcb4('0x25')],'client_id':_0x3f9103['clientId'],'client_secret':_0x3f9103['clientSecret'],'grant_type':_0xfcb4('0x26')},'json':!![]};return rp(_0x280662)[_0xfcb4('0x27')](function(_0x5f12df){accountsTokens[_0x3f9103['id']]={'access_token':_0x5f12df[_0xfcb4('0x1b')],'expires_in':moment()[_0xfcb4('0x28')](_0x5f12df[_0xfcb4('0x29')],_0xfcb4('0x2a'))};_0x5b8ba7(_0x5f12df[_0xfcb4('0x1b')]);})[_0xfcb4('0x2b')](function(_0x377041){logger[_0xfcb4('0x2c')](_0xfcb4('0x2d'),_0x377041[_0xfcb4('0x2e')]);_0x20d54d(_0x377041);});});}function getUser(_0x5b52e5,_0x124658,_0x41e403,_0x3a060e){logger[_0xfcb4('0x2f')]('Search\x20user');return request({'method':'GET','uri':util['format']('https://www.zohoapis.%s/crm/v2/users',_0x124658),'qs':{'type':_0xfcb4('0x30')},'headers':{'Authorization':_0xfcb4('0x31')+_0x5b52e5},'json':!![]})[_0xfcb4('0x27')](function(_0x23c7ea){if(_0x23c7ea[_0xfcb4('0x32')]){var _0x29b162=-0x1;if(_[_0xfcb4('0x33')](_0x23c7ea[_0xfcb4('0x32')])){if(!_[_0xfcb4('0x1a')](_0x3a060e)){_0x29b162=_[_0xfcb4('0x34')](_0x23c7ea[_0xfcb4('0x32')],function(_0x531e94){return _0x531e94[_0xfcb4('0x35')]===_0x3a060e;});}if(_0x29b162>=0x0){logger[_0xfcb4('0x2f')](_0xfcb4('0x36'));}else{logger[_0xfcb4('0x2f')](_0xfcb4('0x37'));_0x29b162=_[_0xfcb4('0x34')](_0x23c7ea[_0xfcb4('0x32')],function(_0x2483b9){return _0x2483b9[_0xfcb4('0x38')]['name']===_0xfcb4('0x39');});}return _0x23c7ea['users'][_0x29b162];}else{if(_0x23c7ea[_0xfcb4('0x3a')][_0xfcb4('0x38')][_0xfcb4('0x17')]==='Administrator'){logger[_0xfcb4('0x2f')]('Using\x20the\x20admin\x20account!');user=_0x23c7ea[_0xfcb4('0x3a')];return user;}else{logger['error'](_0xfcb4('0x3b'),JSON[_0xfcb4('0xb')](_0x23c7ea));throw new Error(_0xfcb4('0x3c')+JSON['stringify'](_0x23c7ea));}}}else{logger[_0xfcb4('0x2c')](_0xfcb4('0x3b'),JSON[_0xfcb4('0xb')](_0x23c7ea));throw new Error(_0xfcb4('0x3c')+JSON[_0xfcb4('0xb')](_0x23c7ea));}})[_0xfcb4('0x2b')](function(_0x45ae41){console[_0xfcb4('0x2c')](_0x45ae41);});}function getZohoUser(_0x277ff0,_0x1a95f1){return new BPromise(function(_0x405c2f,_0x206787){request(_0x277ff0)['then'](function(_0x3c575a){var _0x1b422a=null;if(_0x3c575a){_0x1b422a=_0x3c575a[_0xfcb4('0x3d')][0x0];_0x1b422a[_0xfcb4('0x3e')]=_0x1a95f1;}_0x405c2f(_0x1b422a);})[_0xfcb4('0x2b')](function(_0x492979){_0x206787(_0x492979);});});}function createEndUser(_0x52de53,_0x50b43b,_0x35589e,_0x12c682,_0xf7f29c,_0x311bed){var _0x35589e=getName(_0x35589e);return request({'method':_0xfcb4('0x23'),'uri':'https://www.zohoapis.'+_0x50b43b+_0xfcb4('0x3f')+_[_0xfcb4('0x40')](_0x311bed['moduleCreate'])+'s','body':{'data':[{'Last_Name':_0x35589e[0x1],'First_Name':_0x35589e[0x0],'Phone':_0x12c682,'Owner':{'name':!_['isNil'](_0xf7f29c['role']['name'])?_0xf7f29c[_0xfcb4('0x41')]['name']:!_[_0xfcb4('0x1a')](_0xf7f29c[_0xfcb4('0x42')])?_0xf7f29c['first_name']+'\x20'+_0xf7f29c[_0xfcb4('0x43')]:_0xf7f29c[_0xfcb4('0x43')],'id':_0xf7f29c['id']}}]},'headers':{'Authorization':_0xfcb4('0x31')+_0x52de53},'json':!![]})[_0xfcb4('0x27')](function(_0x2a8ff6){if(_0x2a8ff6&&_0x2a8ff6[_0xfcb4('0x3d')][0x0][_0xfcb4('0x44')]===_0xfcb4('0x45')){var _0x3371f8=_0x2a8ff6[_0xfcb4('0x3d')][0x0]['details'];_0x3371f8[_0xfcb4('0x3e')]=_[_0xfcb4('0x40')](_0x311bed['moduleCreate'])+'s';return _0x3371f8;}logger[_0xfcb4('0x2c')](_0xfcb4('0x3b'),JSON[_0xfcb4('0xb')](data));throw new Error(_0xfcb4('0x46')+JSON[_0xfcb4('0xb')](data));})[_0xfcb4('0x2b')](function(_0x1305ed){console['log'](_0xfcb4('0x47'),_0x1305ed);});}function getEndUser(_0x2bc970,_0x46ace5,_0x16c057,_0xeb0288,_0xedd6b1,_0x4493f1,_0x15e041){var _0x59a954={'method':_0xfcb4('0x48'),'uri':'','headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x2bc970},'json':!![]};switch(_0x15e041[_0xfcb4('0x49')]){case _0xfcb4('0x4a'):_0x59a954[_0xfcb4('0x4b')]=_0xfcb4('0x4c')+_0x46ace5+_0xfcb4('0x4d')+_0xedd6b1+'))';return getZohoUser(_0x59a954,_0xfcb4('0x4e'))[_0xfcb4('0x27')](function(_0x537159){if(_0x537159)return _0x537159;_0x59a954[_0xfcb4('0x4b')]=_0xfcb4('0x4c')+_0x46ace5+_0xfcb4('0x4f')+_0xedd6b1+'))';return getZohoUser(_0x59a954,_0xfcb4('0x50'))[_0xfcb4('0x27')](function(_0x266f21){if(_0x266f21)return _0x266f21;if(_0x15e041[_0xfcb4('0x51')]!=_0xfcb4('0x52')){return createEndUser(_0x2bc970,_0x46ace5,_0xeb0288,_0xedd6b1,_0x4493f1,_0x15e041);}else{return{};}});});break;case _0xfcb4('0x53'):_0x59a954['uri']=_0xfcb4('0x4c')+_0x46ace5+_0xfcb4('0x4d')+_0xedd6b1+'))';return getZohoUser(_0x59a954,_0xfcb4('0x4e'))[_0xfcb4('0x27')](function(_0x47e38b){if(_0x47e38b)return _0x47e38b;if(_0x15e041[_0xfcb4('0x51')]!=_0xfcb4('0x52')){return createEndUser(_0x2bc970,_0x46ace5,_0xeb0288,_0xedd6b1,_0x4493f1,_0x15e041);}else{return{};}});break;case'lead':_0x59a954[_0xfcb4('0x4b')]=_0xfcb4('0x4c')+_0x46ace5+_0xfcb4('0x4f')+_0xedd6b1+'))';return getZohoUser(_0x59a954,_0xfcb4('0x50'))[_0xfcb4('0x27')](function(_0x46a98d){if(_0x46a98d)return _0x46a98d;if(_0x15e041['moduleCreate']!=_0xfcb4('0x52')){return createEndUser(_0x2bc970,_0x46ace5,_0xeb0288,_0xedd6b1,_0x4493f1,_0x15e041);}else{return{};}});break;}}function getCall(_0x5405e4,_0x4a5f20,_0x4d9ed3,_0x5b5ef0,_0x53d2d5,_0x3fcbbf,_0x3580e3,_0x97c78a){logger['info'](_0xfcb4('0x54'));var _0x1ee719={};_0x1ee719[_0xfcb4('0x55')]={'name':!_['isNil'](_0x5b5ef0[_0xfcb4('0x41')][_0xfcb4('0x17')])&&!_[_0xfcb4('0x1a')](_0x5b5ef0[_0xfcb4('0x38')][_0xfcb4('0x17')])&&_0x5b5ef0[_0xfcb4('0x38')][_0xfcb4('0x17')]===_0xfcb4('0x56')?_0x5b5ef0['role'][_0xfcb4('0x17')]:!_[_0xfcb4('0x1a')](_0x5b5ef0[_0xfcb4('0x42')])?_0x5b5ef0[_0xfcb4('0x42')]+'\x20'+_0x5b5ef0[_0xfcb4('0x43')]:_0x5b5ef0['last_name'],'id':_0x5b5ef0['id']};_0x1ee719['Subject']=intUtil[_0xfcb4('0x57')](_0x3fcbbf[_0xfcb4('0x58')],_0x3580e3,'\x20');_0x1ee719[_0xfcb4('0x59')]=intUtil[_0xfcb4('0x57')](_0x3fcbbf[_0xfcb4('0x5a')],_0x3580e3,'\x0a');if(_0x53d2d5[_0xfcb4('0x3e')]===_0xfcb4('0x4e')){_0x1ee719[_0xfcb4('0x5b')]={'name':!_['isNil'](_0x53d2d5[_0xfcb4('0x5c')])?_0x53d2d5[_0xfcb4('0x5c')]:!_[_0xfcb4('0x1a')](_0x53d2d5[_0xfcb4('0x5d')])?_0x53d2d5['First_Name']+'\x20'+_0x53d2d5[_0xfcb4('0x5e')]:_0x53d2d5[_0xfcb4('0x5e')],'id':_0x53d2d5['id']};}if(_0x53d2d5[_0xfcb4('0x3e')]===_0xfcb4('0x50')){_0x1ee719[_0xfcb4('0x5f')]={'name':!_[_0xfcb4('0x1a')](_0x53d2d5[_0xfcb4('0x5c')])?_0x53d2d5[_0xfcb4('0x5c')]:!_[_0xfcb4('0x1a')](_0x53d2d5[_0xfcb4('0x5d')])?_0x53d2d5['First_Name']+'\x20'+_0x53d2d5[_0xfcb4('0x5e')]:_0x53d2d5[_0xfcb4('0x5e')],'id':_0x53d2d5['id']};_0x1ee719['$se_module']=_[_0xfcb4('0x40')](_0x53d2d5[_0xfcb4('0x3e')]);}if(_0x3580e3[_0xfcb4('0x60')]){_0x1ee719[_0xfcb4('0x61')]=moment[_0xfcb4('0x62')](parseInt(_0x3580e3[_0xfcb4('0x60')])*0x3e8)['format']('mm:ss');}else if(_0x3580e3[_0xfcb4('0x63')]&&_0x3580e3['endtime']){_0x1ee719[_0xfcb4('0x61')]=moment[_0xfcb4('0x62')](moment(_0x3580e3[_0xfcb4('0x64')],'YYYY-MM-DDTHH:mm:ss')[_0xfcb4('0x65')](moment(_0x3580e3[_0xfcb4('0x66')],_0xfcb4('0x67'))))['format']('mm:ss');}switch(_0x3580e3[_0xfcb4('0x68')]){case _0xfcb4('0x69'):_0x1ee719['Call_Result']=_0xfcb4('0x6a');break;case _0xfcb4('0x6b'):case _0xfcb4('0x6c'):_0x1ee719[_0xfcb4('0x6d')]=_0xfcb4('0x6e');break;case _0xfcb4('0x6f'):_0x1ee719[_0xfcb4('0x6d')]='Rejected';break;case'abandoned':_0x1ee719[_0xfcb4('0x6d')]=_0xfcb4('0x70');break;case'timeout':_0x1ee719[_0xfcb4('0x6d')]=_0xfcb4('0x71');default:}_0x1ee719[_0xfcb4('0x72')]=(_0x97c78a==='outbound'?moment(_0x3580e3[_0xfcb4('0x66')])[_0xfcb4('0x73')]('YYYY-MM-DDTHH:mm:ss'):moment(_0x3580e3[_0xfcb4('0x74')])[_0xfcb4('0x73')](_0xfcb4('0x67')))||moment()[_0xfcb4('0x73')](_0xfcb4('0x67'));_0x1ee719['Call_Type']=_0x97c78a||'Inbound';_0x1ee719=_[_0xfcb4('0x75')](_0x1ee719,getCustomFields(_0x3fcbbf[_0xfcb4('0x76')],_0x3580e3));return request({'method':_0xfcb4('0x23'),'uri':_0xfcb4('0x4c')+_0x4a5f20+_0xfcb4('0x77'),'headers':{'Authorization':_0xfcb4('0x31')+_0x5405e4},'body':{'data':[_0x1ee719]},'json':!![]})['then'](function(_0x1cb8f6){if(_0x1cb8f6&&_0x1cb8f6['data'][0x0]['code']===_0xfcb4('0x45')){logger[_0xfcb4('0x2f')]('Call\x20created!');return{'id':_0x1cb8f6['data'][0x0]['details']['id']};}})[_0xfcb4('0x2b')](function(_0x4201e1){logger[_0xfcb4('0x2f')](_0xfcb4('0x78'),_0x4201e1[_0xfcb4('0x2e')]);console[_0xfcb4('0x79')](_0xfcb4('0x78'),_0x4201e1);});}exports['queue']=function(_0x1bb80e,_0x1d54ff,_0x4e862e,_0x106408,_0x18b189,_0x5b02c1){var _0x2b8edf,_0x2d893b,_0xd15851;_0x5b02c1['host']=intUtil[_0xfcb4('0x7a')](_0x5b02c1[_0xfcb4('0x7b')]);_0x5b02c1['serverUrl']=intUtil['stripTrailingSlash'](_0x5b02c1[_0xfcb4('0x7c')]);if(_0x18b189&&_0x18b189[_0xfcb4('0x7d')]){logger[_0xfcb4('0x2f')](_0xfcb4('0x7e'),_0xfcb4('0x7f'));_0x1d54ff['recordingURL']=_0x5b02c1[_0xfcb4('0x7c')]+_0xfcb4('0x80')+_0x1d54ff[_0xfcb4('0x81')]+_0xfcb4('0x82')+md5(_0x1d54ff[_0xfcb4('0x81')]);}else{_0x1d54ff[_0xfcb4('0x83')]='';}var _0x727f52=_0x5b02c1[_0xfcb4('0x7b')]===_0xfcb4('0x84')?'eu':_0xfcb4('0x85');return getAccessToken(_0x5b02c1)[_0xfcb4('0x27')](function(_0xfe6c33){_0xd15851=_0xfe6c33;return getUser(_0xd15851,_0x727f52,_0x5b02c1,_0x106408[_0xfcb4('0x35')]);})[_0xfcb4('0x27')](function(_0x3d6a7){_0x2b8edf=_0x3d6a7;logger[_0xfcb4('0x2f')](_0xfcb4('0x86'),_0x2b8edf['id']);return getEndUser(_0xd15851,_0x727f52,_0x5b02c1,_0x1d54ff[_0xfcb4('0x87')],_0x1d54ff[_0xfcb4('0x88')],_0x2b8edf,_0x4e862e);})['then'](function(_0x38a163){_0x2d893b=_0x38a163;return getCall(_0xd15851,_0x727f52,_0x5b02c1,_0x2b8edf,_0x2d893b,_0x4e862e,_0x1d54ff,_0xfcb4('0x89'));})[_0xfcb4('0x27')](function(_0x2d67a7){if(_0x2d67a7){logger[_0xfcb4('0x2f')](_0xfcb4('0x8a'),_0x2d67a7['id']);logger[_0xfcb4('0x2f')](_0xfcb4('0x7e'),_0xfcb4('0x8b'));emit(util[_0xfcb4('0x73')](_0xfcb4('0x8c'),_0x106408[_0xfcb4('0x17')]),_0xfcb4('0x8d'),{'uri':'https://crm.'+_0x5b02c1['host']+_0xfcb4('0x8e')+_0x2d67a7['id']});}})[_0xfcb4('0x2b')](function(_0x2b2b01){logger['error']('[QUEUE]',JSON[_0xfcb4('0xb')](_0x2b2b01));});};exports[_0xfcb4('0x8f')]=function(_0xff6031,_0x33fe76,_0x1cc896,_0x31a77a,_0x4015ff,_0x3efc76,_0x2de64e){var _0x4a573b,_0x8282c9,_0x11e03e;_0x3efc76['host']=intUtil[_0xfcb4('0x7a')](_0x3efc76['host']);_0x3efc76[_0xfcb4('0x7c')]=intUtil[_0xfcb4('0x7a')](_0x3efc76[_0xfcb4('0x7c')]);if(_0x2de64e&&_0x2de64e['recordingFormat']&&_0x2de64e[_0xfcb4('0x90')]!==_0xfcb4('0x91')){logger['info'](_0xfcb4('0x92'),_0xfcb4('0x7f'));_0x33fe76[_0xfcb4('0x83')]=_0x3efc76[_0xfcb4('0x7c')]+_0xfcb4('0x80')+_0x33fe76['uniqueid']+_0xfcb4('0x82')+md5(_0x33fe76[_0xfcb4('0x81')]);}var _0x6d031c=_0x3efc76[_0xfcb4('0x7b')]===_0xfcb4('0x84')?'eu':'com';return getAccessToken(_0x3efc76)[_0xfcb4('0x27')](function(_0x9d7731){_0x11e03e=_0x9d7731;return getUser(_0x11e03e,_0x6d031c,_0x3efc76,_0x31a77a[_0xfcb4('0x35')]);})['then'](function(_0x445fe9){_0x4a573b=_0x445fe9;logger['info'](_0xfcb4('0x86'),_0x4a573b['id']);return getEndUser(_0x11e03e,_0x6d031c,_0x3efc76,_0x33fe76[_0xfcb4('0x93')],_0x33fe76[_0xfcb4('0x94')],_0x4a573b,_0x1cc896);})[_0xfcb4('0x27')](function(_0x564a20){_0x8282c9=_0x564a20;return getCall(_0x11e03e,_0x6d031c,_0x3efc76,_0x4a573b,_0x8282c9,_0x1cc896,_0x33fe76,_0xfcb4('0x95'));})[_0xfcb4('0x27')](function(_0x3ae89b){if(_0x3ae89b){logger[_0xfcb4('0x2f')](_0xfcb4('0x8a'),_0x3ae89b['id']);logger['info'](_0xfcb4('0x92'),_0xfcb4('0x8b'));emit(util[_0xfcb4('0x73')](_0xfcb4('0x8c'),_0x31a77a[_0xfcb4('0x17')]),_0xfcb4('0x8d'),{'uri':_0xfcb4('0x96')+_0x3efc76[_0xfcb4('0x7b')]+'/crm/EntityInfo.do?module=Calls&id='+_0x3ae89b['id']});}})[_0xfcb4('0x2b')](function(_0x2fb576){logger[_0xfcb4('0x2c')](_0xfcb4('0x92'),JSON[_0xfcb4('0xb')](_0x2fb576));});};exports[_0xfcb4('0x97')]=function(_0x980ccf,_0x401950,_0x5266b9,_0x634784,_0xae865d,_0xad37){var _0xce01b8,_0x1bf82d,_0x59095d;_0xad37['host']=intUtil[_0xfcb4('0x7a')](_0xad37[_0xfcb4('0x7b')]);_0xad37[_0xfcb4('0x7c')]=intUtil[_0xfcb4('0x7a')](_0xad37['serverUrl']);if(_0xae865d&&_0xae865d[_0xfcb4('0x7d')]){logger[_0xfcb4('0x2f')]('['+_0x401950[_0xfcb4('0x68')][_0xfcb4('0x98')]()+']',_0xfcb4('0x7f'));_0x401950['recordingURL']=_0xad37['serverUrl']+_0xfcb4('0x80')+_0x401950[_0xfcb4('0x81')]+_0xfcb4('0x82')+md5(_0x401950[_0xfcb4('0x81')]);}else{_0x401950['recordingURL']='';}var _0x5ee5d8=_0xad37[_0xfcb4('0x7b')]===_0xfcb4('0x84')?'eu':_0xfcb4('0x85');return getAccessToken(_0xad37)[_0xfcb4('0x27')](function(_0x54bd0e){_0x59095d=_0x54bd0e;return getUser(_0x59095d,_0x5ee5d8,_0xad37);})[_0xfcb4('0x27')](function(_0x2cb813){_0xce01b8=_0x2cb813;logger[_0xfcb4('0x2f')](_0xfcb4('0x86'),_0xce01b8['id']);return getEndUser(_0x59095d,_0x5ee5d8,_0xad37,_0x401950[_0xfcb4('0x87')],_0x401950[_0xfcb4('0x88')],_0xce01b8,_0x5266b9);})[_0xfcb4('0x27')](function(_0xf97078){_0x1bf82d=_0xf97078;return getCall(_0x59095d,_0x5ee5d8,_0xad37,_0xce01b8,_0x1bf82d,_0x5266b9,_0x401950,'Inbound');})[_0xfcb4('0x27')](function(_0x19731a){if(_0x19731a){logger[_0xfcb4('0x2f')]('The\x20Call\x20ID\x20is:',_0x19731a['id']);}})['catch'](function(_0xe3d092){logger[_0xfcb4('0x2c')]('['+_0x401950[_0xfcb4('0x68')][_0xfcb4('0x98')]()+']',JSON[_0xfcb4('0xb')](_0xe3d092));});};
\ No newline at end of file
+var _0x2666=['contact_lead','Contacts','/crm/v2/Leads/search?criteria=((Phone:equals:','Leads','nothing','contact','uri','lead','Creating\x20new\x20call...','Owner','administrator','Subject','getString','Subjects','Descriptions','Who_Id','Full_Name','First_Name','Last_Name','What_Id','$se_module','talktime','Call_Duration','format','mm:ss','answertime','endtime','YYYY-MM-DDTHH:mm:ss','diff','starttime','lastevent','called','Call_Result','Called','connect','rejected','abandoned','Abandoned','timeout','Timeout','outbound','agentcalledAt','Inbound','Fields','err','queue','host','stripTrailingSlash','serverUrl','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','/api/voice/recordings/','zoho.eu','com','The\x20User\x20ID\x20is:','calleridname','calleridnum','Displaying\x20call\x20to\x20agent\x20in\x20a\x20new\x20tab...','user:%s','trigger:browser:url','/crm/EntityInfo.do?module=Calls&id=','recordingFormat','none','[OUTBOUND]','uniqueid','/downloads?type=uniqueid&token=','email','destcalleridname','destcalleridnum','Outbound','https://crm.','unmanaged','toUpperCase','lodash','request-promise','md5','util','./util','moment','ioredis','bluebird','../../../../config/environment','../../../../config/logger','zoho','redis','defaults','emit','debug','[HTTP]','stringify','length','includes','string','type','idField','toString','variable','variableName','customVariable','Variable','name','toLowerCase','indexOf','split','isNil','access_token','isBefore','expires_in','zone','https://accounts.zoho.com.au','https://accounts.zoho.com.cn','POST','refreshToken','clientSecret','refresh_token','then','seconds','error','Failing\x20creating\x20the\x20access_token','stack','info','GET','https://www.zohoapis.%s/crm/v2/users','ActiveUsers','Zoho-oauthtoken\x20','users','isArrayLikeObject','findIndex','Agent\x20found!','Using\x20the\x20admin\x20account!','profile','Administrator','user','The\x20failing\x20result\x20is','Unable\x20to\x20retrieve\x20zoho\x20account\x20users:\x20','catch','data','enduserType','https://www.zohoapis.','startCase','moduleCreate','role','first_name','last_name','SUCCESS','details','Error:\x20','log','CREATE\x20ERROR','moduleSearch'];(function(_0x7d0066,_0x1462bd){var _0x124bd6=function(_0x47ab17){while(--_0x47ab17){_0x7d0066['push'](_0x7d0066['shift']());}};_0x124bd6(++_0x1462bd);}(_0x2666,0xe3));var _0x6266=function(_0x8a9b4e,_0x2680d7){_0x8a9b4e=_0x8a9b4e-0x0;var _0x539218=_0x2666[_0x8a9b4e];return _0x539218;};'use strict';var _=require(_0x6266('0x0'));var rp=require(_0x6266('0x1'));var md5=require(_0x6266('0x2'));var util=require(_0x6266('0x3'));var intUtil=require(_0x6266('0x4'));var moment=require(_0x6266('0x5'));var Redis=require(_0x6266('0x6'));var BPromise=require(_0x6266('0x7'));var config=require(_0x6266('0x8'));var logger=require(_0x6266('0x9'))(_0x6266('0xa'));config[_0x6266('0xb')]=_[_0x6266('0xc')](config[_0x6266('0xb')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6266('0xb')]));function emit(_0x5c8131,_0x329582,_0x2fc044){io['to'](_0x5c8131)[_0x6266('0xd')](_0x329582,_0x2fc044);}function request(_0x43241b){logger[_0x6266('0xe')](_0x6266('0xf'),JSON[_0x6266('0x10')](_0x43241b));return rp(_0x43241b);}function getCustomFields(_0xbc7c2b,_0xe6ff42){var _0x9964ed={};if(_0xbc7c2b[_0x6266('0x11')]>0x0){_['forEach'](_0xbc7c2b,function(_0x49ac03){if(_[_0x6266('0x12')]([_0x6266('0x13'),'picklist'],_0x49ac03[_0x6266('0x14')])&&_0x49ac03['idField']){_0x9964ed[_0x49ac03[_0x6266('0x15')]]=_0x49ac03['content'][_0x6266('0x16')]();}else if(_0x49ac03[_0x6266('0x14')]===_0x6266('0x17')&&_0x49ac03[_0x6266('0x18')]&&_0x49ac03[_0x6266('0x15')]&&_0xe6ff42[_0x49ac03[_0x6266('0x18')]]){_0x9964ed[_0x49ac03['idField']]=_0xe6ff42[_0x49ac03[_0x6266('0x18')]][_0x6266('0x16')]();}else if(_0x49ac03[_0x6266('0x14')]===_0x6266('0x19')&&_0x49ac03['Variable']&&_0x49ac03[_0x6266('0x1a')][_0x6266('0x1b')]&&_0x49ac03[_0x6266('0x15')]&&_0xe6ff42[_0x49ac03[_0x6266('0x1a')]['name'][_0x6266('0x1c')]()]){_0x9964ed[_0x49ac03['idField']]=_0xe6ff42[_0x49ac03['Variable'][_0x6266('0x1b')]['toLowerCase']()][_0x6266('0x16')]();}});}return _0x9964ed;}function getName(_0x4deec1){if(_0x4deec1[_0x6266('0x1d')]('\x20')>0x0){var _0x208b10=_0x4deec1[_0x6266('0x1e')](/ (.+)/);if(_0x208b10[0x1]){return _0x208b10;}}return[_0x4deec1,_0x4deec1];}var accountsTokens={};function getAccessToken(_0x1ab1c6){return new Promise(function(_0x2d7720,_0x359417){if(!_[_0x6266('0x1f')](accountsTokens[_0x1ab1c6['id']])&&!_[_0x6266('0x1f')](accountsTokens[_0x1ab1c6['id']][_0x6266('0x20')])){if(moment()[_0x6266('0x21')](accountsTokens[_0x1ab1c6['id']][_0x6266('0x22')])){_0x2d7720(accountsTokens[_0x1ab1c6['id']][_0x6266('0x20')]);}}var _0x75e10b;switch(_0x1ab1c6[_0x6266('0x23')]){case'US':_0x75e10b='https://accounts.zoho.com';break;case'AU':_0x75e10b=_0x6266('0x24');break;case'EU':_0x75e10b='https://accounts.zoho.eu';break;case'IN':_0x75e10b='https://accounts.zoho.in';break;case'CN':_0x75e10b=_0x6266('0x25');break;default:_0x75e10b='https://accounts.zoho.eu';break;}var _0x44fcde={'method':_0x6266('0x26'),'uri':_0x75e10b+'/oauth/v2/token','qs':{'refresh_token':_0x1ab1c6[_0x6266('0x27')],'client_id':_0x1ab1c6['clientId'],'client_secret':_0x1ab1c6[_0x6266('0x28')],'grant_type':_0x6266('0x29')},'json':!![]};return rp(_0x44fcde)[_0x6266('0x2a')](function(_0x4a3064){accountsTokens[_0x1ab1c6['id']]={'access_token':_0x4a3064[_0x6266('0x20')],'expires_in':moment()['add'](_0x4a3064[_0x6266('0x22')],_0x6266('0x2b'))};_0x2d7720(_0x4a3064['access_token']);})['catch'](function(_0x355e37){logger[_0x6266('0x2c')](_0x6266('0x2d'),_0x355e37[_0x6266('0x2e')]);_0x359417(_0x355e37);});});}function getUser(_0x4963be,_0x50f69f,_0x4ed1c9,_0x21673f){logger[_0x6266('0x2f')]('Search\x20user');return request({'method':_0x6266('0x30'),'uri':util['format'](_0x6266('0x31'),_0x50f69f),'qs':{'type':_0x6266('0x32')},'headers':{'Authorization':_0x6266('0x33')+_0x4963be},'json':!![]})[_0x6266('0x2a')](function(_0x355075){if(_0x355075[_0x6266('0x34')]){var _0x340b97=-0x1;if(_[_0x6266('0x35')](_0x355075[_0x6266('0x34')])){if(!_[_0x6266('0x1f')](_0x21673f)){_0x340b97=_[_0x6266('0x36')](_0x355075[_0x6266('0x34')],function(_0x1d0f35){return _0x1d0f35['email']===_0x21673f;});}if(_0x340b97>=0x0){logger['info'](_0x6266('0x37'));}else{logger['info'](_0x6266('0x38'));_0x340b97=_['findIndex'](_0x355075['users'],function(_0x5e716f){return _0x5e716f[_0x6266('0x39')][_0x6266('0x1b')]===_0x6266('0x3a');});}return _0x355075[_0x6266('0x34')][_0x340b97];}else{if(_0x355075[_0x6266('0x3b')]['profile'][_0x6266('0x1b')]==='Administrator'){logger[_0x6266('0x2f')](_0x6266('0x38'));user=_0x355075[_0x6266('0x3b')];return user;}else{logger[_0x6266('0x2c')](_0x6266('0x3c'),JSON[_0x6266('0x10')](_0x355075));throw new Error(_0x6266('0x3d')+JSON['stringify'](_0x355075));}}}else{logger[_0x6266('0x2c')](_0x6266('0x3c'),JSON['stringify'](_0x355075));throw new Error(_0x6266('0x3d')+JSON[_0x6266('0x10')](_0x355075));}})[_0x6266('0x3e')](function(_0x4f4d4f){console[_0x6266('0x2c')](_0x4f4d4f);});}function getZohoUser(_0x1ac7c4,_0x5c135f){return new BPromise(function(_0x516079,_0x28c9be){request(_0x1ac7c4)['then'](function(_0x47a844){var _0x56c187=null;if(_0x47a844){_0x56c187=_0x47a844[_0x6266('0x3f')][0x0];_0x56c187[_0x6266('0x40')]=_0x5c135f;}_0x516079(_0x56c187);})['catch'](function(_0xce2f9){_0x28c9be(_0xce2f9);});});}function createEndUser(_0x1e0a9c,_0x37a59a,_0x2cbc48,_0x2b5e74,_0x189b29,_0x1ccc3c){var _0x2cbc48=getName(_0x2cbc48);return request({'method':'POST','uri':_0x6266('0x41')+_0x37a59a+'/crm/v2/'+_[_0x6266('0x42')](_0x1ccc3c[_0x6266('0x43')])+'s','body':{'data':[{'Last_Name':_0x2cbc48[0x1],'First_Name':_0x2cbc48[0x0],'Phone':_0x2b5e74,'Owner':{'name':!_[_0x6266('0x1f')](_0x189b29[_0x6266('0x44')][_0x6266('0x1b')])?_0x189b29['role'][_0x6266('0x1b')]:!_[_0x6266('0x1f')](_0x189b29['first_name'])?_0x189b29[_0x6266('0x45')]+'\x20'+_0x189b29[_0x6266('0x46')]:_0x189b29['last_name'],'id':_0x189b29['id']}}]},'headers':{'Authorization':_0x6266('0x33')+_0x1e0a9c},'json':!![]})['then'](function(_0x2fb77f){if(_0x2fb77f&&_0x2fb77f[_0x6266('0x3f')][0x0]['code']===_0x6266('0x47')){var _0x26b71c=_0x2fb77f['data'][0x0][_0x6266('0x48')];_0x26b71c[_0x6266('0x40')]=_[_0x6266('0x42')](_0x1ccc3c['moduleCreate'])+'s';return _0x26b71c;}logger[_0x6266('0x2c')](_0x6266('0x3c'),JSON['stringify'](data));throw new Error(_0x6266('0x49')+JSON[_0x6266('0x10')](data));})[_0x6266('0x3e')](function(_0x239e4a){console[_0x6266('0x4a')](_0x6266('0x4b'),_0x239e4a);});}function getEndUser(_0x3173f4,_0x29e20b,_0x5494a9,_0x27290c,_0x1d8e15,_0x1674ed,_0x2306e1){var _0x4dfda6={'method':_0x6266('0x30'),'uri':'','headers':{'Authorization':_0x6266('0x33')+_0x3173f4},'json':!![]};switch(_0x2306e1[_0x6266('0x4c')]){case _0x6266('0x4d'):_0x4dfda6['uri']=_0x6266('0x41')+_0x29e20b+'/crm/v2/Contacts/search?criteria=((Phone:equals:'+_0x1d8e15+'))';return getZohoUser(_0x4dfda6,_0x6266('0x4e'))[_0x6266('0x2a')](function(_0x1ae708){if(_0x1ae708)return _0x1ae708;_0x4dfda6['uri']=_0x6266('0x41')+_0x29e20b+_0x6266('0x4f')+_0x1d8e15+'))';return getZohoUser(_0x4dfda6,_0x6266('0x50'))['then'](function(_0x465f00){if(_0x465f00)return _0x465f00;if(_0x2306e1[_0x6266('0x43')]!=_0x6266('0x51')){return createEndUser(_0x3173f4,_0x29e20b,_0x27290c,_0x1d8e15,_0x1674ed,_0x2306e1);}else{return{};}});});break;case _0x6266('0x52'):_0x4dfda6[_0x6266('0x53')]='https://www.zohoapis.'+_0x29e20b+'/crm/v2/Contacts/search?criteria=((Phone:equals:'+_0x1d8e15+'))';return getZohoUser(_0x4dfda6,_0x6266('0x4e'))[_0x6266('0x2a')](function(_0x23207d){if(_0x23207d)return _0x23207d;if(_0x2306e1[_0x6266('0x43')]!=_0x6266('0x51')){return createEndUser(_0x3173f4,_0x29e20b,_0x27290c,_0x1d8e15,_0x1674ed,_0x2306e1);}else{return{};}});break;case _0x6266('0x54'):_0x4dfda6[_0x6266('0x53')]=_0x6266('0x41')+_0x29e20b+_0x6266('0x4f')+_0x1d8e15+'))';return getZohoUser(_0x4dfda6,_0x6266('0x50'))['then'](function(_0x412cf){if(_0x412cf)return _0x412cf;if(_0x2306e1['moduleCreate']!=_0x6266('0x51')){return createEndUser(_0x3173f4,_0x29e20b,_0x27290c,_0x1d8e15,_0x1674ed,_0x2306e1);}else{return{};}});break;}}function getCall(_0x264c92,_0x3f4ab6,_0xc87779,_0xe95851,_0x3db1cb,_0x3df8c4,_0x4cbf5f,_0x1f35d0){logger['info'](_0x6266('0x55'));var _0x261954={};_0x261954[_0x6266('0x56')]={'name':!_[_0x6266('0x1f')](_0xe95851[_0x6266('0x44')]['name'])&&!_[_0x6266('0x1f')](_0xe95851['profile']['name'])&&_0xe95851[_0x6266('0x39')][_0x6266('0x1b')]===_0x6266('0x57')?_0xe95851['role'][_0x6266('0x1b')]:!_['isNil'](_0xe95851[_0x6266('0x45')])?_0xe95851[_0x6266('0x45')]+'\x20'+_0xe95851[_0x6266('0x46')]:_0xe95851['last_name'],'id':_0xe95851['id']};_0x261954[_0x6266('0x58')]=intUtil[_0x6266('0x59')](_0x3df8c4[_0x6266('0x5a')],_0x4cbf5f,'\x20');_0x261954['Description']=intUtil[_0x6266('0x59')](_0x3df8c4[_0x6266('0x5b')],_0x4cbf5f,'\x0a');if(_0x3db1cb[_0x6266('0x40')]===_0x6266('0x4e')){_0x261954[_0x6266('0x5c')]={'name':!_[_0x6266('0x1f')](_0x3db1cb['Full_Name'])?_0x3db1cb[_0x6266('0x5d')]:!_[_0x6266('0x1f')](_0x3db1cb[_0x6266('0x5e')])?_0x3db1cb['First_Name']+'\x20'+_0x3db1cb[_0x6266('0x5f')]:_0x3db1cb[_0x6266('0x5f')],'id':_0x3db1cb['id']};}if(_0x3db1cb[_0x6266('0x40')]==='Leads'){_0x261954[_0x6266('0x60')]={'name':!_[_0x6266('0x1f')](_0x3db1cb[_0x6266('0x5d')])?_0x3db1cb['Full_Name']:!_['isNil'](_0x3db1cb[_0x6266('0x5e')])?_0x3db1cb[_0x6266('0x5e')]+'\x20'+_0x3db1cb[_0x6266('0x5f')]:_0x3db1cb[_0x6266('0x5f')],'id':_0x3db1cb['id']};_0x261954[_0x6266('0x61')]=_[_0x6266('0x42')](_0x3db1cb['enduserType']);}if(_0x4cbf5f[_0x6266('0x62')]){_0x261954[_0x6266('0x63')]=moment['utc'](parseInt(_0x4cbf5f[_0x6266('0x62')])*0x3e8)[_0x6266('0x64')](_0x6266('0x65'));}else if(_0x4cbf5f[_0x6266('0x66')]&&_0x4cbf5f[_0x6266('0x67')]){_0x261954[_0x6266('0x63')]=moment['utc'](moment(_0x4cbf5f[_0x6266('0x67')],_0x6266('0x68'))[_0x6266('0x69')](moment(_0x4cbf5f[_0x6266('0x6a')],_0x6266('0x68'))))[_0x6266('0x64')](_0x6266('0x65'));}switch(_0x4cbf5f[_0x6266('0x6b')]){case _0x6266('0x6c'):_0x261954[_0x6266('0x6d')]=_0x6266('0x6e');break;case'complete':case _0x6266('0x6f'):_0x261954['Call_Result']='Answered';break;case _0x6266('0x70'):_0x261954[_0x6266('0x6d')]='Rejected';break;case _0x6266('0x71'):_0x261954[_0x6266('0x6d')]=_0x6266('0x72');break;case _0x6266('0x73'):_0x261954[_0x6266('0x6d')]=_0x6266('0x74');default:}_0x261954['Call_Start_Time']=(_0x1f35d0===_0x6266('0x75')?moment(_0x4cbf5f[_0x6266('0x6a')])[_0x6266('0x64')](_0x6266('0x68')):moment(_0x4cbf5f[_0x6266('0x76')])['format'](_0x6266('0x68')))||moment()[_0x6266('0x64')](_0x6266('0x68'));_0x261954['Call_Type']=_0x1f35d0||_0x6266('0x77');_0x261954=_['merge'](_0x261954,getCustomFields(_0x3df8c4[_0x6266('0x78')],_0x4cbf5f));return request({'method':'POST','uri':'https://www.zohoapis.'+_0x3f4ab6+'/crm/v2/Calls','headers':{'Authorization':'Zoho-oauthtoken\x20'+_0x264c92},'body':{'data':[_0x261954]},'json':!![]})['then'](function(_0x1e7cd4){if(_0x1e7cd4&&_0x1e7cd4[_0x6266('0x3f')][0x0]['code']==='SUCCESS'){logger['info']('Call\x20created!');return{'id':_0x1e7cd4[_0x6266('0x3f')][0x0][_0x6266('0x48')]['id']};}})[_0x6266('0x3e')](function(_0x5d2f57){logger[_0x6266('0x2f')](_0x6266('0x79'),_0x5d2f57[_0x6266('0x2e')]);console[_0x6266('0x4a')]('err',_0x5d2f57);});}exports[_0x6266('0x7a')]=function(_0x2b1d64,_0x186dbb,_0x3c8c34,_0x924bd3,_0x4b9205,_0x253b80){var _0x1518bb,_0x23f58a,_0x27b5f3;_0x253b80[_0x6266('0x7b')]=intUtil[_0x6266('0x7c')](_0x253b80[_0x6266('0x7b')]);_0x253b80[_0x6266('0x7d')]=intUtil['stripTrailingSlash'](_0x253b80[_0x6266('0x7d')]);if(_0x4b9205&&_0x4b9205[_0x6266('0x7e')]){logger[_0x6266('0x2f')](_0x6266('0x7f'),_0x6266('0x80'));_0x186dbb[_0x6266('0x81')]=_0x253b80[_0x6266('0x7d')]+_0x6266('0x82')+_0x186dbb['uniqueid']+'/downloads?type=uniqueid&token='+md5(_0x186dbb['uniqueid']);}else{_0x186dbb['recordingURL']='';}var _0x2bdcc0=_0x253b80[_0x6266('0x7b')]===_0x6266('0x83')?'eu':_0x6266('0x84');return getAccessToken(_0x253b80)[_0x6266('0x2a')](function(_0x1bfc62){_0x27b5f3=_0x1bfc62;return getUser(_0x27b5f3,_0x2bdcc0,_0x253b80,_0x924bd3['email']);})['then'](function(_0x313100){_0x1518bb=_0x313100;logger[_0x6266('0x2f')](_0x6266('0x85'),_0x1518bb['id']);return getEndUser(_0x27b5f3,_0x2bdcc0,_0x253b80,_0x186dbb[_0x6266('0x86')],_0x186dbb[_0x6266('0x87')],_0x1518bb,_0x3c8c34);})[_0x6266('0x2a')](function(_0x291424){_0x23f58a=_0x291424;return getCall(_0x27b5f3,_0x2bdcc0,_0x253b80,_0x1518bb,_0x23f58a,_0x3c8c34,_0x186dbb,_0x6266('0x77'));})[_0x6266('0x2a')](function(_0x2ad67f){if(_0x2ad67f){logger[_0x6266('0x2f')]('The\x20Call\x20ID\x20is:',_0x2ad67f['id']);logger[_0x6266('0x2f')]('[QUEUE]',_0x6266('0x88'));emit(util['format'](_0x6266('0x89'),_0x924bd3[_0x6266('0x1b')]),_0x6266('0x8a'),{'uri':'https://crm.'+_0x253b80[_0x6266('0x7b')]+_0x6266('0x8b')+_0x2ad67f['id']});}})[_0x6266('0x3e')](function(_0x19f7d8){logger['error']('[QUEUE]',JSON[_0x6266('0x10')](_0x19f7d8));});};exports[_0x6266('0x75')]=function(_0xbf0f7c,_0x3c1f43,_0x3fa311,_0xe666b8,_0x4f223b,_0x4a53c9,_0xeec637){var _0x128e26,_0x164e71,_0x11528b;_0x4a53c9[_0x6266('0x7b')]=intUtil[_0x6266('0x7c')](_0x4a53c9[_0x6266('0x7b')]);_0x4a53c9[_0x6266('0x7d')]=intUtil['stripTrailingSlash'](_0x4a53c9['serverUrl']);if(_0xeec637&&_0xeec637[_0x6266('0x8c')]&&_0xeec637['recordingFormat']!==_0x6266('0x8d')){logger[_0x6266('0x2f')](_0x6266('0x8e'),_0x6266('0x80'));_0x3c1f43['recordingURL']=_0x4a53c9['serverUrl']+'/api/voice/recordings/'+_0x3c1f43[_0x6266('0x8f')]+_0x6266('0x90')+md5(_0x3c1f43['uniqueid']);}var _0x93a818=_0x4a53c9[_0x6266('0x7b')]===_0x6266('0x83')?'eu':'com';return getAccessToken(_0x4a53c9)['then'](function(_0x1b5692){_0x11528b=_0x1b5692;return getUser(_0x11528b,_0x93a818,_0x4a53c9,_0xe666b8[_0x6266('0x91')]);})[_0x6266('0x2a')](function(_0x17efc6){_0x128e26=_0x17efc6;logger[_0x6266('0x2f')](_0x6266('0x85'),_0x128e26['id']);return getEndUser(_0x11528b,_0x93a818,_0x4a53c9,_0x3c1f43[_0x6266('0x92')],_0x3c1f43[_0x6266('0x93')],_0x128e26,_0x3fa311);})[_0x6266('0x2a')](function(_0x595576){_0x164e71=_0x595576;return getCall(_0x11528b,_0x93a818,_0x4a53c9,_0x128e26,_0x164e71,_0x3fa311,_0x3c1f43,_0x6266('0x94'));})[_0x6266('0x2a')](function(_0x5ae121){if(_0x5ae121){logger[_0x6266('0x2f')]('The\x20Call\x20ID\x20is:',_0x5ae121['id']);logger['info'](_0x6266('0x8e'),_0x6266('0x88'));emit(util[_0x6266('0x64')](_0x6266('0x89'),_0xe666b8[_0x6266('0x1b')]),_0x6266('0x8a'),{'uri':_0x6266('0x95')+_0x4a53c9[_0x6266('0x7b')]+_0x6266('0x8b')+_0x5ae121['id']});}})[_0x6266('0x3e')](function(_0x200e46){logger['error'](_0x6266('0x8e'),JSON[_0x6266('0x10')](_0x200e46));});};exports[_0x6266('0x96')]=function(_0x242fc7,_0x3af8ce,_0x7aa28b,_0x3de5c5,_0x5ab242,_0x230c09){var _0x269b74,_0x1ffb0c,_0x472961;_0x230c09['host']=intUtil['stripTrailingSlash'](_0x230c09[_0x6266('0x7b')]);_0x230c09[_0x6266('0x7d')]=intUtil['stripTrailingSlash'](_0x230c09[_0x6266('0x7d')]);if(_0x5ab242&&_0x5ab242[_0x6266('0x7e')]){logger[_0x6266('0x2f')]('['+_0x3af8ce['lastevent'][_0x6266('0x97')]()+']',_0x6266('0x80'));_0x3af8ce[_0x6266('0x81')]=_0x230c09[_0x6266('0x7d')]+'/api/voice/recordings/'+_0x3af8ce['uniqueid']+_0x6266('0x90')+md5(_0x3af8ce[_0x6266('0x8f')]);}else{_0x3af8ce[_0x6266('0x81')]='';}var _0x1fdba0=_0x230c09[_0x6266('0x7b')]===_0x6266('0x83')?'eu':_0x6266('0x84');return getAccessToken(_0x230c09)[_0x6266('0x2a')](function(_0x1112c8){_0x472961=_0x1112c8;return getUser(_0x472961,_0x1fdba0,_0x230c09);})['then'](function(_0x12c127){_0x269b74=_0x12c127;logger[_0x6266('0x2f')]('The\x20User\x20ID\x20is:',_0x269b74['id']);return getEndUser(_0x472961,_0x1fdba0,_0x230c09,_0x3af8ce[_0x6266('0x86')],_0x3af8ce[_0x6266('0x87')],_0x269b74,_0x7aa28b);})[_0x6266('0x2a')](function(_0x1cfb86){_0x1ffb0c=_0x1cfb86;return getCall(_0x472961,_0x1fdba0,_0x230c09,_0x269b74,_0x1ffb0c,_0x7aa28b,_0x3af8ce,_0x6266('0x77'));})['then'](function(_0x58c0c9){if(_0x58c0c9){logger[_0x6266('0x2f')]('The\x20Call\x20ID\x20is:',_0x58c0c9['id']);}})[_0x6266('0x3e')](function(_0x32f4aa){logger[_0x6266('0x2c')]('['+_0x3af8ce[_0x6266('0x6b')][_0x6266('0x97')]()+']',JSON[_0x6266('0x10')](_0x32f4aa));});};
\ No newline at end of file