4477c4a646d6fc5a76ca712c88e365bd81f1e7dc
[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 _0x4802=['socket.io-emitter','register','then','info','VoiceQueueReport,\x20%s,\x20%s','VoiceQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','GetVoiceQueueReport','VoiceQueueReport','options','raw','where','attributes','limit','include','map','model','debug','catch','create','body','CreateVoiceQueueReport','UpdateVoiceQueueReport','update','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis'];(function(_0x4d8666,_0x2ff19d){var _0x37175b=function(_0x1b8de6){while(--_0x1b8de6){_0x4d8666['push'](_0x4d8666['shift']());}};_0x37175b(++_0x2ff19d);}(_0x4802,0xef));var _0x2480=function(_0x3bf83f,_0x181cac){_0x3bf83f=_0x3bf83f-0x0;var _0x22c4a9=_0x4802[_0x3bf83f];return _0x22c4a9;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2480('0x0'));var BPromise=require(_0x2480('0x1'));var rs=require(_0x2480('0x2'));var fs=require('fs');var Redis=require(_0x2480('0x3'));var db=require(_0x2480('0x4'))['db'];var utils=require(_0x2480('0x5'));var logger=require(_0x2480('0x6'))(_0x2480('0x7'));var config=require(_0x2480('0x8'));var jayson=require(_0x2480('0x9'));var client=jayson[_0x2480('0xa')][_0x2480('0xb')]({'port':0x232a});config[_0x2480('0xc')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x2480('0xd'))(new Redis(config['redis']));require('./voiceQueueReport.socket')[_0x2480('0xe')](socket);function respondWithRpcPromise(_0x399466,_0x21fb19,_0x4cbe13){return new BPromise(function(_0xc3492b,_0x3d47a3){return client['request'](_0x399466,_0x4cbe13)[_0x2480('0xf')](function(_0x5b9be3){logger[_0x2480('0x10')](_0x2480('0x11'),_0x21fb19,'request\x20sent');logger['debug'](_0x2480('0x12'),_0x21fb19,_0x2480('0x13'),JSON[_0x2480('0x14')](_0x5b9be3));if(_0x5b9be3[_0x2480('0x15')]){if(_0x5b9be3[_0x2480('0x15')][_0x2480('0x16')]===0x1f4){logger[_0x2480('0x15')]('VoiceQueueReport,\x20%s,\x20%s',_0x21fb19,_0x5b9be3[_0x2480('0x15')]['message']);return _0x3d47a3(_0x5b9be3[_0x2480('0x15')][_0x2480('0x17')]);}logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x21fb19,_0x5b9be3[_0x2480('0x15')]['message']);return _0xc3492b(_0x5b9be3['error']['message']);}else{logger[_0x2480('0x10')](_0x2480('0x11'),_0x21fb19,_0x2480('0x13'));_0xc3492b(_0x5b9be3[_0x2480('0x18')]['message']);}})['catch'](function(_0x50a0cb){logger['error'](_0x2480('0x11'),_0x21fb19,_0x50a0cb);_0x3d47a3(_0x50a0cb);});});}exports[_0x2480('0x19')]=function(_0x5a460a){var _0x37aff6=this;return new Promise(function(_0x346163,_0x164c97){return db[_0x2480('0x1a')]['findAll']({'raw':_0x5a460a[_0x2480('0x1b')]?_0x5a460a['options'][_0x2480('0x1c')]===undefined?!![]:![]:!![],'where':_0x5a460a[_0x2480('0x1b')]?_0x5a460a[_0x2480('0x1b')][_0x2480('0x1d')]||null:null,'attributes':_0x5a460a[_0x2480('0x1b')]?_0x5a460a[_0x2480('0x1b')][_0x2480('0x1e')]||null:null,'limit':_0x5a460a[_0x2480('0x1b')]?_0x5a460a[_0x2480('0x1b')][_0x2480('0x1f')]||null:null,'include':_0x5a460a['options']?_0x5a460a[_0x2480('0x1b')][_0x2480('0x20')]?_[_0x2480('0x21')](_0x5a460a[_0x2480('0x1b')][_0x2480('0x20')],function(_0x3375f3){return{'model':db[_0x3375f3[_0x2480('0x22')]],'as':_0x3375f3['as'],'attributes':_0x3375f3[_0x2480('0x1e')],'include':_0x3375f3[_0x2480('0x20')]?_[_0x2480('0x21')](_0x3375f3['include'],function(_0x316182){return{'model':db[_0x316182[_0x2480('0x22')]],'as':_0x316182['as'],'attributes':_0x316182['attributes'],'include':_0x316182[_0x2480('0x20')]?_[_0x2480('0x21')](_0x316182[_0x2480('0x20')],function(_0x494636){return{'model':db[_0x494636[_0x2480('0x22')]],'as':_0x494636['as'],'attributes':_0x494636[_0x2480('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x2480('0xf')](function(_0x53b796){logger[_0x2480('0x10')](_0x2480('0x19'),_0x5a460a);logger[_0x2480('0x23')]('GetVoiceQueueReport',_0x5a460a,JSON['stringify'](_0x53b796));_0x346163(_0x53b796);})[_0x2480('0x24')](function(_0x5352e1){logger['error']('GetVoiceQueueReport',_0x5352e1[_0x2480('0x17')],_0x5a460a);_0x164c97(_0x37aff6[_0x2480('0x15')](0x1f4,_0x5352e1[_0x2480('0x17')]));});});};exports['CreateVoiceQueueReport']=function(_0xfeaf1d){var _0x4f718e=this;return new Promise(function(_0x2fde67,_0x555165){return db['VoiceQueueReport'][_0x2480('0x25')](_0xfeaf1d[_0x2480('0x26')],{'raw':_0xfeaf1d[_0x2480('0x1b')]?_0xfeaf1d['options'][_0x2480('0x1c')]===undefined?!![]:![]:!![]})[_0x2480('0xf')](function(_0x3d2d8a){logger[_0x2480('0x10')](_0x2480('0x27'),_0xfeaf1d);logger[_0x2480('0x23')](_0x2480('0x27'),_0xfeaf1d,JSON[_0x2480('0x14')](_0x3d2d8a));_0x2fde67(_0x3d2d8a);})['catch'](function(_0x1a2720){logger[_0x2480('0x15')](_0x2480('0x27'),_0x1a2720[_0x2480('0x17')],_0xfeaf1d);_0x555165(_0x4f718e[_0x2480('0x15')](0x1f4,_0x1a2720[_0x2480('0x17')]));});});};exports[_0x2480('0x28')]=function(_0xae8554){var _0x31819b=this;return new Promise(function(_0xcb032a,_0x5ac61a){return db['VoiceQueueReport'][_0x2480('0x29')](_0xae8554[_0x2480('0x26')],{'raw':_0xae8554[_0x2480('0x1b')]?_0xae8554[_0x2480('0x1b')][_0x2480('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xae8554[_0x2480('0x1b')]?_0xae8554['options']['where']||null:null,'attributes':_0xae8554[_0x2480('0x1b')]?_0xae8554['options']['attributes']||null:null,'limit':_0xae8554[_0x2480('0x1b')]?_0xae8554[_0x2480('0x1b')][_0x2480('0x1f')]||null:null})[_0x2480('0xf')](function(_0xe94ab7){logger[_0x2480('0x10')]('UpdateVoiceQueueReport',_0xae8554);logger[_0x2480('0x23')](_0x2480('0x28'),_0xae8554,JSON['stringify'](_0xe94ab7));_0xcb032a(_0xe94ab7);})[_0x2480('0x24')](function(_0x20b6f3){logger[_0x2480('0x15')](_0x2480('0x28'),_0x20b6f3[_0x2480('0x17')],_0xae8554);_0x5ac61a(_0x31819b[_0x2480('0x15')](0x1f4,_0x20b6f3[_0x2480('0x17')]));});});};