Built motion from commit 377f727e.|2.6.28
[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 _0x675a=['stringify','error','code','message','info','result','catch','CreateReportAgentPreview','options','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','ReportAgentPreview,\x20%s,\x20%s','debug','ReportAgentPreview,\x20%s,\x20%s,\x20%s','request\x20sent'];(function(_0x321777,_0x101b1c){var _0x4bacdb=function(_0x9b0b63){while(--_0x9b0b63){_0x321777['push'](_0x321777['shift']());}};_0x4bacdb(++_0x101b1c);}(_0x675a,0x1f0));var _0xa675=function(_0x35d2ec,_0x30848c){_0x35d2ec=_0x35d2ec-0x0;var _0x1ca87d=_0x675a[_0x35d2ec];return _0x1ca87d;};'use strict';var _=require('lodash');var util=require(_0xa675('0x0'));var moment=require(_0xa675('0x1'));var BPromise=require(_0xa675('0x2'));var rs=require(_0xa675('0x3'));var fs=require('fs');var Redis=require(_0xa675('0x4'));var db=require(_0xa675('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xa675('0x6'))('rpc');var config=require(_0xa675('0x7'));var jayson=require(_0xa675('0x8'));var client=jayson[_0xa675('0x9')][_0xa675('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3c9aeb,_0x5a4636,_0xc45a94){return new BPromise(function(_0x3aae41,_0x1e80b2){return client[_0xa675('0xb')](_0x3c9aeb,_0xc45a94)[_0xa675('0xc')](function(_0x37bba5){logger['info'](_0xa675('0xd'),_0x5a4636,'request\x20sent');logger[_0xa675('0xe')](_0xa675('0xf'),_0x5a4636,_0xa675('0x10'),JSON[_0xa675('0x11')](_0x37bba5));if(_0x37bba5[_0xa675('0x12')]){if(_0x37bba5[_0xa675('0x12')][_0xa675('0x13')]===0x1f4){logger[_0xa675('0x12')](_0xa675('0xd'),_0x5a4636,_0x37bba5[_0xa675('0x12')]['message']);return _0x1e80b2(_0x37bba5[_0xa675('0x12')][_0xa675('0x14')]);}logger[_0xa675('0x12')](_0xa675('0xd'),_0x5a4636,_0x37bba5[_0xa675('0x12')]['message']);return _0x3aae41(_0x37bba5[_0xa675('0x12')][_0xa675('0x14')]);}else{logger[_0xa675('0x15')](_0xa675('0xd'),_0x5a4636,_0xa675('0x10'));_0x3aae41(_0x37bba5[_0xa675('0x16')]['message']);}})[_0xa675('0x17')](function(_0xec35d1){logger['error'](_0xa675('0xd'),_0x5a4636,_0xec35d1);_0x1e80b2(_0xec35d1);});});}exports[_0xa675('0x18')]=function(_0x119a51){var _0x238204=this;return new Promise(function(_0x463f77,_0x41cca8){return db['ReportAgentPreview']['create'](_0x119a51['body'],{'raw':_0x119a51[_0xa675('0x19')]?_0x119a51[_0xa675('0x19')][_0xa675('0x1a')]===undefined?!![]:![]:!![]})[_0xa675('0xc')](function(_0x587652){logger[_0xa675('0x15')](_0xa675('0x18'),_0x119a51);logger[_0xa675('0xe')](_0xa675('0x18'),_0x119a51,JSON[_0xa675('0x11')](_0x587652));_0x463f77(_0x587652);})[_0xa675('0x17')](function(_0x59e818){logger[_0xa675('0x12')](_0xa675('0x18'),_0x59e818['message'],_0x119a51);_0x41cca8(_0x238204['error'](0x1f4,_0x59e818[_0xa675('0x14')]));});});};