Built motion from commit (unavailable).|2.5.4
[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 _0xa8af=['include','map','model','then','GetVtigerAccount','debug','stringify','VtigerAccount','find','where','ShowVtigerAccount','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','VtigerAccount,\x20%s,\x20%s','request\x20sent','VtigerAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','findAll','options','raw','attributes','limit'];(function(_0x30248f,_0x454272){var _0x538f45=function(_0x1602f5){while(--_0x1602f5){_0x30248f['push'](_0x30248f['shift']());}};_0x538f45(++_0x454272);}(_0xa8af,0x11c));var _0xfa8a=function(_0x181e6b,_0x590339){_0x181e6b=_0x181e6b-0x0;var _0x4c6078=_0xa8af[_0x181e6b];return _0x4c6078;};'use strict';var _=require(_0xfa8a('0x0'));var util=require(_0xfa8a('0x1'));var moment=require(_0xfa8a('0x2'));var BPromise=require('bluebird');var rs=require(_0xfa8a('0x3'));var fs=require('fs');var Redis=require(_0xfa8a('0x4'));var db=require(_0xfa8a('0x5'))['db'];var utils=require(_0xfa8a('0x6'));var logger=require(_0xfa8a('0x7'))(_0xfa8a('0x8'));var config=require(_0xfa8a('0x9'));var jayson=require(_0xfa8a('0xa'));var client=jayson[_0xfa8a('0xb')][_0xfa8a('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x30561e,_0x20428a,_0x4f3342){return new BPromise(function(_0x3edfa7,_0x434846){return client[_0xfa8a('0xd')](_0x30561e,_0x4f3342)['then'](function(_0x26e550){logger[_0xfa8a('0xe')](_0xfa8a('0xf'),_0x20428a,_0xfa8a('0x10'));logger['debug'](_0xfa8a('0x11'),_0x20428a,_0xfa8a('0x10'),JSON['stringify'](_0x26e550));if(_0x26e550['error']){if(_0x26e550[_0xfa8a('0x12')][_0xfa8a('0x13')]===0x1f4){logger[_0xfa8a('0x12')]('VtigerAccount,\x20%s,\x20%s',_0x20428a,_0x26e550['error'][_0xfa8a('0x14')]);return _0x434846(_0x26e550[_0xfa8a('0x12')]['message']);}logger['error'](_0xfa8a('0xf'),_0x20428a,_0x26e550[_0xfa8a('0x12')]['message']);return _0x3edfa7(_0x26e550[_0xfa8a('0x12')][_0xfa8a('0x14')]);}else{logger[_0xfa8a('0xe')](_0xfa8a('0xf'),_0x20428a,_0xfa8a('0x10'));_0x3edfa7(_0x26e550[_0xfa8a('0x15')]['message']);}})[_0xfa8a('0x16')](function(_0x415b77){logger[_0xfa8a('0x12')]('VtigerAccount,\x20%s,\x20%s',_0x20428a,_0x415b77);_0x434846(_0x415b77);});});}exports['GetVtigerAccount']=function(_0x3f2569){var _0x4b3f52=this;return new Promise(function(_0x2a43a1,_0x2111ca){return db['VtigerAccount'][_0xfa8a('0x17')]({'raw':_0x3f2569['options']?_0x3f2569[_0xfa8a('0x18')][_0xfa8a('0x19')]===undefined?!![]:![]:!![],'where':_0x3f2569[_0xfa8a('0x18')]?_0x3f2569[_0xfa8a('0x18')]['where']||null:null,'attributes':_0x3f2569[_0xfa8a('0x18')]?_0x3f2569[_0xfa8a('0x18')][_0xfa8a('0x1a')]||null:null,'limit':_0x3f2569[_0xfa8a('0x18')]?_0x3f2569[_0xfa8a('0x18')][_0xfa8a('0x1b')]||null:null,'include':_0x3f2569['options']?_0x3f2569[_0xfa8a('0x18')][_0xfa8a('0x1c')]?_[_0xfa8a('0x1d')](_0x3f2569[_0xfa8a('0x18')][_0xfa8a('0x1c')],function(_0x56b82a){return{'model':db[_0x56b82a['model']],'as':_0x56b82a['as'],'attributes':_0x56b82a['attributes'],'include':_0x56b82a[_0xfa8a('0x1c')]?_['map'](_0x56b82a['include'],function(_0x22113a){return{'model':db[_0x22113a[_0xfa8a('0x1e')]],'as':_0x22113a['as'],'attributes':_0x22113a[_0xfa8a('0x1a')],'include':_0x22113a[_0xfa8a('0x1c')]?_['map'](_0x22113a[_0xfa8a('0x1c')],function(_0x5445e6){return{'model':db[_0x5445e6['model']],'as':_0x5445e6['as'],'attributes':_0x5445e6[_0xfa8a('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xfa8a('0x1f')](function(_0x259def){logger['info'](_0xfa8a('0x20'),_0x3f2569);logger[_0xfa8a('0x21')](_0xfa8a('0x20'),_0x3f2569,JSON[_0xfa8a('0x22')](_0x259def));_0x2a43a1(_0x259def);})['catch'](function(_0xa04863){logger['error'](_0xfa8a('0x20'),_0xa04863[_0xfa8a('0x14')],_0x3f2569);_0x2111ca(_0x4b3f52[_0xfa8a('0x12')](0x1f4,_0xa04863[_0xfa8a('0x14')]));});});};exports['ShowVtigerAccount']=function(_0x3ebbb0){var _0x48f806=this;return new Promise(function(_0x57304e,_0x41aa78){return db[_0xfa8a('0x23')][_0xfa8a('0x24')]({'raw':_0x3ebbb0['options']?_0x3ebbb0[_0xfa8a('0x18')][_0xfa8a('0x19')]===undefined?!![]:![]:!![],'where':_0x3ebbb0['options']?_0x3ebbb0['options'][_0xfa8a('0x25')]||null:null,'attributes':_0x3ebbb0[_0xfa8a('0x18')]?_0x3ebbb0[_0xfa8a('0x18')]['attributes']||null:null,'include':_0x3ebbb0[_0xfa8a('0x18')]?_0x3ebbb0[_0xfa8a('0x18')]['include']?_['map'](_0x3ebbb0[_0xfa8a('0x18')][_0xfa8a('0x1c')],function(_0x250a2a){return{'model':db[_0x250a2a[_0xfa8a('0x1e')]],'as':_0x250a2a['as'],'attributes':_0x250a2a[_0xfa8a('0x1a')],'include':_0x250a2a['include']?_[_0xfa8a('0x1d')](_0x250a2a[_0xfa8a('0x1c')],function(_0x4b8870){return{'model':db[_0x4b8870[_0xfa8a('0x1e')]],'as':_0x4b8870['as'],'attributes':_0x4b8870['attributes'],'include':_0x4b8870['include']?_[_0xfa8a('0x1d')](_0x4b8870[_0xfa8a('0x1c')],function(_0x2cc106){return{'model':db[_0x2cc106[_0xfa8a('0x1e')]],'as':_0x2cc106['as'],'attributes':_0x2cc106[_0xfa8a('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xfa8a('0x1f')](function(_0x2a77d8){logger[_0xfa8a('0xe')](_0xfa8a('0x26'),_0x3ebbb0);logger[_0xfa8a('0x21')](_0xfa8a('0x26'),_0x3ebbb0,JSON[_0xfa8a('0x22')](_0x2a77d8));_0x57304e(_0x2a77d8);})[_0xfa8a('0x16')](function(_0x51b598){logger[_0xfa8a('0x12')](_0xfa8a('0x26'),_0x51b598[_0xfa8a('0x14')],_0x3ebbb0);_0x41aa78(_0x48f806[_0xfa8a('0x12')](0x1f4,_0x51b598[_0xfa8a('0x14')]));});});};