79d1d857dce0cfbebfaabd7ccef5ae69c9ee09b5
[motion2.git] / server / api / chatQueueReport / chatQueueReport.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 _0x6d4a=['ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CreateChatQueueReport','ChatQueueReport','create','body','options','raw','info','debug','catch','UpdateChatQueueReport','update','where','limit','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','then','ChatQueueReport,\x20%s,\x20%s','request\x20sent'];(function(_0x14f2c0,_0xe0b572){var _0x43196e=function(_0x5b5537){while(--_0x5b5537){_0x14f2c0['push'](_0x14f2c0['shift']());}};_0x43196e(++_0xe0b572);}(_0x6d4a,0x132));var _0xa6d4=function(_0x10d830,_0x1b7aa7){_0x10d830=_0x10d830-0x0;var _0x3814ee=_0x6d4a[_0x10d830];return _0x3814ee;};'use strict';var _=require('lodash');var util=require(_0xa6d4('0x0'));var moment=require(_0xa6d4('0x1'));var BPromise=require(_0xa6d4('0x2'));var rs=require(_0xa6d4('0x3'));var fs=require('fs');var Redis=require(_0xa6d4('0x4'));var db=require(_0xa6d4('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xa6d4('0x6'));var config=require(_0xa6d4('0x7'));var jayson=require(_0xa6d4('0x8'));var client=jayson[_0xa6d4('0x9')][_0xa6d4('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1f5951,_0x236df9,_0x4fea09){return new BPromise(function(_0x38a78c,_0x173aa2){return client['request'](_0x1f5951,_0x4fea09)[_0xa6d4('0xb')](function(_0x54770d){logger['info'](_0xa6d4('0xc'),_0x236df9,_0xa6d4('0xd'));logger['debug'](_0xa6d4('0xe'),_0x236df9,'request\x20sent',JSON[_0xa6d4('0xf')](_0x54770d));if(_0x54770d[_0xa6d4('0x10')]){if(_0x54770d[_0xa6d4('0x10')]['code']===0x1f4){logger[_0xa6d4('0x10')](_0xa6d4('0xc'),_0x236df9,_0x54770d['error'][_0xa6d4('0x11')]);return _0x173aa2(_0x54770d['error']['message']);}logger[_0xa6d4('0x10')](_0xa6d4('0xc'),_0x236df9,_0x54770d[_0xa6d4('0x10')][_0xa6d4('0x11')]);return _0x38a78c(_0x54770d['error'][_0xa6d4('0x11')]);}else{logger['info'](_0xa6d4('0xc'),_0x236df9,_0xa6d4('0xd'));_0x38a78c(_0x54770d[_0xa6d4('0x12')]['message']);}})['catch'](function(_0x40393c){logger[_0xa6d4('0x10')]('ChatQueueReport,\x20%s,\x20%s',_0x236df9,_0x40393c);_0x173aa2(_0x40393c);});});}exports[_0xa6d4('0x13')]=function(_0x35955d){var _0x1d4e4c=this;return new Promise(function(_0x482824,_0x1a909e){return db[_0xa6d4('0x14')][_0xa6d4('0x15')](_0x35955d[_0xa6d4('0x16')],{'raw':_0x35955d[_0xa6d4('0x17')]?_0x35955d[_0xa6d4('0x17')][_0xa6d4('0x18')]===undefined?!![]:![]:!![]})[_0xa6d4('0xb')](function(_0x125039){logger[_0xa6d4('0x19')](_0xa6d4('0x13'),_0x35955d);logger[_0xa6d4('0x1a')](_0xa6d4('0x13'),_0x35955d,JSON[_0xa6d4('0xf')](_0x125039));_0x482824(_0x125039);})[_0xa6d4('0x1b')](function(_0x371200){logger[_0xa6d4('0x10')](_0xa6d4('0x13'),_0x371200[_0xa6d4('0x11')],_0x35955d);_0x1a909e(_0x1d4e4c[_0xa6d4('0x10')](0x1f4,_0x371200[_0xa6d4('0x11')]));});});};exports[_0xa6d4('0x1c')]=function(_0x1fcd2f){var _0x11ec8d=this;return new Promise(function(_0x4b7563,_0x4b090d){return db[_0xa6d4('0x14')][_0xa6d4('0x1d')](_0x1fcd2f['body'],{'raw':_0x1fcd2f['options']?_0x1fcd2f[_0xa6d4('0x17')][_0xa6d4('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1fcd2f[_0xa6d4('0x17')]?_0x1fcd2f[_0xa6d4('0x17')][_0xa6d4('0x1e')]||null:null,'attributes':_0x1fcd2f[_0xa6d4('0x17')]?_0x1fcd2f[_0xa6d4('0x17')]['attributes']||null:null,'limit':_0x1fcd2f[_0xa6d4('0x17')]?_0x1fcd2f['options'][_0xa6d4('0x1f')]||null:null})['then'](function(_0x155f58){logger[_0xa6d4('0x19')](_0xa6d4('0x1c'),_0x1fcd2f);logger['debug'](_0xa6d4('0x1c'),_0x1fcd2f,JSON[_0xa6d4('0xf')](_0x155f58));_0x4b7563(_0x155f58);})[_0xa6d4('0x1b')](function(_0x431ff6){logger[_0xa6d4('0x10')](_0xa6d4('0x1c'),_0x431ff6[_0xa6d4('0x11')],_0x1fcd2f);_0x4b090d(_0x11ec8d['error'](0x1f4,_0x431ff6['message']));});});};