c040da9d178dca901849ae4605b42c0c8f49dc5a
[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 _0xe2c1=['register','GetSquareProjects','SquareProject','findAll','options','raw','where','attributes','include','map','model','then','info','catch','message','error','ShowSquareProject','find','debug','stringify','lodash','ioredis','../../config/logger','../../config/environment','redis','./squareProject.socket'];(function(_0x1731bd,_0x4830f0){var _0x33e629=function(_0x3475eb){while(--_0x3475eb){_0x1731bd['push'](_0x1731bd['shift']());}};_0x33e629(++_0x4830f0);}(_0xe2c1,0x1ce));var _0x1e2c=function(_0x36f4be,_0x581103){_0x36f4be=_0x36f4be-0x0;var _0x10e6ec=_0xe2c1[_0x36f4be];return _0x10e6ec;};'use strict';var _=require(_0x1e2c('0x0'));var Redis=require(_0x1e2c('0x1'));var db=require('../../mysqldb')['db'];var logger=require(_0x1e2c('0x2'))('rpc');var config=require(_0x1e2c('0x3'));config[_0x1e2c('0x4')]=_['defaults'](config[_0x1e2c('0x4')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1e2c('0x4')]));require(_0x1e2c('0x5'))[_0x1e2c('0x6')](socket);exports[_0x1e2c('0x7')]=function(_0x42dc93){var _0x3499cb=this;return new Promise(function(_0x118f65,_0x3f038b){return db[_0x1e2c('0x8')][_0x1e2c('0x9')]({'raw':_0x42dc93['options']?_0x42dc93[_0x1e2c('0xa')][_0x1e2c('0xb')]===undefined?!![]:![]:!![],'where':_0x42dc93[_0x1e2c('0xa')]?_0x42dc93['options'][_0x1e2c('0xc')]||null:null,'attributes':_0x42dc93[_0x1e2c('0xa')]?_0x42dc93[_0x1e2c('0xa')][_0x1e2c('0xd')]||null:null,'limit':_0x42dc93[_0x1e2c('0xa')]?_0x42dc93[_0x1e2c('0xa')]['limit']||null:null,'include':_0x42dc93[_0x1e2c('0xa')]?_0x42dc93[_0x1e2c('0xa')][_0x1e2c('0xe')]?_[_0x1e2c('0xf')](_0x42dc93['options'][_0x1e2c('0xe')],function(_0x55faf4){return{'model':db[_0x55faf4[_0x1e2c('0x10')]],'as':_0x55faf4['as'],'attributes':_0x55faf4[_0x1e2c('0xd')],'include':_0x55faf4['include']?_[_0x1e2c('0xf')](_0x55faf4[_0x1e2c('0xe')],function(_0x2d22f1){return{'model':db[_0x2d22f1[_0x1e2c('0x10')]],'as':_0x2d22f1['as'],'attributes':_0x2d22f1['attributes'],'include':_0x2d22f1['include']?_[_0x1e2c('0xf')](_0x2d22f1['include'],function(_0x28392c){return{'model':db[_0x28392c['model']],'as':_0x28392c['as'],'attributes':_0x28392c[_0x1e2c('0xd')]};}):[]};}):[]};}):[]:[]})[_0x1e2c('0x11')](function(_0xf246b1){logger[_0x1e2c('0x12')]('GetSquareProjects',_0x42dc93);logger['debug'](_0x1e2c('0x7'),_0x42dc93,JSON['stringify'](_0xf246b1));_0x118f65(_0xf246b1);})[_0x1e2c('0x13')](function(_0x5db118){logger['error']('GetSquareProjects',_0x5db118[_0x1e2c('0x14')],_0x42dc93);_0x3f038b(_0x3499cb[_0x1e2c('0x15')](0x1f4,_0x5db118[_0x1e2c('0x14')]));});});};exports[_0x1e2c('0x16')]=function(_0x2c9e44){var _0x4844ca=this;return new Promise(function(_0x507004,_0x58102){return db[_0x1e2c('0x8')][_0x1e2c('0x17')]({'raw':_0x2c9e44[_0x1e2c('0xa')]?_0x2c9e44[_0x1e2c('0xa')][_0x1e2c('0xb')]===undefined?!![]:![]:!![],'where':_0x2c9e44[_0x1e2c('0xa')]?_0x2c9e44[_0x1e2c('0xa')][_0x1e2c('0xc')]||null:null,'attributes':_0x2c9e44[_0x1e2c('0xa')]?_0x2c9e44[_0x1e2c('0xa')]['attributes']||null:null,'include':_0x2c9e44[_0x1e2c('0xa')]?_0x2c9e44['options'][_0x1e2c('0xe')]?_[_0x1e2c('0xf')](_0x2c9e44[_0x1e2c('0xa')][_0x1e2c('0xe')],function(_0x29115a){return{'model':db[_0x29115a['model']],'as':_0x29115a['as'],'attributes':_0x29115a[_0x1e2c('0xd')],'include':_0x29115a[_0x1e2c('0xe')]?_[_0x1e2c('0xf')](_0x29115a[_0x1e2c('0xe')],function(_0xceac9d){return{'model':db[_0xceac9d['model']],'as':_0xceac9d['as'],'attributes':_0xceac9d[_0x1e2c('0xd')],'include':_0xceac9d[_0x1e2c('0xe')]?_['map'](_0xceac9d[_0x1e2c('0xe')],function(_0x337786){return{'model':db[_0x337786[_0x1e2c('0x10')]],'as':_0x337786['as'],'attributes':_0x337786[_0x1e2c('0xd')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x593075){logger[_0x1e2c('0x12')]('ShowSquareProject',_0x2c9e44);logger[_0x1e2c('0x18')](_0x1e2c('0x16'),_0x2c9e44,JSON[_0x1e2c('0x19')](_0x593075));_0x507004(_0x593075);})['catch'](function(_0x115f58){logger[_0x1e2c('0x15')](_0x1e2c('0x16'),_0x115f58['message'],_0x2c9e44);_0x58102(_0x4844ca[_0x1e2c('0x15')](0x1f4,_0x115f58['message']));});});};