Built motion from commit (unavailable).|2.6.0
[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 _0x28a6=['randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','redis','socket.io-emitter','register','then','info','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','VoiceQueueReport,\x20%s,\x20%s','message','result','catch','GetVoiceQueueReport','VoiceQueueReport','options','raw','where','attributes','map','model','include','create','body','CreateVoiceQueueReport','UpdateVoiceQueueReport','update','limit','lodash','moment','bluebird'];(function(_0x134bfc,_0x144d5f){var _0x2f4dcc=function(_0x56cf22){while(--_0x56cf22){_0x134bfc['push'](_0x134bfc['shift']());}};_0x2f4dcc(++_0x144d5f);}(_0x28a6,0x1e9));var _0x628a=function(_0x4f3242,_0x391954){_0x4f3242=_0x4f3242-0x0;var _0x49844f=_0x28a6[_0x4f3242];return _0x49844f;};'use strict';var _=require(_0x628a('0x0'));var util=require('util');var moment=require(_0x628a('0x1'));var BPromise=require(_0x628a('0x2'));var rs=require(_0x628a('0x3'));var fs=require('fs');var Redis=require(_0x628a('0x4'));var db=require(_0x628a('0x5'))['db'];var utils=require(_0x628a('0x6'));var logger=require(_0x628a('0x7'))(_0x628a('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x628a('0x9')][_0x628a('0xa')]({'port':0x232a});config[_0x628a('0xb')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x628a('0xc'))(new Redis(config[_0x628a('0xb')]));require('./voiceQueueReport.socket')[_0x628a('0xd')](socket);function respondWithRpcPromise(_0x37bf5d,_0x2de44f,_0x273479){return new BPromise(function(_0x548c7e,_0x43224b){return client['request'](_0x37bf5d,_0x273479)[_0x628a('0xe')](function(_0x4de693){logger[_0x628a('0xf')]('VoiceQueueReport,\x20%s,\x20%s',_0x2de44f,'request\x20sent');logger[_0x628a('0x10')](_0x628a('0x11'),_0x2de44f,_0x628a('0x12'),JSON[_0x628a('0x13')](_0x4de693));if(_0x4de693[_0x628a('0x14')]){if(_0x4de693[_0x628a('0x14')][_0x628a('0x15')]===0x1f4){logger[_0x628a('0x14')](_0x628a('0x16'),_0x2de44f,_0x4de693[_0x628a('0x14')]['message']);return _0x43224b(_0x4de693[_0x628a('0x14')][_0x628a('0x17')]);}logger[_0x628a('0x14')](_0x628a('0x16'),_0x2de44f,_0x4de693[_0x628a('0x14')][_0x628a('0x17')]);return _0x548c7e(_0x4de693['error'][_0x628a('0x17')]);}else{logger[_0x628a('0xf')](_0x628a('0x16'),_0x2de44f,'request\x20sent');_0x548c7e(_0x4de693[_0x628a('0x18')]['message']);}})[_0x628a('0x19')](function(_0x501704){logger['error'](_0x628a('0x16'),_0x2de44f,_0x501704);_0x43224b(_0x501704);});});}exports[_0x628a('0x1a')]=function(_0x543d46){var _0x50f214=this;return new Promise(function(_0x1cb2f5,_0x38fccf){return db[_0x628a('0x1b')]['findAll']({'raw':_0x543d46[_0x628a('0x1c')]?_0x543d46[_0x628a('0x1c')][_0x628a('0x1d')]===undefined?!![]:![]:!![],'where':_0x543d46[_0x628a('0x1c')]?_0x543d46[_0x628a('0x1c')][_0x628a('0x1e')]||null:null,'attributes':_0x543d46[_0x628a('0x1c')]?_0x543d46[_0x628a('0x1c')][_0x628a('0x1f')]||null:null,'limit':_0x543d46[_0x628a('0x1c')]?_0x543d46[_0x628a('0x1c')]['limit']||null:null,'include':_0x543d46[_0x628a('0x1c')]?_0x543d46[_0x628a('0x1c')]['include']?_[_0x628a('0x20')](_0x543d46[_0x628a('0x1c')]['include'],function(_0xc661fb){return{'model':db[_0xc661fb[_0x628a('0x21')]],'as':_0xc661fb['as'],'attributes':_0xc661fb[_0x628a('0x1f')],'include':_0xc661fb[_0x628a('0x22')]?_[_0x628a('0x20')](_0xc661fb['include'],function(_0xaf96e2){return{'model':db[_0xaf96e2[_0x628a('0x21')]],'as':_0xaf96e2['as'],'attributes':_0xaf96e2['attributes'],'include':_0xaf96e2['include']?_[_0x628a('0x20')](_0xaf96e2[_0x628a('0x22')],function(_0x36b7bc){return{'model':db[_0x36b7bc[_0x628a('0x21')]],'as':_0x36b7bc['as'],'attributes':_0x36b7bc[_0x628a('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x628a('0xe')](function(_0x5899ef){logger[_0x628a('0xf')]('GetVoiceQueueReport',_0x543d46);logger[_0x628a('0x10')](_0x628a('0x1a'),_0x543d46,JSON[_0x628a('0x13')](_0x5899ef));_0x1cb2f5(_0x5899ef);})[_0x628a('0x19')](function(_0x248bb9){logger[_0x628a('0x14')](_0x628a('0x1a'),_0x248bb9['message'],_0x543d46);_0x38fccf(_0x50f214['error'](0x1f4,_0x248bb9[_0x628a('0x17')]));});});};exports['CreateVoiceQueueReport']=function(_0x2bc22a){var _0x4d99c6=this;return new Promise(function(_0x3514f7,_0x293dc9){return db[_0x628a('0x1b')][_0x628a('0x23')](_0x2bc22a[_0x628a('0x24')],{'raw':_0x2bc22a[_0x628a('0x1c')]?_0x2bc22a['options'][_0x628a('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x36e377){logger[_0x628a('0xf')]('CreateVoiceQueueReport',_0x2bc22a);logger[_0x628a('0x10')](_0x628a('0x25'),_0x2bc22a,JSON[_0x628a('0x13')](_0x36e377));_0x3514f7(_0x36e377);})[_0x628a('0x19')](function(_0xfcb0c6){logger[_0x628a('0x14')](_0x628a('0x25'),_0xfcb0c6[_0x628a('0x17')],_0x2bc22a);_0x293dc9(_0x4d99c6[_0x628a('0x14')](0x1f4,_0xfcb0c6[_0x628a('0x17')]));});});};exports[_0x628a('0x26')]=function(_0x37070d){var _0x104e7f=this;return new Promise(function(_0x2d1816,_0x24b18f){return db[_0x628a('0x1b')][_0x628a('0x27')](_0x37070d['body'],{'raw':_0x37070d[_0x628a('0x1c')]?_0x37070d[_0x628a('0x1c')][_0x628a('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x37070d[_0x628a('0x1c')]?_0x37070d[_0x628a('0x1c')][_0x628a('0x1e')]||null:null,'attributes':_0x37070d['options']?_0x37070d['options'][_0x628a('0x1f')]||null:null,'limit':_0x37070d[_0x628a('0x1c')]?_0x37070d['options'][_0x628a('0x28')]||null:null})[_0x628a('0xe')](function(_0xd2f483){logger[_0x628a('0xf')](_0x628a('0x26'),_0x37070d);logger['debug'](_0x628a('0x26'),_0x37070d,JSON[_0x628a('0x13')](_0xd2f483));_0x2d1816(_0xd2f483);})[_0x628a('0x19')](function(_0x129545){logger['error'](_0x628a('0x26'),_0x129545[_0x628a('0x17')],_0x37070d);_0x24b18f(_0x104e7f[_0x628a('0x14')](0x1f4,_0x129545[_0x628a('0x17')]));});});};