Built motion from commit (unavailable).|2.0.77
[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 _0xdcd3=['bluebird','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','request','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','error','code','message','CreateSquareReport','options','raw','then','stringify','UpdateSquareReport','SquareReport','update','body','where','attributes','limit','util'];(function(_0xc4c9c5,_0x342b0c){var _0x19d614=function(_0x4321ee){while(--_0x4321ee){_0xc4c9c5['push'](_0xc4c9c5['shift']());}};_0x19d614(++_0x342b0c);}(_0xdcd3,0xad));var _0x3dcd=function(_0x53e3de,_0x48b3ce){_0x53e3de=_0x53e3de-0x0;var _0x5922b8=_0xdcd3[_0x53e3de];return _0x5922b8;};'use strict';var _=require('lodash');var util=require(_0x3dcd('0x0'));var moment=require('moment');var BPromise=require(_0x3dcd('0x1'));var rs=require('randomstring');var fs=require('fs');var db=require(_0x3dcd('0x2'))['db'];var utils=require(_0x3dcd('0x3'));var logger=require(_0x3dcd('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x3dcd('0x5'));var client=jayson[_0x3dcd('0x6')][_0x3dcd('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x3db1b0,_0x3192d2,_0x45bd7f){return new BPromise(function(_0x1c866d,_0x3641a9){return client[_0x3dcd('0x8')](_0x3db1b0,_0x45bd7f)['then'](function(_0x208206){logger[_0x3dcd('0x9')](_0x3dcd('0xa'),_0x3192d2,_0x3dcd('0xb'));logger[_0x3dcd('0xc')](_0x3dcd('0xd'),_0x3192d2,_0x3dcd('0xb'),JSON['stringify'](_0x208206));if(_0x208206[_0x3dcd('0xe')]){if(_0x208206[_0x3dcd('0xe')][_0x3dcd('0xf')]===0x1f4){logger[_0x3dcd('0xe')](_0x3dcd('0xa'),_0x3192d2,_0x208206['error']['message']);return _0x3641a9(_0x208206['error'][_0x3dcd('0x10')]);}logger[_0x3dcd('0xe')](_0x3dcd('0xa'),_0x3192d2,_0x208206[_0x3dcd('0xe')][_0x3dcd('0x10')]);return _0x1c866d(_0x208206[_0x3dcd('0xe')][_0x3dcd('0x10')]);}else{logger[_0x3dcd('0x9')](_0x3dcd('0xa'),_0x3192d2,_0x3dcd('0xb'));_0x1c866d(_0x208206['result'][_0x3dcd('0x10')]);}})['catch'](function(_0x5abcfc){logger[_0x3dcd('0xe')]('SquareReport,\x20%s,\x20%s',_0x3192d2,_0x5abcfc);_0x3641a9(_0x5abcfc);});});}exports[_0x3dcd('0x11')]=function(_0x2caaf3){var _0x16369f=this;return new Promise(function(_0x7d89f7,_0x179cbe){return db['SquareReport']['create'](_0x2caaf3['body'],{'raw':_0x2caaf3[_0x3dcd('0x12')]?_0x2caaf3[_0x3dcd('0x12')][_0x3dcd('0x13')]===undefined?!![]:![]:!![]})[_0x3dcd('0x14')](function(_0xfebe06){logger[_0x3dcd('0x9')]('CreateSquareReport',_0x2caaf3);logger[_0x3dcd('0xc')](_0x3dcd('0x11'),_0x2caaf3,JSON[_0x3dcd('0x15')](_0xfebe06));_0x7d89f7(_0xfebe06);})['catch'](function(_0x40104d){logger[_0x3dcd('0xe')](_0x3dcd('0x11'),_0x40104d['message'],_0x2caaf3);_0x179cbe(_0x16369f[_0x3dcd('0xe')](0x1f4,_0x40104d[_0x3dcd('0x10')]));});});};exports[_0x3dcd('0x16')]=function(_0x48f1a7){var _0x1e408a=this;return new Promise(function(_0x1a189c,_0x441c1f){return db[_0x3dcd('0x17')][_0x3dcd('0x18')](_0x48f1a7[_0x3dcd('0x19')],{'raw':_0x48f1a7[_0x3dcd('0x12')]?_0x48f1a7[_0x3dcd('0x12')][_0x3dcd('0x13')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x48f1a7['options']?_0x48f1a7[_0x3dcd('0x12')][_0x3dcd('0x1a')]||null:null,'attributes':_0x48f1a7[_0x3dcd('0x12')]?_0x48f1a7[_0x3dcd('0x12')][_0x3dcd('0x1b')]||null:null,'limit':_0x48f1a7[_0x3dcd('0x12')]?_0x48f1a7[_0x3dcd('0x12')][_0x3dcd('0x1c')]||null:null})[_0x3dcd('0x14')](function(_0x486438){logger['info'](_0x3dcd('0x16'),_0x48f1a7);logger[_0x3dcd('0xc')](_0x3dcd('0x16'),_0x48f1a7,JSON[_0x3dcd('0x15')](_0x486438));_0x1a189c(_0x486438);})['catch'](function(_0x3a2f1d){logger['error'](_0x3dcd('0x16'),_0x3a2f1d[_0x3dcd('0x10')],_0x48f1a7);_0x441c1f(_0x1e408a[_0x3dcd('0xe')](0x1f4,_0x3a2f1d[_0x3dcd('0x10')]));});});};