Built motion from commit b5996064.|2.6.21
[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 _0x5285=['options','raw','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','ReportAgentPreview,\x20%s,\x20%s','request\x20sent','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','CreateReportAgentPreview','create','body'];(function(_0x4792c8,_0x5158a1){var _0x35edb1=function(_0x2472d3){while(--_0x2472d3){_0x4792c8['push'](_0x4792c8['shift']());}};_0x35edb1(++_0x5158a1);}(_0x5285,0x106));var _0x5528=function(_0x1e381c,_0x47b5b9){_0x1e381c=_0x1e381c-0x0;var _0x9b5ea9=_0x5285[_0x1e381c];return _0x9b5ea9;};'use strict';var _=require(_0x5528('0x0'));var util=require('util');var moment=require(_0x5528('0x1'));var BPromise=require(_0x5528('0x2'));var rs=require(_0x5528('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5528('0x4'))['db'];var utils=require(_0x5528('0x5'));var logger=require('../../config/logger')(_0x5528('0x6'));var config=require(_0x5528('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x5528('0x8')][_0x5528('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x10686a,_0x161b5c,_0x469c48){return new BPromise(function(_0x15cda2,_0x56a87c){return client[_0x5528('0xa')](_0x10686a,_0x469c48)['then'](function(_0x2fc6fb){logger['info'](_0x5528('0xb'),_0x161b5c,_0x5528('0xc'));logger[_0x5528('0xd')](_0x5528('0xe'),_0x161b5c,_0x5528('0xc'),JSON[_0x5528('0xf')](_0x2fc6fb));if(_0x2fc6fb[_0x5528('0x10')]){if(_0x2fc6fb[_0x5528('0x10')]['code']===0x1f4){logger[_0x5528('0x10')](_0x5528('0xb'),_0x161b5c,_0x2fc6fb[_0x5528('0x10')][_0x5528('0x11')]);return _0x56a87c(_0x2fc6fb['error']['message']);}logger[_0x5528('0x10')](_0x5528('0xb'),_0x161b5c,_0x2fc6fb[_0x5528('0x10')][_0x5528('0x11')]);return _0x15cda2(_0x2fc6fb['error'][_0x5528('0x11')]);}else{logger[_0x5528('0x12')](_0x5528('0xb'),_0x161b5c,'request\x20sent');_0x15cda2(_0x2fc6fb[_0x5528('0x13')][_0x5528('0x11')]);}})[_0x5528('0x14')](function(_0x21e714){logger[_0x5528('0x10')](_0x5528('0xb'),_0x161b5c,_0x21e714);_0x56a87c(_0x21e714);});});}exports[_0x5528('0x15')]=function(_0x35167b){var _0x2ae4d4=this;return new Promise(function(_0x42ec47,_0x3f4ca8){return db['ReportAgentPreview'][_0x5528('0x16')](_0x35167b[_0x5528('0x17')],{'raw':_0x35167b['options']?_0x35167b[_0x5528('0x18')][_0x5528('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x384d97){logger[_0x5528('0x12')]('CreateReportAgentPreview',_0x35167b);logger[_0x5528('0xd')](_0x5528('0x15'),_0x35167b,JSON[_0x5528('0xf')](_0x384d97));_0x42ec47(_0x384d97);})[_0x5528('0x14')](function(_0x26ddc){logger['error'](_0x5528('0x15'),_0x26ddc['message'],_0x35167b);_0x3f4ca8(_0x2ae4d4[_0x5528('0x10')](0x1f4,_0x26ddc['message']));});});};