29c5e4f1a1ff68f4af07ba7e1955e2adcd36fec5
[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 _0xf8fa=['SquareProject','options','raw','where','limit','include','map','model','attributes','info','debug','stringify','catch','error','message','find','ShowSquareProject','lodash','ioredis','../../mysqldb','../../config/logger','../../config/environment','redis','defaults','socket.io-emitter','register','GetSquareProjects'];(function(_0xb3b452,_0x582e8e){var _0x238983=function(_0x3bc866){while(--_0x3bc866){_0xb3b452['push'](_0xb3b452['shift']());}};_0x238983(++_0x582e8e);}(_0xf8fa,0x170));var _0xaf8f=function(_0x209e98,_0x39cac6){_0x209e98=_0x209e98-0x0;var _0x3825a0=_0xf8fa[_0x209e98];return _0x3825a0;};'use strict';var _=require(_0xaf8f('0x0'));var Redis=require(_0xaf8f('0x1'));var db=require(_0xaf8f('0x2'))['db'];var logger=require(_0xaf8f('0x3'))('rpc');var config=require(_0xaf8f('0x4'));config[_0xaf8f('0x5')]=_[_0xaf8f('0x6')](config[_0xaf8f('0x5')],{'host':'localhost','port':0x18eb});var socket=require(_0xaf8f('0x7'))(new Redis(config[_0xaf8f('0x5')]));require('./squareProject.socket')[_0xaf8f('0x8')](socket);exports[_0xaf8f('0x9')]=function(_0x3c87a7){var _0x34ae1d=this;return new Promise(function(_0x3ac4d8,_0x57f776){return db[_0xaf8f('0xa')]['findAll']({'raw':_0x3c87a7['options']?_0x3c87a7[_0xaf8f('0xb')][_0xaf8f('0xc')]===undefined?!![]:![]:!![],'where':_0x3c87a7[_0xaf8f('0xb')]?_0x3c87a7[_0xaf8f('0xb')][_0xaf8f('0xd')]||null:null,'attributes':_0x3c87a7[_0xaf8f('0xb')]?_0x3c87a7['options']['attributes']||null:null,'limit':_0x3c87a7[_0xaf8f('0xb')]?_0x3c87a7['options'][_0xaf8f('0xe')]||null:null,'include':_0x3c87a7[_0xaf8f('0xb')]?_0x3c87a7['options'][_0xaf8f('0xf')]?_[_0xaf8f('0x10')](_0x3c87a7[_0xaf8f('0xb')]['include'],function(_0x30e1bc){return{'model':db[_0x30e1bc[_0xaf8f('0x11')]],'as':_0x30e1bc['as'],'attributes':_0x30e1bc[_0xaf8f('0x12')],'include':_0x30e1bc['include']?_[_0xaf8f('0x10')](_0x30e1bc[_0xaf8f('0xf')],function(_0x226716){return{'model':db[_0x226716[_0xaf8f('0x11')]],'as':_0x226716['as'],'attributes':_0x226716[_0xaf8f('0x12')],'include':_0x226716[_0xaf8f('0xf')]?_[_0xaf8f('0x10')](_0x226716[_0xaf8f('0xf')],function(_0x16c8d5){return{'model':db[_0x16c8d5[_0xaf8f('0x11')]],'as':_0x16c8d5['as'],'attributes':_0x16c8d5[_0xaf8f('0x12')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x81693c){logger[_0xaf8f('0x13')](_0xaf8f('0x9'),_0x3c87a7);logger[_0xaf8f('0x14')]('GetSquareProjects',_0x3c87a7,JSON[_0xaf8f('0x15')](_0x81693c));_0x3ac4d8(_0x81693c);})[_0xaf8f('0x16')](function(_0x14caca){logger[_0xaf8f('0x17')]('GetSquareProjects',_0x14caca[_0xaf8f('0x18')],_0x3c87a7);_0x57f776(_0x34ae1d['error'](0x1f4,_0x14caca[_0xaf8f('0x18')]));});});};exports['ShowSquareProject']=function(_0x26932b){var _0x108c77=this;return new Promise(function(_0x6b1837,_0x159790){return db[_0xaf8f('0xa')][_0xaf8f('0x19')]({'raw':_0x26932b['options']?_0x26932b[_0xaf8f('0xb')][_0xaf8f('0xc')]===undefined?!![]:![]:!![],'where':_0x26932b[_0xaf8f('0xb')]?_0x26932b[_0xaf8f('0xb')]['where']||null:null,'attributes':_0x26932b[_0xaf8f('0xb')]?_0x26932b['options']['attributes']||null:null,'include':_0x26932b['options']?_0x26932b[_0xaf8f('0xb')][_0xaf8f('0xf')]?_[_0xaf8f('0x10')](_0x26932b[_0xaf8f('0xb')][_0xaf8f('0xf')],function(_0x17e71c){return{'model':db[_0x17e71c['model']],'as':_0x17e71c['as'],'attributes':_0x17e71c[_0xaf8f('0x12')],'include':_0x17e71c[_0xaf8f('0xf')]?_['map'](_0x17e71c['include'],function(_0xd17178){return{'model':db[_0xd17178['model']],'as':_0xd17178['as'],'attributes':_0xd17178[_0xaf8f('0x12')],'include':_0xd17178[_0xaf8f('0xf')]?_['map'](_0xd17178[_0xaf8f('0xf')],function(_0x353c33){return{'model':db[_0x353c33[_0xaf8f('0x11')]],'as':_0x353c33['as'],'attributes':_0x353c33[_0xaf8f('0x12')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x37b501){logger[_0xaf8f('0x13')]('ShowSquareProject',_0x26932b);logger[_0xaf8f('0x14')]('ShowSquareProject',_0x26932b,JSON[_0xaf8f('0x15')](_0x37b501));_0x6b1837(_0x37b501);})[_0xaf8f('0x16')](function(_0x49d268){logger[_0xaf8f('0x17')](_0xaf8f('0x1a'),_0x49d268[_0xaf8f('0x18')],_0x26932b);_0x159790(_0x108c77[_0xaf8f('0x17')](0x1f4,_0x49d268['message']));});});};