Built motion from commit (unavailable).|2.4.0
[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 _0xa533=['randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','info','SquareReport,\x20%s,\x20%s','request\x20sent','debug','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateSquareReport','SquareReport','create','options','then','UpdateSquareReport','body','raw','where','attributes','moment','bluebird'];(function(_0x4d52f0,_0x2e666d){var _0x2938ae=function(_0x170ac8){while(--_0x170ac8){_0x4d52f0['push'](_0x4d52f0['shift']());}};_0x2938ae(++_0x2e666d);}(_0xa533,0x13e));var _0x3a53=function(_0x392cc6,_0x3031f7){_0x392cc6=_0x392cc6-0x0;var _0x3f9f22=_0xa533[_0x392cc6];return _0x3f9f22;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x3a53('0x0'));var BPromise=require(_0x3a53('0x1'));var rs=require(_0x3a53('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3a53('0x3'))['db'];var utils=require(_0x3a53('0x4'));var logger=require(_0x3a53('0x5'))(_0x3a53('0x6'));var config=require(_0x3a53('0x7'));var jayson=require(_0x3a53('0x8'));var client=jayson[_0x3a53('0x9')][_0x3a53('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xcad27,_0x143868,_0x2b9c28){return new BPromise(function(_0x5da482,_0x160b75){return client['request'](_0xcad27,_0x2b9c28)['then'](function(_0x12475c){logger[_0x3a53('0xb')](_0x3a53('0xc'),_0x143868,_0x3a53('0xd'));logger[_0x3a53('0xe')](_0x3a53('0xf'),_0x143868,_0x3a53('0xd'),JSON[_0x3a53('0x10')](_0x12475c));if(_0x12475c[_0x3a53('0x11')]){if(_0x12475c[_0x3a53('0x11')][_0x3a53('0x12')]===0x1f4){logger['error'](_0x3a53('0xc'),_0x143868,_0x12475c['error'][_0x3a53('0x13')]);return _0x160b75(_0x12475c[_0x3a53('0x11')][_0x3a53('0x13')]);}logger[_0x3a53('0x11')](_0x3a53('0xc'),_0x143868,_0x12475c['error'][_0x3a53('0x13')]);return _0x5da482(_0x12475c[_0x3a53('0x11')][_0x3a53('0x13')]);}else{logger[_0x3a53('0xb')](_0x3a53('0xc'),_0x143868,'request\x20sent');_0x5da482(_0x12475c[_0x3a53('0x14')][_0x3a53('0x13')]);}})[_0x3a53('0x15')](function(_0x4eb752){logger[_0x3a53('0x11')]('SquareReport,\x20%s,\x20%s',_0x143868,_0x4eb752);_0x160b75(_0x4eb752);});});}exports[_0x3a53('0x16')]=function(_0x24e356){var _0x3c1213=this;return new Promise(function(_0x3acef8,_0x1f251f){return db[_0x3a53('0x17')][_0x3a53('0x18')](_0x24e356['body'],{'raw':_0x24e356[_0x3a53('0x19')]?_0x24e356[_0x3a53('0x19')]['raw']===undefined?!![]:![]:!![]})[_0x3a53('0x1a')](function(_0x17d063){logger[_0x3a53('0xb')]('CreateSquareReport',_0x24e356);logger[_0x3a53('0xe')](_0x3a53('0x16'),_0x24e356,JSON[_0x3a53('0x10')](_0x17d063));_0x3acef8(_0x17d063);})[_0x3a53('0x15')](function(_0x5dcf5f){logger[_0x3a53('0x11')]('CreateSquareReport',_0x5dcf5f['message'],_0x24e356);_0x1f251f(_0x3c1213['error'](0x1f4,_0x5dcf5f['message']));});});};exports[_0x3a53('0x1b')]=function(_0x2d2b45){var _0x365593=this;return new Promise(function(_0x1f3c89,_0x391047){return db[_0x3a53('0x17')]['update'](_0x2d2b45[_0x3a53('0x1c')],{'raw':_0x2d2b45[_0x3a53('0x19')]?_0x2d2b45['options'][_0x3a53('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2d2b45[_0x3a53('0x19')]?_0x2d2b45['options'][_0x3a53('0x1e')]||null:null,'attributes':_0x2d2b45['options']?_0x2d2b45[_0x3a53('0x19')][_0x3a53('0x1f')]||null:null,'limit':_0x2d2b45[_0x3a53('0x19')]?_0x2d2b45[_0x3a53('0x19')]['limit']||null:null})[_0x3a53('0x1a')](function(_0x467892){logger[_0x3a53('0xb')](_0x3a53('0x1b'),_0x2d2b45);logger['debug'](_0x3a53('0x1b'),_0x2d2b45,JSON['stringify'](_0x467892));_0x1f3c89(_0x467892);})[_0x3a53('0x15')](function(_0x71f734){logger['error'](_0x3a53('0x1b'),_0x71f734[_0x3a53('0x13')],_0x2d2b45);_0x391047(_0x365593[_0x3a53('0x11')](0x1f4,_0x71f734['message']));});});};