44239f0a623db66804833d6f6a70095f8b009dc8
[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 _0xe344=['error','code','SquareProject,\x20%s,\x20%s','message','request\x20sent','result','catch','find','options','where','attributes','include','map','model','ShowSquareProject','lodash','util','moment','randomstring','ioredis','../../config/utils','rpc','jayson/promise','http','defaults','localhost','socket.io-emitter','redis','./squareProject.socket','then','info','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x4171dc,_0xbc44c4){var _0x1377c4=function(_0x1a332d){while(--_0x1a332d){_0x4171dc['push'](_0x4171dc['shift']());}};_0x1377c4(++_0xbc44c4);}(_0xe344,0xdb));var _0x4e34=function(_0x7f0a5,_0x31502){_0x7f0a5=_0x7f0a5-0x0;var _0x559f8f=_0xe344[_0x7f0a5];return _0x559f8f;};'use strict';var _=require(_0x4e34('0x0'));var util=require(_0x4e34('0x1'));var moment=require(_0x4e34('0x2'));var BPromise=require('bluebird');var rs=require(_0x4e34('0x3'));var fs=require('fs');var Redis=require(_0x4e34('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x4e34('0x5'));var logger=require('../../config/logger')(_0x4e34('0x6'));var config=require('../../config/environment');var jayson=require(_0x4e34('0x7'));var client=jayson['client'][_0x4e34('0x8')]({'port':0x232a});config['redis']=_[_0x4e34('0x9')](config['redis'],{'host':_0x4e34('0xa'),'port':0x18eb});var socket=require(_0x4e34('0xb'))(new Redis(config[_0x4e34('0xc')]));require(_0x4e34('0xd'))['register'](socket);function respondWithRpcPromise(_0x44696e,_0x308ce9,_0xee8c1f){return new BPromise(function(_0x3602a3,_0x38df71){return client['request'](_0x44696e,_0xee8c1f)[_0x4e34('0xe')](function(_0x3e6e33){logger[_0x4e34('0xf')]('SquareProject,\x20%s,\x20%s',_0x308ce9,'request\x20sent');logger[_0x4e34('0x10')](_0x4e34('0x11'),_0x308ce9,'request\x20sent',JSON[_0x4e34('0x12')](_0x3e6e33));if(_0x3e6e33[_0x4e34('0x13')]){if(_0x3e6e33['error'][_0x4e34('0x14')]===0x1f4){logger[_0x4e34('0x13')](_0x4e34('0x15'),_0x308ce9,_0x3e6e33[_0x4e34('0x13')][_0x4e34('0x16')]);return _0x38df71(_0x3e6e33['error'][_0x4e34('0x16')]);}logger[_0x4e34('0x13')]('SquareProject,\x20%s,\x20%s',_0x308ce9,_0x3e6e33[_0x4e34('0x13')][_0x4e34('0x16')]);return _0x3602a3(_0x3e6e33['error'][_0x4e34('0x16')]);}else{logger[_0x4e34('0xf')](_0x4e34('0x15'),_0x308ce9,_0x4e34('0x17'));_0x3602a3(_0x3e6e33[_0x4e34('0x18')][_0x4e34('0x16')]);}})[_0x4e34('0x19')](function(_0x4f9283){logger['error'](_0x4e34('0x15'),_0x308ce9,_0x4f9283);_0x38df71(_0x4f9283);});});}exports['ShowSquareProject']=function(_0x12a3e4){var _0x1831d4=this;return new Promise(function(_0x297825,_0x8b56c0){return db['SquareProject'][_0x4e34('0x1a')]({'raw':_0x12a3e4['options']?_0x12a3e4['options']['raw']===undefined?!![]:![]:!![],'where':_0x12a3e4[_0x4e34('0x1b')]?_0x12a3e4[_0x4e34('0x1b')][_0x4e34('0x1c')]||null:null,'attributes':_0x12a3e4[_0x4e34('0x1b')]?_0x12a3e4['options'][_0x4e34('0x1d')]||null:null,'include':_0x12a3e4[_0x4e34('0x1b')]?_0x12a3e4[_0x4e34('0x1b')][_0x4e34('0x1e')]?_[_0x4e34('0x1f')](_0x12a3e4['options'][_0x4e34('0x1e')],function(_0x49c44e){return{'model':db[_0x49c44e[_0x4e34('0x20')]],'as':_0x49c44e['as'],'attributes':_0x49c44e['attributes'],'include':_0x49c44e['include']?_[_0x4e34('0x1f')](_0x49c44e[_0x4e34('0x1e')],function(_0x1bf0b0){return{'model':db[_0x1bf0b0[_0x4e34('0x20')]],'as':_0x1bf0b0['as'],'attributes':_0x1bf0b0[_0x4e34('0x1d')],'include':_0x1bf0b0[_0x4e34('0x1e')]?_[_0x4e34('0x1f')](_0x1bf0b0[_0x4e34('0x1e')],function(_0x3adff8){return{'model':db[_0x3adff8[_0x4e34('0x20')]],'as':_0x3adff8['as'],'attributes':_0x3adff8['attributes']};}):[]};}):[]};}):[]:[]})[_0x4e34('0xe')](function(_0x5310d3){logger[_0x4e34('0xf')](_0x4e34('0x21'),_0x12a3e4);logger[_0x4e34('0x10')](_0x4e34('0x21'),_0x12a3e4,JSON[_0x4e34('0x12')](_0x5310d3));_0x297825(_0x5310d3);})[_0x4e34('0x19')](function(_0x8f819){logger[_0x4e34('0x13')]('ShowSquareProject',_0x8f819[_0x4e34('0x16')],_0x12a3e4);_0x8b56c0(_0x1831d4[_0x4e34('0x13')](0x1f4,_0x8f819['message']));});});};