Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / api / interval / interval.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 _0x73b6=['request\x20sent','Interval,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetInterval','findAll','options','raw','where','attributes','include','model','map','then','debug','Interval','find','ShowInterval','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','info','Interval,\x20%s,\x20%s'];(function(_0x34b245,_0xfe65b4){var _0x3a8984=function(_0x12c6a8){while(--_0x12c6a8){_0x34b245['push'](_0x34b245['shift']());}};_0x3a8984(++_0xfe65b4);}(_0x73b6,0x1ad));var _0x673b=function(_0x102e37,_0x14a181){_0x102e37=_0x102e37-0x0;var _0x35a07c=_0x73b6[_0x102e37];return _0x35a07c;};'use strict';var _=require(_0x673b('0x0'));var util=require(_0x673b('0x1'));var moment=require(_0x673b('0x2'));var BPromise=require(_0x673b('0x3'));var rs=require(_0x673b('0x4'));var fs=require('fs');var db=require(_0x673b('0x5'))['db'];var utils=require(_0x673b('0x6'));var logger=require(_0x673b('0x7'))(_0x673b('0x8'));var config=require('../../config/environment');var jayson=require(_0x673b('0x9'));var client=jayson[_0x673b('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x20c4f7,_0x5f2349,_0x12277b){return new BPromise(function(_0x3bdf08,_0x2ef5ab){return client['request'](_0x20c4f7,_0x12277b)['then'](function(_0x163957){logger[_0x673b('0xb')](_0x673b('0xc'),_0x5f2349,_0x673b('0xd'));logger['debug'](_0x673b('0xe'),_0x5f2349,_0x673b('0xd'),JSON[_0x673b('0xf')](_0x163957));if(_0x163957[_0x673b('0x10')]){if(_0x163957[_0x673b('0x10')][_0x673b('0x11')]===0x1f4){logger[_0x673b('0x10')](_0x673b('0xc'),_0x5f2349,_0x163957[_0x673b('0x10')][_0x673b('0x12')]);return _0x2ef5ab(_0x163957[_0x673b('0x10')][_0x673b('0x12')]);}logger[_0x673b('0x10')]('Interval,\x20%s,\x20%s',_0x5f2349,_0x163957[_0x673b('0x10')][_0x673b('0x12')]);return _0x3bdf08(_0x163957[_0x673b('0x10')][_0x673b('0x12')]);}else{logger[_0x673b('0xb')]('Interval,\x20%s,\x20%s',_0x5f2349,_0x673b('0xd'));_0x3bdf08(_0x163957['result'][_0x673b('0x12')]);}})[_0x673b('0x13')](function(_0x4d0e65){logger[_0x673b('0x10')](_0x673b('0xc'),_0x5f2349,_0x4d0e65);_0x2ef5ab(_0x4d0e65);});});}exports[_0x673b('0x14')]=function(_0x3ed7b9){var _0x60c542=this;return new Promise(function(_0x3c68d0,_0x2af963){return db['Interval'][_0x673b('0x15')]({'raw':_0x3ed7b9[_0x673b('0x16')]?_0x3ed7b9['options'][_0x673b('0x17')]===undefined?!![]:![]:!![],'where':_0x3ed7b9[_0x673b('0x16')]?_0x3ed7b9['options'][_0x673b('0x18')]||null:null,'attributes':_0x3ed7b9['options']?_0x3ed7b9[_0x673b('0x16')][_0x673b('0x19')]||null:null,'limit':_0x3ed7b9['options']?_0x3ed7b9[_0x673b('0x16')]['limit']||null:null,'include':_0x3ed7b9[_0x673b('0x16')]?_0x3ed7b9[_0x673b('0x16')]['include']?_['map'](_0x3ed7b9[_0x673b('0x16')][_0x673b('0x1a')],function(_0x336b20){return{'model':db[_0x336b20[_0x673b('0x1b')]],'as':_0x336b20['as'],'attributes':_0x336b20['attributes'],'include':_0x336b20['include']?_[_0x673b('0x1c')](_0x336b20[_0x673b('0x1a')],function(_0x149a2e){return{'model':db[_0x149a2e[_0x673b('0x1b')]],'as':_0x149a2e['as'],'attributes':_0x149a2e[_0x673b('0x19')],'include':_0x149a2e['include']?_[_0x673b('0x1c')](_0x149a2e[_0x673b('0x1a')],function(_0x42373c){return{'model':db[_0x42373c[_0x673b('0x1b')]],'as':_0x42373c['as'],'attributes':_0x42373c[_0x673b('0x19')]};}):[]};}):[]};}):[]:[]})[_0x673b('0x1d')](function(_0xcfc9d1){logger[_0x673b('0xb')](_0x673b('0x14'),_0x3ed7b9);logger[_0x673b('0x1e')](_0x673b('0x14'),_0x3ed7b9,JSON[_0x673b('0xf')](_0xcfc9d1));_0x3c68d0(_0xcfc9d1);})[_0x673b('0x13')](function(_0x8ee82f){logger[_0x673b('0x10')]('GetInterval',_0x8ee82f[_0x673b('0x12')],_0x3ed7b9);_0x2af963(_0x60c542[_0x673b('0x10')](0x1f4,_0x8ee82f[_0x673b('0x12')]));});});};exports['ShowInterval']=function(_0x234b64){var _0xa0a8c7=this;return new Promise(function(_0x4b6d7e,_0x33b042){return db[_0x673b('0x1f')][_0x673b('0x20')]({'raw':_0x234b64[_0x673b('0x16')]?_0x234b64[_0x673b('0x16')][_0x673b('0x17')]===undefined?!![]:![]:!![],'where':_0x234b64['options']?_0x234b64[_0x673b('0x16')][_0x673b('0x18')]||null:null,'attributes':_0x234b64[_0x673b('0x16')]?_0x234b64['options']['attributes']||null:null,'include':_0x234b64[_0x673b('0x16')]?_0x234b64['options'][_0x673b('0x1a')]?_[_0x673b('0x1c')](_0x234b64[_0x673b('0x16')][_0x673b('0x1a')],function(_0xb5530c){return{'model':db[_0xb5530c[_0x673b('0x1b')]],'as':_0xb5530c['as'],'attributes':_0xb5530c[_0x673b('0x19')],'include':_0xb5530c[_0x673b('0x1a')]?_[_0x673b('0x1c')](_0xb5530c['include'],function(_0x4d6906){return{'model':db[_0x4d6906['model']],'as':_0x4d6906['as'],'attributes':_0x4d6906['attributes'],'include':_0x4d6906[_0x673b('0x1a')]?_[_0x673b('0x1c')](_0x4d6906[_0x673b('0x1a')],function(_0x2ddbac){return{'model':db[_0x2ddbac[_0x673b('0x1b')]],'as':_0x2ddbac['as'],'attributes':_0x2ddbac['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0xdde096){logger[_0x673b('0xb')](_0x673b('0x21'),_0x234b64);logger[_0x673b('0x1e')](_0x673b('0x21'),_0x234b64,JSON['stringify'](_0xdde096));_0x4b6d7e(_0xdde096);})[_0x673b('0x13')](function(_0x5487e3){logger[_0x673b('0x10')](_0x673b('0x21'),_0x5487e3[_0x673b('0x12')],_0x234b64);_0x33b042(_0xa0a8c7[_0x673b('0x10')](0x1f4,_0x5487e3[_0x673b('0x12')]));});});};