Built motion from commit da617fac.|2.6.6
[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 _0x1d23=['SquareReport,\x20%s,\x20%s','request\x20sent','SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','CreateSquareReport','SquareReport','create','body','options','debug','UpdateSquareReport','raw','where','limit','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then'];(function(_0x2fd69d,_0xeb1037){var _0x5d5ef3=function(_0xa9ea9e){while(--_0xa9ea9e){_0x2fd69d['push'](_0x2fd69d['shift']());}};_0x5d5ef3(++_0xeb1037);}(_0x1d23,0x149));var _0x31d2=function(_0x35ad1d,_0x139af2){_0x35ad1d=_0x35ad1d-0x0;var _0x178bde=_0x1d23[_0x35ad1d];return _0x178bde;};'use strict';var _=require('lodash');var util=require(_0x31d2('0x0'));var moment=require(_0x31d2('0x1'));var BPromise=require(_0x31d2('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x31d2('0x3'));var db=require(_0x31d2('0x4'))['db'];var utils=require(_0x31d2('0x5'));var logger=require(_0x31d2('0x6'))(_0x31d2('0x7'));var config=require('../../config/environment');var jayson=require(_0x31d2('0x8'));var client=jayson[_0x31d2('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4f39e2,_0x53acf1,_0x441557){return new BPromise(function(_0x3a7bbc,_0x54013e){return client[_0x31d2('0xa')](_0x4f39e2,_0x441557)[_0x31d2('0xb')](function(_0x56717c){logger['info'](_0x31d2('0xc'),_0x53acf1,_0x31d2('0xd'));logger['debug'](_0x31d2('0xe'),_0x53acf1,_0x31d2('0xd'),JSON[_0x31d2('0xf')](_0x56717c));if(_0x56717c['error']){if(_0x56717c[_0x31d2('0x10')][_0x31d2('0x11')]===0x1f4){logger[_0x31d2('0x10')](_0x31d2('0xc'),_0x53acf1,_0x56717c[_0x31d2('0x10')][_0x31d2('0x12')]);return _0x54013e(_0x56717c[_0x31d2('0x10')][_0x31d2('0x12')]);}logger['error'](_0x31d2('0xc'),_0x53acf1,_0x56717c[_0x31d2('0x10')][_0x31d2('0x12')]);return _0x3a7bbc(_0x56717c[_0x31d2('0x10')][_0x31d2('0x12')]);}else{logger[_0x31d2('0x13')](_0x31d2('0xc'),_0x53acf1,_0x31d2('0xd'));_0x3a7bbc(_0x56717c['result'][_0x31d2('0x12')]);}})[_0x31d2('0x14')](function(_0x48f722){logger[_0x31d2('0x10')](_0x31d2('0xc'),_0x53acf1,_0x48f722);_0x54013e(_0x48f722);});});}exports[_0x31d2('0x15')]=function(_0x435c3d){var _0x5df035=this;return new Promise(function(_0x2df205,_0x542d33){return db[_0x31d2('0x16')][_0x31d2('0x17')](_0x435c3d[_0x31d2('0x18')],{'raw':_0x435c3d[_0x31d2('0x19')]?_0x435c3d[_0x31d2('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x595172){logger['info'](_0x31d2('0x15'),_0x435c3d);logger[_0x31d2('0x1a')](_0x31d2('0x15'),_0x435c3d,JSON['stringify'](_0x595172));_0x2df205(_0x595172);})[_0x31d2('0x14')](function(_0x2bd57e){logger[_0x31d2('0x10')](_0x31d2('0x15'),_0x2bd57e['message'],_0x435c3d);_0x542d33(_0x5df035['error'](0x1f4,_0x2bd57e[_0x31d2('0x12')]));});});};exports[_0x31d2('0x1b')]=function(_0x41f64b){var _0x1d9bae=this;return new Promise(function(_0xc5d321,_0x7541d8){return db['SquareReport']['update'](_0x41f64b[_0x31d2('0x18')],{'raw':_0x41f64b[_0x31d2('0x19')]?_0x41f64b['options'][_0x31d2('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x41f64b[_0x31d2('0x19')]?_0x41f64b['options'][_0x31d2('0x1d')]||null:null,'attributes':_0x41f64b[_0x31d2('0x19')]?_0x41f64b[_0x31d2('0x19')]['attributes']||null:null,'limit':_0x41f64b['options']?_0x41f64b[_0x31d2('0x19')][_0x31d2('0x1e')]||null:null})[_0x31d2('0xb')](function(_0x50a51e){logger[_0x31d2('0x13')](_0x31d2('0x1b'),_0x41f64b);logger[_0x31d2('0x1a')](_0x31d2('0x1b'),_0x41f64b,JSON[_0x31d2('0xf')](_0x50a51e));_0xc5d321(_0x50a51e);})[_0x31d2('0x14')](function(_0xa7cc7c){logger['error'](_0x31d2('0x1b'),_0xa7cc7c[_0x31d2('0x12')],_0x41f64b);_0x7541d8(_0x1d9bae[_0x31d2('0x10')](0x1f4,_0xa7cc7c[_0x31d2('0x12')]));});});};