91f38d0f0a75c90205ea6dd0fe7f882d40dbfbbf
[motion2.git] / server / api / squareReportDetail / squareReportDetail.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 _0xb8a0=['raw','moment','bluebird','ioredis','../../config/environment','jayson/promise','client','http','request','then','info','SquareDetailsReport,\x20%s,\x20%s','request\x20sent','debug','SquareDetailsReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareDetailsReport','SquareDetailsReport','create','body','options'];(function(_0x4164f2,_0x38669f){var _0x2575c7=function(_0x24dca1){while(--_0x24dca1){_0x4164f2['push'](_0x4164f2['shift']());}};_0x2575c7(++_0x38669f);}(_0xb8a0,0x1d5));var _0x0b8a=function(_0x2286ff,_0x2a07d5){_0x2286ff=_0x2286ff-0x0;var _0x5ace0a=_0xb8a0[_0x2286ff];return _0x5ace0a;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x0b8a('0x0'));var BPromise=require(_0x0b8a('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0b8a('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x0b8a('0x3'));var jayson=require(_0x0b8a('0x4'));var client=jayson[_0x0b8a('0x5')][_0x0b8a('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x3527dd,_0x4039c2,_0x33a5bd){return new BPromise(function(_0x463015,_0x29ebdc){return client[_0x0b8a('0x7')](_0x3527dd,_0x33a5bd)[_0x0b8a('0x8')](function(_0x478492){logger[_0x0b8a('0x9')](_0x0b8a('0xa'),_0x4039c2,_0x0b8a('0xb'));logger[_0x0b8a('0xc')](_0x0b8a('0xd'),_0x4039c2,_0x0b8a('0xb'),JSON[_0x0b8a('0xe')](_0x478492));if(_0x478492[_0x0b8a('0xf')]){if(_0x478492[_0x0b8a('0xf')][_0x0b8a('0x10')]===0x1f4){logger['error'](_0x0b8a('0xa'),_0x4039c2,_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);return _0x29ebdc(_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);}logger[_0x0b8a('0xf')](_0x0b8a('0xa'),_0x4039c2,_0x478492[_0x0b8a('0xf')][_0x0b8a('0x11')]);return _0x463015(_0x478492['error'][_0x0b8a('0x11')]);}else{logger[_0x0b8a('0x9')](_0x0b8a('0xa'),_0x4039c2,'request\x20sent');_0x463015(_0x478492[_0x0b8a('0x12')][_0x0b8a('0x11')]);}})[_0x0b8a('0x13')](function(_0x5a2623){logger['error']('SquareDetailsReport,\x20%s,\x20%s',_0x4039c2,_0x5a2623);_0x29ebdc(_0x5a2623);});});}exports[_0x0b8a('0x14')]=function(_0x51d28e){var _0x1a1d6b=this;return new Promise(function(_0x3c80c3,_0x12428e){return db[_0x0b8a('0x15')][_0x0b8a('0x16')](_0x51d28e[_0x0b8a('0x17')],{'raw':_0x51d28e[_0x0b8a('0x18')]?_0x51d28e[_0x0b8a('0x18')][_0x0b8a('0x19')]===undefined?!![]:![]:!![]})[_0x0b8a('0x8')](function(_0x313612){logger['info'](_0x0b8a('0x14'),_0x51d28e);logger[_0x0b8a('0xc')]('CreateSquareDetailsReport',_0x51d28e,JSON[_0x0b8a('0xe')](_0x313612));_0x3c80c3(_0x313612);})[_0x0b8a('0x13')](function(_0xba351e){logger[_0x0b8a('0xf')]('CreateSquareDetailsReport',_0xba351e[_0x0b8a('0x11')],_0x51d28e);_0x12428e(_0x1a1d6b['error'](0x1f4,_0xba351e[_0x0b8a('0x11')]));});});};