Built motion from commit (unavailable).|2.4.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 _0x158a=['raw','where','attributes','limit','include','map','model','debug','catch','ShowVtigerAccount','find','info','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','request\x20sent','VtigerAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VtigerAccount,\x20%s,\x20%s','result','GetVtigerAccount','VtigerAccount','findAll','options'];(function(_0x1feb4d,_0x36f669){var _0x306017=function(_0x3a310e){while(--_0x3a310e){_0x1feb4d['push'](_0x1feb4d['shift']());}};_0x306017(++_0x36f669);}(_0x158a,0x78));var _0xa158=function(_0x4b6f15,_0x200888){_0x4b6f15=_0x4b6f15-0x0;var _0x1cc690=_0x158a[_0x4b6f15];return _0x1cc690;};'use strict';var _=require(_0xa158('0x0'));var util=require('util');var moment=require(_0xa158('0x1'));var BPromise=require(_0xa158('0x2'));var rs=require(_0xa158('0x3'));var fs=require('fs');var Redis=require(_0xa158('0x4'));var db=require(_0xa158('0x5'))['db'];var utils=require(_0xa158('0x6'));var logger=require(_0xa158('0x7'))(_0xa158('0x8'));var config=require('../../config/environment');var jayson=require(_0xa158('0x9'));var client=jayson[_0xa158('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x28b41c,_0x41a46c,_0x54f784){return new BPromise(function(_0x2d57eb,_0x32edff){return client['request'](_0x28b41c,_0x54f784)[_0xa158('0xb')](function(_0x516c1c){logger['info']('VtigerAccount,\x20%s,\x20%s',_0x41a46c,_0xa158('0xc'));logger['debug'](_0xa158('0xd'),_0x41a46c,_0xa158('0xc'),JSON[_0xa158('0xe')](_0x516c1c));if(_0x516c1c['error']){if(_0x516c1c[_0xa158('0xf')][_0xa158('0x10')]===0x1f4){logger['error']('VtigerAccount,\x20%s,\x20%s',_0x41a46c,_0x516c1c['error'][_0xa158('0x11')]);return _0x32edff(_0x516c1c[_0xa158('0xf')][_0xa158('0x11')]);}logger[_0xa158('0xf')](_0xa158('0x12'),_0x41a46c,_0x516c1c['error'][_0xa158('0x11')]);return _0x2d57eb(_0x516c1c[_0xa158('0xf')][_0xa158('0x11')]);}else{logger['info'](_0xa158('0x12'),_0x41a46c,_0xa158('0xc'));_0x2d57eb(_0x516c1c[_0xa158('0x13')][_0xa158('0x11')]);}})['catch'](function(_0xfd1fe5){logger[_0xa158('0xf')](_0xa158('0x12'),_0x41a46c,_0xfd1fe5);_0x32edff(_0xfd1fe5);});});}exports[_0xa158('0x14')]=function(_0x1eef21){var _0x2131ec=this;return new Promise(function(_0x58d100,_0x5c5754){return db[_0xa158('0x15')][_0xa158('0x16')]({'raw':_0x1eef21[_0xa158('0x17')]?_0x1eef21['options'][_0xa158('0x18')]===undefined?!![]:![]:!![],'where':_0x1eef21[_0xa158('0x17')]?_0x1eef21[_0xa158('0x17')][_0xa158('0x19')]||null:null,'attributes':_0x1eef21[_0xa158('0x17')]?_0x1eef21[_0xa158('0x17')][_0xa158('0x1a')]||null:null,'limit':_0x1eef21['options']?_0x1eef21[_0xa158('0x17')][_0xa158('0x1b')]||null:null,'include':_0x1eef21[_0xa158('0x17')]?_0x1eef21['options'][_0xa158('0x1c')]?_[_0xa158('0x1d')](_0x1eef21[_0xa158('0x17')]['include'],function(_0x5526bf){return{'model':db[_0x5526bf[_0xa158('0x1e')]],'as':_0x5526bf['as'],'attributes':_0x5526bf[_0xa158('0x1a')],'include':_0x5526bf[_0xa158('0x1c')]?_['map'](_0x5526bf[_0xa158('0x1c')],function(_0x26167a){return{'model':db[_0x26167a[_0xa158('0x1e')]],'as':_0x26167a['as'],'attributes':_0x26167a[_0xa158('0x1a')],'include':_0x26167a[_0xa158('0x1c')]?_[_0xa158('0x1d')](_0x26167a[_0xa158('0x1c')],function(_0x1435cd){return{'model':db[_0x1435cd[_0xa158('0x1e')]],'as':_0x1435cd['as'],'attributes':_0x1435cd[_0xa158('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xa158('0xb')](function(_0x10b491){logger['info'](_0xa158('0x14'),_0x1eef21);logger[_0xa158('0x1f')](_0xa158('0x14'),_0x1eef21,JSON['stringify'](_0x10b491));_0x58d100(_0x10b491);})[_0xa158('0x20')](function(_0x47b47b){logger[_0xa158('0xf')](_0xa158('0x14'),_0x47b47b[_0xa158('0x11')],_0x1eef21);_0x5c5754(_0x2131ec[_0xa158('0xf')](0x1f4,_0x47b47b['message']));});});};exports[_0xa158('0x21')]=function(_0x10f7f2){var _0x5c3546=this;return new Promise(function(_0x32c1b2,_0x55cd6c){return db[_0xa158('0x15')][_0xa158('0x22')]({'raw':_0x10f7f2[_0xa158('0x17')]?_0x10f7f2['options'][_0xa158('0x18')]===undefined?!![]:![]:!![],'where':_0x10f7f2['options']?_0x10f7f2[_0xa158('0x17')]['where']||null:null,'attributes':_0x10f7f2[_0xa158('0x17')]?_0x10f7f2[_0xa158('0x17')][_0xa158('0x1a')]||null:null,'include':_0x10f7f2['options']?_0x10f7f2['options'][_0xa158('0x1c')]?_[_0xa158('0x1d')](_0x10f7f2[_0xa158('0x17')][_0xa158('0x1c')],function(_0x4638c5){return{'model':db[_0x4638c5[_0xa158('0x1e')]],'as':_0x4638c5['as'],'attributes':_0x4638c5[_0xa158('0x1a')],'include':_0x4638c5[_0xa158('0x1c')]?_[_0xa158('0x1d')](_0x4638c5[_0xa158('0x1c')],function(_0x5d46b9){return{'model':db[_0x5d46b9['model']],'as':_0x5d46b9['as'],'attributes':_0x5d46b9[_0xa158('0x1a')],'include':_0x5d46b9['include']?_[_0xa158('0x1d')](_0x5d46b9[_0xa158('0x1c')],function(_0x29a629){return{'model':db[_0x29a629[_0xa158('0x1e')]],'as':_0x29a629['as'],'attributes':_0x29a629['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x5c7100){logger[_0xa158('0x23')](_0xa158('0x21'),_0x10f7f2);logger[_0xa158('0x1f')](_0xa158('0x21'),_0x10f7f2,JSON[_0xa158('0xe')](_0x5c7100));_0x32c1b2(_0x5c7100);})[_0xa158('0x20')](function(_0x56df8b){logger['error'](_0xa158('0x21'),_0x56df8b['message'],_0x10f7f2);_0x55cd6c(_0x5c3546['error'](0x1f4,_0x56df8b[_0xa158('0x11')]));});});};