Built motion from commit (unavailable).|2.0.82
[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 _0x89dd=['lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','socket.io-emitter','localhost','./squareProject.socket','register','request','then','info','SquareProject,\x20%s,\x20%s','debug','error','message','request\x20sent','result','catch','ShowSquareProject','SquareProject','find','options','raw','where','attributes','map','include','model'];(function(_0x1871cd,_0x2be025){var _0x420476=function(_0xf3f9a){while(--_0xf3f9a){_0x1871cd['push'](_0x1871cd['shift']());}};_0x420476(++_0x2be025);}(_0x89dd,0xcc));var _0xd89d=function(_0x19144e,_0x5eaed4){_0x19144e=_0x19144e-0x0;var _0x2e5ef9=_0x89dd[_0x19144e];return _0x2e5ef9;};'use strict';var _=require(_0xd89d('0x0'));var util=require(_0xd89d('0x1'));var moment=require(_0xd89d('0x2'));var BPromise=require('bluebird');var rs=require(_0xd89d('0x3'));var fs=require('fs');var db=require('../../mysqldb')['db'];var utils=require(_0xd89d('0x4'));var logger=require(_0xd89d('0x5'))(_0xd89d('0x6'));var config=require(_0xd89d('0x7'));var jayson=require(_0xd89d('0x8'));var client=jayson['client'][_0xd89d('0x9')]({'port':0x232a});var socket=require(_0xd89d('0xa'))({'host':_0xd89d('0xb'),'port':0x18eb});require(_0xd89d('0xc'))[_0xd89d('0xd')](socket);function respondWithRpcPromise(_0x2567a2,_0x757936,_0x2c9822){return new BPromise(function(_0x54533e,_0x22ee7f){return client[_0xd89d('0xe')](_0x2567a2,_0x2c9822)[_0xd89d('0xf')](function(_0x4406e1){logger[_0xd89d('0x10')](_0xd89d('0x11'),_0x757936,'request\x20sent');logger[_0xd89d('0x12')]('SquareProject,\x20%s,\x20%s,\x20%s',_0x757936,'request\x20sent',JSON['stringify'](_0x4406e1));if(_0x4406e1['error']){if(_0x4406e1[_0xd89d('0x13')]['code']===0x1f4){logger[_0xd89d('0x13')](_0xd89d('0x11'),_0x757936,_0x4406e1[_0xd89d('0x13')][_0xd89d('0x14')]);return _0x22ee7f(_0x4406e1[_0xd89d('0x13')]['message']);}logger[_0xd89d('0x13')](_0xd89d('0x11'),_0x757936,_0x4406e1['error'][_0xd89d('0x14')]);return _0x54533e(_0x4406e1[_0xd89d('0x13')][_0xd89d('0x14')]);}else{logger['info'](_0xd89d('0x11'),_0x757936,_0xd89d('0x15'));_0x54533e(_0x4406e1[_0xd89d('0x16')]['message']);}})[_0xd89d('0x17')](function(_0x322d74){logger['error'](_0xd89d('0x11'),_0x757936,_0x322d74);_0x22ee7f(_0x322d74);});});}exports[_0xd89d('0x18')]=function(_0x27ba46){var _0x594362=this;return new Promise(function(_0x529282,_0x435f7c){return db[_0xd89d('0x19')][_0xd89d('0x1a')]({'raw':_0x27ba46[_0xd89d('0x1b')]?_0x27ba46[_0xd89d('0x1b')][_0xd89d('0x1c')]===undefined?!![]:![]:!![],'where':_0x27ba46[_0xd89d('0x1b')]?_0x27ba46[_0xd89d('0x1b')][_0xd89d('0x1d')]||null:null,'attributes':_0x27ba46[_0xd89d('0x1b')]?_0x27ba46[_0xd89d('0x1b')][_0xd89d('0x1e')]||null:null,'include':_0x27ba46[_0xd89d('0x1b')]?_0x27ba46['options']['include']?_[_0xd89d('0x1f')](_0x27ba46[_0xd89d('0x1b')][_0xd89d('0x20')],function(_0x2e29bc){return{'model':db[_0x2e29bc[_0xd89d('0x21')]],'as':_0x2e29bc['as'],'attributes':_0x2e29bc['attributes'],'include':_0x2e29bc['include']?_['map'](_0x2e29bc[_0xd89d('0x20')],function(_0x4ad099){return{'model':db[_0x4ad099[_0xd89d('0x21')]],'as':_0x4ad099['as'],'attributes':_0x4ad099[_0xd89d('0x1e')],'include':_0x4ad099['include']?_[_0xd89d('0x1f')](_0x4ad099['include'],function(_0x3782c4){return{'model':db[_0x3782c4[_0xd89d('0x21')]],'as':_0x3782c4['as'],'attributes':_0x3782c4[_0xd89d('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xd89d('0xf')](function(_0x4d5654){logger['info']('ShowSquareProject',_0x27ba46);logger[_0xd89d('0x12')](_0xd89d('0x18'),_0x27ba46,JSON['stringify'](_0x4d5654));_0x529282(_0x4d5654);})[_0xd89d('0x17')](function(_0x45bed3){logger[_0xd89d('0x13')](_0xd89d('0x18'),_0x45bed3[_0xd89d('0x14')],_0x27ba46);_0x435f7c(_0x594362['error'](0x1f4,_0x45bed3[_0xd89d('0x14')]));});});};