04dc4c271c4de6889f8b0451b5190eb57cfcba51
[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 _0xa82b=['stringify','error','message','result','CreateChatQueueReport','create','body','options','raw','catch','UpdateChatQueueReport','ChatQueueReport','update','where','lodash','util','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','request','then','info','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa82b,0x1b2));var _0xba82=function(_0x5aada8,_0x460a35){_0x5aada8=_0x5aada8-0x0;var _0xf5247e=_0xa82b[_0x5aada8];return _0xf5247e;};'use strict';var _=require(_0xba82('0x0'));var util=require(_0xba82('0x1'));var moment=require('moment');var BPromise=require(_0xba82('0x2'));var rs=require(_0xba82('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xba82('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xba82('0x5'));var config=require(_0xba82('0x6'));var jayson=require(_0xba82('0x7'));var client=jayson[_0xba82('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x492416,_0x30450f,_0x5bdc0b){return new BPromise(function(_0x4c3f12,_0x41de41){return client[_0xba82('0x9')](_0x492416,_0x5bdc0b)[_0xba82('0xa')](function(_0x4e9fc0){logger[_0xba82('0xb')](_0xba82('0xc'),_0x30450f,_0xba82('0xd'));logger[_0xba82('0xe')](_0xba82('0xf'),_0x30450f,'request\x20sent',JSON[_0xba82('0x10')](_0x4e9fc0));if(_0x4e9fc0['error']){if(_0x4e9fc0['error']['code']===0x1f4){logger['error'](_0xba82('0xc'),_0x30450f,_0x4e9fc0[_0xba82('0x11')][_0xba82('0x12')]);return _0x41de41(_0x4e9fc0[_0xba82('0x11')][_0xba82('0x12')]);}logger[_0xba82('0x11')](_0xba82('0xc'),_0x30450f,_0x4e9fc0[_0xba82('0x11')]['message']);return _0x4c3f12(_0x4e9fc0[_0xba82('0x11')][_0xba82('0x12')]);}else{logger['info'](_0xba82('0xc'),_0x30450f,_0xba82('0xd'));_0x4c3f12(_0x4e9fc0[_0xba82('0x13')][_0xba82('0x12')]);}})['catch'](function(_0x1d26ab){logger[_0xba82('0x11')](_0xba82('0xc'),_0x30450f,_0x1d26ab);_0x41de41(_0x1d26ab);});});}exports[_0xba82('0x14')]=function(_0x12939f){var _0x1ecedc=this;return new Promise(function(_0xc2da,_0x3a12fe){return db['ChatQueueReport'][_0xba82('0x15')](_0x12939f[_0xba82('0x16')],{'raw':_0x12939f[_0xba82('0x17')]?_0x12939f[_0xba82('0x17')][_0xba82('0x18')]===undefined?!![]:![]:!![]})[_0xba82('0xa')](function(_0x2781db){logger[_0xba82('0xb')](_0xba82('0x14'),_0x12939f);logger[_0xba82('0xe')](_0xba82('0x14'),_0x12939f,JSON[_0xba82('0x10')](_0x2781db));_0xc2da(_0x2781db);})[_0xba82('0x19')](function(_0x1a9909){logger[_0xba82('0x11')](_0xba82('0x14'),_0x1a9909[_0xba82('0x12')],_0x12939f);_0x3a12fe(_0x1ecedc[_0xba82('0x11')](0x1f4,_0x1a9909['message']));});});};exports[_0xba82('0x1a')]=function(_0xb796dd){var _0x53789c=this;return new Promise(function(_0x2aa7e1,_0x8cc5df){return db[_0xba82('0x1b')][_0xba82('0x1c')](_0xb796dd[_0xba82('0x16')],{'raw':_0xb796dd[_0xba82('0x17')]?_0xb796dd[_0xba82('0x17')][_0xba82('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb796dd['options']?_0xb796dd[_0xba82('0x17')][_0xba82('0x1d')]||null:null,'attributes':_0xb796dd['options']?_0xb796dd['options']['attributes']||null:null,'limit':_0xb796dd['options']?_0xb796dd['options']['limit']||null:null})[_0xba82('0xa')](function(_0x1cc721){logger['info'](_0xba82('0x1a'),_0xb796dd);logger['debug'](_0xba82('0x1a'),_0xb796dd,JSON[_0xba82('0x10')](_0x1cc721));_0x2aa7e1(_0x1cc721);})[_0xba82('0x19')](function(_0x3143dc){logger[_0xba82('0x11')](_0xba82('0x1a'),_0x3143dc[_0xba82('0x12')],_0xb796dd);_0x8cc5df(_0x53789c[_0xba82('0x11')](0x1f4,_0x3143dc['message']));});});};