71bb98cb4dc9bdd4aaf01a722152b763fb1c8985
[motion2.git] / server / api / squareProject / squareProject.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 _0x7eb9=['limit','include','map','model','attributes','then','info','GetSquareProjects','stringify','error','message','find','ShowSquareProject','debug','catch','lodash','ioredis','../../config/logger','rpc','redis','localhost','socket.io-emitter','./squareProject.socket','register','SquareProject','findAll','options','raw','where'];(function(_0x13df40,_0x3140c5){var _0x44820e=function(_0x14fb6a){while(--_0x14fb6a){_0x13df40['push'](_0x13df40['shift']());}};_0x44820e(++_0x3140c5);}(_0x7eb9,0x114));var _0x97eb=function(_0x17d9e3,_0x1f969c){_0x17d9e3=_0x17d9e3-0x0;var _0x14192d=_0x7eb9[_0x17d9e3];return _0x14192d;};'use strict';var _=require(_0x97eb('0x0'));var Redis=require(_0x97eb('0x1'));var db=require('../../mysqldb')['db'];var logger=require(_0x97eb('0x2'))(_0x97eb('0x3'));var config=require('../../config/environment');config[_0x97eb('0x4')]=_['defaults'](config[_0x97eb('0x4')],{'host':_0x97eb('0x5'),'port':0x18eb});var socket=require(_0x97eb('0x6'))(new Redis(config[_0x97eb('0x4')]));require(_0x97eb('0x7'))[_0x97eb('0x8')](socket);exports['GetSquareProjects']=function(_0x46a9b6){var _0x35d5b9=this;return new Promise(function(_0x1e83c2,_0x3f3db7){return db[_0x97eb('0x9')][_0x97eb('0xa')]({'raw':_0x46a9b6[_0x97eb('0xb')]?_0x46a9b6[_0x97eb('0xb')][_0x97eb('0xc')]===undefined?!![]:![]:!![],'where':_0x46a9b6['options']?_0x46a9b6[_0x97eb('0xb')][_0x97eb('0xd')]||null:null,'attributes':_0x46a9b6['options']?_0x46a9b6[_0x97eb('0xb')]['attributes']||null:null,'limit':_0x46a9b6[_0x97eb('0xb')]?_0x46a9b6[_0x97eb('0xb')][_0x97eb('0xe')]||null:null,'include':_0x46a9b6[_0x97eb('0xb')]?_0x46a9b6[_0x97eb('0xb')][_0x97eb('0xf')]?_[_0x97eb('0x10')](_0x46a9b6[_0x97eb('0xb')][_0x97eb('0xf')],function(_0x3501a7){return{'model':db[_0x3501a7[_0x97eb('0x11')]],'as':_0x3501a7['as'],'attributes':_0x3501a7[_0x97eb('0x12')],'include':_0x3501a7[_0x97eb('0xf')]?_[_0x97eb('0x10')](_0x3501a7['include'],function(_0x5b28c9){return{'model':db[_0x5b28c9['model']],'as':_0x5b28c9['as'],'attributes':_0x5b28c9[_0x97eb('0x12')],'include':_0x5b28c9[_0x97eb('0xf')]?_[_0x97eb('0x10')](_0x5b28c9[_0x97eb('0xf')],function(_0xf3e3d4){return{'model':db[_0xf3e3d4[_0x97eb('0x11')]],'as':_0xf3e3d4['as'],'attributes':_0xf3e3d4['attributes']};}):[]};}):[]};}):[]:[]})[_0x97eb('0x13')](function(_0x6e603){logger[_0x97eb('0x14')](_0x97eb('0x15'),_0x46a9b6);logger['debug'](_0x97eb('0x15'),_0x46a9b6,JSON[_0x97eb('0x16')](_0x6e603));_0x1e83c2(_0x6e603);})['catch'](function(_0x6f71ed){logger[_0x97eb('0x17')](_0x97eb('0x15'),_0x6f71ed[_0x97eb('0x18')],_0x46a9b6);_0x3f3db7(_0x35d5b9['error'](0x1f4,_0x6f71ed['message']));});});};exports['ShowSquareProject']=function(_0x2b57dc){var _0x58ee53=this;return new Promise(function(_0x407cca,_0x44c551){return db[_0x97eb('0x9')][_0x97eb('0x19')]({'raw':_0x2b57dc['options']?_0x2b57dc[_0x97eb('0xb')][_0x97eb('0xc')]===undefined?!![]:![]:!![],'where':_0x2b57dc[_0x97eb('0xb')]?_0x2b57dc[_0x97eb('0xb')][_0x97eb('0xd')]||null:null,'attributes':_0x2b57dc[_0x97eb('0xb')]?_0x2b57dc['options']['attributes']||null:null,'include':_0x2b57dc[_0x97eb('0xb')]?_0x2b57dc[_0x97eb('0xb')]['include']?_[_0x97eb('0x10')](_0x2b57dc[_0x97eb('0xb')]['include'],function(_0x58a603){return{'model':db[_0x58a603[_0x97eb('0x11')]],'as':_0x58a603['as'],'attributes':_0x58a603['attributes'],'include':_0x58a603[_0x97eb('0xf')]?_[_0x97eb('0x10')](_0x58a603[_0x97eb('0xf')],function(_0x5e2b28){return{'model':db[_0x5e2b28[_0x97eb('0x11')]],'as':_0x5e2b28['as'],'attributes':_0x5e2b28[_0x97eb('0x12')],'include':_0x5e2b28[_0x97eb('0xf')]?_[_0x97eb('0x10')](_0x5e2b28[_0x97eb('0xf')],function(_0x5553ce){return{'model':db[_0x5553ce[_0x97eb('0x11')]],'as':_0x5553ce['as'],'attributes':_0x5553ce[_0x97eb('0x12')]};}):[]};}):[]};}):[]:[]})[_0x97eb('0x13')](function(_0x83d92e){logger['info'](_0x97eb('0x1a'),_0x2b57dc);logger[_0x97eb('0x1b')](_0x97eb('0x1a'),_0x2b57dc,JSON[_0x97eb('0x16')](_0x83d92e));_0x407cca(_0x83d92e);})[_0x97eb('0x1c')](function(_0x595ed3){logger['error'](_0x97eb('0x1a'),_0x595ed3['message'],_0x2b57dc);_0x44c551(_0x58ee53[_0x97eb('0x17')](0x1f4,_0x595ed3[_0x97eb('0x18')]));});});};