Built motion from commit d9028345.|2.5.43
[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 _0x8a83=['catch','CreateSquareReport','SquareReport','create','options','raw','stringify','UpdateSquareReport','update','body','attributes','limit','lodash','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','code','error','message','result'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x8a83,0x1b9));var _0x38a8=function(_0x3ab353,_0x5d5283){_0x3ab353=_0x3ab353-0x0;var _0x1e2285=_0x8a83[_0x3ab353];return _0x1e2285;};'use strict';var _=require(_0x38a8('0x0'));var util=require(_0x38a8('0x1'));var moment=require('moment');var BPromise=require(_0x38a8('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x38a8('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x38a8('0x4'));var logger=require(_0x38a8('0x5'))(_0x38a8('0x6'));var config=require(_0x38a8('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x38a8('0x8')][_0x38a8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4ef55b,_0x46e72d,_0x488d77){return new BPromise(function(_0x60c979,_0x45ae61){return client[_0x38a8('0xa')](_0x4ef55b,_0x488d77)[_0x38a8('0xb')](function(_0x3eb49d){logger[_0x38a8('0xc')](_0x38a8('0xd'),_0x46e72d,_0x38a8('0xe'));logger[_0x38a8('0xf')](_0x38a8('0x10'),_0x46e72d,_0x38a8('0xe'),JSON['stringify'](_0x3eb49d));if(_0x3eb49d['error']){if(_0x3eb49d['error'][_0x38a8('0x11')]===0x1f4){logger[_0x38a8('0x12')](_0x38a8('0xd'),_0x46e72d,_0x3eb49d[_0x38a8('0x12')][_0x38a8('0x13')]);return _0x45ae61(_0x3eb49d['error']['message']);}logger['error']('SquareReport,\x20%s,\x20%s',_0x46e72d,_0x3eb49d['error'][_0x38a8('0x13')]);return _0x60c979(_0x3eb49d[_0x38a8('0x12')]['message']);}else{logger['info']('SquareReport,\x20%s,\x20%s',_0x46e72d,'request\x20sent');_0x60c979(_0x3eb49d[_0x38a8('0x14')][_0x38a8('0x13')]);}})[_0x38a8('0x15')](function(_0x9846b){logger[_0x38a8('0x12')](_0x38a8('0xd'),_0x46e72d,_0x9846b);_0x45ae61(_0x9846b);});});}exports[_0x38a8('0x16')]=function(_0x22e69d){var _0x1bc5b9=this;return new Promise(function(_0x4626fc,_0x366948){return db[_0x38a8('0x17')][_0x38a8('0x18')](_0x22e69d['body'],{'raw':_0x22e69d[_0x38a8('0x19')]?_0x22e69d[_0x38a8('0x19')][_0x38a8('0x1a')]===undefined?!![]:![]:!![]})[_0x38a8('0xb')](function(_0x2702e1){logger[_0x38a8('0xc')]('CreateSquareReport',_0x22e69d);logger['debug']('CreateSquareReport',_0x22e69d,JSON[_0x38a8('0x1b')](_0x2702e1));_0x4626fc(_0x2702e1);})['catch'](function(_0x53851d){logger['error'](_0x38a8('0x16'),_0x53851d[_0x38a8('0x13')],_0x22e69d);_0x366948(_0x1bc5b9[_0x38a8('0x12')](0x1f4,_0x53851d[_0x38a8('0x13')]));});});};exports[_0x38a8('0x1c')]=function(_0x1532ec){var _0x24a0b4=this;return new Promise(function(_0x88a7f9,_0x5171e6){return db[_0x38a8('0x17')][_0x38a8('0x1d')](_0x1532ec[_0x38a8('0x1e')],{'raw':_0x1532ec[_0x38a8('0x19')]?_0x1532ec['options'][_0x38a8('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1532ec['options']?_0x1532ec['options']['where']||null:null,'attributes':_0x1532ec[_0x38a8('0x19')]?_0x1532ec[_0x38a8('0x19')][_0x38a8('0x1f')]||null:null,'limit':_0x1532ec[_0x38a8('0x19')]?_0x1532ec[_0x38a8('0x19')][_0x38a8('0x20')]||null:null})[_0x38a8('0xb')](function(_0x47a57b){logger['info'](_0x38a8('0x1c'),_0x1532ec);logger['debug']('UpdateSquareReport',_0x1532ec,JSON['stringify'](_0x47a57b));_0x88a7f9(_0x47a57b);})[_0x38a8('0x15')](function(_0x2083c0){logger[_0x38a8('0x12')]('UpdateSquareReport',_0x2083c0[_0x38a8('0x13')],_0x1532ec);_0x5171e6(_0x24a0b4[_0x38a8('0x12')](0x1f4,_0x2083c0['message']));});});};