703dcb30dec5e8030ec423f7b9186bc337d8553d
[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 _0x0192=['SquareProject','raw','where','options','attributes','include','map','model','debug','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','request\x20sent','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','SquareProject,\x20%s,\x20%s','message','result','catch','ShowSquareProject'];(function(_0x38a7ac,_0x45514b){var _0x53061a=function(_0x1d2469){while(--_0x1d2469){_0x38a7ac['push'](_0x38a7ac['shift']());}};_0x53061a(++_0x45514b);}(_0x0192,0x15f));var _0x2019=function(_0x357a59,_0x40ec50){_0x357a59=_0x357a59-0x0;var _0x1da1ce=_0x0192[_0x357a59];return _0x1da1ce;};'use strict';var _=require('lodash');var util=require(_0x2019('0x0'));var moment=require(_0x2019('0x1'));var BPromise=require(_0x2019('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2019('0x3'));var db=require(_0x2019('0x4'))['db'];var utils=require(_0x2019('0x5'));var logger=require(_0x2019('0x6'))(_0x2019('0x7'));var config=require(_0x2019('0x8'));var jayson=require(_0x2019('0x9'));var client=jayson['client'][_0x2019('0xa')]({'port':0x232a});config['redis']=_[_0x2019('0xb')](config[_0x2019('0xc')],{'host':_0x2019('0xd'),'port':0x18eb});var socket=require(_0x2019('0xe'))(new Redis(config['redis']));require('./squareProject.socket')[_0x2019('0xf')](socket);function respondWithRpcPromise(_0x35ca93,_0x3c6f7b,_0x57b72f){return new BPromise(function(_0x357956,_0x33ab4a){return client[_0x2019('0x10')](_0x35ca93,_0x57b72f)[_0x2019('0x11')](function(_0x446210){logger[_0x2019('0x12')]('SquareProject,\x20%s,\x20%s',_0x3c6f7b,_0x2019('0x13'));logger['debug'](_0x2019('0x14'),_0x3c6f7b,_0x2019('0x13'),JSON[_0x2019('0x15')](_0x446210));if(_0x446210[_0x2019('0x16')]){if(_0x446210[_0x2019('0x16')][_0x2019('0x17')]===0x1f4){logger[_0x2019('0x16')](_0x2019('0x18'),_0x3c6f7b,_0x446210[_0x2019('0x16')][_0x2019('0x19')]);return _0x33ab4a(_0x446210[_0x2019('0x16')][_0x2019('0x19')]);}logger[_0x2019('0x16')](_0x2019('0x18'),_0x3c6f7b,_0x446210[_0x2019('0x16')][_0x2019('0x19')]);return _0x357956(_0x446210[_0x2019('0x16')][_0x2019('0x19')]);}else{logger[_0x2019('0x12')](_0x2019('0x18'),_0x3c6f7b,_0x2019('0x13'));_0x357956(_0x446210[_0x2019('0x1a')][_0x2019('0x19')]);}})[_0x2019('0x1b')](function(_0x169280){logger[_0x2019('0x16')]('SquareProject,\x20%s,\x20%s',_0x3c6f7b,_0x169280);_0x33ab4a(_0x169280);});});}exports[_0x2019('0x1c')]=function(_0x4c5e40){var _0x146563=this;return new Promise(function(_0x1a1a06,_0x4f6675){return db[_0x2019('0x1d')]['find']({'raw':_0x4c5e40['options']?_0x4c5e40['options'][_0x2019('0x1e')]===undefined?!![]:![]:!![],'where':_0x4c5e40['options']?_0x4c5e40['options'][_0x2019('0x1f')]||null:null,'attributes':_0x4c5e40[_0x2019('0x20')]?_0x4c5e40[_0x2019('0x20')][_0x2019('0x21')]||null:null,'include':_0x4c5e40['options']?_0x4c5e40[_0x2019('0x20')][_0x2019('0x22')]?_[_0x2019('0x23')](_0x4c5e40[_0x2019('0x20')]['include'],function(_0x2b96a8){return{'model':db[_0x2b96a8[_0x2019('0x24')]],'as':_0x2b96a8['as'],'attributes':_0x2b96a8[_0x2019('0x21')],'include':_0x2b96a8['include']?_[_0x2019('0x23')](_0x2b96a8[_0x2019('0x22')],function(_0x1e9e46){return{'model':db[_0x1e9e46[_0x2019('0x24')]],'as':_0x1e9e46['as'],'attributes':_0x1e9e46[_0x2019('0x21')],'include':_0x1e9e46[_0x2019('0x22')]?_[_0x2019('0x23')](_0x1e9e46['include'],function(_0x54dc7b){return{'model':db[_0x54dc7b['model']],'as':_0x54dc7b['as'],'attributes':_0x54dc7b['attributes']};}):[]};}):[]};}):[]:[]})[_0x2019('0x11')](function(_0x1c0151){logger[_0x2019('0x12')](_0x2019('0x1c'),_0x4c5e40);logger[_0x2019('0x25')](_0x2019('0x1c'),_0x4c5e40,JSON[_0x2019('0x15')](_0x1c0151));_0x1a1a06(_0x1c0151);})[_0x2019('0x1b')](function(_0x2acd57){logger[_0x2019('0x16')]('ShowSquareProject',_0x2acd57[_0x2019('0x19')],_0x4c5e40);_0x4f6675(_0x146563[_0x2019('0x16')](0x1f4,_0x2acd57[_0x2019('0x19')]));});});};