Built motion from commit da617fac.|2.6.6
[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 _0x4058=['queueChannels','Redirect','exten','context','trunks','outboundChannels','campaigns','run','event','custom:','faxAccounts','send','checkAfterSend','server','127.0.0.1','AMI\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','RPC\x20listening\x20on\x20port:','lodash','util','jayson/promise','validate','moment','../../../config/environment','../properties','../ami','listen','format','%s/%s','SIP','timers','timer','updateAcw','agents','asterisk','ami\x20disconnected','join','pick','keys','action','Reload','Action','then','message','catch','error','isConnected','username','command','Command','content','voiceQueues','hasOwnProperty','name','strategy','answered','available','loggedIn','pTalking','sumDuration','total','type','unmanaged','abandoned','waiting','loggedInDb','outbound','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','temp','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','Interval','push','length','omit','undefined','values','channels','voicechannel','map','uniqueid','channel','%s.%s','filename','ai(mixmonitorid)','find','/var/spool/asterisk/monitor/','toLowerCase','isNil','monitors','YYYY-MM-DD\x20HH:mm:ss','rec','mixmonitorid','status','MixMonitor\x20Success','Channel\x20doesn\x27t\x20exist','resolve','StopMixMonitor','destinationchannel','wav','voicequeuechannel','voicequeuechannelhangup','Hangup','voicequeuechannelredirect'];(function(_0x3f3b97,_0x395d93){var _0xb6ab0c=function(_0x330c5a){while(--_0x330c5a){_0x3f3b97['push'](_0x3f3b97['shift']());}};_0xb6ab0c(++_0x395d93);}(_0x4058,0x129));var _0x8405=function(_0xa3b3ac,_0x355966){_0xa3b3ac=_0xa3b3ac-0x0;var _0x4bc57c=_0x4058[_0xa3b3ac];return _0x4bc57c;};'use strict';var _=require(_0x8405('0x0'));var util=require(_0x8405('0x1'));var jayson=require(_0x8405('0x2'));var schema=require(_0x8405('0x3'));var moment=require(_0x8405('0x4'));var config=require(_0x8405('0x5'));var properties=require(_0x8405('0x6'));var ami=require(_0x8405('0x7'));exports[_0x8405('0x8')]=function(_0x4948b2,_0x5ebf0e,_0x57fb07){return new Promise(function(_0x1db7ea,_0x257d43){var _0x3d9bf6={'QueuePause':function(_0x1322e5){return new Promise(function(_0x1cb061){var _0x479c97=util[_0x8405('0x9')](_0x8405('0xa'),_0x8405('0xb'),_0x1322e5['name']);if(_0x4948b2[_0x8405('0xc')]&&_0x4948b2['timers'][_0x479c97]&&_0x4948b2[_0x8405('0xc')][_0x479c97][_0x8405('0xd')]){_0x4948b2['timers'][_0x479c97][_0x8405('0xe')]();}if(_0x4948b2[_0x8405('0xf')][_0x479c97]){_0x4948b2['agents'][_0x479c97]['updateStatusRealtime']({'statePause':_0x1322e5['pause']?!![]:![]});}_0x1cb061({'code':0xc8,'message':'QueuePause'});});},'Reload':function(_0x262d32){var _0x575fcb=this;return new Promise(function(_0x495190,_0x4e6477){if(ami['isConnected']()==![]){return _0x4e6477(_0x575fcb['error'](0x1f4,[config[_0x8405('0x10')]['ip'],config[_0x8405('0x10')]['username'],_0x8405('0x11')][_0x8405('0x12')]('\x20')));}_0x262d32=_[_0x8405('0x13')](_0x262d32,_[_0x8405('0x14')](properties['module']));_0x262d32[_0x8405('0x15')]=_0x8405('0x16');return ami[_0x8405('0x17')](_0x262d32)[_0x8405('0x18')](function(_0x135190){_0x495190({'code':0xc8,'message':_0x135190[_0x8405('0x19')]});})[_0x8405('0x1a')](function(_0x358633){_0x4e6477(_0x575fcb[_0x8405('0x1b')](0x1f5,_0x358633[_0x8405('0x19')]));});});},'Command':function(_0x34c79c){var _0x21376d=this;return new Promise(function(_0x131857,_0x241000){if(ami[_0x8405('0x1c')]()==![]){return _0x241000(_0x21376d[_0x8405('0x1b')](0x1f4,[config[_0x8405('0x10')]['ip'],config[_0x8405('0x10')][_0x8405('0x1d')],_0x8405('0x11')][_0x8405('0x12')]('\x20')));}_0x34c79c=_[_0x8405('0x13')](_0x34c79c,_0x8405('0x1e'));_0x34c79c[_0x8405('0x15')]=_0x8405('0x1f');return ami[_0x8405('0x17')](_0x34c79c)['then'](function(_0x4b0786){_0x131857({'code':0xc8,'message':_0x4b0786[_0x8405('0x20')]});})[_0x8405('0x1a')](function(_0x14436a){_0x241000(_0x21376d['error'](0x1f5,_0x14436a[_0x8405('0x19')]));});});},'VoiceQueues':function(){return new Promise(function(_0x5d51a9){var _0x48c5ea=[];for(var _0x480ad2 in _0x4948b2[_0x8405('0x21')]){if(_0x4948b2[_0x8405('0x21')][_0x8405('0x22')](_0x480ad2)){var _0x4450eb=_0x4948b2[_0x8405('0x21')][_0x480ad2];var _0x3e5b4c={'id':_0x4450eb['id'],'name':_0x4450eb[_0x8405('0x23')],'strategy':_0x4450eb[_0x8405('0x24')],'answered':_0x4450eb[_0x8405('0x25')],'available':_0x4450eb[_0x8405('0x26')],'loggedIn':_0x4450eb[_0x8405('0x27')],'pTalking':_0x4450eb[_0x8405('0x28')],'sumBillable':_0x4450eb['sumBillable'],'sumDuration':_0x4450eb[_0x8405('0x29')],'sumHoldTime':_0x4450eb['sumHoldTime']||0x0,'talking':_0x4450eb['talking'],'total':_0x4450eb[_0x8405('0x2a')],'type':_0x4450eb[_0x8405('0x2b')],'unmanaged':_0x4450eb[_0x8405('0x2c')],'abandoned':_0x4450eb[_0x8405('0x2d')],'waiting':_0x4450eb[_0x8405('0x2e')],'loggedInDb':_0x4450eb[_0x8405('0x2f')]};if(_0x4450eb[_0x8405('0x2b')]===_0x8405('0x30')){_0x3e5b4c[_0x8405('0x31')]=_0x4450eb[_0x8405('0x31')];_0x3e5b4c[_0x8405('0x32')]=_0x4450eb[_0x8405('0x32')];_0x3e5b4c[_0x8405('0x33')]=_0x4450eb['dialOriginateCallerIdName'];_0x3e5b4c[_0x8405('0x34')]=_0x4450eb[_0x8405('0x34')];_0x3e5b4c['dialOriginateTimeout']=_0x4450eb[_0x8405('0x35')];_0x3e5b4c[_0x8405('0x36')]=_0x4450eb[_0x8405('0x36')];_0x3e5b4c['temp']=_0x4450eb[_0x8405('0x37')];_0x3e5b4c[_0x8405('0x38')]=_0x4450eb[_0x8405('0x38')];_0x3e5b4c['outboundAnswerCallsDay']=_0x4450eb[_0x8405('0x39')];_0x3e5b4c[_0x8405('0x3a')]=_0x4450eb['outboundBlacklistCallsDay'];_0x3e5b4c[_0x8405('0x3b')]=_0x4450eb['outboundBusyCallsDay'];_0x3e5b4c[_0x8405('0x3c')]=_0x4450eb[_0x8405('0x3c')];_0x3e5b4c[_0x8405('0x3d')]=_0x4450eb[_0x8405('0x3d')];_0x3e5b4c[_0x8405('0x3e')]=_0x4450eb[_0x8405('0x3e')];_0x3e5b4c[_0x8405('0x3f')]=_0x4450eb[_0x8405('0x3f')];_0x3e5b4c[_0x8405('0x40')]=_0x4450eb[_0x8405('0x40')];_0x3e5b4c[_0x8405('0x41')]=_0x4450eb[_0x8405('0x41')];_0x3e5b4c['outboundOriginateFailureCallsDay']=_0x4450eb[_0x8405('0x42')];_0x3e5b4c['outboundReCallsDay']=_0x4450eb['outboundReCallsDay'];_0x3e5b4c[_0x8405('0x43')]=_0x4450eb[_0x8405('0x43')];_0x3e5b4c['outboundUnknownCallsDay']=_0x4450eb[_0x8405('0x44')];_0x3e5b4c[_0x8405('0x45')]=_0x4450eb[_0x8405('0x45')];_0x3e5b4c[_0x8405('0x46')]=_0x4450eb[_0x8405('0x46')];_0x3e5b4c['predictiveIntervalAvgTalktime']=_0x4450eb[_0x8405('0x47')];_0x3e5b4c[_0x8405('0x48')]=_0x4450eb[_0x8405('0x48')];_0x3e5b4c[_0x8405('0x49')]=_0x4450eb[_0x8405('0x49')];_0x3e5b4c['predictiveIntervalErlangCalls']=_0x4450eb[_0x8405('0x4a')];_0x3e5b4c[_0x8405('0x4b')]=_0x4450eb[_0x8405('0x4b')];_0x3e5b4c[_0x8405('0x4c')]=_0x4450eb[_0x8405('0x4c')];_0x3e5b4c[_0x8405('0x4d')]=_0x4450eb['predictiveIntervalMultiplicativeFactor'];_0x3e5b4c[_0x8405('0x4e')]=_0x4450eb[_0x8405('0x4e')];_0x3e5b4c[_0x8405('0x4f')]=_0x4450eb[_0x8405('0x4f')];_0x3e5b4c[_0x8405('0x50')]=_0x4450eb[_0x8405('0x50')];_0x3e5b4c[_0x8405('0x19')]=_0x4450eb['message'];_0x3e5b4c[_0x8405('0x51')]=_0x4450eb['originated'];_0x3e5b4c[_0x8405('0x52')]=_0x4450eb[_0x8405('0x52')];_0x3e5b4c['erlangCallToSecond']=_0x4450eb[_0x8405('0x53')];_0x3e5b4c[_0x8405('0x54')]=_0x4450eb[_0x8405('0x54')];_0x3e5b4c[_0x8405('0x55')]=_0x4450eb[_0x8405('0x55')];_0x3e5b4c[_0x8405('0x56')]=_0x4450eb[_0x8405('0x56')];_0x3e5b4c[_0x8405('0x57')]=_0x4450eb[_0x8405('0x57')];}if(_0x4450eb[_0x8405('0x58')]){_0x3e5b4c['Trunk']={'id':_0x4450eb['Trunk']['id'],'name':_0x4450eb[_0x8405('0x58')]['name'],'active':_0x4450eb[_0x8405('0x58')][_0x8405('0x59')],'callerid':_0x4450eb[_0x8405('0x58')]['callerid']};}if(_0x4450eb[_0x8405('0x5a')]){_0x3e5b4c[_0x8405('0x5a')]={'id':_0x4450eb['Interval']['id'],'name':_0x4450eb[_0x8405('0x5a')][_0x8405('0x23')]};}_0x48c5ea[_0x8405('0x5b')](_0x3e5b4c);}}_0x5d51a9({'count':_0x48c5ea[_0x8405('0x5c')],'rows':_0x48c5ea});});},'UpdateVoiceQueue':function(_0x55d189){return new Promise(function(_0x3b68b4,_0x336927){var _0x4fec13=_['find'](_0x4948b2['voiceQueues'],{'id':parseInt(_0x55d189['id'])});var _0x84020b=_[_0x8405('0x5d')](_0x55d189,['id']);if(_0x4fec13){for(var _0x1c0350 in _0x84020b){if(typeof _0x84020b[_0x1c0350]!==_0x8405('0x5e')&&typeof _0x4fec13[_0x1c0350]!=='undefined'){_0x4fec13[_0x1c0350]=_0x84020b[_0x1c0350];}}_0x3b68b4(_0x4fec13);}else{_0x336927();}});},'VoiceChannels':function(){return new Promise(function(_0x51ffcc){var _0x3c4ab2=_[_0x8405('0x5f')](_0x4948b2[_0x8405('0x60')]);_0x51ffcc({'count':_0x3c4ab2[_0x8405('0x5c')],'rows':_0x3c4ab2});});},'VoiceChannelMixMonitor':function(_0x2eced5){var _0x3c516f=this;return new Promise(function(_0x11a2d5,_0x600035){if(ami['isConnected']()==![]){return _0x600035(_0x3c516f[_0x8405('0x1b')](0x1f4,[config['asterisk']['ip'],config[_0x8405('0x10')][_0x8405('0x1d')],_0x8405('0x11')][_0x8405('0x12')]('\x20')));}var _0x9a0ffe=schema(properties[_0x8405('0x61')])[_0x8405('0x3')](_0x2eced5);if(_0x9a0ffe[_0x8405('0x5c')]>0x0){return _0x600035(_0x3c516f['error'](0x1f4,_[_0x8405('0x62')](_0x9a0ffe,_0x8405('0x19'))[_0x8405('0x12')](',\x20')));}var _0x3e4473=_['find'](_0x4948b2['channels'],{'uniqueid':_0x2eced5[_0x8405('0x63')]});if(_0x3e4473&&_0x3e4473[_0x8405('0x64')]){var _0x152757=util[_0x8405('0x9')](_0x8405('0x65'),_0x2eced5[_0x8405('0x66')]||_0x2eced5[_0x8405('0x63')],_0x2eced5['format']||'wav');return ami[_0x8405('0x17')]({'action':'MixMonitor','channel':_0x3e4473[_0x8405('0x64')],'file':_0x152757,'options':_0x8405('0x67')})[_0x8405('0x18')](function(_0x4b8443){var _0x5b8a93=_[_0x8405('0x68')](_0x3e4473['monitors'],{'filename':_0x8405('0x69')+_0x152757[_0x8405('0x6a')]()});if(_[_0x8405('0x6b')](_0x5b8a93)){_0x3e4473[_0x8405('0x6c')][_0x8405('0x5b')]({'filename':_0x8405('0x69')+_0x152757[_0x8405('0x6a')](),'createdAt':moment()[_0x8405('0x9')](_0x8405('0x6d')),'mixmonitorid':_0x4b8443['mixmonitorid'],'status':_0x8405('0x6e')});}else{_0x5b8a93[_0x8405('0x6f')]=_0x4b8443[_0x8405('0x6f')];_0x5b8a93[_0x8405('0x70')]='rec';}_0x11a2d5({'code':0xc8,'message':[_0x2eced5[_0x8405('0x63')],_0x8405('0x71'),_0x4b8443[_0x8405('0x6f')]][_0x8405('0x12')]('\x20'),'mixmonitorid':_0x4b8443[_0x8405('0x6f')]});})[_0x8405('0x1a')](function(_0x4a2381){_0x600035(_0x3c516f[_0x8405('0x1b')](0x1f5,[_0x2eced5[_0x8405('0x63')],_0x4a2381[_0x8405('0x19')]['toLowerCase']()][_0x8405('0x12')]('\x20')));});}else{return _0x600035(_0x3c516f[_0x8405('0x1b')](0x1f5,_0x8405('0x72')));}});},'VoiceChannelStopMixMonitor':function(_0x2b8334){var _0x9b3747=this;return new Promise(function(_0x3bbdc5,_0x283dcb){if(ami[_0x8405('0x1c')]()==![]){return _0x283dcb(_0x9b3747[_0x8405('0x1b')](0x1f4,[config[_0x8405('0x10')]['ip'],config['asterisk'][_0x8405('0x1d')],'ami\x20disconnected'][_0x8405('0x12')]('\x20')));}var _0x4f96f8=schema(properties[_0x8405('0x61')])[_0x8405('0x3')](_0x2b8334);if(_0x4f96f8[_0x8405('0x5c')]>0x0){return _0x283dcb(_0x9b3747[_0x8405('0x1b')](0x1f4,_[_0x8405('0x62')](_0x4f96f8,'message')[_0x8405('0x12')](',\x20')));}var _0x48f7a7=_['find'](_0x4948b2[_0x8405('0x60')],{'uniqueid':_0x2b8334['uniqueid']});if(_0x48f7a7){return Promise[_0x8405('0x73')]()[_0x8405('0x18')](function(){if(_0x48f7a7[_0x8405('0x64')]){return ami['Action']({'action':_0x8405('0x74'),'channel':_0x48f7a7[_0x8405('0x64')],'mixmonitorid':_0x2b8334[_0x8405('0x6f')]})[_0x8405('0x1a')](function(){});}})[_0x8405('0x18')](function(){if(_0x48f7a7[_0x8405('0x75')]){return ami['Action']({'action':_0x8405('0x74'),'channel':_0x48f7a7[_0x8405('0x75')],'mixmonitorid':_0x2b8334[_0x8405('0x6f')]})['catch'](function(){});}})['then'](function(){var _0x230e33=_[_0x8405('0x68')](_0x48f7a7[_0x8405('0x6c')],{'mixmonitorid':_0x2b8334[_0x8405('0x6f')]});if(_0x230e33){_0x230e33[_0x8405('0x70')]='stop';}})['then'](function(){var _0x5cd043=util[_0x8405('0x9')](_0x8405('0x65'),_0x2b8334[_0x8405('0x66')]||_0x2b8334[_0x8405('0x63')],_0x2b8334[_0x8405('0x9')]||_0x8405('0x76'));var _0x1a4861=_[_0x8405('0x68')](_0x48f7a7[_0x8405('0x6c')],{'filename':_0x8405('0x69')+_0x5cd043[_0x8405('0x6a')]()});if(_0x1a4861){_0x1a4861[_0x8405('0x70')]='stop';}})[_0x8405('0x18')](function(){_0x3bbdc5({'code':0xc8,'message':[_0x2b8334[_0x8405('0x63')],'StopMixMonitor\x20Success'][_0x8405('0x12')]('\x20')});})[_0x8405('0x1a')](function(_0x2c0413){_0x283dcb(_0x9b3747[_0x8405('0x1b')](0x1f5,[_0x2b8334[_0x8405('0x63')],_0x2c0413[_0x8405('0x19')][_0x8405('0x6a')]()][_0x8405('0x12')]('\x20')));});}else{return _0x283dcb(_0x9b3747[_0x8405('0x1b')](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'VoiceQueuesChannels':function(){return new Promise(function(_0x1db269){var _0x4732dc=_[_0x8405('0x5f')](_0x4948b2['queueChannels']);_0x1db269({'count':_0x4732dc[_0x8405('0x5c')],'rows':_0x4732dc});});},'VoiceQueuesChannel':function(_0x320b03){var _0x20e9ac=this;return new Promise(function(_0x211e38,_0x27f1ef){var _0x4d9f1f=schema(properties[_0x8405('0x77')])[_0x8405('0x3')](_0x320b03);if(_0x4d9f1f[_0x8405('0x5c')]>0x0){return _0x27f1ef(_0x20e9ac[_0x8405('0x1b')](0x1f4,_[_0x8405('0x62')](_0x4d9f1f,_0x8405('0x19'))[_0x8405('0x12')](',\x20')));}var _0x83a45b=_[_0x8405('0x68')](_0x4948b2['queueChannels'],{'uniqueid':_0x320b03[_0x8405('0x63')]});if(_0x83a45b){_0x211e38(_0x83a45b);}else{return _0x27f1ef(_0x20e9ac['error'](0x1f5,_0x8405('0x72')));}});},'VoiceQueuesChannelHangup':function(_0x8390dc){var _0x52592c=this;return new Promise(function(_0x4f203d,_0x5f4bb6){if(ami['isConnected']()==![]){return _0x5f4bb6(_0x52592c[_0x8405('0x1b')](0x1f4,[config['asterisk']['ip'],config[_0x8405('0x10')][_0x8405('0x1d')],_0x8405('0x11')][_0x8405('0x12')]('\x20')));}var _0x372ca9=schema(properties[_0x8405('0x78')])[_0x8405('0x3')](_0x8390dc);if(_0x372ca9['length']>0x0){return _0x5f4bb6(_0x52592c[_0x8405('0x1b')](0x1f4,_[_0x8405('0x62')](_0x372ca9,'message')['join'](',\x20')));}var _0x48b045=_['find'](_0x4948b2['queueChannels'],{'uniqueid':_0x8390dc['uniqueid']});if(_0x48b045&&_0x48b045[_0x8405('0x64')]){return ami[_0x8405('0x17')]({'action':_0x8405('0x79'),'channel':_0x48b045[_0x8405('0x64')]})[_0x8405('0x18')](function(_0x5a6844){_0x4f203d({'code':0xc8,'message':[_0x8390dc[_0x8405('0x63')],_0x5a6844[_0x8405('0x19')][_0x8405('0x6a')]()][_0x8405('0x12')]('\x20')});})[_0x8405('0x1a')](function(_0x5c1bdb){_0x5f4bb6(_0x52592c[_0x8405('0x1b')](0x1f5,[_0x8390dc[_0x8405('0x63')],_0x5c1bdb[_0x8405('0x19')][_0x8405('0x6a')]()][_0x8405('0x12')]('\x20')));});}else{return _0x5f4bb6(_0x52592c[_0x8405('0x1b')](0x1f5,_0x8405('0x72')));}});},'VoiceQueuesChannelRedirect':function(_0x1b2737){var _0x575115=this;return new Promise(function(_0x42049d,_0x132a09){if(ami[_0x8405('0x1c')]()==![]){return _0x132a09(_0x575115[_0x8405('0x1b')](0x1f4,[config[_0x8405('0x10')]['ip'],config[_0x8405('0x10')][_0x8405('0x1d')],_0x8405('0x11')][_0x8405('0x12')]('\x20')));}var _0x2be89b=schema(properties[_0x8405('0x7a')])[_0x8405('0x3')](_0x1b2737);if(_0x2be89b[_0x8405('0x5c')]>0x0){return _0x132a09(_0x575115[_0x8405('0x1b')](0x1f4,_[_0x8405('0x62')](_0x2be89b,_0x8405('0x19'))['join'](',\x20')));}var _0x2562c8=_[_0x8405('0x68')](_0x4948b2[_0x8405('0x7b')],{'uniqueid':_0x1b2737['uniqueid']});if(_0x2562c8&&_0x2562c8[_0x8405('0x64')]){return ami[_0x8405('0x17')]({'action':_0x8405('0x7c'),'channel':_0x2562c8[_0x8405('0x64')],'exten':_0x1b2737[_0x8405('0x7d')],'context':_0x1b2737[_0x8405('0x7e')]||_0x2562c8[_0x8405('0x7e')],'priority':0x1})[_0x8405('0x18')](function(_0x352112){_0x42049d({'code':0xc8,'message':[_0x1b2737[_0x8405('0x63')],_0x352112['message']['toLowerCase']()][_0x8405('0x12')]('\x20')});})[_0x8405('0x1a')](function(_0x5e6b24){_0x132a09(_0x575115[_0x8405('0x1b')](0x1f5,[_0x1b2737[_0x8405('0x63')],_0x5e6b24[_0x8405('0x19')]['toLowerCase']()]['join']('\x20')));});}else{return _0x132a09(_0x575115['error'](0x1f5,'Channel\x20doesn\x27t\x20exist'));}});},'Agents':function(_0x151b4f){return new Promise(function(_0x337233){var _0x37a642=_['values'](_0x4948b2[_0x8405('0xf')]);if(_0x151b4f&&_0x151b4f['id']){var _0x35607a=_[_0x8405('0x68')](_0x37a642,function(_0x73c924){return _0x73c924['id']===_0x151b4f['id'];});_0x337233(_0x35607a);}else{_0x337233({'count':_0x37a642['length'],'rows':_0x37a642});}});},'Telephones':function(){return new Promise(function(_0x4bc83b){var _0x31b673=_[_0x8405('0x5f')](_0x4948b2['telephones']);_0x4bc83b({'count':_0x31b673[_0x8405('0x5c')],'rows':_0x31b673});});},'Trunks':function(){return new Promise(function(_0x1bbb21){var _0xc1f4ec=_['values'](_0x4948b2[_0x8405('0x7f')]);_0x1bbb21({'count':_0xc1f4ec[_0x8405('0x5c')],'rows':_0xc1f4ec});});},'OutboundChannels':function(){return new Promise(function(_0x23022d){var _0x360e0a=_[_0x8405('0x5f')](_0x4948b2[_0x8405('0x80')]);_0x23022d({'count':_0x360e0a[_0x8405('0x5c')],'rows':_0x360e0a});});},'Outbound':function(){return new Promise(function(_0x2ca863){_0x2ca863(_0x4948b2[_0x8405('0x30')]);});},'Campaigns':function(){return new Promise(function(_0x9aa5a6){var _0x488a7f=_[_0x8405('0x5f')](_0x4948b2[_0x8405('0x81')]);_0x9aa5a6({'count':_0x488a7f[_0x8405('0x5c')],'rows':_0x488a7f});});},'VoiceQueuesPreview':function(_0x4ea2bf){var _0x57adfd=this;return new Promise(function(_0x572981,_0x13c442){_0x5ebf0e[_0x8405('0x82')](_0x4ea2bf['id'])[_0x8405('0x18')](function(_0x279bd1){_0x572981({'code':0xc8,'message':_0x279bd1['message']});})[_0x8405('0x1a')](function(_0x1a3cc6){_0x13c442(_0x57adfd[_0x8405('0x1b')](0x1f4,_0x1a3cc6[_0x8405('0x19')]));});});},'EventManager':function(_0x9d6230){var _0x1f3e97=this;return new Promise(function(_0xbd79a0,_0x40da84){if(!_0x9d6230[_0x8405('0x83')]){return _0x40da84(_0x1f3e97[_0x8405('0x1b')](0x1f4,'Event\x20name\x20mandatory'));}ami['emit'](_0x8405('0x84')+_0x9d6230[_0x8405('0x83')],_0x9d6230[_0x8405('0x19')]);_0xbd79a0({'code':0xc8,'message':_0x9d6230});});},'FaxAccounts':function(){return new Promise(function(_0x3d855d){var _0x689ca1=_[_0x8405('0x5f')](_0x4948b2[_0x8405('0x85')]);_0x3d855d({'count':_0x689ca1[_0x8405('0x5c')],'rows':_0x689ca1});});},'SendFax':function(_0x2300d3){var _0x4c2153=this;return new Promise(function(_0x264c5d,_0x1c1d17){_0x57fb07[_0x8405('0x86')](_0x2300d3)['then'](function(_0x36cf2b){_0x264c5d({'code':0xc8,'message':_0x36cf2b[_0x8405('0x19')]});})[_0x8405('0x1a')](function(_0x4cc691){_0x1c1d17(_0x4c2153['error'](0x1f4,_0x4cc691['message']));});});},'CheckAfterSend':function(_0x6d0055){var _0x5c1a48=this;return new Promise(function(_0x57b076,_0x66c9f9){_0x57fb07[_0x8405('0x87')](_0x6d0055)['then'](function(_0x2dc00f){_0x57b076({'code':0xc8,'message':_0x2dc00f[_0x8405('0x19')]});})[_0x8405('0x1a')](function(_0x273e11){_0x66c9f9(_0x5c1a48[_0x8405('0x1b')](0x1f4,_0x273e11['message']));});});}};var _0x49ecf0=jayson[_0x8405('0x88')](_0x3d9bf6)['http']();_0x49ecf0['on'](_0x8405('0x1b'),function(_0x19dca3){return _0x257d43(_0x19dca3);});_0x49ecf0[_0x8405('0x8')](0x232a,_0x8405('0x89'),function(){console['log'](_0x8405('0x8a'),0x232a);return _0x1db7ea(_0x8405('0x8b')+0x232a);});});};