Built motion from commit d69f4380.|2.6.29
[motion2.git] / server / api / intVtigerAccount / intVtigerAccount.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 _0xf290=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','debug','VtigerAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetVtigerAccount','findAll','options','raw','where','map','include','model','attributes','stringify','VtigerAccount','ShowVtigerAccount','util','bluebird'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xf290,0xde));var _0x0f29=function(_0x5a2d3f,_0x27b04e){_0x5a2d3f=_0x5a2d3f-0x0;var _0x5c65d8=_0xf290[_0x5a2d3f];return _0x5c65d8;};'use strict';var _=require('lodash');var util=require(_0x0f29('0x0'));var moment=require('moment');var BPromise=require(_0x0f29('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0f29('0x2'));var db=require(_0x0f29('0x3'))['db'];var utils=require(_0x0f29('0x4'));var logger=require(_0x0f29('0x5'))(_0x0f29('0x6'));var config=require('../../config/environment');var jayson=require(_0x0f29('0x7'));var client=jayson['client'][_0x0f29('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1c45ec,_0x355e21,_0xaa2675){return new BPromise(function(_0xc78ca2,_0x45350b){return client[_0x0f29('0x9')](_0x1c45ec,_0xaa2675)[_0x0f29('0xa')](function(_0x376de4){logger[_0x0f29('0xb')](_0x0f29('0xc'),_0x355e21,_0x0f29('0xd'));logger[_0x0f29('0xe')](_0x0f29('0xf'),_0x355e21,_0x0f29('0xd'),JSON['stringify'](_0x376de4));if(_0x376de4[_0x0f29('0x10')]){if(_0x376de4['error'][_0x0f29('0x11')]===0x1f4){logger[_0x0f29('0x10')](_0x0f29('0xc'),_0x355e21,_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);return _0x45350b(_0x376de4[_0x0f29('0x10')]['message']);}logger[_0x0f29('0x10')](_0x0f29('0xc'),_0x355e21,_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);return _0xc78ca2(_0x376de4[_0x0f29('0x10')][_0x0f29('0x12')]);}else{logger[_0x0f29('0xb')](_0x0f29('0xc'),_0x355e21,'request\x20sent');_0xc78ca2(_0x376de4['result'][_0x0f29('0x12')]);}})[_0x0f29('0x13')](function(_0x38031e){logger[_0x0f29('0x10')]('VtigerAccount,\x20%s,\x20%s',_0x355e21,_0x38031e);_0x45350b(_0x38031e);});});}exports[_0x0f29('0x14')]=function(_0x5d72a5){var _0x17b994=this;return new Promise(function(_0x4ca5e8,_0x5ddc74){return db['VtigerAccount'][_0x0f29('0x15')]({'raw':_0x5d72a5[_0x0f29('0x16')]?_0x5d72a5[_0x0f29('0x16')][_0x0f29('0x17')]===undefined?!![]:![]:!![],'where':_0x5d72a5[_0x0f29('0x16')]?_0x5d72a5[_0x0f29('0x16')][_0x0f29('0x18')]||null:null,'attributes':_0x5d72a5['options']?_0x5d72a5[_0x0f29('0x16')]['attributes']||null:null,'limit':_0x5d72a5['options']?_0x5d72a5['options']['limit']||null:null,'include':_0x5d72a5[_0x0f29('0x16')]?_0x5d72a5[_0x0f29('0x16')]['include']?_[_0x0f29('0x19')](_0x5d72a5[_0x0f29('0x16')][_0x0f29('0x1a')],function(_0x3402dc){return{'model':db[_0x3402dc[_0x0f29('0x1b')]],'as':_0x3402dc['as'],'attributes':_0x3402dc['attributes'],'include':_0x3402dc[_0x0f29('0x1a')]?_['map'](_0x3402dc[_0x0f29('0x1a')],function(_0x26f46f){return{'model':db[_0x26f46f[_0x0f29('0x1b')]],'as':_0x26f46f['as'],'attributes':_0x26f46f[_0x0f29('0x1c')],'include':_0x26f46f['include']?_[_0x0f29('0x19')](_0x26f46f['include'],function(_0x58b201){return{'model':db[_0x58b201[_0x0f29('0x1b')]],'as':_0x58b201['as'],'attributes':_0x58b201['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x57dcc7){logger['info'](_0x0f29('0x14'),_0x5d72a5);logger[_0x0f29('0xe')]('GetVtigerAccount',_0x5d72a5,JSON[_0x0f29('0x1d')](_0x57dcc7));_0x4ca5e8(_0x57dcc7);})[_0x0f29('0x13')](function(_0x274c9d){logger['error']('GetVtigerAccount',_0x274c9d[_0x0f29('0x12')],_0x5d72a5);_0x5ddc74(_0x17b994['error'](0x1f4,_0x274c9d[_0x0f29('0x12')]));});});};exports['ShowVtigerAccount']=function(_0x526364){var _0x7b10f=this;return new Promise(function(_0x409b19,_0xf59431){return db[_0x0f29('0x1e')]['find']({'raw':_0x526364['options']?_0x526364[_0x0f29('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x526364['options']?_0x526364[_0x0f29('0x16')]['where']||null:null,'attributes':_0x526364[_0x0f29('0x16')]?_0x526364['options']['attributes']||null:null,'include':_0x526364[_0x0f29('0x16')]?_0x526364[_0x0f29('0x16')][_0x0f29('0x1a')]?_[_0x0f29('0x19')](_0x526364[_0x0f29('0x16')]['include'],function(_0x426a3e){return{'model':db[_0x426a3e['model']],'as':_0x426a3e['as'],'attributes':_0x426a3e[_0x0f29('0x1c')],'include':_0x426a3e[_0x0f29('0x1a')]?_[_0x0f29('0x19')](_0x426a3e[_0x0f29('0x1a')],function(_0x4852a5){return{'model':db[_0x4852a5[_0x0f29('0x1b')]],'as':_0x4852a5['as'],'attributes':_0x4852a5[_0x0f29('0x1c')],'include':_0x4852a5['include']?_[_0x0f29('0x19')](_0x4852a5[_0x0f29('0x1a')],function(_0x5e40ac){return{'model':db[_0x5e40ac['model']],'as':_0x5e40ac['as'],'attributes':_0x5e40ac[_0x0f29('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x0f29('0xa')](function(_0x3691d4){logger[_0x0f29('0xb')](_0x0f29('0x1f'),_0x526364);logger[_0x0f29('0xe')]('ShowVtigerAccount',_0x526364,JSON[_0x0f29('0x1d')](_0x3691d4));_0x409b19(_0x3691d4);})['catch'](function(_0x331dc7){logger['error'](_0x0f29('0x1f'),_0x331dc7[_0x0f29('0x12')],_0x526364);_0xf59431(_0x7b10f[_0x0f29('0x10')](0x1f4,_0x331dc7['message']));});});};