Built motion from commit 753c950e.|2.5.42
[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 _0xecd4=['result','ShowSquareProject','SquareProject','find','options','raw','attributes','include','map','model','catch','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./squareProject.socket','request','then','info','SquareProject,\x20%s,\x20%s','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent'];(function(_0x57aa71,_0x182a6b){var _0xa03199=function(_0x109f02){while(--_0x109f02){_0x57aa71['push'](_0x57aa71['shift']());}};_0xa03199(++_0x182a6b);}(_0xecd4,0xc4));var _0x4ecd=function(_0x3d2a90,_0x2073ae){_0x3d2a90=_0x3d2a90-0x0;var _0x33fb5c=_0xecd4[_0x3d2a90];return _0x33fb5c;};'use strict';var _=require(_0x4ecd('0x0'));var util=require(_0x4ecd('0x1'));var moment=require(_0x4ecd('0x2'));var BPromise=require('bluebird');var rs=require(_0x4ecd('0x3'));var fs=require('fs');var Redis=require(_0x4ecd('0x4'));var db=require(_0x4ecd('0x5'))['db'];var utils=require(_0x4ecd('0x6'));var logger=require(_0x4ecd('0x7'))(_0x4ecd('0x8'));var config=require(_0x4ecd('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x4ecd('0xa')][_0x4ecd('0xb')]({'port':0x232a});config[_0x4ecd('0xc')]=_['defaults'](config[_0x4ecd('0xc')],{'host':_0x4ecd('0xd'),'port':0x18eb});var socket=require(_0x4ecd('0xe'))(new Redis(config['redis']));require(_0x4ecd('0xf'))['register'](socket);function respondWithRpcPromise(_0x43a3b8,_0x3b474a,_0x3ffb6c){return new BPromise(function(_0x12ef8e,_0x4773c5){return client[_0x4ecd('0x10')](_0x43a3b8,_0x3ffb6c)[_0x4ecd('0x11')](function(_0x5d1454){logger[_0x4ecd('0x12')](_0x4ecd('0x13'),_0x3b474a,'request\x20sent');logger[_0x4ecd('0x14')](_0x4ecd('0x15'),_0x3b474a,'request\x20sent',JSON[_0x4ecd('0x16')](_0x5d1454));if(_0x5d1454[_0x4ecd('0x17')]){if(_0x5d1454[_0x4ecd('0x17')]['code']===0x1f4){logger[_0x4ecd('0x17')]('SquareProject,\x20%s,\x20%s',_0x3b474a,_0x5d1454[_0x4ecd('0x17')][_0x4ecd('0x18')]);return _0x4773c5(_0x5d1454[_0x4ecd('0x17')]['message']);}logger['error'](_0x4ecd('0x13'),_0x3b474a,_0x5d1454[_0x4ecd('0x17')][_0x4ecd('0x18')]);return _0x12ef8e(_0x5d1454[_0x4ecd('0x17')][_0x4ecd('0x18')]);}else{logger[_0x4ecd('0x12')]('SquareProject,\x20%s,\x20%s',_0x3b474a,_0x4ecd('0x19'));_0x12ef8e(_0x5d1454[_0x4ecd('0x1a')][_0x4ecd('0x18')]);}})['catch'](function(_0x21a040){logger[_0x4ecd('0x17')](_0x4ecd('0x13'),_0x3b474a,_0x21a040);_0x4773c5(_0x21a040);});});}exports[_0x4ecd('0x1b')]=function(_0x686797){var _0x96660d=this;return new Promise(function(_0x469de4,_0x4cf51e){return db[_0x4ecd('0x1c')][_0x4ecd('0x1d')]({'raw':_0x686797[_0x4ecd('0x1e')]?_0x686797['options'][_0x4ecd('0x1f')]===undefined?!![]:![]:!![],'where':_0x686797[_0x4ecd('0x1e')]?_0x686797['options']['where']||null:null,'attributes':_0x686797[_0x4ecd('0x1e')]?_0x686797[_0x4ecd('0x1e')][_0x4ecd('0x20')]||null:null,'include':_0x686797[_0x4ecd('0x1e')]?_0x686797[_0x4ecd('0x1e')][_0x4ecd('0x21')]?_[_0x4ecd('0x22')](_0x686797[_0x4ecd('0x1e')][_0x4ecd('0x21')],function(_0x49ca8c){return{'model':db[_0x49ca8c['model']],'as':_0x49ca8c['as'],'attributes':_0x49ca8c[_0x4ecd('0x20')],'include':_0x49ca8c['include']?_['map'](_0x49ca8c[_0x4ecd('0x21')],function(_0x141850){return{'model':db[_0x141850[_0x4ecd('0x23')]],'as':_0x141850['as'],'attributes':_0x141850[_0x4ecd('0x20')],'include':_0x141850[_0x4ecd('0x21')]?_[_0x4ecd('0x22')](_0x141850[_0x4ecd('0x21')],function(_0x4974e4){return{'model':db[_0x4974e4[_0x4ecd('0x23')]],'as':_0x4974e4['as'],'attributes':_0x4974e4['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2738c6){logger[_0x4ecd('0x12')](_0x4ecd('0x1b'),_0x686797);logger[_0x4ecd('0x14')]('ShowSquareProject',_0x686797,JSON[_0x4ecd('0x16')](_0x2738c6));_0x469de4(_0x2738c6);})[_0x4ecd('0x24')](function(_0x1d9e41){logger['error'](_0x4ecd('0x1b'),_0x1d9e41[_0x4ecd('0x18')],_0x686797);_0x4cf51e(_0x96660d['error'](0x1f4,_0x1d9e41[_0x4ecd('0x18')]));});});};