2a12c65c6b95f96627cd987563ae0458efe49f58
[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 _0xcacc=['display_name','moduleSearch','contact_lead','additionalSearchContact','merge','$or','Contact','cloneDeep','additionalSearchLead','account_contact_lead','additionalSearchAccount','Account','execute','Lead','first','attributes','toLowerCase','Enduser\x20(%s)\x20with\x20phone\x20%s\x20found','Enduser\x20with\x20phone\x20%s\x20not\x20found','moduleCreate','LastName','<unknown>','format','Caller\x20-\x20%s','Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.','Company','No\x20Company','upperFirst','forEach','includes','type','idField','content','toString','variableName','customVariable','Variable','name','password','concat','Connection','remoteUri','https://login.salesforce.com','clientId','clientSecret','username','queue','serverUrl','stripTrailingSlash','monitor_format','[QUEUE]','Recording\x20is\x20enabled!','recordingURL','%s/api/voice/recordings/%s/downloads?type=uniqueid&token=%s','uniqueid','email','calleridname','[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','%s/%s/e','instanceUrl','error','[QUEUE]\x20Salesforce\x20account\x20type\x20not\x20recognized.','catch','outbound','recordingFormat','[OUTBOUND]','destcalleridname','Fields','[OUTBOUND]\x20Displaying\x20ticket\x20%s\x20to\x20agent\x20%s.\x20Integration\x20account\x20type\x20%s.','unmanaged','lastevent','toUpperCase',']\x20Ticket\x20%s\x20created.',']\x20Integration\x20account\x20type\x20%s.','lodash','request-promise','moment','bluebird','./util','../../../../config/logger','redis','defaults','localhost','socket.io-emitter','emit','assign','getString','Subjects','Descriptions','ticketType','ActivityDate','utc','IsReminderSet','endUserType','contact','lead','WhoId','WhatId','Case','account','AccountId','leadId','info','sobject','create','validateEmail','User','find','then','length','Agent\x20%s\x20found.','resolve','Name','Agent\x20%s\x20not\x20found.\x20Switch\x20to\x20the\x20admin\x20account.','identity','user_id'];(function(_0x194dfe,_0xf53dc2){var _0x40701d=function(_0x3a6836){while(--_0x3a6836){_0x194dfe['push'](_0x194dfe['shift']());}};_0x40701d(++_0xf53dc2);}(_0xcacc,0x1be));var _0xccac=function(_0x36c594,_0x11931c){_0x36c594=_0x36c594-0x0;var _0x3e2c0b=_0xcacc[_0x36c594];return _0x3e2c0b;};'use strict';var _=require(_0xccac('0x0'));var rp=require(_0xccac('0x1'));var moment=require(_0xccac('0x2'));var BPromise=require(_0xccac('0x3'));var md5=require('md5');var jsforce=require('jsforce');var util=require('util');var Redis=require('ioredis');var intUtil=require(_0xccac('0x4'));var config=require('../../../../config/environment');var logger=require(_0xccac('0x5'))('salesforce');config[_0xccac('0x6')]=_[_0xccac('0x7')](config[_0xccac('0x6')],{'host':_0xccac('0x8'),'port':0x18eb});var io=require(_0xccac('0x9'))(new Redis(config[_0xccac('0x6')]));function emit(_0x1aa85b,_0x492920,_0x2e51c3){io['to'](_0x1aa85b)[_0xccac('0xa')](_0x492920,_0x2e51c3);}function getTicket(_0x1a279a,_0x3076fa,_0x1277e2,_0x523c2e,_0x51d34d,_0x249520,_0x33769e,_0x54d99d){var _0x5df534=Object[_0xccac('0xb')]({},{'OwnerId':_0x3076fa['id'],'Subject':intUtil[_0xccac('0xc')](_0x523c2e[_0xccac('0xd')],_0x51d34d,'\x20'),'Description':intUtil[_0xccac('0xc')](_0x523c2e[_0xccac('0xe')],_0x51d34d,'\x0a')},getCustomFields(_0x249520,_0x51d34d));if(_0x1277e2){if(_0x523c2e[_0xccac('0xf')]==='Task'){_0x5df534[_0xccac('0x10')]=moment[_0xccac('0x11')]();_0x5df534[_0xccac('0x12')]=![];_0x5df534['IsRecurrence']=![];if(_0x1277e2[_0xccac('0x13')]===_0xccac('0x14')||_0x1277e2[_0xccac('0x13')]===_0xccac('0x15')){_0x5df534[_0xccac('0x16')]=_0x1277e2['id'];}else if(_0x1277e2['endUserType']==='account'){_0x5df534[_0xccac('0x17')]=_0x1277e2['id'];}}else if(_0x523c2e['ticketType']===_0xccac('0x18')){if(_0x1277e2[_0xccac('0x13')]===_0xccac('0x14')){_0x5df534['ContactId']=_0x1277e2['id'];}else if(_0x1277e2['endUserType']===_0xccac('0x19')){_0x5df534[_0xccac('0x1a')]=_0x1277e2['id'];}else if(_0x1277e2[_0xccac('0x13')]===_0xccac('0x15')&&_0x523c2e[_0xccac('0x1b')]){_0x5df534[_0x523c2e[_0xccac('0x1b')]]=_0x1277e2['id'];}else{logger[_0xccac('0x1c')]('Association\x20between\x20Case\x20and\x20Lead\x20skipped');}}}return _0x33769e[_0xccac('0x1d')](_0x523c2e[_0xccac('0xf')])[_0xccac('0x1e')](_0x5df534);}function getUser(_0x185c22,_0x1a001b,_0x49ceff){if(!_['isNil'](_0x1a001b)&&intUtil[_0xccac('0x1f')](_0x1a001b)){var _0x49f0b7={'Email':_0x1a001b};var _0xd107fc={'Id':!![],'Username':!![],'Name':!![],'Email':!![]};return _0x49ceff[_0xccac('0x1d')](_0xccac('0x20'))[_0xccac('0x21')](_0x49f0b7,_0xd107fc)['execute']()[_0xccac('0x22')](function(_0x5d58e2){if(_0x5d58e2[_0xccac('0x23')]){var _0x9fdf63=_[_0xccac('0x21')](_0x5d58e2,function(_0x24f3c6){return _0x24f3c6['Email']===_0x1a001b;});if(_0x9fdf63){logger[_0xccac('0x1c')](_0xccac('0x24'),_0x1a001b);return BPromise[_0xccac('0x25')]({'id':_0x9fdf63['Id'],'name':_0x9fdf63[_0xccac('0x26')]});}}else{logger[_0xccac('0x1c')](_0xccac('0x27'),_0x1a001b);return _0x49ceff[_0xccac('0x28')]()[_0xccac('0x22')](function(_0x191863){return BPromise['resolve']({'id':_0x191863[_0xccac('0x29')],'name':_0x191863[_0xccac('0x2a')]});});}});}else{logger[_0xccac('0x1c')](_0xccac('0x27'),_0x1a001b);return _0x49ceff[_0xccac('0x28')]()[_0xccac('0x22')](function(_0x35dceb){return BPromise[_0xccac('0x25')]({'id':_0x35dceb[_0xccac('0x29')],'name':_0x35dceb[_0xccac('0x2a')]});});}}function getEndUser(_0x35a44f,_0x3e33bf,_0x3d82b5,_0x41b076,_0x453a30){var _0x1de702={'$or':{'Phone':_0x41b076}};var _0x33fc34={'Id':!![],'Name':!![],'Phone':!![]};return BPromise['resolve']()['then'](function(){logger[_0xccac('0x1c')]('Searching\x20enduser\x20with\x20phone\x20%s.\x20Serching\x20method\x20used\x20%s.',_0x41b076,_0x3e33bf[_0xccac('0x2b')]);switch(_0x3e33bf[_0xccac('0x2b')]){case _0xccac('0x2c'):var _0x5be6be=_['cloneDeep'](_0x1de702);if(_0x3e33bf[_0xccac('0x2d')]){var _0x56429b={};_0x56429b[_0x3e33bf[_0xccac('0x2d')]]=_0x41b076;_[_0xccac('0x2e')](_0x5be6be[_0xccac('0x2f')],_0x56429b);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x30'))[_0xccac('0x21')](_0x5be6be,_0x33fc34)['execute']()[_0xccac('0x22')](function(_0xb00160){if(_0xb00160&&_0xb00160['length']){return _0xb00160;}else{var _0x275ee3=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf['additionalSearchLead']){var _0x1b8ae7={};_0x1b8ae7[_0x3e33bf[_0xccac('0x32')]]=_0x41b076;_[_0xccac('0x2e')](_0x275ee3[_0xccac('0x2f')],_0x1b8ae7);}return _0x453a30['sobject']('Lead')[_0xccac('0x21')](_0x275ee3,_0x33fc34);}});case _0xccac('0x33'):var _0x1fb0c5=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf[_0xccac('0x34')]){var _0x56429b={};_0x56429b[_0x3e33bf[_0xccac('0x34')]]=_0x41b076;_[_0xccac('0x2e')](_0x1fb0c5[_0xccac('0x2f')],_0x56429b);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x35'))[_0xccac('0x21')](_0x1fb0c5,_0x33fc34)[_0xccac('0x36')]()['then'](function(_0x1e23ac){if(_0x1e23ac&&_0x1e23ac[_0xccac('0x23')]){return _0x1e23ac;}else{var _0x4f3083=_['cloneDeep'](_0x1de702);if(_0x3e33bf[_0xccac('0x2d')]){var _0x1d83f6={};_0x1d83f6[_0x3e33bf['additionalSearchContact']]=_0x41b076;_['merge'](_0x4f3083[_0xccac('0x2f')],_0x1d83f6);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x30'))['find'](_0x4f3083,_0x33fc34)[_0xccac('0x22')](function(_0x5f3d98){if(_0x5f3d98&&_0x5f3d98[_0xccac('0x23')]){return _0x5f3d98;}else{var _0x50d706=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf[_0xccac('0x32')]){var _0x1835b3={};_0x1835b3[_0x3e33bf[_0xccac('0x32')]]=_0x41b076;_['merge'](_0x50d706[_0xccac('0x2f')],_0x1835b3);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x37'))['find'](_0x50d706,_0x33fc34);}});}});case _0xccac('0x14'):var _0x5be6be=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf['additionalSearchContact']){var _0x56429b={};_0x56429b[_0x3e33bf['additionalSearchContact']]=_0x41b076;_[_0xccac('0x2e')](_0x5be6be[_0xccac('0x2f')],_0x56429b);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x30'))[_0xccac('0x21')](_0x5be6be,_0x33fc34)['execute']();case _0xccac('0x15'):var _0x54d696=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf[_0xccac('0x32')]){var _0x56429b={};_0x56429b[_0x3e33bf[_0xccac('0x32')]]=_0x41b076;_[_0xccac('0x2e')](_0x54d696[_0xccac('0x2f')],_0x56429b);}return _0x453a30['sobject'](_0xccac('0x37'))[_0xccac('0x21')](_0x54d696,_0x33fc34);case _0xccac('0x19'):var _0x1fb0c5=_[_0xccac('0x31')](_0x1de702);if(_0x3e33bf[_0xccac('0x34')]){var _0x56429b={};_0x56429b[_0x3e33bf[_0xccac('0x34')]]=_0x41b076;_[_0xccac('0x2e')](_0x1fb0c5[_0xccac('0x2f')],_0x56429b);}return _0x453a30[_0xccac('0x1d')](_0xccac('0x35'))[_0xccac('0x21')](_0x1fb0c5,_0x33fc34);default:return null;}})[_0xccac('0x22')](function(_0x1aa42a){if(_0x1aa42a&&_0x1aa42a[_0xccac('0x23')]){var _0x5837fc=_[_0xccac('0x38')](_0x1aa42a);if(_0x5837fc){return BPromise[_0xccac('0x25')]({'id':_0x5837fc['Id'],'name':_0x5837fc['Name'],'phone':_0x5837fc['Phone'],'endUserType':_0x5837fc[_0xccac('0x39')]['type'][_0xccac('0x3a')]()});}}})[_0xccac('0x22')](function(_0x21fe67){if(_0x21fe67){logger[_0xccac('0x1c')](_0xccac('0x3b'),_0x21fe67[_0xccac('0x13')],_0x41b076);return BPromise[_0xccac('0x25')](_0x21fe67);}else{logger[_0xccac('0x1c')](_0xccac('0x3c'),_0x41b076);var _0x3ec419={'Phone':_0x41b076};if(_0x3e33bf[_0xccac('0x3d')]){if(_0x3e33bf[_0xccac('0x3d')]===_0xccac('0x14')){logger[_0xccac('0x1c')]('Enduser\x20with\x20phone\x20%s.\x20Creating\x20method\x20used\x20%s.',_0x41b076,_0x3e33bf[_0xccac('0x3d')]);_0x3ec419[_0xccac('0x3e')]=_0x3d82b5!==_0xccac('0x3f')?_0x3d82b5:util[_0xccac('0x40')](_0xccac('0x41'),_0x41b076);}else if(_0x3e33bf[_0xccac('0x3d')]===_0xccac('0x15')){logger[_0xccac('0x1c')](_0xccac('0x42'),_0x41b076,_0x3e33bf[_0xccac('0x3d')]);_0x3ec419[_0xccac('0x3e')]=_0x3d82b5!==_0xccac('0x3f')?_0x3d82b5:util[_0xccac('0x40')]('Caller\x20-\x20%s',_0x41b076);_0x3ec419[_0xccac('0x43')]=_0xccac('0x44');}else if(_0x3e33bf['moduleCreate']===_0xccac('0x19')){logger['info'](_0xccac('0x42'),_0x41b076,_0x3e33bf['moduleCreate']);_0x3ec419[_0xccac('0x26')]=_0x3d82b5!==_0xccac('0x3f')?_0x3d82b5:util[_0xccac('0x40')]('Caller\x20-\x20%s',_0x41b076);}else{return null;}}return _0x453a30[_0xccac('0x1d')](_[_0xccac('0x45')](_0x3e33bf[_0xccac('0x3d')]))[_0xccac('0x1e')](_0x3ec419)['then'](function(_0x4f1258){return BPromise[_0xccac('0x25')]({'id':_0x4f1258['id'],'endUserType':_0x3e33bf[_0xccac('0x3d')]});});}});}function getCustomFields(_0x74d8ea,_0x3b4be9){var _0x36071b={};if(_0x74d8ea[_0xccac('0x23')]>0x0){_[_0xccac('0x46')](_0x74d8ea,function(_0x504068){if(_[_0xccac('0x47')](['string','picklist'],_0x504068[_0xccac('0x48')])&&_0x504068['idField']){_0x36071b[_0x504068[_0xccac('0x49')]]=_0x504068[_0xccac('0x4a')][_0xccac('0x4b')]();}else if(_0x504068['type']==='variable'&&_0x504068[_0xccac('0x4c')]&&_0x504068[_0xccac('0x49')]){_0x3b4be9[_0x504068[_0xccac('0x4c')]]&&(_0x36071b[_0x504068[_0xccac('0x49')]]=_0x3b4be9[_0x504068[_0xccac('0x4c')]][_0xccac('0x4b')]());}else if(_0x504068['type']===_0xccac('0x4d')&&_0x504068['Variable']&&_0x504068[_0xccac('0x4e')]['name']&&_0x504068[_0xccac('0x49')]){_0x3b4be9[_0x504068['Variable']['name'][_0xccac('0x3a')]()]&&(_0x36071b[_0x504068[_0xccac('0x49')]]=_0x3b4be9[_0x504068['Variable'][_0xccac('0x4f')][_0xccac('0x3a')]()][_0xccac('0x4b')]());}});}return _0x36071b;}function getConnection(_0x204945){var _0x48ae26=_0x204945[_0xccac('0x50')][_0xccac('0x51')](_0x204945['securityToken']);var _0x2d0c2e=new jsforce[(_0xccac('0x52'))]({'oauth2':{'loginUrl':_0x204945[_0xccac('0x53')]||_0xccac('0x54'),'clientId':_0x204945[_0xccac('0x55')],'clientSecret':_0x204945[_0xccac('0x56')]}});return _0x2d0c2e['login'](_0x204945[_0xccac('0x57')],_0x48ae26)[_0xccac('0x22')](function(){logger['info']('Connection\x20established.');return _0x2d0c2e;});}exports[_0xccac('0x58')]=function(_0x34270b,_0x3b4f2c,_0x3ceb32,_0x2999e6,_0x5051e4,_0x2aec09){var _0x2066b3,_0x956f34,_0x5d942e,_0xaf9067;_0x2aec09[_0xccac('0x59')]=intUtil[_0xccac('0x5a')](_0x2aec09[_0xccac('0x59')]);_0x2aec09[_0xccac('0x53')]=intUtil[_0xccac('0x5a')](_0x2aec09[_0xccac('0x53')]);if(_0x5051e4&&_0x5051e4[_0xccac('0x5b')]){logger[_0xccac('0x1c')](_0xccac('0x5c'),_0xccac('0x5d'));_0x3b4f2c[_0xccac('0x5e')]=util[_0xccac('0x40')](_0xccac('0x5f'),_0x2aec09[_0xccac('0x59')],_0x3b4f2c[_0xccac('0x60')],md5(_0x3b4f2c['uniqueid']));}else{_0x3b4f2c[_0xccac('0x5e')]='';}return getConnection(_0x2aec09)[_0xccac('0x22')](function(_0x19e264){_0xaf9067=_0x19e264;return getUser(_0x2aec09,_0x2999e6[_0xccac('0x61')],_0xaf9067);})[_0xccac('0x22')](function(_0x583463){_0x2066b3=_0x583463;return getEndUser(_0x2aec09,_0x3ceb32,_0x3b4f2c[_0xccac('0x62')],_0x3b4f2c['calleridnum'],_0xaf9067);})[_0xccac('0x22')](function(_0x2edc0e){_0x956f34=_0x2edc0e;return getTicket(_0x2aec09,_0x2066b3,_0x956f34,_0x3ceb32,_0x3b4f2c,_0x3ceb32['Fields'],_0xaf9067,'queue');})[_0xccac('0x22')](function(_0x41a15d){_0x5d942e=_0x41a15d;logger[_0xccac('0x1c')](_0xccac('0x63'),_0x5d942e['id']);logger['info'](_0xccac('0x64'),_0x5d942e['id'],_0x2999e6[_0xccac('0x4f')],_0x2aec09['type']);switch(_0x2aec09['type']){case _0xccac('0x65'):emit(util['format'](_0xccac('0x66'),_0x2999e6[_0xccac('0x4f')]),_0xccac('0x67'),{'recordId':_0x5d942e['id']});break;case _0xccac('0x68'):emit(util[_0xccac('0x40')](_0xccac('0x66'),_0x2999e6[_0xccac('0x4f')]),_0xccac('0x69'),{'uri':util[_0xccac('0x40')](_0xccac('0x6a'),_0xaf9067[_0xccac('0x6b')],_0x5d942e['id'])});break;default:logger[_0xccac('0x6c')](_0xccac('0x6d'));}})[_0xccac('0x6e')](function(_0x5096ad){logger[_0xccac('0x6c')]('[QUEUE]',_0x5096ad);});};exports[_0xccac('0x6f')]=function(_0xba5507,_0x23eb41,_0x412b96,_0x32b4cf,_0x396e3b,_0x29ceae,_0x4d2f6b){var _0x9e4ae8,_0x4b36ef,_0xeded8f,_0xe65600;_0x29ceae[_0xccac('0x59')]=intUtil['stripTrailingSlash'](_0x29ceae[_0xccac('0x59')]);_0x29ceae[_0xccac('0x53')]=intUtil[_0xccac('0x5a')](_0x29ceae[_0xccac('0x53')]);if(_0x4d2f6b&&_0x4d2f6b[_0xccac('0x70')]&&_0x4d2f6b[_0xccac('0x70')]!=='none'){logger[_0xccac('0x1c')](_0xccac('0x71'),_0xccac('0x5d'));_0x23eb41[_0xccac('0x5e')]=util[_0xccac('0x40')](_0xccac('0x5f'),_0x29ceae[_0xccac('0x59')],_0x23eb41[_0xccac('0x60')],md5(_0x23eb41['uniqueid']));}return getConnection(_0x29ceae)[_0xccac('0x22')](function(_0x39ce38){_0xe65600=_0x39ce38;return getUser(_0x29ceae,_0x32b4cf[_0xccac('0x61')],_0xe65600);})['then'](function(_0x24b073){_0x9e4ae8=_0x24b073;return getEndUser(_0x29ceae,_0x412b96,_0x23eb41[_0xccac('0x72')],_0x23eb41['destcalleridnum'],_0xe65600);})[_0xccac('0x22')](function(_0x147e96){_0x4b36ef=_0x147e96;return getTicket(_0x29ceae,_0x9e4ae8,_0x4b36ef,_0x412b96,_0x23eb41,_0x412b96[_0xccac('0x73')],_0xe65600,_0xccac('0x6f'));})['then'](function(_0x1c4bd8){_0xeded8f=_0x1c4bd8;logger[_0xccac('0x1c')]('[OUTBOUND]\x20Ticket\x20%s\x20created.',_0xeded8f['id']);logger['info'](_0xccac('0x74'),_0xeded8f['id'],_0x32b4cf[_0xccac('0x4f')],_0x29ceae[_0xccac('0x48')]);switch(_0x29ceae['type']){case _0xccac('0x65'):emit(util['format']('user:%s',_0x32b4cf[_0xccac('0x4f')]),_0xccac('0x67'),{'recordId':_0xeded8f['id']});break;case _0xccac('0x68'):emit(util[_0xccac('0x40')]('user:%s',_0x32b4cf[_0xccac('0x4f')]),_0xccac('0x69'),{'uri':util['format']('%s/%s/e',_0xe65600[_0xccac('0x6b')],_0xeded8f['id'])});break;default:logger['error']('[OUTBOUND]','Salesforce\x20account\x20type\x20not\x20recognized');}})[_0xccac('0x6e')](function(_0x1b2519){logger[_0xccac('0x6c')](_0xccac('0x71'),_0x1b2519);});};exports[_0xccac('0x75')]=function(_0x4c0726,_0x3a67fd,_0x4dad8f,_0x36375b,_0x4efd30,_0x46e341){var _0x4508ef,_0x263b02,_0x435862,_0x4fe970;_0x46e341[_0xccac('0x59')]=intUtil[_0xccac('0x5a')](_0x46e341[_0xccac('0x59')]);_0x46e341[_0xccac('0x53')]=intUtil[_0xccac('0x5a')](_0x46e341[_0xccac('0x53')]);if(_0x4efd30&&_0x4efd30[_0xccac('0x5b')]){logger[_0xccac('0x1c')]('['+_0x3a67fd[_0xccac('0x76')][_0xccac('0x77')]()+']',_0xccac('0x5d'));_0x3a67fd['recordingURL']=util[_0xccac('0x40')](_0xccac('0x5f'),_0x46e341['serverUrl'],_0x3a67fd['uniqueid'],md5(_0x3a67fd['uniqueid']));}else{_0x3a67fd['recordingURL']='';}return getConnection(_0x46e341)[_0xccac('0x22')](function(_0x5b7387){_0x4fe970=_0x5b7387;if(!_['isNil'](_0x36375b)){return getUser(_0x46e341,_0x36375b[_0xccac('0x4f')],_0x4fe970);}else{return getUser(_0x46e341,null,_0x4fe970);}})[_0xccac('0x22')](function(_0x3deea6){_0x4508ef=_0x3deea6;return getEndUser(_0x46e341,_0x4dad8f,_0x3a67fd['calleridname'],_0x3a67fd['calleridnum'],_0x4fe970);})[_0xccac('0x22')](function(_0xded84c){_0x263b02=_0xded84c;return getTicket(_0x46e341,_0x4508ef,_0x263b02,_0x4dad8f,_0x3a67fd,_0x4dad8f[_0xccac('0x73')],_0x4fe970);})['then'](function(_0x4b45d0){_0x435862=_0x4b45d0;logger[_0xccac('0x1c')]('['+_0x3a67fd[_0xccac('0x76')][_0xccac('0x77')]()+_0xccac('0x78'),_0x435862['id']);logger[_0xccac('0x1c')]('['+_0x3a67fd[_0xccac('0x76')][_0xccac('0x77')]()+_0xccac('0x79'),_0x46e341[_0xccac('0x48')]);})['catch'](function(_0x13e276){logger[_0xccac('0x6c')]('['+_0x3a67fd[_0xccac('0x76')]['toUpperCase']()+']',_0x13e276);});};