Built motion from commit e6806ed6.|2.6.0
[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 _0xceaf=['debug','error','code','message','request\x20sent','result','ShowSquareProject','SquareProject','find','options','raw','where','attributes','include','map','model','stringify','catch','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','socket.io-emitter','redis','request','then','info','SquareProject,\x20%s,\x20%s'];(function(_0x418f0b,_0xe47fcf){var _0x4c0491=function(_0xf1922e){while(--_0xf1922e){_0x418f0b['push'](_0x418f0b['shift']());}};_0x4c0491(++_0xe47fcf);}(_0xceaf,0x10e));var _0xfcea=function(_0x2cf1b7,_0x3d64cb){_0x2cf1b7=_0x2cf1b7-0x0;var _0xf8b2cf=_0xceaf[_0x2cf1b7];return _0xf8b2cf;};'use strict';var _=require('lodash');var util=require(_0xfcea('0x0'));var moment=require(_0xfcea('0x1'));var BPromise=require(_0xfcea('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfcea('0x3'))['db'];var utils=require(_0xfcea('0x4'));var logger=require(_0xfcea('0x5'))(_0xfcea('0x6'));var config=require(_0xfcea('0x7'));var jayson=require(_0xfcea('0x8'));var client=jayson[_0xfcea('0x9')][_0xfcea('0xa')]({'port':0x232a});config['redis']=_[_0xfcea('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xfcea('0xc'))(new Redis(config[_0xfcea('0xd')]));require('./squareProject.socket')['register'](socket);function respondWithRpcPromise(_0x38e57e,_0x5d2328,_0x1764d0){return new BPromise(function(_0x5bf5a5,_0x4752af){return client[_0xfcea('0xe')](_0x38e57e,_0x1764d0)[_0xfcea('0xf')](function(_0x4303d1){logger[_0xfcea('0x10')](_0xfcea('0x11'),_0x5d2328,'request\x20sent');logger[_0xfcea('0x12')]('SquareProject,\x20%s,\x20%s,\x20%s',_0x5d2328,'request\x20sent',JSON['stringify'](_0x4303d1));if(_0x4303d1['error']){if(_0x4303d1[_0xfcea('0x13')][_0xfcea('0x14')]===0x1f4){logger[_0xfcea('0x13')]('SquareProject,\x20%s,\x20%s',_0x5d2328,_0x4303d1[_0xfcea('0x13')]['message']);return _0x4752af(_0x4303d1['error'][_0xfcea('0x15')]);}logger[_0xfcea('0x13')](_0xfcea('0x11'),_0x5d2328,_0x4303d1[_0xfcea('0x13')][_0xfcea('0x15')]);return _0x5bf5a5(_0x4303d1[_0xfcea('0x13')][_0xfcea('0x15')]);}else{logger[_0xfcea('0x10')]('SquareProject,\x20%s,\x20%s',_0x5d2328,_0xfcea('0x16'));_0x5bf5a5(_0x4303d1[_0xfcea('0x17')][_0xfcea('0x15')]);}})['catch'](function(_0x332aee){logger['error'](_0xfcea('0x11'),_0x5d2328,_0x332aee);_0x4752af(_0x332aee);});});}exports[_0xfcea('0x18')]=function(_0x1bec0a){var _0x2b2589=this;return new Promise(function(_0x169147,_0x587242){return db[_0xfcea('0x19')][_0xfcea('0x1a')]({'raw':_0x1bec0a[_0xfcea('0x1b')]?_0x1bec0a[_0xfcea('0x1b')][_0xfcea('0x1c')]===undefined?!![]:![]:!![],'where':_0x1bec0a[_0xfcea('0x1b')]?_0x1bec0a[_0xfcea('0x1b')][_0xfcea('0x1d')]||null:null,'attributes':_0x1bec0a['options']?_0x1bec0a[_0xfcea('0x1b')][_0xfcea('0x1e')]||null:null,'include':_0x1bec0a['options']?_0x1bec0a[_0xfcea('0x1b')][_0xfcea('0x1f')]?_[_0xfcea('0x20')](_0x1bec0a[_0xfcea('0x1b')][_0xfcea('0x1f')],function(_0x35ef74){return{'model':db[_0x35ef74[_0xfcea('0x21')]],'as':_0x35ef74['as'],'attributes':_0x35ef74[_0xfcea('0x1e')],'include':_0x35ef74[_0xfcea('0x1f')]?_[_0xfcea('0x20')](_0x35ef74['include'],function(_0x465d76){return{'model':db[_0x465d76[_0xfcea('0x21')]],'as':_0x465d76['as'],'attributes':_0x465d76['attributes'],'include':_0x465d76[_0xfcea('0x1f')]?_[_0xfcea('0x20')](_0x465d76[_0xfcea('0x1f')],function(_0x232808){return{'model':db[_0x232808[_0xfcea('0x21')]],'as':_0x232808['as'],'attributes':_0x232808[_0xfcea('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xfcea('0xf')](function(_0x43798e){logger[_0xfcea('0x10')]('ShowSquareProject',_0x1bec0a);logger[_0xfcea('0x12')]('ShowSquareProject',_0x1bec0a,JSON[_0xfcea('0x22')](_0x43798e));_0x169147(_0x43798e);})[_0xfcea('0x23')](function(_0xbeb551){logger[_0xfcea('0x13')](_0xfcea('0x18'),_0xbeb551[_0xfcea('0x15')],_0x1bec0a);_0x587242(_0x2b2589['error'](0x1f4,_0xbeb551[_0xfcea('0x15')]));});});};