ea121e3b7e460ab6c0c7ab2bd60ccdaebd878155
[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 _0xc2f5=['defaults','localhost','socket.io-emitter','./squareProject.socket','register','GetSquareProjects','findAll','options','raw','where','attributes','limit','include','map','model','then','stringify','error','message','find','info','debug','ShowSquareProject','catch','lodash','ioredis','rpc','redis'];(function(_0x3dc538,_0x4f7702){var _0x72c2fd=function(_0x5a7260){while(--_0x5a7260){_0x3dc538['push'](_0x3dc538['shift']());}};_0x72c2fd(++_0x4f7702);}(_0xc2f5,0x6c));var _0x5c2f=function(_0x5da12a,_0x5dc184){_0x5da12a=_0x5da12a-0x0;var _0x59645e=_0xc2f5[_0x5da12a];return _0x59645e;};'use strict';var _=require(_0x5c2f('0x0'));var Redis=require(_0x5c2f('0x1'));var db=require('../../mysqldb')['db'];var logger=require('../../config/logger')(_0x5c2f('0x2'));var config=require('../../config/environment');config[_0x5c2f('0x3')]=_[_0x5c2f('0x4')](config[_0x5c2f('0x3')],{'host':_0x5c2f('0x5'),'port':0x18eb});var socket=require(_0x5c2f('0x6'))(new Redis(config[_0x5c2f('0x3')]));require(_0x5c2f('0x7'))[_0x5c2f('0x8')](socket);exports[_0x5c2f('0x9')]=function(_0x41a094){var _0x394ac9=this;return new Promise(function(_0x246b09,_0x219b52){return db['SquareProject'][_0x5c2f('0xa')]({'raw':_0x41a094[_0x5c2f('0xb')]?_0x41a094[_0x5c2f('0xb')][_0x5c2f('0xc')]===undefined?!![]:![]:!![],'where':_0x41a094[_0x5c2f('0xb')]?_0x41a094[_0x5c2f('0xb')][_0x5c2f('0xd')]||null:null,'attributes':_0x41a094[_0x5c2f('0xb')]?_0x41a094[_0x5c2f('0xb')][_0x5c2f('0xe')]||null:null,'limit':_0x41a094['options']?_0x41a094[_0x5c2f('0xb')][_0x5c2f('0xf')]||null:null,'include':_0x41a094[_0x5c2f('0xb')]?_0x41a094[_0x5c2f('0xb')][_0x5c2f('0x10')]?_[_0x5c2f('0x11')](_0x41a094[_0x5c2f('0xb')]['include'],function(_0xb67ac){return{'model':db[_0xb67ac[_0x5c2f('0x12')]],'as':_0xb67ac['as'],'attributes':_0xb67ac['attributes'],'include':_0xb67ac[_0x5c2f('0x10')]?_[_0x5c2f('0x11')](_0xb67ac[_0x5c2f('0x10')],function(_0x22f740){return{'model':db[_0x22f740['model']],'as':_0x22f740['as'],'attributes':_0x22f740[_0x5c2f('0xe')],'include':_0x22f740[_0x5c2f('0x10')]?_['map'](_0x22f740[_0x5c2f('0x10')],function(_0x2cf247){return{'model':db[_0x2cf247[_0x5c2f('0x12')]],'as':_0x2cf247['as'],'attributes':_0x2cf247[_0x5c2f('0xe')]};}):[]};}):[]};}):[]:[]})[_0x5c2f('0x13')](function(_0x4f08bc){logger['info'](_0x5c2f('0x9'),_0x41a094);logger['debug'](_0x5c2f('0x9'),_0x41a094,JSON[_0x5c2f('0x14')](_0x4f08bc));_0x246b09(_0x4f08bc);})['catch'](function(_0x12dfff){logger[_0x5c2f('0x15')](_0x5c2f('0x9'),_0x12dfff[_0x5c2f('0x16')],_0x41a094);_0x219b52(_0x394ac9[_0x5c2f('0x15')](0x1f4,_0x12dfff[_0x5c2f('0x16')]));});});};exports['ShowSquareProject']=function(_0x4a5e66){var _0xd84fe=this;return new Promise(function(_0x5bf6b1,_0xe9429){return db['SquareProject'][_0x5c2f('0x17')]({'raw':_0x4a5e66[_0x5c2f('0xb')]?_0x4a5e66['options'][_0x5c2f('0xc')]===undefined?!![]:![]:!![],'where':_0x4a5e66[_0x5c2f('0xb')]?_0x4a5e66[_0x5c2f('0xb')]['where']||null:null,'attributes':_0x4a5e66[_0x5c2f('0xb')]?_0x4a5e66[_0x5c2f('0xb')]['attributes']||null:null,'include':_0x4a5e66[_0x5c2f('0xb')]?_0x4a5e66[_0x5c2f('0xb')][_0x5c2f('0x10')]?_[_0x5c2f('0x11')](_0x4a5e66[_0x5c2f('0xb')]['include'],function(_0x494f71){return{'model':db[_0x494f71[_0x5c2f('0x12')]],'as':_0x494f71['as'],'attributes':_0x494f71[_0x5c2f('0xe')],'include':_0x494f71['include']?_['map'](_0x494f71[_0x5c2f('0x10')],function(_0x293d3b){return{'model':db[_0x293d3b[_0x5c2f('0x12')]],'as':_0x293d3b['as'],'attributes':_0x293d3b[_0x5c2f('0xe')],'include':_0x293d3b[_0x5c2f('0x10')]?_['map'](_0x293d3b[_0x5c2f('0x10')],function(_0x36381c){return{'model':db[_0x36381c[_0x5c2f('0x12')]],'as':_0x36381c['as'],'attributes':_0x36381c[_0x5c2f('0xe')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x56ed65){logger[_0x5c2f('0x18')]('ShowSquareProject',_0x4a5e66);logger[_0x5c2f('0x19')](_0x5c2f('0x1a'),_0x4a5e66,JSON[_0x5c2f('0x14')](_0x56ed65));_0x5bf6b1(_0x56ed65);})[_0x5c2f('0x1b')](function(_0x302070){logger['error'](_0x5c2f('0x1a'),_0x302070[_0x5c2f('0x16')],_0x4a5e66);_0xe9429(_0xd84fe[_0x5c2f('0x15')](0x1f4,_0x302070[_0x5c2f('0x16')]));});});};