Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / squareReport / squareReport.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 _0x8ca0=['raw','where','attributes','limit','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','request','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','SquareReport','create','body','options','then','CreateSquareReport','UpdateSquareReport','update'];(function(_0x4f9f37,_0x1c2b67){var _0x370c88=function(_0x37641b){while(--_0x37641b){_0x4f9f37['push'](_0x4f9f37['shift']());}};_0x370c88(++_0x1c2b67);}(_0x8ca0,0x6a));var _0x08ca=function(_0x3601b6,_0x7b6214){_0x3601b6=_0x3601b6-0x0;var _0x169995=_0x8ca0[_0x3601b6];return _0x169995;};'use strict';var _=require(_0x08ca('0x0'));var util=require('util');var moment=require(_0x08ca('0x1'));var BPromise=require(_0x08ca('0x2'));var rs=require(_0x08ca('0x3'));var fs=require('fs');var Redis=require(_0x08ca('0x4'));var db=require(_0x08ca('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x08ca('0x6'))(_0x08ca('0x7'));var config=require('../../config/environment');var jayson=require(_0x08ca('0x8'));var client=jayson[_0x08ca('0x9')][_0x08ca('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x28d3d3,_0x441725,_0x2da9ca){return new BPromise(function(_0x2996f3,_0x1009cc){return client[_0x08ca('0xb')](_0x28d3d3,_0x2da9ca)['then'](function(_0x10d432){logger[_0x08ca('0xc')](_0x08ca('0xd'),_0x441725,_0x08ca('0xe'));logger[_0x08ca('0xf')]('SquareReport,\x20%s,\x20%s,\x20%s',_0x441725,_0x08ca('0xe'),JSON[_0x08ca('0x10')](_0x10d432));if(_0x10d432[_0x08ca('0x11')]){if(_0x10d432[_0x08ca('0x11')][_0x08ca('0x12')]===0x1f4){logger[_0x08ca('0x11')]('SquareReport,\x20%s,\x20%s',_0x441725,_0x10d432[_0x08ca('0x11')][_0x08ca('0x13')]);return _0x1009cc(_0x10d432[_0x08ca('0x11')][_0x08ca('0x13')]);}logger[_0x08ca('0x11')](_0x08ca('0xd'),_0x441725,_0x10d432[_0x08ca('0x11')]['message']);return _0x2996f3(_0x10d432[_0x08ca('0x11')]['message']);}else{logger[_0x08ca('0xc')](_0x08ca('0xd'),_0x441725,'request\x20sent');_0x2996f3(_0x10d432[_0x08ca('0x14')][_0x08ca('0x13')]);}})[_0x08ca('0x15')](function(_0x328efa){logger[_0x08ca('0x11')](_0x08ca('0xd'),_0x441725,_0x328efa);_0x1009cc(_0x328efa);});});}exports['CreateSquareReport']=function(_0x204fe2){var _0x5cbb68=this;return new Promise(function(_0x308684,_0x92a3d7){return db[_0x08ca('0x16')][_0x08ca('0x17')](_0x204fe2[_0x08ca('0x18')],{'raw':_0x204fe2[_0x08ca('0x19')]?_0x204fe2[_0x08ca('0x19')]['raw']===undefined?!![]:![]:!![]})[_0x08ca('0x1a')](function(_0x3dcb23){logger[_0x08ca('0xc')](_0x08ca('0x1b'),_0x204fe2);logger['debug'](_0x08ca('0x1b'),_0x204fe2,JSON['stringify'](_0x3dcb23));_0x308684(_0x3dcb23);})[_0x08ca('0x15')](function(_0x368329){logger['error']('CreateSquareReport',_0x368329[_0x08ca('0x13')],_0x204fe2);_0x92a3d7(_0x5cbb68[_0x08ca('0x11')](0x1f4,_0x368329[_0x08ca('0x13')]));});});};exports[_0x08ca('0x1c')]=function(_0x525bb6){var _0x2ded3d=this;return new Promise(function(_0x46288e,_0x45f9b4){return db['SquareReport'][_0x08ca('0x1d')](_0x525bb6[_0x08ca('0x18')],{'raw':_0x525bb6[_0x08ca('0x19')]?_0x525bb6[_0x08ca('0x19')][_0x08ca('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x525bb6[_0x08ca('0x19')]?_0x525bb6[_0x08ca('0x19')][_0x08ca('0x1f')]||null:null,'attributes':_0x525bb6[_0x08ca('0x19')]?_0x525bb6[_0x08ca('0x19')][_0x08ca('0x20')]||null:null,'limit':_0x525bb6[_0x08ca('0x19')]?_0x525bb6[_0x08ca('0x19')][_0x08ca('0x21')]||null:null})[_0x08ca('0x1a')](function(_0x4e24eb){logger['info'](_0x08ca('0x1c'),_0x525bb6);logger[_0x08ca('0xf')](_0x08ca('0x1c'),_0x525bb6,JSON[_0x08ca('0x10')](_0x4e24eb));_0x46288e(_0x4e24eb);})['catch'](function(_0x557319){logger[_0x08ca('0x11')](_0x08ca('0x1c'),_0x557319[_0x08ca('0x13')],_0x525bb6);_0x45f9b4(_0x2ded3d[_0x08ca('0x11')](0x1f4,_0x557319[_0x08ca('0x13')]));});});};