689c49c38e0d2aa223a6950e8d71e3dcafae24ef
[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 _0x42cb=['body','options','raw','lodash','moment','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','then','ReportAgentPreview,\x20%s,\x20%s','request\x20sent','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','CreateReportAgentPreview','ReportAgentPreview'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x42cb,0x1ac));var _0xb42c=function(_0x135c4f,_0x27293a){_0x135c4f=_0x135c4f-0x0;var _0x168d47=_0x42cb[_0x135c4f];return _0x168d47;};'use strict';var _=require(_0xb42c('0x0'));var util=require('util');var moment=require(_0xb42c('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xb42c('0x2'));var logger=require(_0xb42c('0x3'))('rpc');var config=require(_0xb42c('0x4'));var jayson=require(_0xb42c('0x5'));var client=jayson[_0xb42c('0x6')][_0xb42c('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x220e46,_0x428f3c,_0xa33879){return new BPromise(function(_0x5195a3,_0x269480){return client['request'](_0x220e46,_0xa33879)[_0xb42c('0x8')](function(_0x2b6e4f){logger['info'](_0xb42c('0x9'),_0x428f3c,_0xb42c('0xa'));logger[_0xb42c('0xb')](_0xb42c('0xc'),_0x428f3c,_0xb42c('0xa'),JSON[_0xb42c('0xd')](_0x2b6e4f));if(_0x2b6e4f[_0xb42c('0xe')]){if(_0x2b6e4f[_0xb42c('0xe')][_0xb42c('0xf')]===0x1f4){logger[_0xb42c('0xe')](_0xb42c('0x9'),_0x428f3c,_0x2b6e4f['error'][_0xb42c('0x10')]);return _0x269480(_0x2b6e4f[_0xb42c('0xe')][_0xb42c('0x10')]);}logger[_0xb42c('0xe')](_0xb42c('0x9'),_0x428f3c,_0x2b6e4f[_0xb42c('0xe')][_0xb42c('0x10')]);return _0x5195a3(_0x2b6e4f['error']['message']);}else{logger[_0xb42c('0x11')]('ReportAgentPreview,\x20%s,\x20%s',_0x428f3c,_0xb42c('0xa'));_0x5195a3(_0x2b6e4f[_0xb42c('0x12')]['message']);}})[_0xb42c('0x13')](function(_0x3d5f05){logger['error'](_0xb42c('0x9'),_0x428f3c,_0x3d5f05);_0x269480(_0x3d5f05);});});}exports[_0xb42c('0x14')]=function(_0x2ac812){var _0x431ab5=this;return new Promise(function(_0x48c846,_0x1f6ff6){return db[_0xb42c('0x15')]['create'](_0x2ac812[_0xb42c('0x16')],{'raw':_0x2ac812[_0xb42c('0x17')]?_0x2ac812[_0xb42c('0x17')][_0xb42c('0x18')]===undefined?!![]:![]:!![]})[_0xb42c('0x8')](function(_0x1727ae){logger['info'](_0xb42c('0x14'),_0x2ac812);logger[_0xb42c('0xb')](_0xb42c('0x14'),_0x2ac812,JSON[_0xb42c('0xd')](_0x1727ae));_0x48c846(_0x1727ae);})[_0xb42c('0x13')](function(_0xbbe068){logger[_0xb42c('0xe')](_0xb42c('0x14'),_0xbbe068[_0xb42c('0x10')],_0x2ac812);_0x1f6ff6(_0x431ab5[_0xb42c('0xe')](0x1f4,_0xbbe068[_0xb42c('0x10')]));});});};