9c911b8efd6f288b514e514c2fe380f178805dd2
[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 _0x6883=['find','options','raw','attributes','include','model','map','ShowSquareProject','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','redis','defaults','localhost','socket.io-emitter','then','info','SquareProject,\x20%s,\x20%s','request\x20sent','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','SquareProject'];(function(_0x32d457,_0x1a39c9){var _0x338386=function(_0x199d7a){while(--_0x199d7a){_0x32d457['push'](_0x32d457['shift']());}};_0x338386(++_0x1a39c9);}(_0x6883,0x143));var _0x3688=function(_0x252cc2,_0x1d343f){_0x252cc2=_0x252cc2-0x0;var _0xc53f00=_0x6883[_0x252cc2];return _0xc53f00;};'use strict';var _=require('lodash');var util=require(_0x3688('0x0'));var moment=require(_0x3688('0x1'));var BPromise=require(_0x3688('0x2'));var rs=require(_0x3688('0x3'));var fs=require('fs');var Redis=require(_0x3688('0x4'));var db=require(_0x3688('0x5'))['db'];var utils=require(_0x3688('0x6'));var logger=require(_0x3688('0x7'))(_0x3688('0x8'));var config=require('../../config/environment');var jayson=require(_0x3688('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0x3688('0xa')]=_[_0x3688('0xb')](config['redis'],{'host':_0x3688('0xc'),'port':0x18eb});var socket=require(_0x3688('0xd'))(new Redis(config['redis']));require('./squareProject.socket')['register'](socket);function respondWithRpcPromise(_0x20044d,_0x4717e7,_0x3bbb0e){return new BPromise(function(_0xf67909,_0x55c91d){return client['request'](_0x20044d,_0x3bbb0e)[_0x3688('0xe')](function(_0x35085e){logger[_0x3688('0xf')](_0x3688('0x10'),_0x4717e7,_0x3688('0x11'));logger[_0x3688('0x12')](_0x3688('0x13'),_0x4717e7,_0x3688('0x11'),JSON[_0x3688('0x14')](_0x35085e));if(_0x35085e[_0x3688('0x15')]){if(_0x35085e[_0x3688('0x15')][_0x3688('0x16')]===0x1f4){logger[_0x3688('0x15')]('SquareProject,\x20%s,\x20%s',_0x4717e7,_0x35085e['error']['message']);return _0x55c91d(_0x35085e[_0x3688('0x15')][_0x3688('0x17')]);}logger['error'](_0x3688('0x10'),_0x4717e7,_0x35085e['error'][_0x3688('0x17')]);return _0xf67909(_0x35085e['error']['message']);}else{logger[_0x3688('0xf')](_0x3688('0x10'),_0x4717e7,_0x3688('0x11'));_0xf67909(_0x35085e[_0x3688('0x18')][_0x3688('0x17')]);}})[_0x3688('0x19')](function(_0x173f43){logger[_0x3688('0x15')]('SquareProject,\x20%s,\x20%s',_0x4717e7,_0x173f43);_0x55c91d(_0x173f43);});});}exports['ShowSquareProject']=function(_0x5f435f){var _0x409d2d=this;return new Promise(function(_0x20c1d5,_0xbaa322){return db[_0x3688('0x1a')][_0x3688('0x1b')]({'raw':_0x5f435f['options']?_0x5f435f[_0x3688('0x1c')][_0x3688('0x1d')]===undefined?!![]:![]:!![],'where':_0x5f435f[_0x3688('0x1c')]?_0x5f435f[_0x3688('0x1c')]['where']||null:null,'attributes':_0x5f435f[_0x3688('0x1c')]?_0x5f435f['options'][_0x3688('0x1e')]||null:null,'include':_0x5f435f[_0x3688('0x1c')]?_0x5f435f[_0x3688('0x1c')][_0x3688('0x1f')]?_['map'](_0x5f435f[_0x3688('0x1c')][_0x3688('0x1f')],function(_0x2dd222){return{'model':db[_0x2dd222[_0x3688('0x20')]],'as':_0x2dd222['as'],'attributes':_0x2dd222[_0x3688('0x1e')],'include':_0x2dd222[_0x3688('0x1f')]?_['map'](_0x2dd222['include'],function(_0x202279){return{'model':db[_0x202279[_0x3688('0x20')]],'as':_0x202279['as'],'attributes':_0x202279['attributes'],'include':_0x202279[_0x3688('0x1f')]?_[_0x3688('0x21')](_0x202279[_0x3688('0x1f')],function(_0xa767c2){return{'model':db[_0xa767c2['model']],'as':_0xa767c2['as'],'attributes':_0xa767c2[_0x3688('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x3688('0xe')](function(_0x228e2d){logger[_0x3688('0xf')](_0x3688('0x22'),_0x5f435f);logger[_0x3688('0x12')](_0x3688('0x22'),_0x5f435f,JSON[_0x3688('0x14')](_0x228e2d));_0x20c1d5(_0x228e2d);})['catch'](function(_0x5efff0){logger[_0x3688('0x15')]('ShowSquareProject',_0x5efff0[_0x3688('0x17')],_0x5f435f);_0xbaa322(_0x409d2d[_0x3688('0x15')](0x1f4,_0x5efff0['message']));});});};