454bf2b9f3412c0cfc6829f57f6ad0ad773909be
[motion2.git] / server / services / ami / server / index.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 _0x4522=['trunks','outboundChannels','campaigns','run','emit','custom:','event','faxAccounts','checkAfterSend','server','127.0.0.1','log','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','jayson/promise','validate','moment','../properties','../ami','listen','format','%s/%s','SIP','name','timers','updateAcw','agents','updateStatusRealtime','pause','QueuePause','error','asterisk','ami\x20disconnected','join','keys','action','Reload','Action','then','message','catch','isConnected','username','Command','content','voiceQueues','hasOwnProperty','strategy','answered','available','pTalking','sumBillable','talking','total','type','unmanaged','abandoned','waiting','outbound','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','callerid','Interval','find','omit','undefined','values','channels','length','voicechannel','uniqueid','channel','%s.%s','filename','ai(mixmonitorid)','monitors','/var/spool/asterisk/monitor/','toLowerCase','YYYY-MM-DD\x20HH:mm:ss','rec','mixmonitorid','status','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','map','resolve','StopMixMonitor','destinationchannel','stop','queueChannels','voicequeuechannelhangup','Hangup','Redirect','exten','context','telephones'];(function(_0x5a056e,_0x382a98){var _0x5e1dab=function(_0x1059a4){while(--_0x1059a4){_0x5a056e['push'](_0x5a056e['shift']());}};_0x5e1dab(++_0x382a98);}(_0x4522,0x1a0));var _0x2452=function(_0x357f46,_0x1a087c){_0x357f46=_0x357f46-0x0;var _0x3d6648=_0x4522[_0x357f46];return _0x3d6648;};'use strict';var _=require('lodash');var util=require('util');var jayson=require(_0x2452('0x0'));var schema=require(_0x2452('0x1'));var moment=require(_0x2452('0x2'));var config=require('../../../config/environment');var properties=require(_0x2452('0x3'));var ami=require(_0x2452('0x4'));exports[_0x2452('0x5')]=function(_0x2f21dc,_0x34ff44,_0x243893){return new Promise(function(_0x15fc69,_0x226578){var _0x2f0139={'QueuePause':function(_0x149807){return new Promise(function(_0x3bc193){var _0x33b935=util[_0x2452('0x6')](_0x2452('0x7'),_0x2452('0x8'),_0x149807[_0x2452('0x9')]);if(_0x2f21dc['timers']&&_0x2f21dc['timers'][_0x33b935]&&_0x2f21dc[_0x2452('0xa')][_0x33b935]['timer']){_0x2f21dc['timers'][_0x33b935][_0x2452('0xb')]();}if(_0x2f21dc[_0x2452('0xc')][_0x33b935]){_0x2f21dc[_0x2452('0xc')][_0x33b935][_0x2452('0xd')]({'statePause':_0x149807[_0x2452('0xe')]?!![]:![]});}_0x3bc193({'code':0xc8,'message':_0x2452('0xf')});});},'Reload':function(_0x2c1e0f){var _0x2377b9=this;return new Promise(function(_0x4968e8,_0x529fb2){if(ami['isConnected']()==![]){return _0x529fb2(_0x2377b9[_0x2452('0x10')](0x1f4,[config['asterisk']['ip'],config[_0x2452('0x11')]['username'],_0x2452('0x12')][_0x2452('0x13')]('\x20')));}_0x2c1e0f=_['pick'](_0x2c1e0f,_[_0x2452('0x14')](properties['module']));_0x2c1e0f[_0x2452('0x15')]=_0x2452('0x16');return ami[_0x2452('0x17')](_0x2c1e0f)[_0x2452('0x18')](function(_0x4e1d20){_0x4968e8({'code':0xc8,'message':_0x4e1d20[_0x2452('0x19')]});})[_0x2452('0x1a')](function(_0x59d89a){_0x529fb2(_0x2377b9['error'](0x1f5,_0x59d89a[_0x2452('0x19')]));});});},'Command':function(_0x37c6a6){var _0x377c12=this;return new Promise(function(_0x57cb03,_0x914d2b){if(ami[_0x2452('0x1b')]()==![]){return _0x914d2b(_0x377c12[_0x2452('0x10')](0x1f4,[config[_0x2452('0x11')]['ip'],config[_0x2452('0x11')][_0x2452('0x1c')],_0x2452('0x12')][_0x2452('0x13')]('\x20')));}_0x37c6a6=_['pick'](_0x37c6a6,'command');_0x37c6a6[_0x2452('0x15')]=_0x2452('0x1d');return ami['Action'](_0x37c6a6)[_0x2452('0x18')](function(_0x395cf1){_0x57cb03({'code':0xc8,'message':_0x395cf1[_0x2452('0x1e')]});})[_0x2452('0x1a')](function(_0x285281){_0x914d2b(_0x377c12[_0x2452('0x10')](0x1f5,_0x285281[_0x2452('0x19')]));});});},'VoiceQueues':function(){return new Promise(function(_0x543b06){var _0x119bf6=[];for(var _0x27d049 in _0x2f21dc[_0x2452('0x1f')]){if(_0x2f21dc[_0x2452('0x1f')][_0x2452('0x20')](_0x27d049)){var _0x516fcf=_0x2f21dc['voiceQueues'][_0x27d049];var _0x295be0={'id':_0x516fcf['id'],'name':_0x516fcf[_0x2452('0x9')],'strategy':_0x516fcf[_0x2452('0x21')],'answered':_0x516fcf[_0x2452('0x22')],'available':_0x516fcf[_0x2452('0x23')],'loggedIn':_0x516fcf['loggedIn'],'pTalking':_0x516fcf[_0x2452('0x24')],'sumBillable':_0x516fcf[_0x2452('0x25')],'sumDuration':_0x516fcf['sumDuration'],'sumHoldTime':_0x516fcf['sumHoldTime']||0x0,'talking':_0x516fcf[_0x2452('0x26')],'total':_0x516fcf[_0x2452('0x27')],'type':_0x516fcf[_0x2452('0x28')],'unmanaged':_0x516fcf[_0x2452('0x29')],'abandoned':_0x516fcf[_0x2452('0x2a')],'waiting':_0x516fcf[_0x2452('0x2b')],'loggedInDb':_0x516fcf['loggedInDb']};if(_0x516fcf['type']===_0x2452('0x2c')){_0x295be0[_0x2452('0x2d')]=_0x516fcf[_0x2452('0x2d')];_0x295be0['dialMethod']=_0x516fcf[_0x2452('0x2e')];_0x295be0[_0x2452('0x2f')]=_0x516fcf['dialOriginateCallerIdName'];_0x295be0[_0x2452('0x30')]=_0x516fcf[_0x2452('0x30')];_0x295be0[_0x2452('0x31')]=_0x516fcf[_0x2452('0x31')];_0x295be0[_0x2452('0x32')]=_0x516fcf[_0x2452('0x32')];_0x295be0[_0x2452('0x33')]=_0x516fcf[_0x2452('0x33')];_0x295be0[_0x2452('0x34')]=_0x516fcf[_0x2452('0x34')];_0x295be0[_0x2452('0x35')]=_0x516fcf[_0x2452('0x35')];_0x295be0[_0x2452('0x36')]=_0x516fcf['outboundBlacklistCallsDay'];_0x295be0[_0x2452('0x37')]=_0x516fcf[_0x2452('0x37')];_0x295be0['outboundCongestionCallsDay']=_0x516fcf[_0x2452('0x38')];_0x295be0['outboundDropCallsDayACS']=_0x516fcf[_0x2452('0x39')];_0x295be0[_0x2452('0x3a')]=_0x516fcf['outboundDropCallsDayCallersExit'];_0x295be0[_0x2452('0x3b')]=_0x516fcf[_0x2452('0x3b')];_0x295be0[_0x2452('0x3c')]=_0x516fcf['outboundNoAnswerCallsDay'];_0x295be0[_0x2452('0x3d')]=_0x516fcf[_0x2452('0x3d')];_0x295be0['outboundOriginateFailureCallsDay']=_0x516fcf[_0x2452('0x3e')];_0x295be0[_0x2452('0x3f')]=_0x516fcf[_0x2452('0x3f')];_0x295be0[_0x2452('0x40')]=_0x516fcf[_0x2452('0x40')];_0x295be0['outboundUnknownCallsDay']=_0x516fcf['outboundUnknownCallsDay'];_0x295be0['predictiveIntervalAnsweredCalls']=_0x516fcf[_0x2452('0x41')];_0x295be0[_0x2452('0x42')]=_0x516fcf[_0x2452('0x42')];_0x295be0[_0x2452('0x43')]=_0x516fcf[_0x2452('0x43')];_0x295be0['predictiveIntervalDroppedCallsCallersExit']=_0x516fcf[_0x2452('0x44')];_0x295be0['predictiveIntervalDroppedCallsTimeout']=_0x516fcf['predictiveIntervalDroppedCallsTimeout'];_0x295be0[_0x2452('0x45')]=_0x516fcf['predictiveIntervalErlangCalls'];_0x295be0[_0x2452('0x46')]=_0x516fcf[_0x2452('0x46')];_0x295be0['predictiveIntervalHitRate']=_0x516fcf[_0x2452('0x47')];_0x295be0[_0x2452('0x48')]=_0x516fcf[_0x2452('0x48')];_0x295be0[_0x2452('0x49')]=_0x516fcf[_0x2452('0x49')];_0x295be0[_0x2452('0x4a')]=_0x516fcf[_0x2452('0x4a')];_0x295be0[_0x2452('0x4b')]=_0x516fcf['predictiveIntervalTotalCalls'];_0x295be0[_0x2452('0x19')]=_0x516fcf['message'];_0x295be0[_0x2452('0x4c')]=_0x516fcf[_0x2452('0x4c')];_0x295be0['erlangCalls']=_0x516fcf[_0x2452('0x4d')];_0x295be0[_0x2452('0x4e')]=_0x516fcf[_0x2452('0x4e')];_0x295be0[_0x2452('0x4f')]=_0x516fcf[_0x2452('0x4f')];_0x295be0['erlangBusyFactor']=_0x516fcf[_0x2452('0x50')];_0x295be0[_0x2452('0x51')]=_0x516fcf['startPredictive'];_0x295be0[_0x2452('0x52')]=_0x516fcf[_0x2452('0x52')];}if(_0x516fcf[_0x2452('0x53')]){_0x295be0[_0x2452('0x53')]={'id':_0x516fcf['Trunk']['id'],'name':_0x516fcf[_0x2452('0x53')][_0x2452('0x9')],'active':_0x516fcf[_0x2452('0x53')][_0x2452('0x54')],'callerid':_0x516fcf[_0x2452('0x53')][_0x2452('0x55')]};}if(_0x516fcf['Interval']){_0x295be0[_0x2452('0x56')]={'id':_0x516fcf['Interval']['id'],'name':_0x516fcf[_0x2452('0x56')][_0x2452('0x9')]};}_0x119bf6['push'](_0x295be0);}}_0x543b06({'count':_0x119bf6['length'],'rows':_0x119bf6});});},'UpdateVoiceQueue':function(_0x50f700){return new Promise(function(_0x5014b8,_0xd62892){var _0x4ec49f=_[_0x2452('0x57')](_0x2f21dc['voiceQueues'],{'id':parseInt(_0x50f700['id'])});var _0x1ef02b=_[_0x2452('0x58')](_0x50f700,['id']);if(_0x4ec49f){for(var _0x55de3d in _0x1ef02b){if(typeof _0x1ef02b[_0x55de3d]!=='undefined'&&typeof _0x4ec49f[_0x55de3d]!==_0x2452('0x59')){_0x4ec49f[_0x55de3d]=_0x1ef02b[_0x55de3d];}}_0x5014b8(_0x4ec49f);}else{_0xd62892();}});},'VoiceChannels':function(){return new Promise(function(_0x4d9437){var _0x596b65=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x5b')]);_0x4d9437({'count':_0x596b65[_0x2452('0x5c')],'rows':_0x596b65});});},'VoiceChannelMixMonitor':function(_0x57f815){var _0x491089=this;return new Promise(function(_0x3e4a8b,_0x38615e){if(ami[_0x2452('0x1b')]()==![]){return _0x38615e(_0x491089[_0x2452('0x10')](0x1f4,[config[_0x2452('0x11')]['ip'],config['asterisk'][_0x2452('0x1c')],'ami\x20disconnected'][_0x2452('0x13')]('\x20')));}var _0x53fd05=schema(properties[_0x2452('0x5d')])[_0x2452('0x1')](_0x57f815);if(_0x53fd05['length']>0x0){return _0x38615e(_0x491089[_0x2452('0x10')](0x1f4,_['map'](_0x53fd05,_0x2452('0x19'))['join'](',\x20')));}var _0x4fc8d4=_['find'](_0x2f21dc[_0x2452('0x5b')],{'uniqueid':_0x57f815[_0x2452('0x5e')]});if(_0x4fc8d4&&_0x4fc8d4[_0x2452('0x5f')]){var _0x4b705f=util[_0x2452('0x6')](_0x2452('0x60'),_0x57f815[_0x2452('0x61')]||_0x57f815[_0x2452('0x5e')],_0x57f815[_0x2452('0x6')]||'wav');return ami[_0x2452('0x17')]({'action':'MixMonitor','channel':_0x4fc8d4[_0x2452('0x5f')],'file':_0x4b705f,'options':_0x2452('0x62')})[_0x2452('0x18')](function(_0x51eb53){var _0x6ee99d=_[_0x2452('0x57')](_0x4fc8d4[_0x2452('0x63')],{'filename':_0x2452('0x64')+_0x4b705f[_0x2452('0x65')]()});if(_['isNil'](_0x6ee99d)){_0x4fc8d4[_0x2452('0x63')]['push']({'filename':_0x2452('0x64')+_0x4b705f['toLowerCase'](),'createdAt':moment()[_0x2452('0x6')](_0x2452('0x66')),'mixmonitorid':_0x51eb53['mixmonitorid'],'status':_0x2452('0x67')});}else{_0x6ee99d[_0x2452('0x68')]=_0x51eb53[_0x2452('0x68')];_0x6ee99d[_0x2452('0x69')]=_0x2452('0x67');}_0x3e4a8b({'code':0xc8,'message':[_0x57f815[_0x2452('0x5e')],_0x2452('0x6a'),_0x51eb53[_0x2452('0x68')]][_0x2452('0x13')]('\x20'),'mixmonitorid':_0x51eb53[_0x2452('0x68')]});})[_0x2452('0x1a')](function(_0x4c203f){_0x38615e(_0x491089[_0x2452('0x10')](0x1f5,[_0x57f815['uniqueid'],_0x4c203f[_0x2452('0x19')]['toLowerCase']()][_0x2452('0x13')]('\x20')));});}else{return _0x38615e(_0x491089[_0x2452('0x10')](0x1f5,_0x2452('0x6b')));}});},'VoiceChannelStopMixMonitor':function(_0x1cc61){var _0x321092=this;return new Promise(function(_0x3b3a5a,_0x2c2bce){if(ami[_0x2452('0x1b')]()==![]){return _0x2c2bce(_0x321092[_0x2452('0x10')](0x1f4,[config[_0x2452('0x11')]['ip'],config[_0x2452('0x11')]['username'],_0x2452('0x12')][_0x2452('0x13')]('\x20')));}var _0x37ed11=schema(properties[_0x2452('0x5d')])[_0x2452('0x1')](_0x1cc61);if(_0x37ed11[_0x2452('0x5c')]>0x0){return _0x2c2bce(_0x321092['error'](0x1f4,_[_0x2452('0x6c')](_0x37ed11,_0x2452('0x19'))['join'](',\x20')));}var _0x2c8480=_[_0x2452('0x57')](_0x2f21dc[_0x2452('0x5b')],{'uniqueid':_0x1cc61[_0x2452('0x5e')]});if(_0x2c8480){return Promise[_0x2452('0x6d')]()[_0x2452('0x18')](function(){if(_0x2c8480[_0x2452('0x5f')]){return ami[_0x2452('0x17')]({'action':_0x2452('0x6e'),'channel':_0x2c8480[_0x2452('0x5f')],'mixmonitorid':_0x1cc61[_0x2452('0x68')]})['catch'](function(){});}})['then'](function(){if(_0x2c8480[_0x2452('0x6f')]){return ami['Action']({'action':_0x2452('0x6e'),'channel':_0x2c8480[_0x2452('0x6f')],'mixmonitorid':_0x1cc61[_0x2452('0x68')]})[_0x2452('0x1a')](function(){});}})[_0x2452('0x18')](function(){var _0x3181e0=_['find'](_0x2c8480['monitors'],{'mixmonitorid':_0x1cc61[_0x2452('0x68')]});if(_0x3181e0){_0x3181e0['status']=_0x2452('0x70');}})['then'](function(){var _0x224cc0=util[_0x2452('0x6')](_0x2452('0x60'),_0x1cc61[_0x2452('0x61')]||_0x1cc61['uniqueid'],_0x1cc61['format']||'wav');var _0x9ef864=_[_0x2452('0x57')](_0x2c8480['monitors'],{'filename':'/var/spool/asterisk/monitor/'+_0x224cc0['toLowerCase']()});if(_0x9ef864){_0x9ef864['status']='stop';}})[_0x2452('0x18')](function(){_0x3b3a5a({'code':0xc8,'message':[_0x1cc61['uniqueid'],'StopMixMonitor\x20Success'][_0x2452('0x13')]('\x20')});})[_0x2452('0x1a')](function(_0x3ce2e0){_0x2c2bce(_0x321092[_0x2452('0x10')](0x1f5,[_0x1cc61[_0x2452('0x5e')],_0x3ce2e0[_0x2452('0x19')]['toLowerCase']()][_0x2452('0x13')]('\x20')));});}else{return _0x2c2bce(_0x321092[_0x2452('0x10')](0x1f5,_0x2452('0x6b')));}});},'VoiceQueuesChannels':function(){return new Promise(function(_0x565817){var _0x490b25=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x71')]);_0x565817({'count':_0x490b25[_0x2452('0x5c')],'rows':_0x490b25});});},'VoiceQueuesChannel':function(_0x1dec54){var _0x401628=this;return new Promise(function(_0x336fc6,_0x4dd13d){var _0x2b2033=schema(properties['voicequeuechannel'])[_0x2452('0x1')](_0x1dec54);if(_0x2b2033[_0x2452('0x5c')]>0x0){return _0x4dd13d(_0x401628[_0x2452('0x10')](0x1f4,_[_0x2452('0x6c')](_0x2b2033,'message')[_0x2452('0x13')](',\x20')));}var _0x132cd3=_['find'](_0x2f21dc[_0x2452('0x71')],{'uniqueid':_0x1dec54[_0x2452('0x5e')]});if(_0x132cd3){_0x336fc6(_0x132cd3);}else{return _0x4dd13d(_0x401628[_0x2452('0x10')](0x1f5,_0x2452('0x6b')));}});},'VoiceQueuesChannelHangup':function(_0x19cf40){var _0x23cf93=this;return new Promise(function(_0x3e5269,_0xb53074){if(ami['isConnected']()==![]){return _0xb53074(_0x23cf93['error'](0x1f4,[config[_0x2452('0x11')]['ip'],config[_0x2452('0x11')][_0x2452('0x1c')],_0x2452('0x12')]['join']('\x20')));}var _0x19d376=schema(properties[_0x2452('0x72')])[_0x2452('0x1')](_0x19cf40);if(_0x19d376[_0x2452('0x5c')]>0x0){return _0xb53074(_0x23cf93['error'](0x1f4,_[_0x2452('0x6c')](_0x19d376,_0x2452('0x19'))[_0x2452('0x13')](',\x20')));}var _0x411c0b=_['find'](_0x2f21dc['queueChannels'],{'uniqueid':_0x19cf40[_0x2452('0x5e')]});if(_0x411c0b&&_0x411c0b[_0x2452('0x5f')]){return ami['Action']({'action':_0x2452('0x73'),'channel':_0x411c0b[_0x2452('0x5f')]})[_0x2452('0x18')](function(_0x19b52b){_0x3e5269({'code':0xc8,'message':[_0x19cf40[_0x2452('0x5e')],_0x19b52b[_0x2452('0x19')][_0x2452('0x65')]()][_0x2452('0x13')]('\x20')});})[_0x2452('0x1a')](function(_0x378224){_0xb53074(_0x23cf93[_0x2452('0x10')](0x1f5,[_0x19cf40[_0x2452('0x5e')],_0x378224[_0x2452('0x19')][_0x2452('0x65')]()][_0x2452('0x13')]('\x20')));});}else{return _0xb53074(_0x23cf93[_0x2452('0x10')](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannelRedirect':function(_0x16ca73){var _0x40ca65=this;return new Promise(function(_0x2d4f2f,_0x4e8688){if(ami['isConnected']()==![]){return _0x4e8688(_0x40ca65['error'](0x1f4,[config[_0x2452('0x11')]['ip'],config[_0x2452('0x11')][_0x2452('0x1c')],_0x2452('0x12')]['join']('\x20')));}var _0x5b5719=schema(properties['voicequeuechannelredirect'])[_0x2452('0x1')](_0x16ca73);if(_0x5b5719['length']>0x0){return _0x4e8688(_0x40ca65[_0x2452('0x10')](0x1f4,_['map'](_0x5b5719,_0x2452('0x19'))['join'](',\x20')));}var _0xc14791=_['find'](_0x2f21dc[_0x2452('0x71')],{'uniqueid':_0x16ca73[_0x2452('0x5e')]});if(_0xc14791&&_0xc14791[_0x2452('0x5f')]){return ami[_0x2452('0x17')]({'action':_0x2452('0x74'),'channel':_0xc14791['channel'],'exten':_0x16ca73[_0x2452('0x75')],'context':_0x16ca73[_0x2452('0x76')]||_0xc14791[_0x2452('0x76')],'priority':0x1})[_0x2452('0x18')](function(_0x285407){_0x2d4f2f({'code':0xc8,'message':[_0x16ca73[_0x2452('0x5e')],_0x285407[_0x2452('0x19')][_0x2452('0x65')]()][_0x2452('0x13')]('\x20')});})[_0x2452('0x1a')](function(_0x3f1126){_0x4e8688(_0x40ca65['error'](0x1f5,[_0x16ca73[_0x2452('0x5e')],_0x3f1126['message'][_0x2452('0x65')]()]['join']('\x20')));});}else{return _0x4e8688(_0x40ca65['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'Agents':function(_0x59119f){return new Promise(function(_0x5f5c4f){var _0x4f485c=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0xc')]);if(_0x59119f&&_0x59119f['id']){var _0x2cdeca=_['find'](_0x4f485c,function(_0x4ef9ed){return _0x4ef9ed['id']===_0x59119f['id'];});_0x5f5c4f(_0x2cdeca);}else{_0x5f5c4f({'count':_0x4f485c['length'],'rows':_0x4f485c});}});},'Telephones':function(){return new Promise(function(_0x352a66){var _0x2167dc=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x77')]);_0x352a66({'count':_0x2167dc[_0x2452('0x5c')],'rows':_0x2167dc});});},'Trunks':function(){return new Promise(function(_0x5cbc70){var _0x3454e3=_['values'](_0x2f21dc[_0x2452('0x78')]);_0x5cbc70({'count':_0x3454e3[_0x2452('0x5c')],'rows':_0x3454e3});});},'OutboundChannels':function(){return new Promise(function(_0x5090f8){var _0x3c1519=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x79')]);_0x5090f8({'count':_0x3c1519[_0x2452('0x5c')],'rows':_0x3c1519});});},'Outbound':function(){return new Promise(function(_0x4fc46f){_0x4fc46f(_0x2f21dc[_0x2452('0x2c')]);});},'Campaigns':function(){return new Promise(function(_0x5a25cb){var _0x102a82=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x7a')]);_0x5a25cb({'count':_0x102a82[_0x2452('0x5c')],'rows':_0x102a82});});},'VoiceQueuesPreview':function(_0x1aacaa){var _0x558eb8=this;return new Promise(function(_0x19465d,_0x20ae3c){_0x34ff44[_0x2452('0x7b')](_0x1aacaa['id'])[_0x2452('0x18')](function(_0x52fc60){_0x19465d({'code':0xc8,'message':_0x52fc60[_0x2452('0x19')]});})[_0x2452('0x1a')](function(_0xdeeeff){_0x20ae3c(_0x558eb8[_0x2452('0x10')](0x1f4,_0xdeeeff[_0x2452('0x19')]));});});},'EventManager':function(_0xcdd3dc){var _0x2dae0b=this;return new Promise(function(_0x4e7078,_0x1c6afe){if(!_0xcdd3dc['event']){return _0x1c6afe(_0x2dae0b['error'](0x1f4,'Event\x20name\x20mandatory'));}ami[_0x2452('0x7c')](_0x2452('0x7d')+_0xcdd3dc[_0x2452('0x7e')],_0xcdd3dc[_0x2452('0x19')]);_0x4e7078({'code':0xc8,'message':_0xcdd3dc});});},'FaxAccounts':function(){return new Promise(function(_0x276eed){var _0x38524b=_[_0x2452('0x5a')](_0x2f21dc[_0x2452('0x7f')]);_0x276eed({'count':_0x38524b[_0x2452('0x5c')],'rows':_0x38524b});});},'SendFax':function(_0x4d182d){var _0x4c85ef=this;return new Promise(function(_0x57aa9e,_0x28c8a8){_0x243893['send'](_0x4d182d)['then'](function(_0xec2569){_0x57aa9e({'code':0xc8,'message':_0xec2569[_0x2452('0x19')]});})[_0x2452('0x1a')](function(_0xbcee27){_0x28c8a8(_0x4c85ef[_0x2452('0x10')](0x1f4,_0xbcee27['message']));});});},'CheckAfterSend':function(_0x416cae){var _0x4145a5=this;return new Promise(function(_0x1c7232,_0x2c4829){_0x243893[_0x2452('0x80')](_0x416cae)['then'](function(_0x205bef){_0x1c7232({'code':0xc8,'message':_0x205bef['message']});})[_0x2452('0x1a')](function(_0x51b6ef){_0x2c4829(_0x4145a5[_0x2452('0x10')](0x1f4,_0x51b6ef[_0x2452('0x19')]));});});}};var _0x267f50=jayson[_0x2452('0x81')](_0x2f0139)['http']();_0x267f50['on']('error',function(_0x50e44a){return _0x226578(_0x50e44a);});_0x267f50[_0x2452('0x5')](0x232a,_0x2452('0x82'),function(){console[_0x2452('0x83')](_0x2452('0x84'),0x232a);return _0x15fc69(_0x2452('0x85')+0x232a);});});};