Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / voiceQueueReport / voiceQueueReport.rpc.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 _0x9129=['catch','VoiceQueueReport','options','raw','where','attributes','limit','include','map','model','GetVoiceQueueReport','CreateVoiceQueueReport','create','body','UpdateVoiceQueueReport','update','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','register','request','then','VoiceQueueReport,\x20%s,\x20%s','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result'];(function(_0xac151d,_0x4ea1d2){var _0x111dba=function(_0x13d7f4){while(--_0x13d7f4){_0xac151d['push'](_0xac151d['shift']());}};_0x111dba(++_0x4ea1d2);}(_0x9129,0x1aa));var _0x9912=function(_0x593cbd,_0x141c5b){_0x593cbd=_0x593cbd-0x0;var _0x1ea4aa=_0x9129[_0x593cbd];return _0x1ea4aa;};'use strict';var _=require('lodash');var util=require(_0x9912('0x0'));var moment=require(_0x9912('0x1'));var BPromise=require(_0x9912('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9912('0x3'));var db=require(_0x9912('0x4'))['db'];var utils=require(_0x9912('0x5'));var logger=require(_0x9912('0x6'))(_0x9912('0x7'));var config=require(_0x9912('0x8'));var jayson=require(_0x9912('0x9'));var client=jayson['client'][_0x9912('0xa')]({'port':0x232a});config[_0x9912('0xb')]=_['defaults'](config[_0x9912('0xb')],{'host':_0x9912('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9912('0xb')]));require('./voiceQueueReport.socket')[_0x9912('0xd')](socket);function respondWithRpcPromise(_0x1b4f69,_0x50d0c9,_0x13699b){return new BPromise(function(_0x2c1729,_0x2a397f){return client[_0x9912('0xe')](_0x1b4f69,_0x13699b)[_0x9912('0xf')](function(_0x43bdcc){logger['info'](_0x9912('0x10'),_0x50d0c9,'request\x20sent');logger[_0x9912('0x11')](_0x9912('0x12'),_0x50d0c9,'request\x20sent',JSON[_0x9912('0x13')](_0x43bdcc));if(_0x43bdcc[_0x9912('0x14')]){if(_0x43bdcc[_0x9912('0x14')][_0x9912('0x15')]===0x1f4){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x50d0c9,_0x43bdcc[_0x9912('0x14')]['message']);return _0x2a397f(_0x43bdcc['error'][_0x9912('0x16')]);}logger[_0x9912('0x14')](_0x9912('0x10'),_0x50d0c9,_0x43bdcc[_0x9912('0x14')][_0x9912('0x16')]);return _0x2c1729(_0x43bdcc[_0x9912('0x14')][_0x9912('0x16')]);}else{logger[_0x9912('0x17')](_0x9912('0x10'),_0x50d0c9,'request\x20sent');_0x2c1729(_0x43bdcc[_0x9912('0x18')]['message']);}})[_0x9912('0x19')](function(_0x2084b6){logger[_0x9912('0x14')]('VoiceQueueReport,\x20%s,\x20%s',_0x50d0c9,_0x2084b6);_0x2a397f(_0x2084b6);});});}exports['GetVoiceQueueReport']=function(_0x407555){var _0x4e8aba=this;return new Promise(function(_0x811708,_0x39cc45){return db[_0x9912('0x1a')]['findAll']({'raw':_0x407555['options']?_0x407555[_0x9912('0x1b')][_0x9912('0x1c')]===undefined?!![]:![]:!![],'where':_0x407555[_0x9912('0x1b')]?_0x407555['options'][_0x9912('0x1d')]||null:null,'attributes':_0x407555[_0x9912('0x1b')]?_0x407555[_0x9912('0x1b')][_0x9912('0x1e')]||null:null,'limit':_0x407555['options']?_0x407555[_0x9912('0x1b')][_0x9912('0x1f')]||null:null,'include':_0x407555[_0x9912('0x1b')]?_0x407555[_0x9912('0x1b')][_0x9912('0x20')]?_[_0x9912('0x21')](_0x407555[_0x9912('0x1b')][_0x9912('0x20')],function(_0x39e2e5){return{'model':db[_0x39e2e5[_0x9912('0x22')]],'as':_0x39e2e5['as'],'attributes':_0x39e2e5[_0x9912('0x1e')],'include':_0x39e2e5['include']?_[_0x9912('0x21')](_0x39e2e5['include'],function(_0x37d538){return{'model':db[_0x37d538[_0x9912('0x22')]],'as':_0x37d538['as'],'attributes':_0x37d538[_0x9912('0x1e')],'include':_0x37d538[_0x9912('0x20')]?_[_0x9912('0x21')](_0x37d538['include'],function(_0x2c0527){return{'model':db[_0x2c0527[_0x9912('0x22')]],'as':_0x2c0527['as'],'attributes':_0x2c0527[_0x9912('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x9912('0xf')](function(_0x406f09){logger[_0x9912('0x17')](_0x9912('0x23'),_0x407555);logger['debug'](_0x9912('0x23'),_0x407555,JSON[_0x9912('0x13')](_0x406f09));_0x811708(_0x406f09);})[_0x9912('0x19')](function(_0x4b0011){logger[_0x9912('0x14')](_0x9912('0x23'),_0x4b0011['message'],_0x407555);_0x39cc45(_0x4e8aba[_0x9912('0x14')](0x1f4,_0x4b0011[_0x9912('0x16')]));});});};exports[_0x9912('0x24')]=function(_0x13f5a4){var _0x9503b7=this;return new Promise(function(_0x9e36e2,_0x366b40){return db[_0x9912('0x1a')][_0x9912('0x25')](_0x13f5a4[_0x9912('0x26')],{'raw':_0x13f5a4[_0x9912('0x1b')]?_0x13f5a4['options'][_0x9912('0x1c')]===undefined?!![]:![]:!![]})[_0x9912('0xf')](function(_0x510a5c){logger[_0x9912('0x17')](_0x9912('0x24'),_0x13f5a4);logger[_0x9912('0x11')]('CreateVoiceQueueReport',_0x13f5a4,JSON['stringify'](_0x510a5c));_0x9e36e2(_0x510a5c);})[_0x9912('0x19')](function(_0x406b6c){logger[_0x9912('0x14')](_0x9912('0x24'),_0x406b6c[_0x9912('0x16')],_0x13f5a4);_0x366b40(_0x9503b7[_0x9912('0x14')](0x1f4,_0x406b6c['message']));});});};exports[_0x9912('0x27')]=function(_0x5d9750){var _0x364e1b=this;return new Promise(function(_0x57989c,_0x519bce){return db[_0x9912('0x1a')][_0x9912('0x28')](_0x5d9750[_0x9912('0x26')],{'raw':_0x5d9750[_0x9912('0x1b')]?_0x5d9750['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5d9750['options']?_0x5d9750[_0x9912('0x1b')][_0x9912('0x1d')]||null:null,'attributes':_0x5d9750[_0x9912('0x1b')]?_0x5d9750['options']['attributes']||null:null,'limit':_0x5d9750['options']?_0x5d9750[_0x9912('0x1b')][_0x9912('0x1f')]||null:null})[_0x9912('0xf')](function(_0x3069b2){logger[_0x9912('0x17')](_0x9912('0x27'),_0x5d9750);logger[_0x9912('0x11')](_0x9912('0x27'),_0x5d9750,JSON[_0x9912('0x13')](_0x3069b2));_0x57989c(_0x3069b2);})['catch'](function(_0x15e6b3){logger[_0x9912('0x14')](_0x9912('0x27'),_0x15e6b3[_0x9912('0x16')],_0x5d9750);_0x519bce(_0x364e1b['error'](0x1f4,_0x15e6b3['message']));});});};