ef36cc35fab9eb346acf72a0e4de228ef3fbf057
[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 _0x729c=['raw','CreateSquareReport','catch','SquareReport','update','where','attributes','limit','UpdateSquareReport','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','client','then','info','SquareReport,\x20%s,\x20%s','debug','stringify','code','error','message','request\x20sent','create','body','options'];(function(_0x4cdcea,_0x551728){var _0x335949=function(_0x2e1288){while(--_0x2e1288){_0x4cdcea['push'](_0x4cdcea['shift']());}};_0x335949(++_0x551728);}(_0x729c,0x1e9));var _0xc729=function(_0x1ef0c5,_0x49c061){_0x1ef0c5=_0x1ef0c5-0x0;var _0x114307=_0x729c[_0x1ef0c5];return _0x114307;};'use strict';var _=require(_0xc729('0x0'));var util=require('util');var moment=require(_0xc729('0x1'));var BPromise=require(_0xc729('0x2'));var rs=require(_0xc729('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc729('0x4'))['db'];var utils=require(_0xc729('0x5'));var logger=require('../../config/logger')(_0xc729('0x6'));var config=require(_0xc729('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xc729('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4366a7,_0xe06ac4,_0x29f344){return new BPromise(function(_0x49293c,_0x430c4e){return client['request'](_0x4366a7,_0x29f344)[_0xc729('0x9')](function(_0xedfec1){logger[_0xc729('0xa')](_0xc729('0xb'),_0xe06ac4,'request\x20sent');logger[_0xc729('0xc')]('SquareReport,\x20%s,\x20%s,\x20%s',_0xe06ac4,'request\x20sent',JSON[_0xc729('0xd')](_0xedfec1));if(_0xedfec1['error']){if(_0xedfec1['error'][_0xc729('0xe')]===0x1f4){logger[_0xc729('0xf')](_0xc729('0xb'),_0xe06ac4,_0xedfec1[_0xc729('0xf')][_0xc729('0x10')]);return _0x430c4e(_0xedfec1[_0xc729('0xf')][_0xc729('0x10')]);}logger['error'](_0xc729('0xb'),_0xe06ac4,_0xedfec1['error'][_0xc729('0x10')]);return _0x49293c(_0xedfec1[_0xc729('0xf')][_0xc729('0x10')]);}else{logger[_0xc729('0xa')]('SquareReport,\x20%s,\x20%s',_0xe06ac4,_0xc729('0x11'));_0x49293c(_0xedfec1['result'][_0xc729('0x10')]);}})['catch'](function(_0x29ece1){logger[_0xc729('0xf')](_0xc729('0xb'),_0xe06ac4,_0x29ece1);_0x430c4e(_0x29ece1);});});}exports['CreateSquareReport']=function(_0x1738a8){var _0x304159=this;return new Promise(function(_0x42d34e,_0x1f5d5f){return db['SquareReport'][_0xc729('0x12')](_0x1738a8[_0xc729('0x13')],{'raw':_0x1738a8[_0xc729('0x14')]?_0x1738a8['options'][_0xc729('0x15')]===undefined?!![]:![]:!![]})[_0xc729('0x9')](function(_0x4bdef3){logger[_0xc729('0xa')](_0xc729('0x16'),_0x1738a8);logger['debug']('CreateSquareReport',_0x1738a8,JSON[_0xc729('0xd')](_0x4bdef3));_0x42d34e(_0x4bdef3);})[_0xc729('0x17')](function(_0x5e5f25){logger['error'](_0xc729('0x16'),_0x5e5f25[_0xc729('0x10')],_0x1738a8);_0x1f5d5f(_0x304159[_0xc729('0xf')](0x1f4,_0x5e5f25[_0xc729('0x10')]));});});};exports['UpdateSquareReport']=function(_0x506f38){var _0x351d31=this;return new Promise(function(_0x1d2386,_0x215259){return db[_0xc729('0x18')][_0xc729('0x19')](_0x506f38[_0xc729('0x13')],{'raw':_0x506f38['options']?_0x506f38['options'][_0xc729('0x15')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x506f38[_0xc729('0x14')]?_0x506f38[_0xc729('0x14')][_0xc729('0x1a')]||null:null,'attributes':_0x506f38[_0xc729('0x14')]?_0x506f38[_0xc729('0x14')][_0xc729('0x1b')]||null:null,'limit':_0x506f38['options']?_0x506f38[_0xc729('0x14')][_0xc729('0x1c')]||null:null})[_0xc729('0x9')](function(_0x1a1149){logger[_0xc729('0xa')](_0xc729('0x1d'),_0x506f38);logger['debug'](_0xc729('0x1d'),_0x506f38,JSON[_0xc729('0xd')](_0x1a1149));_0x1d2386(_0x1a1149);})['catch'](function(_0x1a6aea){logger[_0xc729('0xf')]('UpdateSquareReport',_0x1a6aea[_0xc729('0x10')],_0x506f38);_0x215259(_0x351d31[_0xc729('0xf')](0x1f4,_0x1a6aea[_0xc729('0x10')]));});});};