fd712811265cab07f689c74c954fec912d343efd
[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 _0x20e6=['client','http','request','ChatQueueReport,\x20%s,\x20%s','request\x20sent','debug','ChatQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','CreateChatQueueReport','ChatQueueReport','create','body','raw','then','catch','update','options','where','attributes','UpdateChatQueueReport','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','jayson/promise'];(function(_0x3902c1,_0x1c9eb2){var _0x1266cc=function(_0x50c2c5){while(--_0x50c2c5){_0x3902c1['push'](_0x3902c1['shift']());}};_0x1266cc(++_0x1c9eb2);}(_0x20e6,0xd8));var _0x620e=function(_0x1b5c53,_0x371cb4){_0x1b5c53=_0x1b5c53-0x0;var _0x64c606=_0x20e6[_0x1b5c53];return _0x64c606;};'use strict';var _=require(_0x620e('0x0'));var util=require(_0x620e('0x1'));var moment=require(_0x620e('0x2'));var BPromise=require('bluebird');var rs=require(_0x620e('0x3'));var fs=require('fs');var Redis=require(_0x620e('0x4'));var db=require(_0x620e('0x5'))['db'];var utils=require(_0x620e('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x620e('0x7'));var client=jayson[_0x620e('0x8')][_0x620e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x57e3cc,_0x428fb9,_0x466fe3){return new BPromise(function(_0x33b534,_0xe2368d){return client[_0x620e('0xa')](_0x57e3cc,_0x466fe3)['then'](function(_0xb336ea){logger['info'](_0x620e('0xb'),_0x428fb9,_0x620e('0xc'));logger[_0x620e('0xd')](_0x620e('0xe'),_0x428fb9,_0x620e('0xc'),JSON[_0x620e('0xf')](_0xb336ea));if(_0xb336ea['error']){if(_0xb336ea[_0x620e('0x10')][_0x620e('0x11')]===0x1f4){logger['error'](_0x620e('0xb'),_0x428fb9,_0xb336ea[_0x620e('0x10')]['message']);return _0xe2368d(_0xb336ea[_0x620e('0x10')][_0x620e('0x12')]);}logger['error'](_0x620e('0xb'),_0x428fb9,_0xb336ea['error']['message']);return _0x33b534(_0xb336ea[_0x620e('0x10')][_0x620e('0x12')]);}else{logger[_0x620e('0x13')](_0x620e('0xb'),_0x428fb9,'request\x20sent');_0x33b534(_0xb336ea['result'][_0x620e('0x12')]);}})['catch'](function(_0x3801c9){logger[_0x620e('0x10')](_0x620e('0xb'),_0x428fb9,_0x3801c9);_0xe2368d(_0x3801c9);});});}exports[_0x620e('0x14')]=function(_0x16c603){var _0x289162=this;return new Promise(function(_0x2b9882,_0x1839da){return db[_0x620e('0x15')][_0x620e('0x16')](_0x16c603[_0x620e('0x17')],{'raw':_0x16c603['options']?_0x16c603['options'][_0x620e('0x18')]===undefined?!![]:![]:!![]})[_0x620e('0x19')](function(_0x2c722d){logger['info'](_0x620e('0x14'),_0x16c603);logger[_0x620e('0xd')](_0x620e('0x14'),_0x16c603,JSON[_0x620e('0xf')](_0x2c722d));_0x2b9882(_0x2c722d);})[_0x620e('0x1a')](function(_0x18575b){logger[_0x620e('0x10')]('CreateChatQueueReport',_0x18575b['message'],_0x16c603);_0x1839da(_0x289162[_0x620e('0x10')](0x1f4,_0x18575b[_0x620e('0x12')]));});});};exports['UpdateChatQueueReport']=function(_0x237572){var _0x4810a5=this;return new Promise(function(_0x3da715,_0x3125bb){return db[_0x620e('0x15')][_0x620e('0x1b')](_0x237572[_0x620e('0x17')],{'raw':_0x237572['options']?_0x237572[_0x620e('0x1c')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x237572[_0x620e('0x1c')]?_0x237572[_0x620e('0x1c')][_0x620e('0x1d')]||null:null,'attributes':_0x237572[_0x620e('0x1c')]?_0x237572['options'][_0x620e('0x1e')]||null:null,'limit':_0x237572[_0x620e('0x1c')]?_0x237572[_0x620e('0x1c')]['limit']||null:null})[_0x620e('0x19')](function(_0x5ae75e){logger['info']('UpdateChatQueueReport',_0x237572);logger[_0x620e('0xd')]('UpdateChatQueueReport',_0x237572,JSON[_0x620e('0xf')](_0x5ae75e));_0x3da715(_0x5ae75e);})[_0x620e('0x1a')](function(_0x29dd76){logger[_0x620e('0x10')](_0x620e('0x1f'),_0x29dd76[_0x620e('0x12')],_0x237572);_0x3125bb(_0x4810a5[_0x620e('0x10')](0x1f4,_0x29dd76['message']));});});};