046b59dc74135a6015fd062cb54c2347110127ef
[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 _0xafdc=['ChatQueueReport,\x20%s,\x20%s','message','create','options','raw','CreateChatQueueReport','stringify','catch','UpdateChatQueueReport','ChatQueueReport','update','body','where','attributes','limit','lodash','util','bluebird','randomstring','ioredis','../../config/utils','rpc','../../config/environment','client','http','request','then','info','request\x20sent','debug','error','code'];(function(_0x2cf2e9,_0xd58ea1){var _0xd3670d=function(_0x272868){while(--_0x272868){_0x2cf2e9['push'](_0x2cf2e9['shift']());}};_0xd3670d(++_0xd58ea1);}(_0xafdc,0x1af));var _0xcafd=function(_0x2ac608,_0x4ffc74){_0x2ac608=_0x2ac608-0x0;var _0x1e9151=_0xafdc[_0x2ac608];return _0x1e9151;};'use strict';var _=require(_0xcafd('0x0'));var util=require(_0xcafd('0x1'));var moment=require('moment');var BPromise=require(_0xcafd('0x2'));var rs=require(_0xcafd('0x3'));var fs=require('fs');var Redis=require(_0xcafd('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xcafd('0x5'));var logger=require('../../config/logger')(_0xcafd('0x6'));var config=require(_0xcafd('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xcafd('0x8')][_0xcafd('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x33710e,_0x26ebe6,_0x1568ca){return new BPromise(function(_0x186ce0,_0x175f56){return client[_0xcafd('0xa')](_0x33710e,_0x1568ca)[_0xcafd('0xb')](function(_0x37d151){logger[_0xcafd('0xc')]('ChatQueueReport,\x20%s,\x20%s',_0x26ebe6,_0xcafd('0xd'));logger[_0xcafd('0xe')]('ChatQueueReport,\x20%s,\x20%s,\x20%s',_0x26ebe6,_0xcafd('0xd'),JSON['stringify'](_0x37d151));if(_0x37d151[_0xcafd('0xf')]){if(_0x37d151[_0xcafd('0xf')][_0xcafd('0x10')]===0x1f4){logger[_0xcafd('0xf')](_0xcafd('0x11'),_0x26ebe6,_0x37d151['error'][_0xcafd('0x12')]);return _0x175f56(_0x37d151['error'][_0xcafd('0x12')]);}logger[_0xcafd('0xf')]('ChatQueueReport,\x20%s,\x20%s',_0x26ebe6,_0x37d151['error'][_0xcafd('0x12')]);return _0x186ce0(_0x37d151[_0xcafd('0xf')][_0xcafd('0x12')]);}else{logger[_0xcafd('0xc')]('ChatQueueReport,\x20%s,\x20%s',_0x26ebe6,'request\x20sent');_0x186ce0(_0x37d151['result'][_0xcafd('0x12')]);}})['catch'](function(_0x382551){logger[_0xcafd('0xf')](_0xcafd('0x11'),_0x26ebe6,_0x382551);_0x175f56(_0x382551);});});}exports['CreateChatQueueReport']=function(_0xe67922){var _0x5040af=this;return new Promise(function(_0x47f55a,_0x1abc43){return db['ChatQueueReport'][_0xcafd('0x13')](_0xe67922['body'],{'raw':_0xe67922[_0xcafd('0x14')]?_0xe67922[_0xcafd('0x14')][_0xcafd('0x15')]===undefined?!![]:![]:!![]})[_0xcafd('0xb')](function(_0xc28bcc){logger['info'](_0xcafd('0x16'),_0xe67922);logger[_0xcafd('0xe')](_0xcafd('0x16'),_0xe67922,JSON[_0xcafd('0x17')](_0xc28bcc));_0x47f55a(_0xc28bcc);})[_0xcafd('0x18')](function(_0x146f13){logger['error'](_0xcafd('0x16'),_0x146f13[_0xcafd('0x12')],_0xe67922);_0x1abc43(_0x5040af[_0xcafd('0xf')](0x1f4,_0x146f13[_0xcafd('0x12')]));});});};exports[_0xcafd('0x19')]=function(_0x59bb96){var _0x314b01=this;return new Promise(function(_0x343b35,_0x3ba3b1){return db[_0xcafd('0x1a')][_0xcafd('0x1b')](_0x59bb96[_0xcafd('0x1c')],{'raw':_0x59bb96[_0xcafd('0x14')]?_0x59bb96[_0xcafd('0x14')][_0xcafd('0x15')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x59bb96[_0xcafd('0x14')]?_0x59bb96[_0xcafd('0x14')][_0xcafd('0x1d')]||null:null,'attributes':_0x59bb96[_0xcafd('0x14')]?_0x59bb96['options'][_0xcafd('0x1e')]||null:null,'limit':_0x59bb96['options']?_0x59bb96['options'][_0xcafd('0x1f')]||null:null})[_0xcafd('0xb')](function(_0x5b5cf3){logger[_0xcafd('0xc')](_0xcafd('0x19'),_0x59bb96);logger['debug']('UpdateChatQueueReport',_0x59bb96,JSON[_0xcafd('0x17')](_0x5b5cf3));_0x343b35(_0x5b5cf3);})['catch'](function(_0x5be84a){logger['error'](_0xcafd('0x19'),_0x5be84a[_0xcafd('0x12')],_0x59bb96);_0x3ba3b1(_0x314b01[_0xcafd('0xf')](0x1f4,_0x5be84a[_0xcafd('0x12')]));});});};