Built motion from commit (unavailable).|2.5.19
[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 _0x6ba4=['SquareProject,\x20%s,\x20%s','debug','SquareProject,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','info','result','ShowSquareProject','SquareProject','find','options','raw','where','include','map','model','attributes','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','redis','localhost','socket.io-emitter','then'];(function(_0x5ab7b2,_0x343568){var _0x528fd0=function(_0x54f395){while(--_0x54f395){_0x5ab7b2['push'](_0x5ab7b2['shift']());}};_0x528fd0(++_0x343568);}(_0x6ba4,0xad));var _0x46ba=function(_0x3c44a3,_0x1ae7b5){_0x3c44a3=_0x3c44a3-0x0;var _0x3c6f7b=_0x6ba4[_0x3c44a3];return _0x3c6f7b;};'use strict';var _=require(_0x46ba('0x0'));var util=require(_0x46ba('0x1'));var moment=require(_0x46ba('0x2'));var BPromise=require(_0x46ba('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x46ba('0x4'))['db'];var utils=require(_0x46ba('0x5'));var logger=require(_0x46ba('0x6'))(_0x46ba('0x7'));var config=require(_0x46ba('0x8'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x46ba('0x9')]=_['defaults'](config['redis'],{'host':_0x46ba('0xa'),'port':0x18eb});var socket=require(_0x46ba('0xb'))(new Redis(config[_0x46ba('0x9')]));require('./squareProject.socket')['register'](socket);function respondWithRpcPromise(_0x40d15f,_0x756853,_0x1e0417){return new BPromise(function(_0x128021,_0x19cfbb){return client['request'](_0x40d15f,_0x1e0417)[_0x46ba('0xc')](function(_0x1d1f07){logger['info'](_0x46ba('0xd'),_0x756853,'request\x20sent');logger[_0x46ba('0xe')](_0x46ba('0xf'),_0x756853,_0x46ba('0x10'),JSON['stringify'](_0x1d1f07));if(_0x1d1f07[_0x46ba('0x11')]){if(_0x1d1f07[_0x46ba('0x11')]['code']===0x1f4){logger[_0x46ba('0x11')](_0x46ba('0xd'),_0x756853,_0x1d1f07[_0x46ba('0x11')][_0x46ba('0x12')]);return _0x19cfbb(_0x1d1f07['error'][_0x46ba('0x12')]);}logger[_0x46ba('0x11')]('SquareProject,\x20%s,\x20%s',_0x756853,_0x1d1f07[_0x46ba('0x11')][_0x46ba('0x12')]);return _0x128021(_0x1d1f07[_0x46ba('0x11')][_0x46ba('0x12')]);}else{logger[_0x46ba('0x13')](_0x46ba('0xd'),_0x756853,'request\x20sent');_0x128021(_0x1d1f07[_0x46ba('0x14')]['message']);}})['catch'](function(_0x8bc204){logger[_0x46ba('0x11')](_0x46ba('0xd'),_0x756853,_0x8bc204);_0x19cfbb(_0x8bc204);});});}exports[_0x46ba('0x15')]=function(_0x52ec8c){var _0x222c9f=this;return new Promise(function(_0x95b597,_0x27c65f){return db[_0x46ba('0x16')][_0x46ba('0x17')]({'raw':_0x52ec8c[_0x46ba('0x18')]?_0x52ec8c[_0x46ba('0x18')][_0x46ba('0x19')]===undefined?!![]:![]:!![],'where':_0x52ec8c[_0x46ba('0x18')]?_0x52ec8c[_0x46ba('0x18')][_0x46ba('0x1a')]||null:null,'attributes':_0x52ec8c[_0x46ba('0x18')]?_0x52ec8c[_0x46ba('0x18')]['attributes']||null:null,'include':_0x52ec8c[_0x46ba('0x18')]?_0x52ec8c[_0x46ba('0x18')][_0x46ba('0x1b')]?_[_0x46ba('0x1c')](_0x52ec8c[_0x46ba('0x18')][_0x46ba('0x1b')],function(_0x3028ac){return{'model':db[_0x3028ac[_0x46ba('0x1d')]],'as':_0x3028ac['as'],'attributes':_0x3028ac[_0x46ba('0x1e')],'include':_0x3028ac[_0x46ba('0x1b')]?_['map'](_0x3028ac[_0x46ba('0x1b')],function(_0x2d6562){return{'model':db[_0x2d6562[_0x46ba('0x1d')]],'as':_0x2d6562['as'],'attributes':_0x2d6562[_0x46ba('0x1e')],'include':_0x2d6562[_0x46ba('0x1b')]?_[_0x46ba('0x1c')](_0x2d6562[_0x46ba('0x1b')],function(_0x5dfe0a){return{'model':db[_0x5dfe0a[_0x46ba('0x1d')]],'as':_0x5dfe0a['as'],'attributes':_0x5dfe0a[_0x46ba('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x46ba('0xc')](function(_0x466431){logger[_0x46ba('0x13')](_0x46ba('0x15'),_0x52ec8c);logger['debug']('ShowSquareProject',_0x52ec8c,JSON['stringify'](_0x466431));_0x95b597(_0x466431);})['catch'](function(_0x45c3ec){logger[_0x46ba('0x11')](_0x46ba('0x15'),_0x45c3ec[_0x46ba('0x12')],_0x52ec8c);_0x27c65f(_0x222c9f[_0x46ba('0x11')](0x1f4,_0x45c3ec[_0x46ba('0x12')]));});});};