Built motion from commit caf7d5f0.|2.5.39
[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 _0x8afd=['attributes','info','ShowSquareProject','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./squareProject.socket','register','request','then','SquareProject,\x20%s,\x20%s','request\x20sent','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','find','options','raw','where','include','map','model'];(function(_0x311eb0,_0x469a4e){var _0x511d58=function(_0x2996ea){while(--_0x2996ea){_0x311eb0['push'](_0x311eb0['shift']());}};_0x511d58(++_0x469a4e);}(_0x8afd,0x1d7));var _0xd8af=function(_0x180e86,_0xc85c3){_0x180e86=_0x180e86-0x0;var _0x11cdcd=_0x8afd[_0x180e86];return _0x11cdcd;};'use strict';var _=require(_0xd8af('0x0'));var util=require(_0xd8af('0x1'));var moment=require(_0xd8af('0x2'));var BPromise=require(_0xd8af('0x3'));var rs=require(_0xd8af('0x4'));var fs=require('fs');var Redis=require(_0xd8af('0x5'));var db=require(_0xd8af('0x6'))['db'];var utils=require(_0xd8af('0x7'));var logger=require('../../config/logger')(_0xd8af('0x8'));var config=require(_0xd8af('0x9'));var jayson=require(_0xd8af('0xa'));var client=jayson[_0xd8af('0xb')][_0xd8af('0xc')]({'port':0x232a});config[_0xd8af('0xd')]=_['defaults'](config['redis'],{'host':_0xd8af('0xe'),'port':0x18eb});var socket=require(_0xd8af('0xf'))(new Redis(config[_0xd8af('0xd')]));require(_0xd8af('0x10'))[_0xd8af('0x11')](socket);function respondWithRpcPromise(_0x4cedf8,_0x2f108a,_0x157cff){return new BPromise(function(_0x8ea2e5,_0x3fab04){return client[_0xd8af('0x12')](_0x4cedf8,_0x157cff)[_0xd8af('0x13')](function(_0x212109){logger['info'](_0xd8af('0x14'),_0x2f108a,_0xd8af('0x15'));logger[_0xd8af('0x16')](_0xd8af('0x17'),_0x2f108a,_0xd8af('0x15'),JSON[_0xd8af('0x18')](_0x212109));if(_0x212109[_0xd8af('0x19')]){if(_0x212109[_0xd8af('0x19')][_0xd8af('0x1a')]===0x1f4){logger['error']('SquareProject,\x20%s,\x20%s',_0x2f108a,_0x212109['error'][_0xd8af('0x1b')]);return _0x3fab04(_0x212109[_0xd8af('0x19')][_0xd8af('0x1b')]);}logger[_0xd8af('0x19')]('SquareProject,\x20%s,\x20%s',_0x2f108a,_0x212109[_0xd8af('0x19')][_0xd8af('0x1b')]);return _0x8ea2e5(_0x212109[_0xd8af('0x19')]['message']);}else{logger['info'](_0xd8af('0x14'),_0x2f108a,_0xd8af('0x15'));_0x8ea2e5(_0x212109['result'][_0xd8af('0x1b')]);}})[_0xd8af('0x1c')](function(_0x5d8f92){logger[_0xd8af('0x19')](_0xd8af('0x14'),_0x2f108a,_0x5d8f92);_0x3fab04(_0x5d8f92);});});}exports['ShowSquareProject']=function(_0x282593){var _0x11d5fd=this;return new Promise(function(_0x316273,_0x1cfa81){return db['SquareProject'][_0xd8af('0x1d')]({'raw':_0x282593[_0xd8af('0x1e')]?_0x282593[_0xd8af('0x1e')][_0xd8af('0x1f')]===undefined?!![]:![]:!![],'where':_0x282593[_0xd8af('0x1e')]?_0x282593['options'][_0xd8af('0x20')]||null:null,'attributes':_0x282593[_0xd8af('0x1e')]?_0x282593[_0xd8af('0x1e')]['attributes']||null:null,'include':_0x282593[_0xd8af('0x1e')]?_0x282593['options'][_0xd8af('0x21')]?_[_0xd8af('0x22')](_0x282593[_0xd8af('0x1e')][_0xd8af('0x21')],function(_0x4a8d26){return{'model':db[_0x4a8d26[_0xd8af('0x23')]],'as':_0x4a8d26['as'],'attributes':_0x4a8d26[_0xd8af('0x24')],'include':_0x4a8d26[_0xd8af('0x21')]?_[_0xd8af('0x22')](_0x4a8d26[_0xd8af('0x21')],function(_0x28332d){return{'model':db[_0x28332d[_0xd8af('0x23')]],'as':_0x28332d['as'],'attributes':_0x28332d['attributes'],'include':_0x28332d['include']?_[_0xd8af('0x22')](_0x28332d[_0xd8af('0x21')],function(_0x1f16b4){return{'model':db[_0x1f16b4[_0xd8af('0x23')]],'as':_0x1f16b4['as'],'attributes':_0x1f16b4[_0xd8af('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4e256){logger[_0xd8af('0x25')](_0xd8af('0x26'),_0x282593);logger[_0xd8af('0x16')](_0xd8af('0x26'),_0x282593,JSON[_0xd8af('0x18')](_0x4e256));_0x316273(_0x4e256);})[_0xd8af('0x1c')](function(_0x3e31c5){logger[_0xd8af('0x19')](_0xd8af('0x26'),_0x3e31c5[_0xd8af('0x1b')],_0x282593);_0x1cfa81(_0x11d5fd[_0xd8af('0x19')](0x1f4,_0x3e31c5[_0xd8af('0x1b')]));});});};