b92b276ecf542819a57b0f52606c0e4235b204c3
[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 _0x4b04=['register','request','then','SquareProject,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','ShowSquareProject','SquareProject','find','options','raw','where','include','model','attributes','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./squareProject.socket'];(function(_0x2cd1fb,_0x291f55){var _0x48fd2b=function(_0x18e23e){while(--_0x18e23e){_0x2cd1fb['push'](_0x2cd1fb['shift']());}};_0x48fd2b(++_0x291f55);}(_0x4b04,0xed));var _0x44b0=function(_0x455bcb,_0x2707d6){_0x455bcb=_0x455bcb-0x0;var _0x5f900=_0x4b04[_0x455bcb];return _0x5f900;};'use strict';var _=require(_0x44b0('0x0'));var util=require(_0x44b0('0x1'));var moment=require(_0x44b0('0x2'));var BPromise=require('bluebird');var rs=require(_0x44b0('0x3'));var fs=require('fs');var Redis=require(_0x44b0('0x4'));var db=require(_0x44b0('0x5'))['db'];var utils=require(_0x44b0('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x44b0('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x44b0('0x8')][_0x44b0('0x9')]({'port':0x232a});config[_0x44b0('0xa')]=_[_0x44b0('0xb')](config[_0x44b0('0xa')],{'host':_0x44b0('0xc'),'port':0x18eb});var socket=require(_0x44b0('0xd'))(new Redis(config[_0x44b0('0xa')]));require(_0x44b0('0xe'))[_0x44b0('0xf')](socket);function respondWithRpcPromise(_0x48820b,_0xc8cb9b,_0x341199){return new BPromise(function(_0x1fc5d1,_0x39d8a7){return client[_0x44b0('0x10')](_0x48820b,_0x341199)[_0x44b0('0x11')](function(_0x5dff8f){logger['info'](_0x44b0('0x12'),_0xc8cb9b,_0x44b0('0x13'));logger[_0x44b0('0x14')]('SquareProject,\x20%s,\x20%s,\x20%s',_0xc8cb9b,'request\x20sent',JSON[_0x44b0('0x15')](_0x5dff8f));if(_0x5dff8f['error']){if(_0x5dff8f[_0x44b0('0x16')][_0x44b0('0x17')]===0x1f4){logger['error']('SquareProject,\x20%s,\x20%s',_0xc8cb9b,_0x5dff8f[_0x44b0('0x16')][_0x44b0('0x18')]);return _0x39d8a7(_0x5dff8f[_0x44b0('0x16')][_0x44b0('0x18')]);}logger[_0x44b0('0x16')](_0x44b0('0x12'),_0xc8cb9b,_0x5dff8f['error']['message']);return _0x1fc5d1(_0x5dff8f['error'][_0x44b0('0x18')]);}else{logger['info']('SquareProject,\x20%s,\x20%s',_0xc8cb9b,'request\x20sent');_0x1fc5d1(_0x5dff8f[_0x44b0('0x19')][_0x44b0('0x18')]);}})[_0x44b0('0x1a')](function(_0x3535e7){logger[_0x44b0('0x16')](_0x44b0('0x12'),_0xc8cb9b,_0x3535e7);_0x39d8a7(_0x3535e7);});});}exports[_0x44b0('0x1b')]=function(_0x41f541){var _0x53bda9=this;return new Promise(function(_0x5098bd,_0x3a3740){return db[_0x44b0('0x1c')][_0x44b0('0x1d')]({'raw':_0x41f541[_0x44b0('0x1e')]?_0x41f541['options'][_0x44b0('0x1f')]===undefined?!![]:![]:!![],'where':_0x41f541[_0x44b0('0x1e')]?_0x41f541[_0x44b0('0x1e')][_0x44b0('0x20')]||null:null,'attributes':_0x41f541['options']?_0x41f541['options']['attributes']||null:null,'include':_0x41f541['options']?_0x41f541[_0x44b0('0x1e')]['include']?_['map'](_0x41f541[_0x44b0('0x1e')][_0x44b0('0x21')],function(_0x13d36e){return{'model':db[_0x13d36e[_0x44b0('0x22')]],'as':_0x13d36e['as'],'attributes':_0x13d36e[_0x44b0('0x23')],'include':_0x13d36e[_0x44b0('0x21')]?_['map'](_0x13d36e['include'],function(_0x15ceb8){return{'model':db[_0x15ceb8[_0x44b0('0x22')]],'as':_0x15ceb8['as'],'attributes':_0x15ceb8[_0x44b0('0x23')],'include':_0x15ceb8[_0x44b0('0x21')]?_['map'](_0x15ceb8[_0x44b0('0x21')],function(_0x5d3d73){return{'model':db[_0x5d3d73[_0x44b0('0x22')]],'as':_0x5d3d73['as'],'attributes':_0x5d3d73['attributes']};}):[]};}):[]};}):[]:[]})[_0x44b0('0x11')](function(_0x5a8d82){logger['info']('ShowSquareProject',_0x41f541);logger['debug'](_0x44b0('0x1b'),_0x41f541,JSON[_0x44b0('0x15')](_0x5a8d82));_0x5098bd(_0x5a8d82);})[_0x44b0('0x1a')](function(_0x21dbd7){logger[_0x44b0('0x16')](_0x44b0('0x1b'),_0x21dbd7[_0x44b0('0x18')],_0x41f541);_0x3a3740(_0x53bda9['error'](0x1f4,_0x21dbd7['message']));});});};