54652a506ccaed77a8e36050d67687d782d82f0e
[motion2.git] / server / api / reportAgentPreview / reportAgentPreview.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 _0x9f45=['request','ReportAgentPreview,\x20%s,\x20%s','request\x20sent','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','CreateReportAgentPreview','create','options','catch','lodash','util','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x4c7d90,_0x130199){var _0x48c35d=function(_0x534c91){while(--_0x534c91){_0x4c7d90['push'](_0x4c7d90['shift']());}};_0x48c35d(++_0x130199);}(_0x9f45,0x92));var _0x59f4=function(_0x48f74c,_0x1d725c){_0x48f74c=_0x48f74c-0x0;var _0x59eda5=_0x9f45[_0x48f74c];return _0x59eda5;};'use strict';var _=require(_0x59f4('0x0'));var util=require(_0x59f4('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x59f4('0x2'));var fs=require('fs');var Redis=require(_0x59f4('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x59f4('0x4'))(_0x59f4('0x5'));var config=require(_0x59f4('0x6'));var jayson=require(_0x59f4('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x3b3fc5,_0x543964,_0x5af8de){return new BPromise(function(_0x269589,_0x445a60){return client[_0x59f4('0x8')](_0x3b3fc5,_0x5af8de)['then'](function(_0x2ad443){logger['info'](_0x59f4('0x9'),_0x543964,_0x59f4('0xa'));logger[_0x59f4('0xb')](_0x59f4('0xc'),_0x543964,_0x59f4('0xa'),JSON[_0x59f4('0xd')](_0x2ad443));if(_0x2ad443[_0x59f4('0xe')]){if(_0x2ad443['error']['code']===0x1f4){logger['error'](_0x59f4('0x9'),_0x543964,_0x2ad443[_0x59f4('0xe')]['message']);return _0x445a60(_0x2ad443[_0x59f4('0xe')][_0x59f4('0xf')]);}logger[_0x59f4('0xe')]('ReportAgentPreview,\x20%s,\x20%s',_0x543964,_0x2ad443[_0x59f4('0xe')]['message']);return _0x269589(_0x2ad443['error']['message']);}else{logger[_0x59f4('0x10')](_0x59f4('0x9'),_0x543964,_0x59f4('0xa'));_0x269589(_0x2ad443[_0x59f4('0x11')][_0x59f4('0xf')]);}})['catch'](function(_0x2d6664){logger['error']('ReportAgentPreview,\x20%s,\x20%s',_0x543964,_0x2d6664);_0x445a60(_0x2d6664);});});}exports[_0x59f4('0x12')]=function(_0x19133e){var _0x52c1d2=this;return new Promise(function(_0x555664,_0x302077){return db['ReportAgentPreview'][_0x59f4('0x13')](_0x19133e['body'],{'raw':_0x19133e['options']?_0x19133e[_0x59f4('0x14')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x22eb08){logger[_0x59f4('0x10')]('CreateReportAgentPreview',_0x19133e);logger[_0x59f4('0xb')](_0x59f4('0x12'),_0x19133e,JSON['stringify'](_0x22eb08));_0x555664(_0x22eb08);})[_0x59f4('0x15')](function(_0x1a5b3a){logger[_0x59f4('0xe')](_0x59f4('0x12'),_0x1a5b3a[_0x59f4('0xf')],_0x19133e);_0x302077(_0x52c1d2[_0x59f4('0xe')](0x1f4,_0x1a5b3a[_0x59f4('0xf')]));});});};