Built motion from commit (unavailable).|2.2.5
[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 _0x65f6=['SquareReport,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareReport,\x20%s,\x20%s','message','result','catch','CreateSquareReport','body','options','raw','UpdateSquareReport','SquareReport','update','attributes','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','request','then','info','request\x20sent','debug'];(function(_0x33b4f9,_0x3ef512){var _0xbd1993=function(_0x541016){while(--_0x541016){_0x33b4f9['push'](_0x33b4f9['shift']());}};_0xbd1993(++_0x3ef512);}(_0x65f6,0x170));var _0x665f=function(_0x328312,_0x22e73b){_0x328312=_0x328312-0x0;var _0x42d918=_0x65f6[_0x328312];return _0x42d918;};'use strict';var _=require(_0x665f('0x0'));var util=require('util');var moment=require(_0x665f('0x1'));var BPromise=require(_0x665f('0x2'));var rs=require(_0x665f('0x3'));var fs=require('fs');var Redis=require(_0x665f('0x4'));var db=require(_0x665f('0x5'))['db'];var utils=require(_0x665f('0x6'));var logger=require('../../config/logger')(_0x665f('0x7'));var config=require('../../config/environment');var jayson=require(_0x665f('0x8'));var client=jayson[_0x665f('0x9')][_0x665f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xa6d22,_0x3ce1bf,_0x59d660){return new BPromise(function(_0x3245ab,_0x11a86d){return client[_0x665f('0xb')](_0xa6d22,_0x59d660)[_0x665f('0xc')](function(_0x28fc8a){logger[_0x665f('0xd')]('SquareReport,\x20%s,\x20%s',_0x3ce1bf,_0x665f('0xe'));logger[_0x665f('0xf')](_0x665f('0x10'),_0x3ce1bf,_0x665f('0xe'),JSON[_0x665f('0x11')](_0x28fc8a));if(_0x28fc8a[_0x665f('0x12')]){if(_0x28fc8a[_0x665f('0x12')][_0x665f('0x13')]===0x1f4){logger[_0x665f('0x12')](_0x665f('0x14'),_0x3ce1bf,_0x28fc8a[_0x665f('0x12')]['message']);return _0x11a86d(_0x28fc8a['error'][_0x665f('0x15')]);}logger[_0x665f('0x12')](_0x665f('0x14'),_0x3ce1bf,_0x28fc8a[_0x665f('0x12')][_0x665f('0x15')]);return _0x3245ab(_0x28fc8a[_0x665f('0x12')]['message']);}else{logger['info'](_0x665f('0x14'),_0x3ce1bf,_0x665f('0xe'));_0x3245ab(_0x28fc8a[_0x665f('0x16')][_0x665f('0x15')]);}})[_0x665f('0x17')](function(_0x1928b4){logger['error']('SquareReport,\x20%s,\x20%s',_0x3ce1bf,_0x1928b4);_0x11a86d(_0x1928b4);});});}exports[_0x665f('0x18')]=function(_0x54b11b){var _0x31ba29=this;return new Promise(function(_0xabc5a5,_0x5b508b){return db['SquareReport']['create'](_0x54b11b[_0x665f('0x19')],{'raw':_0x54b11b[_0x665f('0x1a')]?_0x54b11b['options'][_0x665f('0x1b')]===undefined?!![]:![]:!![]})[_0x665f('0xc')](function(_0x12dd05){logger[_0x665f('0xd')](_0x665f('0x18'),_0x54b11b);logger['debug'](_0x665f('0x18'),_0x54b11b,JSON[_0x665f('0x11')](_0x12dd05));_0xabc5a5(_0x12dd05);})[_0x665f('0x17')](function(_0x33699d){logger['error'](_0x665f('0x18'),_0x33699d[_0x665f('0x15')],_0x54b11b);_0x5b508b(_0x31ba29[_0x665f('0x12')](0x1f4,_0x33699d[_0x665f('0x15')]));});});};exports[_0x665f('0x1c')]=function(_0x4ab43d){var _0x386752=this;return new Promise(function(_0x3365d8,_0x20e7d1){return db[_0x665f('0x1d')][_0x665f('0x1e')](_0x4ab43d['body'],{'raw':_0x4ab43d[_0x665f('0x1a')]?_0x4ab43d[_0x665f('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4ab43d[_0x665f('0x1a')]?_0x4ab43d[_0x665f('0x1a')]['where']||null:null,'attributes':_0x4ab43d[_0x665f('0x1a')]?_0x4ab43d[_0x665f('0x1a')][_0x665f('0x1f')]||null:null,'limit':_0x4ab43d[_0x665f('0x1a')]?_0x4ab43d['options']['limit']||null:null})[_0x665f('0xc')](function(_0x31781a){logger[_0x665f('0xd')]('UpdateSquareReport',_0x4ab43d);logger[_0x665f('0xf')](_0x665f('0x1c'),_0x4ab43d,JSON[_0x665f('0x11')](_0x31781a));_0x3365d8(_0x31781a);})[_0x665f('0x17')](function(_0x4d83dc){logger['error'](_0x665f('0x1c'),_0x4d83dc[_0x665f('0x15')],_0x4ab43d);_0x20e7d1(_0x386752[_0x665f('0x12')](0x1f4,_0x4d83dc[_0x665f('0x15')]));});});};