9aa4ef25908f0e58fd6d7c13fb07ea662ddf6b66
[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 _0x78e8=['ShowSquareProject','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','http','defaults','redis','localhost','socket.io-emitter','./squareProject.socket','request','then','info','SquareProject,\x20%s,\x20%s','debug','SquareProject,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','catch','find','options','raw','where','include','map','model','attributes'];(function(_0x3d9565,_0x5db973){var _0x546f66=function(_0x137352){while(--_0x137352){_0x3d9565['push'](_0x3d9565['shift']());}};_0x546f66(++_0x5db973);}(_0x78e8,0xef));var _0x878e=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0x78e8[_0x5b644e];return _0x49c6bf;};'use strict';var _=require('lodash');var util=require(_0x878e('0x0'));var moment=require(_0x878e('0x1'));var BPromise=require(_0x878e('0x2'));var rs=require(_0x878e('0x3'));var fs=require('fs');var Redis=require(_0x878e('0x4'));var db=require(_0x878e('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x878e('0x6'));var config=require(_0x878e('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x878e('0x8')]({'port':0x232a});config['redis']=_[_0x878e('0x9')](config[_0x878e('0xa')],{'host':_0x878e('0xb'),'port':0x18eb});var socket=require(_0x878e('0xc'))(new Redis(config['redis']));require(_0x878e('0xd'))['register'](socket);function respondWithRpcPromise(_0x4eca77,_0xfbb629,_0x9371de){return new BPromise(function(_0x8c579,_0x37b5f9){return client[_0x878e('0xe')](_0x4eca77,_0x9371de)[_0x878e('0xf')](function(_0x14d821){logger[_0x878e('0x10')](_0x878e('0x11'),_0xfbb629,'request\x20sent');logger[_0x878e('0x12')](_0x878e('0x13'),_0xfbb629,_0x878e('0x14'),JSON['stringify'](_0x14d821));if(_0x14d821[_0x878e('0x15')]){if(_0x14d821[_0x878e('0x15')][_0x878e('0x16')]===0x1f4){logger['error']('SquareProject,\x20%s,\x20%s',_0xfbb629,_0x14d821[_0x878e('0x15')][_0x878e('0x17')]);return _0x37b5f9(_0x14d821[_0x878e('0x15')][_0x878e('0x17')]);}logger[_0x878e('0x15')](_0x878e('0x11'),_0xfbb629,_0x14d821[_0x878e('0x15')][_0x878e('0x17')]);return _0x8c579(_0x14d821[_0x878e('0x15')][_0x878e('0x17')]);}else{logger[_0x878e('0x10')](_0x878e('0x11'),_0xfbb629,_0x878e('0x14'));_0x8c579(_0x14d821['result']['message']);}})[_0x878e('0x18')](function(_0x10aba0){logger[_0x878e('0x15')](_0x878e('0x11'),_0xfbb629,_0x10aba0);_0x37b5f9(_0x10aba0);});});}exports['ShowSquareProject']=function(_0x563b45){var _0x2cc5f3=this;return new Promise(function(_0x4ac10,_0x32568e){return db['SquareProject'][_0x878e('0x19')]({'raw':_0x563b45[_0x878e('0x1a')]?_0x563b45[_0x878e('0x1a')][_0x878e('0x1b')]===undefined?!![]:![]:!![],'where':_0x563b45[_0x878e('0x1a')]?_0x563b45['options'][_0x878e('0x1c')]||null:null,'attributes':_0x563b45[_0x878e('0x1a')]?_0x563b45[_0x878e('0x1a')]['attributes']||null:null,'include':_0x563b45['options']?_0x563b45[_0x878e('0x1a')][_0x878e('0x1d')]?_[_0x878e('0x1e')](_0x563b45[_0x878e('0x1a')][_0x878e('0x1d')],function(_0x1660b2){return{'model':db[_0x1660b2[_0x878e('0x1f')]],'as':_0x1660b2['as'],'attributes':_0x1660b2['attributes'],'include':_0x1660b2[_0x878e('0x1d')]?_[_0x878e('0x1e')](_0x1660b2[_0x878e('0x1d')],function(_0x217ce5){return{'model':db[_0x217ce5[_0x878e('0x1f')]],'as':_0x217ce5['as'],'attributes':_0x217ce5[_0x878e('0x20')],'include':_0x217ce5[_0x878e('0x1d')]?_[_0x878e('0x1e')](_0x217ce5[_0x878e('0x1d')],function(_0x471959){return{'model':db[_0x471959[_0x878e('0x1f')]],'as':_0x471959['as'],'attributes':_0x471959[_0x878e('0x20')]};}):[]};}):[]};}):[]:[]})[_0x878e('0xf')](function(_0x6b9d62){logger[_0x878e('0x10')](_0x878e('0x21'),_0x563b45);logger[_0x878e('0x12')](_0x878e('0x21'),_0x563b45,JSON['stringify'](_0x6b9d62));_0x4ac10(_0x6b9d62);})['catch'](function(_0x48527b){logger[_0x878e('0x15')]('ShowSquareProject',_0x48527b[_0x878e('0x17')],_0x563b45);_0x32568e(_0x2cc5f3['error'](0x1f4,_0x48527b['message']));});});};