Built motion from commit (unavailable).|2.5.21
[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 _0x4eae=['moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','client','redis','localhost','socket.io-emitter','register','request','info','SquareProject,\x20%s,\x20%s','request\x20sent','debug','SquareProject,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSquareProject','find','options','attributes','include','map','model','then','util'];(function(_0x3cddbe,_0x4f0040){var _0x83bd46=function(_0x35a256){while(--_0x35a256){_0x3cddbe['push'](_0x3cddbe['shift']());}};_0x83bd46(++_0x4f0040);}(_0x4eae,0x18b));var _0xe4ea=function(_0x2f62aa,_0x108e95){_0x2f62aa=_0x2f62aa-0x0;var _0x1a341f=_0x4eae[_0x2f62aa];return _0x1a341f;};'use strict';var _=require('lodash');var util=require(_0xe4ea('0x0'));var moment=require(_0xe4ea('0x1'));var BPromise=require(_0xe4ea('0x2'));var rs=require(_0xe4ea('0x3'));var fs=require('fs');var Redis=require(_0xe4ea('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xe4ea('0x5'));var logger=require(_0xe4ea('0x6'))('rpc');var config=require(_0xe4ea('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xe4ea('0x8')]['http']({'port':0x232a});config[_0xe4ea('0x9')]=_['defaults'](config[_0xe4ea('0x9')],{'host':_0xe4ea('0xa'),'port':0x18eb});var socket=require(_0xe4ea('0xb'))(new Redis(config[_0xe4ea('0x9')]));require('./squareProject.socket')[_0xe4ea('0xc')](socket);function respondWithRpcPromise(_0x4b15d8,_0x43f371,_0xc059d){return new BPromise(function(_0x3ddc59,_0x6f6450){return client[_0xe4ea('0xd')](_0x4b15d8,_0xc059d)['then'](function(_0x10131f){logger[_0xe4ea('0xe')](_0xe4ea('0xf'),_0x43f371,_0xe4ea('0x10'));logger[_0xe4ea('0x11')](_0xe4ea('0x12'),_0x43f371,_0xe4ea('0x10'),JSON[_0xe4ea('0x13')](_0x10131f));if(_0x10131f['error']){if(_0x10131f[_0xe4ea('0x14')][_0xe4ea('0x15')]===0x1f4){logger['error']('SquareProject,\x20%s,\x20%s',_0x43f371,_0x10131f[_0xe4ea('0x14')][_0xe4ea('0x16')]);return _0x6f6450(_0x10131f[_0xe4ea('0x14')][_0xe4ea('0x16')]);}logger['error'](_0xe4ea('0xf'),_0x43f371,_0x10131f[_0xe4ea('0x14')][_0xe4ea('0x16')]);return _0x3ddc59(_0x10131f[_0xe4ea('0x14')][_0xe4ea('0x16')]);}else{logger[_0xe4ea('0xe')](_0xe4ea('0xf'),_0x43f371,_0xe4ea('0x10'));_0x3ddc59(_0x10131f[_0xe4ea('0x17')][_0xe4ea('0x16')]);}})[_0xe4ea('0x18')](function(_0x25f050){logger[_0xe4ea('0x14')](_0xe4ea('0xf'),_0x43f371,_0x25f050);_0x6f6450(_0x25f050);});});}exports[_0xe4ea('0x19')]=function(_0x3879d5){var _0x771487=this;return new Promise(function(_0x15551a,_0x628d54){return db['SquareProject'][_0xe4ea('0x1a')]({'raw':_0x3879d5[_0xe4ea('0x1b')]?_0x3879d5[_0xe4ea('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x3879d5[_0xe4ea('0x1b')]?_0x3879d5[_0xe4ea('0x1b')]['where']||null:null,'attributes':_0x3879d5[_0xe4ea('0x1b')]?_0x3879d5[_0xe4ea('0x1b')][_0xe4ea('0x1c')]||null:null,'include':_0x3879d5['options']?_0x3879d5[_0xe4ea('0x1b')][_0xe4ea('0x1d')]?_[_0xe4ea('0x1e')](_0x3879d5[_0xe4ea('0x1b')][_0xe4ea('0x1d')],function(_0x13d14b){return{'model':db[_0x13d14b[_0xe4ea('0x1f')]],'as':_0x13d14b['as'],'attributes':_0x13d14b['attributes'],'include':_0x13d14b[_0xe4ea('0x1d')]?_['map'](_0x13d14b[_0xe4ea('0x1d')],function(_0x17ced8){return{'model':db[_0x17ced8['model']],'as':_0x17ced8['as'],'attributes':_0x17ced8[_0xe4ea('0x1c')],'include':_0x17ced8[_0xe4ea('0x1d')]?_[_0xe4ea('0x1e')](_0x17ced8['include'],function(_0x5c53b7){return{'model':db[_0x5c53b7[_0xe4ea('0x1f')]],'as':_0x5c53b7['as'],'attributes':_0x5c53b7[_0xe4ea('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xe4ea('0x20')](function(_0x2e491a){logger[_0xe4ea('0xe')](_0xe4ea('0x19'),_0x3879d5);logger[_0xe4ea('0x11')](_0xe4ea('0x19'),_0x3879d5,JSON[_0xe4ea('0x13')](_0x2e491a));_0x15551a(_0x2e491a);})[_0xe4ea('0x18')](function(_0x10a679){logger[_0xe4ea('0x14')]('ShowSquareProject',_0x10a679['message'],_0x3879d5);_0x628d54(_0x771487['error'](0x1f4,_0x10a679[_0xe4ea('0x16')]));});});};