460d089d1e47ae55951963bc9695af2ddae85371
[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 _0x7497=['raw','lodash','ioredis','../../mysqldb','rpc','../../config/environment','redis','socket.io-emitter','register','GetSquareProjects','SquareProject','findAll','options','limit','include','map','model','attributes','then','debug','stringify','catch','error','message','ShowSquareProject','find'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x7497,0xeb));var _0x7749=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7497[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x7749('0x0'));var Redis=require(_0x7749('0x1'));var db=require(_0x7749('0x2'))['db'];var logger=require('../../config/logger')(_0x7749('0x3'));var config=require(_0x7749('0x4'));config[_0x7749('0x5')]=_['defaults'](config[_0x7749('0x5')],{'host':'localhost','port':0x18eb});var socket=require(_0x7749('0x6'))(new Redis(config[_0x7749('0x5')]));require('./squareProject.socket')[_0x7749('0x7')](socket);exports[_0x7749('0x8')]=function(_0x508c81){var _0x135890=this;return new Promise(function(_0x26b388,_0x388390){return db[_0x7749('0x9')][_0x7749('0xa')]({'raw':_0x508c81[_0x7749('0xb')]?_0x508c81[_0x7749('0xb')]['raw']===undefined?!![]:![]:!![],'where':_0x508c81[_0x7749('0xb')]?_0x508c81[_0x7749('0xb')]['where']||null:null,'attributes':_0x508c81[_0x7749('0xb')]?_0x508c81[_0x7749('0xb')]['attributes']||null:null,'limit':_0x508c81[_0x7749('0xb')]?_0x508c81[_0x7749('0xb')][_0x7749('0xc')]||null:null,'include':_0x508c81['options']?_0x508c81[_0x7749('0xb')][_0x7749('0xd')]?_[_0x7749('0xe')](_0x508c81[_0x7749('0xb')][_0x7749('0xd')],function(_0x57f5d5){return{'model':db[_0x57f5d5[_0x7749('0xf')]],'as':_0x57f5d5['as'],'attributes':_0x57f5d5[_0x7749('0x10')],'include':_0x57f5d5['include']?_[_0x7749('0xe')](_0x57f5d5[_0x7749('0xd')],function(_0xc016dc){return{'model':db[_0xc016dc[_0x7749('0xf')]],'as':_0xc016dc['as'],'attributes':_0xc016dc[_0x7749('0x10')],'include':_0xc016dc[_0x7749('0xd')]?_[_0x7749('0xe')](_0xc016dc[_0x7749('0xd')],function(_0x39ba18){return{'model':db[_0x39ba18[_0x7749('0xf')]],'as':_0x39ba18['as'],'attributes':_0x39ba18[_0x7749('0x10')]};}):[]};}):[]};}):[]:[]})[_0x7749('0x11')](function(_0x1e4ce5){logger['info'](_0x7749('0x8'),_0x508c81);logger[_0x7749('0x12')](_0x7749('0x8'),_0x508c81,JSON[_0x7749('0x13')](_0x1e4ce5));_0x26b388(_0x1e4ce5);})[_0x7749('0x14')](function(_0x57fe5d){logger[_0x7749('0x15')]('GetSquareProjects',_0x57fe5d['message'],_0x508c81);_0x388390(_0x135890['error'](0x1f4,_0x57fe5d[_0x7749('0x16')]));});});};exports[_0x7749('0x17')]=function(_0x14f4bc){var _0x251162=this;return new Promise(function(_0x2dda34,_0xa44edc){return db[_0x7749('0x9')][_0x7749('0x18')]({'raw':_0x14f4bc['options']?_0x14f4bc[_0x7749('0xb')][_0x7749('0x19')]===undefined?!![]:![]:!![],'where':_0x14f4bc['options']?_0x14f4bc['options']['where']||null:null,'attributes':_0x14f4bc[_0x7749('0xb')]?_0x14f4bc['options'][_0x7749('0x10')]||null:null,'include':_0x14f4bc['options']?_0x14f4bc[_0x7749('0xb')][_0x7749('0xd')]?_[_0x7749('0xe')](_0x14f4bc[_0x7749('0xb')][_0x7749('0xd')],function(_0x403c81){return{'model':db[_0x403c81[_0x7749('0xf')]],'as':_0x403c81['as'],'attributes':_0x403c81['attributes'],'include':_0x403c81[_0x7749('0xd')]?_['map'](_0x403c81[_0x7749('0xd')],function(_0x506089){return{'model':db[_0x506089['model']],'as':_0x506089['as'],'attributes':_0x506089['attributes'],'include':_0x506089[_0x7749('0xd')]?_[_0x7749('0xe')](_0x506089['include'],function(_0x3ab9f1){return{'model':db[_0x3ab9f1[_0x7749('0xf')]],'as':_0x3ab9f1['as'],'attributes':_0x3ab9f1[_0x7749('0x10')]};}):[]};}):[]};}):[]:[]})[_0x7749('0x11')](function(_0x387db4){logger['info']('ShowSquareProject',_0x14f4bc);logger[_0x7749('0x12')](_0x7749('0x17'),_0x14f4bc,JSON[_0x7749('0x13')](_0x387db4));_0x2dda34(_0x387db4);})[_0x7749('0x14')](function(_0x590cb3){logger[_0x7749('0x15')](_0x7749('0x17'),_0x590cb3[_0x7749('0x16')],_0x14f4bc);_0xa44edc(_0x251162['error'](0x1f4,_0x590cb3['message']));});});};