Built motion from commit ddca4d0d.|2.5.47
[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 _0x6ebc=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','info','SquareProject,\x20%s,\x20%s','request\x20sent','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareProject','SquareProject','find','options','raw','attributes','include','map','model','then','debug','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x4e7e29,_0x54cf1f){var _0x32b057=function(_0x589275){while(--_0x589275){_0x4e7e29['push'](_0x4e7e29['shift']());}};_0x32b057(++_0x54cf1f);}(_0x6ebc,0x19e));var _0xc6eb=function(_0x5c811c,_0x313b25){_0x5c811c=_0x5c811c-0x0;var _0x5df3af=_0x6ebc[_0x5c811c];return _0x5df3af;};'use strict';var _=require('lodash');var util=require(_0xc6eb('0x0'));var moment=require(_0xc6eb('0x1'));var BPromise=require(_0xc6eb('0x2'));var rs=require(_0xc6eb('0x3'));var fs=require('fs');var Redis=require(_0xc6eb('0x4'));var db=require(_0xc6eb('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc6eb('0x6'))(_0xc6eb('0x7'));var config=require(_0xc6eb('0x8'));var jayson=require(_0xc6eb('0x9'));var client=jayson[_0xc6eb('0xa')][_0xc6eb('0xb')]({'port':0x232a});config[_0xc6eb('0xc')]=_[_0xc6eb('0xd')](config[_0xc6eb('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc6eb('0xc')]));require('./squareProject.socket')['register'](socket);function respondWithRpcPromise(_0x41c326,_0x231682,_0xc48b7f){return new BPromise(function(_0x68e141,_0x703ffc){return client['request'](_0x41c326,_0xc48b7f)['then'](function(_0x3d3f35){logger[_0xc6eb('0xe')](_0xc6eb('0xf'),_0x231682,_0xc6eb('0x10'));logger['debug'](_0xc6eb('0x11'),_0x231682,_0xc6eb('0x10'),JSON[_0xc6eb('0x12')](_0x3d3f35));if(_0x3d3f35[_0xc6eb('0x13')]){if(_0x3d3f35['error'][_0xc6eb('0x14')]===0x1f4){logger['error'](_0xc6eb('0xf'),_0x231682,_0x3d3f35[_0xc6eb('0x13')][_0xc6eb('0x15')]);return _0x703ffc(_0x3d3f35[_0xc6eb('0x13')]['message']);}logger[_0xc6eb('0x13')](_0xc6eb('0xf'),_0x231682,_0x3d3f35[_0xc6eb('0x13')][_0xc6eb('0x15')]);return _0x68e141(_0x3d3f35[_0xc6eb('0x13')][_0xc6eb('0x15')]);}else{logger[_0xc6eb('0xe')](_0xc6eb('0xf'),_0x231682,'request\x20sent');_0x68e141(_0x3d3f35[_0xc6eb('0x16')][_0xc6eb('0x15')]);}})[_0xc6eb('0x17')](function(_0x20ad98){logger[_0xc6eb('0x13')]('SquareProject,\x20%s,\x20%s',_0x231682,_0x20ad98);_0x703ffc(_0x20ad98);});});}exports[_0xc6eb('0x18')]=function(_0x33594b){var _0x58ec23=this;return new Promise(function(_0x2e4f25,_0x4b67b3){return db[_0xc6eb('0x19')][_0xc6eb('0x1a')]({'raw':_0x33594b['options']?_0x33594b[_0xc6eb('0x1b')][_0xc6eb('0x1c')]===undefined?!![]:![]:!![],'where':_0x33594b[_0xc6eb('0x1b')]?_0x33594b[_0xc6eb('0x1b')]['where']||null:null,'attributes':_0x33594b['options']?_0x33594b['options'][_0xc6eb('0x1d')]||null:null,'include':_0x33594b['options']?_0x33594b['options'][_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x33594b['options'][_0xc6eb('0x1e')],function(_0x35cb75){return{'model':db[_0x35cb75[_0xc6eb('0x20')]],'as':_0x35cb75['as'],'attributes':_0x35cb75['attributes'],'include':_0x35cb75[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x35cb75[_0xc6eb('0x1e')],function(_0x102ff3){return{'model':db[_0x102ff3[_0xc6eb('0x20')]],'as':_0x102ff3['as'],'attributes':_0x102ff3[_0xc6eb('0x1d')],'include':_0x102ff3[_0xc6eb('0x1e')]?_[_0xc6eb('0x1f')](_0x102ff3[_0xc6eb('0x1e')],function(_0x53a64e){return{'model':db[_0x53a64e[_0xc6eb('0x20')]],'as':_0x53a64e['as'],'attributes':_0x53a64e[_0xc6eb('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xc6eb('0x21')](function(_0x512333){logger[_0xc6eb('0xe')](_0xc6eb('0x18'),_0x33594b);logger[_0xc6eb('0x22')](_0xc6eb('0x18'),_0x33594b,JSON[_0xc6eb('0x12')](_0x512333));_0x2e4f25(_0x512333);})[_0xc6eb('0x17')](function(_0x2d2165){logger[_0xc6eb('0x13')](_0xc6eb('0x18'),_0x2d2165[_0xc6eb('0x15')],_0x33594b);_0x4b67b3(_0x58ec23['error'](0x1f4,_0x2d2165[_0xc6eb('0x15')]));});});};