b866e9161e4bb8f352fb49cee21a2f60bcd09cf4
[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 _0xfa83=['attributes','limit','UpdateSquareReport','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','jayson/promise','http','request','then','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','CreateSquareReport','SquareReport','body','options','raw','catch','update','where'];(function(_0x1c685f,_0x8411eb){var _0x42285f=function(_0x437112){while(--_0x437112){_0x1c685f['push'](_0x1c685f['shift']());}};_0x42285f(++_0x8411eb);}(_0xfa83,0x1a3));var _0x3fa8=function(_0x3daef9,_0x1c796f){_0x3daef9=_0x3daef9-0x0;var _0x49698=_0xfa83[_0x3daef9];return _0x49698;};'use strict';var _=require(_0x3fa8('0x0'));var util=require(_0x3fa8('0x1'));var moment=require(_0x3fa8('0x2'));var BPromise=require(_0x3fa8('0x3'));var rs=require(_0x3fa8('0x4'));var fs=require('fs');var Redis=require(_0x3fa8('0x5'));var db=require(_0x3fa8('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3fa8('0x7'));var config=require('../../config/environment');var jayson=require(_0x3fa8('0x8'));var client=jayson['client'][_0x3fa8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x31c2c3,_0x144ea7,_0x5b6a4c){return new BPromise(function(_0x3ff949,_0x5cbe7c){return client[_0x3fa8('0xa')](_0x31c2c3,_0x5b6a4c)[_0x3fa8('0xb')](function(_0x26d4f1){logger['info'](_0x3fa8('0xc'),_0x144ea7,_0x3fa8('0xd'));logger[_0x3fa8('0xe')](_0x3fa8('0xf'),_0x144ea7,_0x3fa8('0xd'),JSON[_0x3fa8('0x10')](_0x26d4f1));if(_0x26d4f1['error']){if(_0x26d4f1[_0x3fa8('0x11')]['code']===0x1f4){logger[_0x3fa8('0x11')]('SquareReport,\x20%s,\x20%s',_0x144ea7,_0x26d4f1['error']['message']);return _0x5cbe7c(_0x26d4f1[_0x3fa8('0x11')][_0x3fa8('0x12')]);}logger['error'](_0x3fa8('0xc'),_0x144ea7,_0x26d4f1[_0x3fa8('0x11')][_0x3fa8('0x12')]);return _0x3ff949(_0x26d4f1[_0x3fa8('0x11')][_0x3fa8('0x12')]);}else{logger[_0x3fa8('0x13')](_0x3fa8('0xc'),_0x144ea7,_0x3fa8('0xd'));_0x3ff949(_0x26d4f1[_0x3fa8('0x14')][_0x3fa8('0x12')]);}})['catch'](function(_0x582777){logger['error']('SquareReport,\x20%s,\x20%s',_0x144ea7,_0x582777);_0x5cbe7c(_0x582777);});});}exports[_0x3fa8('0x15')]=function(_0x1be0c2){var _0x564e35=this;return new Promise(function(_0x33ba3a,_0x3fbbcf){return db[_0x3fa8('0x16')]['create'](_0x1be0c2[_0x3fa8('0x17')],{'raw':_0x1be0c2[_0x3fa8('0x18')]?_0x1be0c2[_0x3fa8('0x18')][_0x3fa8('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x3ce4c0){logger[_0x3fa8('0x13')]('CreateSquareReport',_0x1be0c2);logger['debug'](_0x3fa8('0x15'),_0x1be0c2,JSON[_0x3fa8('0x10')](_0x3ce4c0));_0x33ba3a(_0x3ce4c0);})[_0x3fa8('0x1a')](function(_0x4706ea){logger[_0x3fa8('0x11')](_0x3fa8('0x15'),_0x4706ea['message'],_0x1be0c2);_0x3fbbcf(_0x564e35[_0x3fa8('0x11')](0x1f4,_0x4706ea[_0x3fa8('0x12')]));});});};exports['UpdateSquareReport']=function(_0x7e04d0){var _0xd733cc=this;return new Promise(function(_0x792066,_0x2b9757){return db['SquareReport'][_0x3fa8('0x1b')](_0x7e04d0[_0x3fa8('0x17')],{'raw':_0x7e04d0[_0x3fa8('0x18')]?_0x7e04d0[_0x3fa8('0x18')][_0x3fa8('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x7e04d0[_0x3fa8('0x18')]?_0x7e04d0['options'][_0x3fa8('0x1c')]||null:null,'attributes':_0x7e04d0[_0x3fa8('0x18')]?_0x7e04d0[_0x3fa8('0x18')][_0x3fa8('0x1d')]||null:null,'limit':_0x7e04d0['options']?_0x7e04d0[_0x3fa8('0x18')][_0x3fa8('0x1e')]||null:null})[_0x3fa8('0xb')](function(_0x19e19f){logger[_0x3fa8('0x13')](_0x3fa8('0x1f'),_0x7e04d0);logger[_0x3fa8('0xe')](_0x3fa8('0x1f'),_0x7e04d0,JSON['stringify'](_0x19e19f));_0x792066(_0x19e19f);})[_0x3fa8('0x1a')](function(_0x45e53b){logger[_0x3fa8('0x11')](_0x3fa8('0x1f'),_0x45e53b['message'],_0x7e04d0);_0x2b9757(_0xd733cc[_0x3fa8('0x11')](0x1f4,_0x45e53b[_0x3fa8('0x12')]));});});};