28851abbad6320fc8f20dbb8ab3d92d0af1460ed
[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 _0x6910=['debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','stringify','error','code','ReportAgentPreview,\x20%s,\x20%s','message','result','catch','CreateReportAgentPreview','ReportAgentPreview','options','lodash','util','moment','bluebird','randomstring','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent'];(function(_0x10b695,_0x1347c9){var _0x5a5a48=function(_0x421efa){while(--_0x421efa){_0x10b695['push'](_0x10b695['shift']());}};_0x5a5a48(++_0x1347c9);}(_0x6910,0x186));var _0x0691=function(_0xa72931,_0x37d87a){_0xa72931=_0xa72931-0x0;var _0x13b2f5=_0x6910[_0xa72931];return _0x13b2f5;};'use strict';var _=require(_0x0691('0x0'));var util=require(_0x0691('0x1'));var moment=require(_0x0691('0x2'));var BPromise=require(_0x0691('0x3'));var rs=require(_0x0691('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x0691('0x5'));var logger=require('../../config/logger')(_0x0691('0x6'));var config=require(_0x0691('0x7'));var jayson=require(_0x0691('0x8'));var client=jayson[_0x0691('0x9')][_0x0691('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3ce751,_0x1c4d51,_0x380bed){return new BPromise(function(_0x546275,_0x172603){return client[_0x0691('0xb')](_0x3ce751,_0x380bed)[_0x0691('0xc')](function(_0x446f2f){logger[_0x0691('0xd')]('ReportAgentPreview,\x20%s,\x20%s',_0x1c4d51,_0x0691('0xe'));logger[_0x0691('0xf')](_0x0691('0x10'),_0x1c4d51,'request\x20sent',JSON[_0x0691('0x11')](_0x446f2f));if(_0x446f2f['error']){if(_0x446f2f[_0x0691('0x12')][_0x0691('0x13')]===0x1f4){logger[_0x0691('0x12')](_0x0691('0x14'),_0x1c4d51,_0x446f2f[_0x0691('0x12')][_0x0691('0x15')]);return _0x172603(_0x446f2f[_0x0691('0x12')]['message']);}logger[_0x0691('0x12')](_0x0691('0x14'),_0x1c4d51,_0x446f2f[_0x0691('0x12')][_0x0691('0x15')]);return _0x546275(_0x446f2f[_0x0691('0x12')]['message']);}else{logger[_0x0691('0xd')](_0x0691('0x14'),_0x1c4d51,_0x0691('0xe'));_0x546275(_0x446f2f[_0x0691('0x16')]['message']);}})[_0x0691('0x17')](function(_0x586351){logger['error'](_0x0691('0x14'),_0x1c4d51,_0x586351);_0x172603(_0x586351);});});}exports[_0x0691('0x18')]=function(_0x107109){var _0x333a40=this;return new Promise(function(_0x2ab156,_0x5de59c){return db[_0x0691('0x19')]['create'](_0x107109['body'],{'raw':_0x107109['options']?_0x107109[_0x0691('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x0691('0xc')](function(_0x3af820){logger['info'](_0x0691('0x18'),_0x107109);logger[_0x0691('0xf')](_0x0691('0x18'),_0x107109,JSON[_0x0691('0x11')](_0x3af820));_0x2ab156(_0x3af820);})[_0x0691('0x17')](function(_0x172aaf){logger[_0x0691('0x12')](_0x0691('0x18'),_0x172aaf['message'],_0x107109);_0x5de59c(_0x333a40[_0x0691('0x12')](0x1f4,_0x172aaf[_0x0691('0x15')]));});});};