695f87a090b0a121db4c286292820c8a4a8f1232
[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 _0xdf2b=['stringify','catch','error','message','ShowSquareProject','SquareProject','find','lodash','ioredis','../../config/logger','rpc','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','options','where','attributes','include','map','model','then','GetSquareProjects','debug'];(function(_0x4133d0,_0xc13db4){var _0xc8222c=function(_0x309763){while(--_0x309763){_0x4133d0['push'](_0x4133d0['shift']());}};_0xc8222c(++_0xc13db4);}(_0xdf2b,0x165));var _0xbdf2=function(_0x13a7a2,_0x28589a){_0x13a7a2=_0x13a7a2-0x0;var _0x3e6e0a=_0xdf2b[_0x13a7a2];return _0x3e6e0a;};'use strict';var _=require(_0xbdf2('0x0'));var Redis=require(_0xbdf2('0x1'));var db=require('../../mysqldb')['db'];var logger=require(_0xbdf2('0x2'))(_0xbdf2('0x3'));var config=require('../../config/environment');config[_0xbdf2('0x4')]=_[_0xbdf2('0x5')](config[_0xbdf2('0x4')],{'host':_0xbdf2('0x6'),'port':0x18eb});var socket=require(_0xbdf2('0x7'))(new Redis(config[_0xbdf2('0x4')]));require(_0xbdf2('0x8'))['register'](socket);exports['GetSquareProjects']=function(_0xe107c3){var _0x51092c=this;return new Promise(function(_0x4163c5,_0x178d47){return db['SquareProject']['findAll']({'raw':_0xe107c3[_0xbdf2('0x9')]?_0xe107c3[_0xbdf2('0x9')]['raw']===undefined?!![]:![]:!![],'where':_0xe107c3[_0xbdf2('0x9')]?_0xe107c3[_0xbdf2('0x9')][_0xbdf2('0xa')]||null:null,'attributes':_0xe107c3[_0xbdf2('0x9')]?_0xe107c3[_0xbdf2('0x9')][_0xbdf2('0xb')]||null:null,'limit':_0xe107c3[_0xbdf2('0x9')]?_0xe107c3[_0xbdf2('0x9')]['limit']||null:null,'include':_0xe107c3['options']?_0xe107c3[_0xbdf2('0x9')][_0xbdf2('0xc')]?_[_0xbdf2('0xd')](_0xe107c3[_0xbdf2('0x9')]['include'],function(_0x96cc2f){return{'model':db[_0x96cc2f[_0xbdf2('0xe')]],'as':_0x96cc2f['as'],'attributes':_0x96cc2f['attributes'],'include':_0x96cc2f[_0xbdf2('0xc')]?_[_0xbdf2('0xd')](_0x96cc2f[_0xbdf2('0xc')],function(_0x36eed8){return{'model':db[_0x36eed8[_0xbdf2('0xe')]],'as':_0x36eed8['as'],'attributes':_0x36eed8[_0xbdf2('0xb')],'include':_0x36eed8[_0xbdf2('0xc')]?_[_0xbdf2('0xd')](_0x36eed8['include'],function(_0x2930a1){return{'model':db[_0x2930a1[_0xbdf2('0xe')]],'as':_0x2930a1['as'],'attributes':_0x2930a1[_0xbdf2('0xb')]};}):[]};}):[]};}):[]:[]})[_0xbdf2('0xf')](function(_0x115444){logger['info'](_0xbdf2('0x10'),_0xe107c3);logger[_0xbdf2('0x11')](_0xbdf2('0x10'),_0xe107c3,JSON[_0xbdf2('0x12')](_0x115444));_0x4163c5(_0x115444);})[_0xbdf2('0x13')](function(_0x83d52e){logger[_0xbdf2('0x14')](_0xbdf2('0x10'),_0x83d52e[_0xbdf2('0x15')],_0xe107c3);_0x178d47(_0x51092c[_0xbdf2('0x14')](0x1f4,_0x83d52e[_0xbdf2('0x15')]));});});};exports[_0xbdf2('0x16')]=function(_0x359575){var _0x112c58=this;return new Promise(function(_0x329c66,_0x5784c6){return db[_0xbdf2('0x17')][_0xbdf2('0x18')]({'raw':_0x359575[_0xbdf2('0x9')]?_0x359575[_0xbdf2('0x9')]['raw']===undefined?!![]:![]:!![],'where':_0x359575['options']?_0x359575[_0xbdf2('0x9')][_0xbdf2('0xa')]||null:null,'attributes':_0x359575[_0xbdf2('0x9')]?_0x359575[_0xbdf2('0x9')][_0xbdf2('0xb')]||null:null,'include':_0x359575['options']?_0x359575[_0xbdf2('0x9')][_0xbdf2('0xc')]?_['map'](_0x359575['options'][_0xbdf2('0xc')],function(_0x2aa545){return{'model':db[_0x2aa545[_0xbdf2('0xe')]],'as':_0x2aa545['as'],'attributes':_0x2aa545[_0xbdf2('0xb')],'include':_0x2aa545[_0xbdf2('0xc')]?_[_0xbdf2('0xd')](_0x2aa545[_0xbdf2('0xc')],function(_0x4b204d){return{'model':db[_0x4b204d[_0xbdf2('0xe')]],'as':_0x4b204d['as'],'attributes':_0x4b204d[_0xbdf2('0xb')],'include':_0x4b204d[_0xbdf2('0xc')]?_[_0xbdf2('0xd')](_0x4b204d['include'],function(_0x280793){return{'model':db[_0x280793[_0xbdf2('0xe')]],'as':_0x280793['as'],'attributes':_0x280793[_0xbdf2('0xb')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x366d10){logger['info'](_0xbdf2('0x16'),_0x359575);logger[_0xbdf2('0x11')](_0xbdf2('0x16'),_0x359575,JSON[_0xbdf2('0x12')](_0x366d10));_0x329c66(_0x366d10);})[_0xbdf2('0x13')](function(_0x32f728){logger[_0xbdf2('0x14')](_0xbdf2('0x16'),_0x32f728[_0xbdf2('0x15')],_0x359575);_0x5784c6(_0x112c58[_0xbdf2('0x14')](0x1f4,_0x32f728[_0xbdf2('0x15')]));});});};