378a1c0f956516bbfdf8fb47914ad1ec2eba4db3
[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 _0xea92=['find','ShowVtigerAccount','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','VtigerAccount,\x20%s,\x20%s','VtigerAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','result','catch','GetVtigerAccount','findAll','options','where','limit','include','map','attributes','model','debug','VtigerAccount'];(function(_0x87a5e9,_0x51642b){var _0x1e6c81=function(_0x37a13){while(--_0x37a13){_0x87a5e9['push'](_0x87a5e9['shift']());}};_0x1e6c81(++_0x51642b);}(_0xea92,0x146));var _0x2ea9=function(_0x5e4752,_0x327bcb){_0x5e4752=_0x5e4752-0x0;var _0x51690f=_0xea92[_0x5e4752];return _0x51690f;};'use strict';var _=require(_0x2ea9('0x0'));var util=require(_0x2ea9('0x1'));var moment=require('moment');var BPromise=require(_0x2ea9('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x2ea9('0x3'));var db=require(_0x2ea9('0x4'))['db'];var utils=require(_0x2ea9('0x5'));var logger=require(_0x2ea9('0x6'))(_0x2ea9('0x7'));var config=require(_0x2ea9('0x8'));var jayson=require(_0x2ea9('0x9'));var client=jayson['client'][_0x2ea9('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3dd6b5,_0x436123,_0xdfa3c){return new BPromise(function(_0x114529,_0x4e7538){return client[_0x2ea9('0xb')](_0x3dd6b5,_0xdfa3c)[_0x2ea9('0xc')](function(_0x57b010){logger[_0x2ea9('0xd')](_0x2ea9('0xe'),_0x436123,'request\x20sent');logger['debug'](_0x2ea9('0xf'),_0x436123,_0x2ea9('0x10'),JSON[_0x2ea9('0x11')](_0x57b010));if(_0x57b010['error']){if(_0x57b010['error'][_0x2ea9('0x12')]===0x1f4){logger[_0x2ea9('0x13')](_0x2ea9('0xe'),_0x436123,_0x57b010['error']['message']);return _0x4e7538(_0x57b010['error'][_0x2ea9('0x14')]);}logger[_0x2ea9('0x13')](_0x2ea9('0xe'),_0x436123,_0x57b010[_0x2ea9('0x13')]['message']);return _0x114529(_0x57b010[_0x2ea9('0x13')][_0x2ea9('0x14')]);}else{logger[_0x2ea9('0xd')](_0x2ea9('0xe'),_0x436123,_0x2ea9('0x10'));_0x114529(_0x57b010[_0x2ea9('0x15')][_0x2ea9('0x14')]);}})[_0x2ea9('0x16')](function(_0xa173de){logger[_0x2ea9('0x13')]('VtigerAccount,\x20%s,\x20%s',_0x436123,_0xa173de);_0x4e7538(_0xa173de);});});}exports[_0x2ea9('0x17')]=function(_0x34cf4f){var _0x1538eb=this;return new Promise(function(_0x473d05,_0x6af24a){return db['VtigerAccount'][_0x2ea9('0x18')]({'raw':_0x34cf4f[_0x2ea9('0x19')]?_0x34cf4f['options']['raw']===undefined?!![]:![]:!![],'where':_0x34cf4f[_0x2ea9('0x19')]?_0x34cf4f[_0x2ea9('0x19')][_0x2ea9('0x1a')]||null:null,'attributes':_0x34cf4f[_0x2ea9('0x19')]?_0x34cf4f[_0x2ea9('0x19')]['attributes']||null:null,'limit':_0x34cf4f[_0x2ea9('0x19')]?_0x34cf4f[_0x2ea9('0x19')][_0x2ea9('0x1b')]||null:null,'include':_0x34cf4f[_0x2ea9('0x19')]?_0x34cf4f[_0x2ea9('0x19')][_0x2ea9('0x1c')]?_[_0x2ea9('0x1d')](_0x34cf4f[_0x2ea9('0x19')][_0x2ea9('0x1c')],function(_0x15eaf6){return{'model':db[_0x15eaf6['model']],'as':_0x15eaf6['as'],'attributes':_0x15eaf6[_0x2ea9('0x1e')],'include':_0x15eaf6['include']?_[_0x2ea9('0x1d')](_0x15eaf6[_0x2ea9('0x1c')],function(_0x35c3fa){return{'model':db[_0x35c3fa['model']],'as':_0x35c3fa['as'],'attributes':_0x35c3fa[_0x2ea9('0x1e')],'include':_0x35c3fa[_0x2ea9('0x1c')]?_[_0x2ea9('0x1d')](_0x35c3fa[_0x2ea9('0x1c')],function(_0x3a02f7){return{'model':db[_0x3a02f7[_0x2ea9('0x1f')]],'as':_0x3a02f7['as'],'attributes':_0x3a02f7[_0x2ea9('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x2ea9('0xc')](function(_0x3d3f2b){logger[_0x2ea9('0xd')](_0x2ea9('0x17'),_0x34cf4f);logger[_0x2ea9('0x20')](_0x2ea9('0x17'),_0x34cf4f,JSON[_0x2ea9('0x11')](_0x3d3f2b));_0x473d05(_0x3d3f2b);})[_0x2ea9('0x16')](function(_0x9ef422){logger[_0x2ea9('0x13')](_0x2ea9('0x17'),_0x9ef422[_0x2ea9('0x14')],_0x34cf4f);_0x6af24a(_0x1538eb[_0x2ea9('0x13')](0x1f4,_0x9ef422[_0x2ea9('0x14')]));});});};exports['ShowVtigerAccount']=function(_0x3192f9){var _0x5ecde8=this;return new Promise(function(_0xfdc2b3,_0x522729){return db[_0x2ea9('0x21')][_0x2ea9('0x22')]({'raw':_0x3192f9['options']?_0x3192f9[_0x2ea9('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x3192f9['options']?_0x3192f9['options']['where']||null:null,'attributes':_0x3192f9[_0x2ea9('0x19')]?_0x3192f9[_0x2ea9('0x19')]['attributes']||null:null,'include':_0x3192f9[_0x2ea9('0x19')]?_0x3192f9['options'][_0x2ea9('0x1c')]?_[_0x2ea9('0x1d')](_0x3192f9[_0x2ea9('0x19')][_0x2ea9('0x1c')],function(_0x4b4481){return{'model':db[_0x4b4481[_0x2ea9('0x1f')]],'as':_0x4b4481['as'],'attributes':_0x4b4481['attributes'],'include':_0x4b4481[_0x2ea9('0x1c')]?_['map'](_0x4b4481[_0x2ea9('0x1c')],function(_0xae302e){return{'model':db[_0xae302e['model']],'as':_0xae302e['as'],'attributes':_0xae302e[_0x2ea9('0x1e')],'include':_0xae302e['include']?_[_0x2ea9('0x1d')](_0xae302e['include'],function(_0x2e21cf){return{'model':db[_0x2e21cf['model']],'as':_0x2e21cf['as'],'attributes':_0x2e21cf[_0x2ea9('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x448f2c){logger[_0x2ea9('0xd')](_0x2ea9('0x23'),_0x3192f9);logger[_0x2ea9('0x20')](_0x2ea9('0x23'),_0x3192f9,JSON[_0x2ea9('0x11')](_0x448f2c));_0xfdc2b3(_0x448f2c);})['catch'](function(_0x572bd1){logger[_0x2ea9('0x13')](_0x2ea9('0x23'),_0x572bd1[_0x2ea9('0x14')],_0x3192f9);_0x522729(_0x5ecde8[_0x2ea9('0x13')](0x1f4,_0x572bd1[_0x2ea9('0x14')]));});});};