fb4fe596610d19773355a303dfd6c7a2c3d5544c
[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 _0xdb93=['include','map','model','then','debug','stringify','error','message','ShowSquareProject','find','info','catch','ioredis','../../mysqldb','../../config/logger','../../config/environment','redis','localhost','./squareProject.socket','GetSquareProjects','SquareProject','findAll','options','raw','where','attributes','limit'];(function(_0x3b29ce,_0x13de5f){var _0x57b233=function(_0x5e4248){while(--_0x5e4248){_0x3b29ce['push'](_0x3b29ce['shift']());}};_0x57b233(++_0x13de5f);}(_0xdb93,0x78));var _0x3db9=function(_0x2576d7,_0x167624){_0x2576d7=_0x2576d7-0x0;var _0x16a08c=_0xdb93[_0x2576d7];return _0x16a08c;};'use strict';var _=require('lodash');var Redis=require(_0x3db9('0x0'));var db=require(_0x3db9('0x1'))['db'];var logger=require(_0x3db9('0x2'))('rpc');var config=require(_0x3db9('0x3'));config['redis']=_['defaults'](config[_0x3db9('0x4')],{'host':_0x3db9('0x5'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3db9('0x4')]));require(_0x3db9('0x6'))['register'](socket);exports[_0x3db9('0x7')]=function(_0x349710){var _0x56000b=this;return new Promise(function(_0x4de10e,_0x1cce1b){return db[_0x3db9('0x8')][_0x3db9('0x9')]({'raw':_0x349710[_0x3db9('0xa')]?_0x349710[_0x3db9('0xa')][_0x3db9('0xb')]===undefined?!![]:![]:!![],'where':_0x349710['options']?_0x349710[_0x3db9('0xa')][_0x3db9('0xc')]||null:null,'attributes':_0x349710[_0x3db9('0xa')]?_0x349710[_0x3db9('0xa')][_0x3db9('0xd')]||null:null,'limit':_0x349710[_0x3db9('0xa')]?_0x349710['options'][_0x3db9('0xe')]||null:null,'include':_0x349710[_0x3db9('0xa')]?_0x349710[_0x3db9('0xa')][_0x3db9('0xf')]?_[_0x3db9('0x10')](_0x349710[_0x3db9('0xa')][_0x3db9('0xf')],function(_0x3f4a28){return{'model':db[_0x3f4a28[_0x3db9('0x11')]],'as':_0x3f4a28['as'],'attributes':_0x3f4a28[_0x3db9('0xd')],'include':_0x3f4a28[_0x3db9('0xf')]?_[_0x3db9('0x10')](_0x3f4a28[_0x3db9('0xf')],function(_0x2620ad){return{'model':db[_0x2620ad[_0x3db9('0x11')]],'as':_0x2620ad['as'],'attributes':_0x2620ad[_0x3db9('0xd')],'include':_0x2620ad[_0x3db9('0xf')]?_[_0x3db9('0x10')](_0x2620ad[_0x3db9('0xf')],function(_0x5ec52d){return{'model':db[_0x5ec52d[_0x3db9('0x11')]],'as':_0x5ec52d['as'],'attributes':_0x5ec52d[_0x3db9('0xd')]};}):[]};}):[]};}):[]:[]})[_0x3db9('0x12')](function(_0x1e45ab){logger['info'](_0x3db9('0x7'),_0x349710);logger[_0x3db9('0x13')](_0x3db9('0x7'),_0x349710,JSON[_0x3db9('0x14')](_0x1e45ab));_0x4de10e(_0x1e45ab);})['catch'](function(_0x1f53d4){logger[_0x3db9('0x15')]('GetSquareProjects',_0x1f53d4[_0x3db9('0x16')],_0x349710);_0x1cce1b(_0x56000b[_0x3db9('0x15')](0x1f4,_0x1f53d4['message']));});});};exports[_0x3db9('0x17')]=function(_0x3813f5){var _0x197ecc=this;return new Promise(function(_0xa88638,_0x3ce625){return db['SquareProject'][_0x3db9('0x18')]({'raw':_0x3813f5[_0x3db9('0xa')]?_0x3813f5[_0x3db9('0xa')][_0x3db9('0xb')]===undefined?!![]:![]:!![],'where':_0x3813f5[_0x3db9('0xa')]?_0x3813f5['options']['where']||null:null,'attributes':_0x3813f5[_0x3db9('0xa')]?_0x3813f5[_0x3db9('0xa')][_0x3db9('0xd')]||null:null,'include':_0x3813f5[_0x3db9('0xa')]?_0x3813f5[_0x3db9('0xa')]['include']?_[_0x3db9('0x10')](_0x3813f5[_0x3db9('0xa')]['include'],function(_0x98b153){return{'model':db[_0x98b153[_0x3db9('0x11')]],'as':_0x98b153['as'],'attributes':_0x98b153[_0x3db9('0xd')],'include':_0x98b153[_0x3db9('0xf')]?_[_0x3db9('0x10')](_0x98b153[_0x3db9('0xf')],function(_0x2f13d3){return{'model':db[_0x2f13d3[_0x3db9('0x11')]],'as':_0x2f13d3['as'],'attributes':_0x2f13d3[_0x3db9('0xd')],'include':_0x2f13d3['include']?_['map'](_0x2f13d3['include'],function(_0x2ce4fe){return{'model':db[_0x2ce4fe[_0x3db9('0x11')]],'as':_0x2ce4fe['as'],'attributes':_0x2ce4fe[_0x3db9('0xd')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x18d3c5){logger[_0x3db9('0x19')]('ShowSquareProject',_0x3813f5);logger['debug'](_0x3db9('0x17'),_0x3813f5,JSON['stringify'](_0x18d3c5));_0xa88638(_0x18d3c5);})[_0x3db9('0x1a')](function(_0x4dcef1){logger[_0x3db9('0x15')](_0x3db9('0x17'),_0x4dcef1['message'],_0x3813f5);_0x3ce625(_0x197ecc[_0x3db9('0x15')](0x1f4,_0x4dcef1[_0x3db9('0x16')]));});});};