d641db2e4a92f3b3bab89a8eb4f0ce6f2b527fa5
[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 _0x871b=['model','then','info','debug','stringify','error','ShowSquareProject','find','message','../../mysqldb','../../config/logger','rpc','../../config/environment','redis','socket.io-emitter','register','GetSquareProjects','SquareProject','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x874cf1,_0x2a4954){var _0x233579=function(_0xa6e939){while(--_0xa6e939){_0x874cf1['push'](_0x874cf1['shift']());}};_0x233579(++_0x2a4954);}(_0x871b,0x8b));var _0xb871=function(_0x4f815f,_0x1002e0){_0x4f815f=_0x4f815f-0x0;var _0x242b0f=_0x871b[_0x4f815f];return _0x242b0f;};'use strict';var _=require('lodash');var Redis=require('ioredis');var db=require(_0xb871('0x0'))['db'];var logger=require(_0xb871('0x1'))(_0xb871('0x2'));var config=require(_0xb871('0x3'));config['redis']=_['defaults'](config[_0xb871('0x4')],{'host':'localhost','port':0x18eb});var socket=require(_0xb871('0x5'))(new Redis(config[_0xb871('0x4')]));require('./squareProject.socket')[_0xb871('0x6')](socket);exports[_0xb871('0x7')]=function(_0x44940d){var _0x1d5b30=this;return new Promise(function(_0x3fc170,_0x20cd58){return db[_0xb871('0x8')][_0xb871('0x9')]({'raw':_0x44940d[_0xb871('0xa')]?_0x44940d[_0xb871('0xa')][_0xb871('0xb')]===undefined?!![]:![]:!![],'where':_0x44940d[_0xb871('0xa')]?_0x44940d[_0xb871('0xa')][_0xb871('0xc')]||null:null,'attributes':_0x44940d[_0xb871('0xa')]?_0x44940d[_0xb871('0xa')][_0xb871('0xd')]||null:null,'limit':_0x44940d[_0xb871('0xa')]?_0x44940d['options'][_0xb871('0xe')]||null:null,'include':_0x44940d[_0xb871('0xa')]?_0x44940d[_0xb871('0xa')][_0xb871('0xf')]?_[_0xb871('0x10')](_0x44940d['options'][_0xb871('0xf')],function(_0x11f21e){return{'model':db[_0x11f21e[_0xb871('0x11')]],'as':_0x11f21e['as'],'attributes':_0x11f21e[_0xb871('0xd')],'include':_0x11f21e[_0xb871('0xf')]?_['map'](_0x11f21e['include'],function(_0x28ab8a){return{'model':db[_0x28ab8a[_0xb871('0x11')]],'as':_0x28ab8a['as'],'attributes':_0x28ab8a[_0xb871('0xd')],'include':_0x28ab8a[_0xb871('0xf')]?_[_0xb871('0x10')](_0x28ab8a[_0xb871('0xf')],function(_0x59b5d0){return{'model':db[_0x59b5d0[_0xb871('0x11')]],'as':_0x59b5d0['as'],'attributes':_0x59b5d0[_0xb871('0xd')]};}):[]};}):[]};}):[]:[]})[_0xb871('0x12')](function(_0x304a71){logger[_0xb871('0x13')](_0xb871('0x7'),_0x44940d);logger[_0xb871('0x14')](_0xb871('0x7'),_0x44940d,JSON[_0xb871('0x15')](_0x304a71));_0x3fc170(_0x304a71);})['catch'](function(_0xe9fa3a){logger[_0xb871('0x16')](_0xb871('0x7'),_0xe9fa3a['message'],_0x44940d);_0x20cd58(_0x1d5b30[_0xb871('0x16')](0x1f4,_0xe9fa3a['message']));});});};exports[_0xb871('0x17')]=function(_0x5444be){var _0x44dee1=this;return new Promise(function(_0x46f975,_0x2b5c80){return db[_0xb871('0x8')][_0xb871('0x18')]({'raw':_0x5444be[_0xb871('0xa')]?_0x5444be[_0xb871('0xa')][_0xb871('0xb')]===undefined?!![]:![]:!![],'where':_0x5444be[_0xb871('0xa')]?_0x5444be[_0xb871('0xa')]['where']||null:null,'attributes':_0x5444be['options']?_0x5444be[_0xb871('0xa')][_0xb871('0xd')]||null:null,'include':_0x5444be[_0xb871('0xa')]?_0x5444be[_0xb871('0xa')]['include']?_['map'](_0x5444be[_0xb871('0xa')][_0xb871('0xf')],function(_0x3a9ae5){return{'model':db[_0x3a9ae5[_0xb871('0x11')]],'as':_0x3a9ae5['as'],'attributes':_0x3a9ae5[_0xb871('0xd')],'include':_0x3a9ae5['include']?_['map'](_0x3a9ae5[_0xb871('0xf')],function(_0x25434c){return{'model':db[_0x25434c[_0xb871('0x11')]],'as':_0x25434c['as'],'attributes':_0x25434c[_0xb871('0xd')],'include':_0x25434c[_0xb871('0xf')]?_[_0xb871('0x10')](_0x25434c[_0xb871('0xf')],function(_0x28d3ab){return{'model':db[_0x28d3ab['model']],'as':_0x28d3ab['as'],'attributes':_0x28d3ab[_0xb871('0xd')]};}):[]};}):[]};}):[]:[]})[_0xb871('0x12')](function(_0x12106a){logger['info'](_0xb871('0x17'),_0x5444be);logger[_0xb871('0x14')](_0xb871('0x17'),_0x5444be,JSON[_0xb871('0x15')](_0x12106a));_0x46f975(_0x12106a);})['catch'](function(_0x245f9d){logger[_0xb871('0x16')](_0xb871('0x17'),_0x245f9d['message'],_0x5444be);_0x2b5c80(_0x44dee1[_0xb871('0x16')](0x1f4,_0x245f9d[_0xb871('0x19')]));});});};