Built motion from commit (unavailable).|2.5.4
[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 _0xbdbd=['map','attributes','lodash','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./squareProject.socket','register','request','then','info','SquareProject,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','ShowSquareProject','find','options','raw','where','include','model'];(function(_0x3730b1,_0x28a04b){var _0x2a75db=function(_0x348b9b){while(--_0x348b9b){_0x3730b1['push'](_0x3730b1['shift']());}};_0x2a75db(++_0x28a04b);}(_0xbdbd,0xda));var _0xdbdb=function(_0x1cba9b,_0x2cfcb4){_0x1cba9b=_0x1cba9b-0x0;var _0xbafdda=_0xbdbd[_0x1cba9b];return _0xbafdda;};'use strict';var _=require(_0xdbdb('0x0'));var util=require('util');var moment=require(_0xdbdb('0x1'));var BPromise=require(_0xdbdb('0x2'));var rs=require(_0xdbdb('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xdbdb('0x4'));var logger=require(_0xdbdb('0x5'))(_0xdbdb('0x6'));var config=require(_0xdbdb('0x7'));var jayson=require(_0xdbdb('0x8'));var client=jayson[_0xdbdb('0x9')][_0xdbdb('0xa')]({'port':0x232a});config[_0xdbdb('0xb')]=_[_0xdbdb('0xc')](config[_0xdbdb('0xb')],{'host':_0xdbdb('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xdbdb('0xb')]));require(_0xdbdb('0xe'))[_0xdbdb('0xf')](socket);function respondWithRpcPromise(_0x437c4a,_0xe31d77,_0x2dcdbd){return new BPromise(function(_0x4b938e,_0x2a2ade){return client[_0xdbdb('0x10')](_0x437c4a,_0x2dcdbd)[_0xdbdb('0x11')](function(_0xdf4c53){logger[_0xdbdb('0x12')](_0xdbdb('0x13'),_0xe31d77,_0xdbdb('0x14'));logger['debug']('SquareProject,\x20%s,\x20%s,\x20%s',_0xe31d77,_0xdbdb('0x14'),JSON[_0xdbdb('0x15')](_0xdf4c53));if(_0xdf4c53[_0xdbdb('0x16')]){if(_0xdf4c53[_0xdbdb('0x16')][_0xdbdb('0x17')]===0x1f4){logger[_0xdbdb('0x16')]('SquareProject,\x20%s,\x20%s',_0xe31d77,_0xdf4c53['error'][_0xdbdb('0x18')]);return _0x2a2ade(_0xdf4c53[_0xdbdb('0x16')][_0xdbdb('0x18')]);}logger[_0xdbdb('0x16')](_0xdbdb('0x13'),_0xe31d77,_0xdf4c53['error'][_0xdbdb('0x18')]);return _0x4b938e(_0xdf4c53[_0xdbdb('0x16')][_0xdbdb('0x18')]);}else{logger[_0xdbdb('0x12')]('SquareProject,\x20%s,\x20%s',_0xe31d77,_0xdbdb('0x14'));_0x4b938e(_0xdf4c53[_0xdbdb('0x19')][_0xdbdb('0x18')]);}})[_0xdbdb('0x1a')](function(_0x9e8ff8){logger[_0xdbdb('0x16')](_0xdbdb('0x13'),_0xe31d77,_0x9e8ff8);_0x2a2ade(_0x9e8ff8);});});}exports[_0xdbdb('0x1b')]=function(_0x7e4b14){var _0xc8cb8f=this;return new Promise(function(_0xc0f741,_0x4fe40a){return db['SquareProject'][_0xdbdb('0x1c')]({'raw':_0x7e4b14['options']?_0x7e4b14[_0xdbdb('0x1d')][_0xdbdb('0x1e')]===undefined?!![]:![]:!![],'where':_0x7e4b14[_0xdbdb('0x1d')]?_0x7e4b14[_0xdbdb('0x1d')][_0xdbdb('0x1f')]||null:null,'attributes':_0x7e4b14[_0xdbdb('0x1d')]?_0x7e4b14[_0xdbdb('0x1d')]['attributes']||null:null,'include':_0x7e4b14[_0xdbdb('0x1d')]?_0x7e4b14[_0xdbdb('0x1d')][_0xdbdb('0x20')]?_['map'](_0x7e4b14[_0xdbdb('0x1d')][_0xdbdb('0x20')],function(_0x5f0186){return{'model':db[_0x5f0186[_0xdbdb('0x21')]],'as':_0x5f0186['as'],'attributes':_0x5f0186['attributes'],'include':_0x5f0186[_0xdbdb('0x20')]?_[_0xdbdb('0x22')](_0x5f0186[_0xdbdb('0x20')],function(_0x267ead){return{'model':db[_0x267ead[_0xdbdb('0x21')]],'as':_0x267ead['as'],'attributes':_0x267ead[_0xdbdb('0x23')],'include':_0x267ead[_0xdbdb('0x20')]?_[_0xdbdb('0x22')](_0x267ead[_0xdbdb('0x20')],function(_0x29b7ee){return{'model':db[_0x29b7ee[_0xdbdb('0x21')]],'as':_0x29b7ee['as'],'attributes':_0x29b7ee[_0xdbdb('0x23')]};}):[]};}):[]};}):[]:[]})[_0xdbdb('0x11')](function(_0x91d8f5){logger[_0xdbdb('0x12')](_0xdbdb('0x1b'),_0x7e4b14);logger['debug'](_0xdbdb('0x1b'),_0x7e4b14,JSON[_0xdbdb('0x15')](_0x91d8f5));_0xc0f741(_0x91d8f5);})[_0xdbdb('0x1a')](function(_0x50a78e){logger[_0xdbdb('0x16')](_0xdbdb('0x1b'),_0x50a78e[_0xdbdb('0x18')],_0x7e4b14);_0x4fe40a(_0xc8cb8f[_0xdbdb('0x16')](0x1f4,_0x50a78e[_0xdbdb('0x18')]));});});};