Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 8d56977..0e1f082 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbc50=['send','index','SugarcrmAccount','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','order','sort','where','filter','merge','includeAll','include','rows','show','params','options','create','body','find','destroy','getConfigurations','SugarcrmConfiguration','pick','hasOwnProperty','nolimit','addConfiguration','findOne','AccountId','Subjects','channel','Descriptions','getDescriptions','SugarcrmField','getFields','duration_minutes','direction','username','password','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','login','JSON','xCALLY\x20Motion\x20Integration','Invalid\x20Login','Password\x20Expired','get_module_fields','values','module_fields','remove','includes','label','value','test','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','statusCode','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','reject','update','stack','name'];(function(_0x38f6ae,_0x33adc5){var _0x5b0831=function(_0x19462f){while(--_0x19462f){_0x38f6ae['push'](_0x38f6ae['shift']());}};_0x5b0831(++_0x33adc5);}(_0xbc50,0x153));var _0x0bc5=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xbc50[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x0bc5('0x0'));var emlformat=require(_0x0bc5('0x1'));var rimraf=require(_0x0bc5('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0bc5('0x3'));var rp=require(_0x0bc5('0x4'));var moment=require(_0x0bc5('0x5'));var BPromise=require(_0x0bc5('0x6'));var Mustache=require(_0x0bc5('0x7'));var util=require(_0x0bc5('0x8'));var path=require(_0x0bc5('0x9'));var sox=require(_0x0bc5('0xa'));var csv=require(_0x0bc5('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x0bc5('0xc'));var squel=require(_0x0bc5('0xd'));var crypto=require(_0x0bc5('0xe'));var jsforce=require(_0x0bc5('0xf'));var deskjs=require(_0x0bc5('0x10'));var toCsv=require(_0x0bc5('0xb'));var querystring=require(_0x0bc5('0x11'));var Papa=require(_0x0bc5('0x12'));var Redis=require(_0x0bc5('0x13'));var authService=require(_0x0bc5('0x14'));var qs=require(_0x0bc5('0x15'));var as=require(_0x0bc5('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0bc5('0x17'))(_0x0bc5('0x18'));var utils=require(_0x0bc5('0x19'));var config=require(_0x0bc5('0x1a'));var licenseUtil=require(_0x0bc5('0x1b'));var db=require(_0x0bc5('0x1c'))['db'];var integrations=require(_0x0bc5('0x1d'));var jayson=require(_0x0bc5('0x1e'));var client=jayson[_0x0bc5('0x1f')][_0x0bc5('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x7ae28f,_0x5221fe,_0x4e6455,_0x57fb2f){return new BPromise(function(_0x1eb335,_0x328682){var _0x1c9894=_0x57fb2f||client;return _0x1c9894[_0x0bc5('0x21')](_0x7ae28f,_0x4e6455)[_0x0bc5('0x22')](function(_0x571229){logger[_0x0bc5('0x23')](_0x0bc5('0x24'),_0x5221fe,'request\x20sent');logger[_0x0bc5('0x25')](_0x0bc5('0x26'),_0x5221fe,_0x0bc5('0x27'),JSON[_0x0bc5('0x28')](_0x571229));if(_0x571229[_0x0bc5('0x29')]){if(_0x571229[_0x0bc5('0x29')][_0x0bc5('0x2a')]===0x1f4){logger[_0x0bc5('0x29')](_0x0bc5('0x24'),_0x5221fe,_0x571229['error'][_0x0bc5('0x2b')]);return _0x328682(_0x571229[_0x0bc5('0x29')][_0x0bc5('0x2b')]);}logger['error'](_0x0bc5('0x24'),_0x5221fe,_0x571229['error'][_0x0bc5('0x2b')]);return _0x1eb335(_0x571229[_0x0bc5('0x29')][_0x0bc5('0x2b')]);}else{logger[_0x0bc5('0x23')](_0x0bc5('0x24'),_0x5221fe,'request\x20sent');_0x1eb335(_0x571229[_0x0bc5('0x2c')]['message']);}})[_0x0bc5('0x2d')](function(_0x474e05){logger[_0x0bc5('0x29')](_0x0bc5('0x24'),_0x5221fe,_0x474e05);_0x328682(_0x474e05);});});}function respondWithStatusCode(_0x2d6a47,_0x45f17b){_0x45f17b=_0x45f17b||0xcc;return function(_0x39ec5d){if(_0x39ec5d){return _0x2d6a47[_0x0bc5('0x2e')](_0x45f17b);}return _0x2d6a47[_0x0bc5('0x2f')](_0x45f17b)[_0x0bc5('0x30')]();};}function respondWithResult(_0x24de88,_0x3d18d5){_0x3d18d5=_0x3d18d5||0xc8;return function(_0x3edf41){if(_0x3edf41){return _0x24de88[_0x0bc5('0x2f')](_0x3d18d5)['json'](_0x3edf41);}};}function respondWithFilteredResult(_0x3f004e,_0x37efed){return function(_0x480d06){if(_0x480d06){var _0x2167ec=_0x480d06[_0x0bc5('0x31')],_0x1a8e6e=_0x37efed[_0x0bc5('0x32')],_0x491a9b=_0x37efed[_0x0bc5('0x32')]+_0x37efed[_0x0bc5('0x33')],_0x8c66c3;if(_0x491a9b>=_0x2167ec){_0x491a9b=_0x2167ec;_0x8c66c3=0xc8;}else{_0x8c66c3=0xce;}_0x3f004e[_0x0bc5('0x2f')](_0x8c66c3);return _0x3f004e[_0x0bc5('0x34')](_0x0bc5('0x35'),_0x1a8e6e+'-'+_0x491a9b+'/'+_0x2167ec)[_0x0bc5('0x36')](_0x480d06);}return null;};}function patchUpdates(_0x18bc39){return function(_0x15ed1a){try{jsonpatch[_0x0bc5('0x37')](_0x15ed1a,_0x18bc39,!![]);}catch(_0x4c794f){return BPromise[_0x0bc5('0x38')](_0x4c794f);}return _0x15ed1a['save']();};}function saveUpdates(_0x51c32f,_0x3823e4){return function(_0x5c63d0){if(_0x5c63d0){return _0x5c63d0[_0x0bc5('0x39')](_0x51c32f)['then'](function(_0xf382bb){return _0xf382bb;});}return null;};}function removeEntity(_0x4c3dcf,_0x59da4f){return function(_0x2f2dfe){if(_0x2f2dfe){return _0x2f2dfe['destroy']()[_0x0bc5('0x22')](function(){_0x4c3dcf[_0x0bc5('0x2f')](0xcc)[_0x0bc5('0x30')]();});}};}function handleEntityNotFound(_0xb7beb4,_0x2ef2db){return function(_0x519920){if(!_0x519920){_0xb7beb4['sendStatus'](0x194);}return _0x519920;};}function handleError(_0x19a395,_0xe5f62a){_0xe5f62a=_0xe5f62a||0x1f4;return function(_0xf7ba9a){logger[_0x0bc5('0x29')](_0xf7ba9a[_0x0bc5('0x3a')]);if(_0xf7ba9a['name']){delete _0xf7ba9a[_0x0bc5('0x3b')];}_0x19a395[_0x0bc5('0x2f')](_0xe5f62a)[_0x0bc5('0x3c')](_0xf7ba9a);};}exports[_0x0bc5('0x3d')]=function(_0x99bc58,_0x763856){var _0x294019={},_0x3fcb94={},_0xd0681e={'count':0x0,'rows':[]};var _0x422972=_['map'](db[_0x0bc5('0x3e')][_0x0bc5('0x3f')],function(_0x24c9e5){return{'name':_0x24c9e5[_0x0bc5('0x40')],'type':_0x24c9e5[_0x0bc5('0x41')][_0x0bc5('0x42')]};});_0x3fcb94[_0x0bc5('0x43')]=_[_0x0bc5('0x44')](_0x422972,_0x0bc5('0x3b'));_0x3fcb94[_0x0bc5('0x45')]=_[_0x0bc5('0x46')](_0x99bc58[_0x0bc5('0x45')]);_0x3fcb94[_0x0bc5('0x47')]=_[_0x0bc5('0x48')](_0x3fcb94['model'],_0x3fcb94['query']);_0x294019[_0x0bc5('0x49')]=_[_0x0bc5('0x48')](_0x3fcb94['model'],qs[_0x0bc5('0x4a')](_0x99bc58[_0x0bc5('0x45')]['fields']));_0x294019[_0x0bc5('0x49')]=_0x294019[_0x0bc5('0x49')][_0x0bc5('0x4b')]?_0x294019[_0x0bc5('0x49')]:_0x3fcb94['model'];if(!_0x99bc58[_0x0bc5('0x45')]['hasOwnProperty']('nolimit')){_0x294019[_0x0bc5('0x33')]=qs[_0x0bc5('0x33')](_0x99bc58[_0x0bc5('0x45')][_0x0bc5('0x33')]);_0x294019[_0x0bc5('0x32')]=qs[_0x0bc5('0x32')](_0x99bc58[_0x0bc5('0x45')]['offset']);}_0x294019[_0x0bc5('0x4c')]=qs['sort'](_0x99bc58[_0x0bc5('0x45')][_0x0bc5('0x4d')]);_0x294019[_0x0bc5('0x4e')]=qs[_0x0bc5('0x47')](_['pick'](_0x99bc58[_0x0bc5('0x45')],_0x3fcb94[_0x0bc5('0x47')]),_0x422972);if(_0x99bc58['query'][_0x0bc5('0x4f')]){_0x294019[_0x0bc5('0x4e')]=_['merge'](_0x294019[_0x0bc5('0x4e')],{'$or':_[_0x0bc5('0x44')](_0x422972,function(_0x4610e3){if(_0x4610e3['type']!=='VIRTUAL'){var _0x3f2774={};_0x3f2774[_0x4610e3['name']]={'$like':'%'+_0x99bc58['query']['filter']+'%'};return _0x3f2774;}})});}_0x294019=_[_0x0bc5('0x50')]({},_0x294019,_0x99bc58['options']);var _0x144a1d={'where':_0x294019[_0x0bc5('0x4e')]};return db['SugarcrmAccount'][_0x0bc5('0x31')](_0x144a1d)[_0x0bc5('0x22')](function(_0x491b5d){_0xd0681e['count']=_0x491b5d;if(_0x99bc58[_0x0bc5('0x45')][_0x0bc5('0x51')]){_0x294019[_0x0bc5('0x52')]=[{'all':!![]}];}return db[_0x0bc5('0x3e')]['findAll'](_0x294019);})[_0x0bc5('0x22')](function(_0x5825ff){_0xd0681e[_0x0bc5('0x53')]=_0x5825ff;return _0xd0681e;})[_0x0bc5('0x22')](respondWithFilteredResult(_0x763856,_0x294019))[_0x0bc5('0x2d')](handleError(_0x763856,null));};exports[_0x0bc5('0x54')]=function(_0x1c551a,_0x47f3c0){var _0x276d40={'raw':![],'where':{'id':_0x1c551a[_0x0bc5('0x55')]['id']}},_0x533c07={};_0x533c07['model']=_[_0x0bc5('0x46')](db[_0x0bc5('0x3e')][_0x0bc5('0x3f')]);_0x533c07['query']=_['keys'](_0x1c551a['query']);_0x533c07[_0x0bc5('0x47')]=_['intersection'](_0x533c07[_0x0bc5('0x43')],_0x533c07[_0x0bc5('0x45')]);_0x276d40[_0x0bc5('0x49')]=_[_0x0bc5('0x48')](_0x533c07['model'],qs[_0x0bc5('0x4a')](_0x1c551a[_0x0bc5('0x45')][_0x0bc5('0x4a')]));_0x276d40[_0x0bc5('0x49')]=_0x276d40[_0x0bc5('0x49')][_0x0bc5('0x4b')]?_0x276d40['attributes']:_0x533c07[_0x0bc5('0x43')];if(_0x1c551a[_0x0bc5('0x45')][_0x0bc5('0x51')]){_0x276d40[_0x0bc5('0x52')]=[{'all':!![]}];}_0x276d40=_[_0x0bc5('0x50')]({},_0x276d40,_0x1c551a[_0x0bc5('0x56')]);return db[_0x0bc5('0x3e')]['find'](_0x276d40)['then'](handleEntityNotFound(_0x47f3c0,null))[_0x0bc5('0x22')](respondWithResult(_0x47f3c0,null))[_0x0bc5('0x2d')](handleError(_0x47f3c0,null));};exports[_0x0bc5('0x57')]=function(_0x3fbee4,_0x2dbc2b){return db['SugarcrmAccount']['create'](_0x3fbee4['body'],{})[_0x0bc5('0x22')](respondWithResult(_0x2dbc2b,0xc9))[_0x0bc5('0x2d')](handleError(_0x2dbc2b,null));};exports[_0x0bc5('0x39')]=function(_0x5c01d6,_0x3ee49c){if(_0x5c01d6['body']['id']){delete _0x5c01d6[_0x0bc5('0x58')]['id'];}return db['SugarcrmAccount'][_0x0bc5('0x59')]({'where':{'id':_0x5c01d6[_0x0bc5('0x55')]['id']}})[_0x0bc5('0x22')](handleEntityNotFound(_0x3ee49c,null))[_0x0bc5('0x22')](saveUpdates(_0x5c01d6[_0x0bc5('0x58')],null))[_0x0bc5('0x22')](respondWithResult(_0x3ee49c,null))[_0x0bc5('0x2d')](handleError(_0x3ee49c,null));};exports[_0x0bc5('0x5a')]=function(_0x1b64e2,_0x250100){return db[_0x0bc5('0x3e')][_0x0bc5('0x59')]({'where':{'id':_0x1b64e2[_0x0bc5('0x55')]['id']}})['then'](handleEntityNotFound(_0x250100,null))[_0x0bc5('0x22')](removeEntity(_0x250100,null))['catch'](handleError(_0x250100,null));};exports[_0x0bc5('0x5b')]=function(_0x2bf53b,_0x5b9f3b,_0x252e39){var _0x3f8be4={};var _0x2f0b8e={};var _0x4b14b2;var _0x1de2af;return db['SugarcrmAccount']['findOne']({'where':{'id':_0x2bf53b['params']['id']}})[_0x0bc5('0x22')](handleEntityNotFound(_0x5b9f3b,null))[_0x0bc5('0x22')](function(_0x3232a7){if(_0x3232a7){_0x4b14b2=_0x3232a7;_0x2f0b8e[_0x0bc5('0x43')]=_['keys'](db[_0x0bc5('0x5c')][_0x0bc5('0x3f')]);_0x2f0b8e[_0x0bc5('0x45')]=_[_0x0bc5('0x46')](_0x2bf53b[_0x0bc5('0x45')]);_0x2f0b8e[_0x0bc5('0x47')]=_[_0x0bc5('0x48')](_0x2f0b8e[_0x0bc5('0x43')],_0x2f0b8e[_0x0bc5('0x45')]);_0x3f8be4['attributes']=_[_0x0bc5('0x48')](_0x2f0b8e[_0x0bc5('0x43')],qs[_0x0bc5('0x4a')](_0x2bf53b['query']['fields']));_0x3f8be4['attributes']=_0x3f8be4[_0x0bc5('0x49')][_0x0bc5('0x4b')]?_0x3f8be4[_0x0bc5('0x49')]:_0x2f0b8e[_0x0bc5('0x43')];_0x3f8be4['order']=qs[_0x0bc5('0x4d')](_0x2bf53b['query'][_0x0bc5('0x4d')]);_0x3f8be4[_0x0bc5('0x4e')]=qs[_0x0bc5('0x47')](_[_0x0bc5('0x5d')](_0x2bf53b[_0x0bc5('0x45')],_0x2f0b8e[_0x0bc5('0x47')]));if(_0x2bf53b[_0x0bc5('0x45')]['filter']){_0x3f8be4[_0x0bc5('0x4e')]=_['merge'](_0x3f8be4[_0x0bc5('0x4e')],{'$or':_['map'](_0x3f8be4[_0x0bc5('0x49')],function(_0x4cfdd6){var _0x4ae3c0={};_0x4ae3c0[_0x4cfdd6]={'$like':'%'+_0x2bf53b[_0x0bc5('0x45')][_0x0bc5('0x4f')]+'%'};return _0x4ae3c0;})});}_0x3f8be4=_[_0x0bc5('0x50')]({},_0x3f8be4,_0x2bf53b[_0x0bc5('0x56')]);return _0x4b14b2['getConfigurations'](_0x3f8be4);}})[_0x0bc5('0x22')](function(_0x359f1e){if(_0x359f1e){_0x1de2af=_0x359f1e['length'];if(!_0x2bf53b[_0x0bc5('0x45')][_0x0bc5('0x5e')](_0x0bc5('0x5f'))){_0x3f8be4[_0x0bc5('0x33')]=qs[_0x0bc5('0x33')](_0x2bf53b[_0x0bc5('0x45')][_0x0bc5('0x33')]);_0x3f8be4[_0x0bc5('0x32')]=qs[_0x0bc5('0x32')](_0x2bf53b['query']['offset']);}return _0x4b14b2[_0x0bc5('0x5b')](_0x3f8be4);}})[_0x0bc5('0x22')](function(_0x3bbe2a){if(_0x3bbe2a){return _0x3bbe2a?{'count':_0x1de2af,'rows':_0x3bbe2a}:null;}})[_0x0bc5('0x22')](respondWithResult(_0x5b9f3b,null))[_0x0bc5('0x2d')](handleError(_0x5b9f3b,null));};exports[_0x0bc5('0x60')]=function(_0xad303a,_0x23c26b,_0x4200c9){if(_0xad303a[_0x0bc5('0x58')]['id']){delete _0xad303a[_0x0bc5('0x58')]['id'];}return db[_0x0bc5('0x3e')][_0x0bc5('0x61')]({'where':{'id':_0xad303a['params']['id']}})[_0x0bc5('0x22')](handleEntityNotFound(_0x23c26b,null))[_0x0bc5('0x22')](function(_0x16809d){if(_0x16809d){_0xad303a['body'][_0x0bc5('0x62')]=_0x16809d['id'];_0xad303a[_0x0bc5('0x58')][_0x0bc5('0x63')]=integrations['getSubjects'](_0xad303a[_0x0bc5('0x58')][_0x0bc5('0x64')],_0xad303a['body'][_0x0bc5('0x41')]);_0xad303a['body'][_0x0bc5('0x65')]=integrations[_0x0bc5('0x66')](_0xad303a['body'][_0x0bc5('0x64')],_0xad303a[_0x0bc5('0x58')]['type']);return db[_0x0bc5('0x5c')]['create'](_0xad303a['body'],{'include':[{'model':db[_0x0bc5('0x67')],'as':'Subjects'},{'model':db['SugarcrmField'],'as':'Descriptions'}]});}return null;})[_0x0bc5('0x22')](respondWithResult(_0x23c26b,null))[_0x0bc5('0x2d')](handleError(_0x23c26b,null));};exports[_0x0bc5('0x68')]=function(_0x1e81e9,_0x3176d1,_0x40c524){var _0x2b6717='';var _0x636b92=['id',_0x0bc5('0x3b'),'assigned_user_id','created_by','description','date_start','duration_hours',_0x0bc5('0x69'),'parent_id','parent_type','parent_name',_0x0bc5('0x6a')];return db[_0x0bc5('0x3e')][_0x0bc5('0x61')]({'where':{'id':_0x1e81e9[_0x0bc5('0x55')]['id']},'attributes':['id',_0x0bc5('0x6b'),_0x0bc5('0x6c'),_0x0bc5('0x6d')]})[_0x0bc5('0x22')](handleEntityNotFound(_0x3176d1,null))[_0x0bc5('0x22')](function(_0x5edf51){if(_0x5edf51){_0x2b6717=_0x5edf51[_0x0bc5('0x6d')];var _0x51bafc=_0x2b6717[_0x0bc5('0x6e')](-0x1);if(_0x51bafc==='/'){_0x2b6717=_0x2b6717[_0x0bc5('0x6f')](0x0,_0x2b6717[_0x0bc5('0x70')](_0x51bafc));}return rp({'method':_0x0bc5('0x71'),'uri':util[_0x0bc5('0x72')](_0x0bc5('0x73'),_0x2b6717,_0x0bc5('0x74')),'json':!![],'form':{'method':_0x0bc5('0x75'),'input_type':_0x0bc5('0x76'),'response_type':_0x0bc5('0x76'),'rest_data':JSON[_0x0bc5('0x28')]({'user_auth':{'user_name':_0x5edf51[_0x0bc5('0x6b')],'password':_0x5edf51[_0x0bc5('0x6c')],'encryption':'PLAIN'},'application':_0x0bc5('0x77')})}});}})[_0x0bc5('0x22')](function(_0x29c554){if(_0x29c554&&_0x29c554[_0x0bc5('0x3b')]!==_0x0bc5('0x78')&&_0x29c554['name']!==_0x0bc5('0x79')){return rp({'method':_0x0bc5('0x71'),'uri':util[_0x0bc5('0x72')]('%s%s',_0x2b6717,_0x0bc5('0x74')),'json':!![],'form':{'method':_0x0bc5('0x7a'),'input_type':'JSON','response_type':_0x0bc5('0x76'),'rest_data':JSON[_0x0bc5('0x28')]({'session':_0x29c554['id'],'module_name':'Calls'})}})['then'](function(_0x322b05){if(_0x322b05){var _0x3eddbf=_[_0x0bc5('0x7b')](_0x322b05[_0x0bc5('0x7c')]);_[_0x0bc5('0x7d')](_0x3eddbf,function(_0x48a073){return _0x636b92[_0x0bc5('0x7e')](_0x48a073[_0x0bc5('0x3b')]);});return{'count':_0x3eddbf[_0x0bc5('0x4b')],'rows':_[_0x0bc5('0x44')](_0x3eddbf,function(_0x40ca65){return{'id':_0x40ca65[_0x0bc5('0x3b')],'name':_0x40ca65[_0x0bc5('0x7f')],'custom':_['endsWith'](_0x40ca65['name'],'_c')?!![]:![],'options':_0x40ca65[_0x0bc5('0x56')]?_[_0x0bc5('0x44')](_['values'](_0x40ca65[_0x0bc5('0x56')]),function(_0x274ae5){return{'name':_0x274ae5[_0x0bc5('0x80')],'value':_0x274ae5[_0x0bc5('0x3b')]};}):[]};})};}})['then'](respondWithResult(_0x3176d1,null))['catch'](function(_0x4c59be){var _0xf5c088=_0x1e81e9[_0x0bc5('0x45')][_0x0bc5('0x81')]?0x1f4:_0x4c59be['statusCode']||0x1f4;logger[_0x0bc5('0x29')](_0x0bc5('0x82'),_0x0bc5('0x68'),_0xf5c088,JSON[_0x0bc5('0x28')](_0x4c59be));delete _0x4c59be[_0x0bc5('0x3b')];if(_0xf5c088===0x191){_0xf5c088=0x190;}_0x3176d1[_0x0bc5('0x2f')](_0xf5c088)['send'](_0x1e81e9[_0x0bc5('0x45')][_0x0bc5('0x81')]?{'message':_0x0bc5('0x83'),'statusCode':_0x4c59be[_0x0bc5('0x84')]}:_0x4c59be);});}else{var _0x207f01=0x1f4;_0x3176d1[_0x0bc5('0x2f')](_0x207f01)[_0x0bc5('0x3c')]({'message':'Wrong\x20credentials','statusCode':0x190});}});};
\ No newline at end of file
+var _0x58a4=['show','params','length','find','create','body','destroy','getConfigurations','findOne','SugarcrmConfiguration','addConfiguration','AccountId','Subjects','channel','getDescriptions','SugarcrmField','Descriptions','getFields','created_by','description','parent_id','parent_name','direction','username','password','remoteUri','substring','lastIndexOf','POST','%s%s','login','JSON','stringify','PLAIN','xCALLY\x20Motion\x20Integration','Invalid\x20Login','Password\x20Expired','/service/v4_1/rest.php','get_module_fields','Calls','values','includes','label','endsWith','value','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','error','stack','name','send','index','map','SugarcrmAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','then','catch'];(function(_0x4186fa,_0x26a01c){var _0x136990=function(_0x13324f){while(--_0x13324f){_0x4186fa['push'](_0x4186fa['shift']());}};_0x136990(++_0x26a01c);}(_0x58a4,0x196));var _0x458a=function(_0xbe6d5d,_0x308a41){_0xbe6d5d=_0xbe6d5d-0x0;var _0x2cb584=_0x58a4[_0xbe6d5d];return _0x2cb584;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x458a('0x0'));var zipdir=require(_0x458a('0x1'));var jsonpatch=require(_0x458a('0x2'));var rp=require('request-promise');var moment=require(_0x458a('0x3'));var BPromise=require(_0x458a('0x4'));var Mustache=require(_0x458a('0x5'));var util=require(_0x458a('0x6'));var path=require('path');var sox=require(_0x458a('0x7'));var csv=require(_0x458a('0x8'));var ejs=require(_0x458a('0x9'));var fs=require('fs');var fs_extra=require(_0x458a('0xa'));var _=require('lodash');var squel=require(_0x458a('0xb'));var crypto=require(_0x458a('0xc'));var jsforce=require(_0x458a('0xd'));var deskjs=require(_0x458a('0xe'));var toCsv=require(_0x458a('0x8'));var querystring=require(_0x458a('0xf'));var Papa=require(_0x458a('0x10'));var Redis=require(_0x458a('0x11'));var authService=require(_0x458a('0x12'));var qs=require(_0x458a('0x13'));var as=require(_0x458a('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x458a('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x458a('0x16'));var db=require(_0x458a('0x17'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x357dfd,_0x33fbe7){_0x33fbe7=_0x33fbe7||0xcc;return function(_0x4ea160){if(_0x4ea160){return _0x357dfd[_0x458a('0x18')](_0x33fbe7);}return _0x357dfd[_0x458a('0x19')](_0x33fbe7)[_0x458a('0x1a')]();};}function respondWithResult(_0x3f97eb,_0x3909dd){_0x3909dd=_0x3909dd||0xc8;return function(_0x432e9f){if(_0x432e9f){return _0x3f97eb['status'](_0x3909dd)[_0x458a('0x1b')](_0x432e9f);}};}function respondWithFilteredResult(_0x48eb95,_0x312085){return function(_0x172a84){if(_0x172a84){var _0x4edb57=typeof _0x312085[_0x458a('0x1c')]===_0x458a('0x1d')&&typeof _0x312085[_0x458a('0x1e')]==='undefined';var _0x40524b=_0x172a84[_0x458a('0x1f')];var _0x40d804=_0x4edb57?0x0:_0x312085[_0x458a('0x1c')];var _0x354e31=_0x4edb57?_0x172a84[_0x458a('0x1f')]:_0x312085['offset']+_0x312085[_0x458a('0x1e')];var _0x41a894;if(_0x354e31>=_0x40524b){_0x354e31=_0x40524b;_0x41a894=0xc8;}else{_0x41a894=0xce;}_0x48eb95['status'](_0x41a894);return _0x48eb95[_0x458a('0x20')](_0x458a('0x21'),_0x40d804+'-'+_0x354e31+'/'+_0x40524b)[_0x458a('0x1b')](_0x172a84);}return null;};}function patchUpdates(_0x15155e){return function(_0x2aecb1){try{jsonpatch['apply'](_0x2aecb1,_0x15155e,!![]);}catch(_0x350072){return BPromise[_0x458a('0x22')](_0x350072);}return _0x2aecb1[_0x458a('0x23')]();};}function saveUpdates(_0x46c6ff,_0x4a0a7b){return function(_0x252c9a){if(_0x252c9a){return _0x252c9a[_0x458a('0x24')](_0x46c6ff)['then'](function(_0x421c5e){return _0x421c5e;});}return null;};}function removeEntity(_0x1f943b,_0xf3dbb){return function(_0x3ea4cd){if(_0x3ea4cd){return _0x3ea4cd['destroy']()['then'](function(){_0x1f943b['status'](0xcc)[_0x458a('0x1a')]();});}};}function handleEntityNotFound(_0x239821,_0x37a8fc){return function(_0xb18de7){if(!_0xb18de7){_0x239821[_0x458a('0x18')](0x194);}return _0xb18de7;};}function handleError(_0x5274cb,_0x22019a){_0x22019a=_0x22019a||0x1f4;return function(_0x27b02e){logger[_0x458a('0x25')](_0x27b02e[_0x458a('0x26')]);if(_0x27b02e['name']){delete _0x27b02e[_0x458a('0x27')];}_0x5274cb[_0x458a('0x19')](_0x22019a)[_0x458a('0x28')](_0x27b02e);};}exports[_0x458a('0x29')]=function(_0x156b66,_0x5429d9){var _0xd21328={},_0xab831d={},_0x415c8e={'count':0x0,'rows':[]};var _0x334bb3=_[_0x458a('0x2a')](db[_0x458a('0x2b')][_0x458a('0x2c')],function(_0x2b591e){return{'name':_0x2b591e[_0x458a('0x2d')],'type':_0x2b591e[_0x458a('0x2e')][_0x458a('0x2f')]};});_0xab831d[_0x458a('0x30')]=_[_0x458a('0x2a')](_0x334bb3,_0x458a('0x27'));_0xab831d[_0x458a('0x31')]=_[_0x458a('0x32')](_0x156b66[_0x458a('0x31')]);_0xab831d[_0x458a('0x33')]=_[_0x458a('0x34')](_0xab831d[_0x458a('0x30')],_0xab831d[_0x458a('0x31')]);_0xd21328[_0x458a('0x35')]=_[_0x458a('0x34')](_0xab831d[_0x458a('0x30')],qs[_0x458a('0x36')](_0x156b66[_0x458a('0x31')][_0x458a('0x36')]));_0xd21328[_0x458a('0x35')]=_0xd21328[_0x458a('0x35')]['length']?_0xd21328['attributes']:_0xab831d[_0x458a('0x30')];if(!_0x156b66['query'][_0x458a('0x37')](_0x458a('0x38'))){_0xd21328['limit']=qs[_0x458a('0x1e')](_0x156b66['query'][_0x458a('0x1e')]);_0xd21328['offset']=qs[_0x458a('0x1c')](_0x156b66[_0x458a('0x31')][_0x458a('0x1c')]);}_0xd21328[_0x458a('0x39')]=qs[_0x458a('0x3a')](_0x156b66[_0x458a('0x31')][_0x458a('0x3a')]);_0xd21328['where']=qs[_0x458a('0x33')](_[_0x458a('0x3b')](_0x156b66[_0x458a('0x31')],_0xab831d['filters']),_0x334bb3);if(_0x156b66[_0x458a('0x31')][_0x458a('0x3c')]){_0xd21328[_0x458a('0x3d')]=_[_0x458a('0x3e')](_0xd21328[_0x458a('0x3d')],{'$or':_[_0x458a('0x2a')](_0x334bb3,function(_0x46c2f6){if(_0x46c2f6[_0x458a('0x2e')]!==_0x458a('0x3f')){var _0x60dfc0={};_0x60dfc0[_0x46c2f6[_0x458a('0x27')]]={'$like':'%'+_0x156b66[_0x458a('0x31')]['filter']+'%'};return _0x60dfc0;}})});}_0xd21328=_['merge']({},_0xd21328,_0x156b66[_0x458a('0x40')]);var _0x4c2aba={'where':_0xd21328[_0x458a('0x3d')]};return db[_0x458a('0x2b')][_0x458a('0x1f')](_0x4c2aba)['then'](function(_0xb4d73d){_0x415c8e[_0x458a('0x1f')]=_0xb4d73d;if(_0x156b66[_0x458a('0x31')][_0x458a('0x41')]){_0xd21328[_0x458a('0x42')]=[{'all':!![]}];}return db[_0x458a('0x2b')][_0x458a('0x43')](_0xd21328);})['then'](function(_0x480ccf){_0x415c8e['rows']=_0x480ccf;return _0x415c8e;})[_0x458a('0x44')](respondWithFilteredResult(_0x5429d9,_0xd21328))[_0x458a('0x45')](handleError(_0x5429d9,null));};exports[_0x458a('0x46')]=function(_0x525776,_0x293923){var _0x16dc79={'raw':![],'where':{'id':_0x525776[_0x458a('0x47')]['id']}},_0x3d7033={};_0x3d7033['model']=_[_0x458a('0x32')](db['SugarcrmAccount'][_0x458a('0x2c')]);_0x3d7033[_0x458a('0x31')]=_['keys'](_0x525776['query']);_0x3d7033['filters']=_[_0x458a('0x34')](_0x3d7033[_0x458a('0x30')],_0x3d7033[_0x458a('0x31')]);_0x16dc79[_0x458a('0x35')]=_[_0x458a('0x34')](_0x3d7033[_0x458a('0x30')],qs[_0x458a('0x36')](_0x525776[_0x458a('0x31')][_0x458a('0x36')]));_0x16dc79[_0x458a('0x35')]=_0x16dc79[_0x458a('0x35')][_0x458a('0x48')]?_0x16dc79[_0x458a('0x35')]:_0x3d7033[_0x458a('0x30')];if(_0x525776[_0x458a('0x31')][_0x458a('0x41')]){_0x16dc79[_0x458a('0x42')]=[{'all':!![]}];}_0x16dc79=_[_0x458a('0x3e')]({},_0x16dc79,_0x525776[_0x458a('0x40')]);return db[_0x458a('0x2b')][_0x458a('0x49')](_0x16dc79)[_0x458a('0x44')](handleEntityNotFound(_0x293923,null))['then'](respondWithResult(_0x293923,null))[_0x458a('0x45')](handleError(_0x293923,null));};exports[_0x458a('0x4a')]=function(_0x51ffbc,_0x469724){return db[_0x458a('0x2b')][_0x458a('0x4a')](_0x51ffbc[_0x458a('0x4b')],{})[_0x458a('0x44')](respondWithResult(_0x469724,0xc9))[_0x458a('0x45')](handleError(_0x469724,null));};exports[_0x458a('0x24')]=function(_0x58e229,_0x1b7d63){if(_0x58e229[_0x458a('0x4b')]['id']){delete _0x58e229[_0x458a('0x4b')]['id'];}return db['SugarcrmAccount'][_0x458a('0x49')]({'where':{'id':_0x58e229[_0x458a('0x47')]['id']}})['then'](handleEntityNotFound(_0x1b7d63,null))[_0x458a('0x44')](saveUpdates(_0x58e229['body'],null))['then'](respondWithResult(_0x1b7d63,null))[_0x458a('0x45')](handleError(_0x1b7d63,null));};exports[_0x458a('0x4c')]=function(_0xc97b5f,_0x41f9c6){return db[_0x458a('0x2b')]['find']({'where':{'id':_0xc97b5f[_0x458a('0x47')]['id']}})[_0x458a('0x44')](handleEntityNotFound(_0x41f9c6,null))[_0x458a('0x44')](removeEntity(_0x41f9c6,null))[_0x458a('0x45')](handleError(_0x41f9c6,null));};exports[_0x458a('0x4d')]=function(_0x4df6c2,_0x61c134,_0x34e6d8){var _0x52c750={};var _0x38be91={};var _0x1e0ca3;var _0x1d2ce4;return db[_0x458a('0x2b')][_0x458a('0x4e')]({'where':{'id':_0x4df6c2[_0x458a('0x47')]['id']}})['then'](handleEntityNotFound(_0x61c134,null))[_0x458a('0x44')](function(_0x465243){if(_0x465243){_0x1e0ca3=_0x465243;_0x38be91['model']=_['keys'](db[_0x458a('0x4f')][_0x458a('0x2c')]);_0x38be91[_0x458a('0x31')]=_[_0x458a('0x32')](_0x4df6c2[_0x458a('0x31')]);_0x38be91[_0x458a('0x33')]=_['intersection'](_0x38be91[_0x458a('0x30')],_0x38be91[_0x458a('0x31')]);_0x52c750['attributes']=_[_0x458a('0x34')](_0x38be91[_0x458a('0x30')],qs[_0x458a('0x36')](_0x4df6c2[_0x458a('0x31')]['fields']));_0x52c750['attributes']=_0x52c750['attributes'][_0x458a('0x48')]?_0x52c750[_0x458a('0x35')]:_0x38be91['model'];_0x52c750[_0x458a('0x39')]=qs[_0x458a('0x3a')](_0x4df6c2[_0x458a('0x31')]['sort']);_0x52c750[_0x458a('0x3d')]=qs[_0x458a('0x33')](_[_0x458a('0x3b')](_0x4df6c2[_0x458a('0x31')],_0x38be91[_0x458a('0x33')]));if(_0x4df6c2[_0x458a('0x31')][_0x458a('0x3c')]){_0x52c750[_0x458a('0x3d')]=_[_0x458a('0x3e')](_0x52c750[_0x458a('0x3d')],{'$or':_['map'](_0x52c750[_0x458a('0x35')],function(_0x2a43f5){var _0x48d9ae={};_0x48d9ae[_0x2a43f5]={'$like':'%'+_0x4df6c2['query'][_0x458a('0x3c')]+'%'};return _0x48d9ae;})});}_0x52c750=_[_0x458a('0x3e')]({},_0x52c750,_0x4df6c2[_0x458a('0x40')]);return _0x1e0ca3[_0x458a('0x4d')](_0x52c750);}})[_0x458a('0x44')](function(_0x3890be){if(_0x3890be){_0x1d2ce4=_0x3890be[_0x458a('0x48')];if(!_0x4df6c2[_0x458a('0x31')][_0x458a('0x37')](_0x458a('0x38'))){_0x52c750[_0x458a('0x1e')]=qs[_0x458a('0x1e')](_0x4df6c2[_0x458a('0x31')][_0x458a('0x1e')]);_0x52c750['offset']=qs[_0x458a('0x1c')](_0x4df6c2['query'][_0x458a('0x1c')]);}return _0x1e0ca3['getConfigurations'](_0x52c750);}})['then'](function(_0x4584f9){if(_0x4584f9){return _0x4584f9?{'count':_0x1d2ce4,'rows':_0x4584f9}:null;}})[_0x458a('0x44')](respondWithResult(_0x61c134,null))[_0x458a('0x45')](handleError(_0x61c134,null));};exports[_0x458a('0x50')]=function(_0x1e08f2,_0x55557b,_0x47724a){if(_0x1e08f2[_0x458a('0x4b')]['id']){delete _0x1e08f2[_0x458a('0x4b')]['id'];}return db[_0x458a('0x2b')]['findOne']({'where':{'id':_0x1e08f2['params']['id']}})['then'](handleEntityNotFound(_0x55557b,null))[_0x458a('0x44')](function(_0x530928){if(_0x530928){_0x1e08f2[_0x458a('0x4b')][_0x458a('0x51')]=_0x530928['id'];_0x1e08f2[_0x458a('0x4b')][_0x458a('0x52')]=integrations['getSubjects'](_0x1e08f2['body'][_0x458a('0x53')],_0x1e08f2[_0x458a('0x4b')][_0x458a('0x2e')]);_0x1e08f2[_0x458a('0x4b')]['Descriptions']=integrations[_0x458a('0x54')](_0x1e08f2[_0x458a('0x4b')][_0x458a('0x53')],_0x1e08f2[_0x458a('0x4b')]['type']);return db[_0x458a('0x4f')]['create'](_0x1e08f2[_0x458a('0x4b')],{'include':[{'model':db[_0x458a('0x55')],'as':_0x458a('0x52')},{'model':db[_0x458a('0x55')],'as':_0x458a('0x56')}]});}return null;})[_0x458a('0x44')](respondWithResult(_0x55557b,null))[_0x458a('0x45')](handleError(_0x55557b,null));};exports[_0x458a('0x57')]=function(_0x4ea096,_0x11dedb,_0x414e39){var _0x377c7d='';var _0x3ea53d=['id',_0x458a('0x27'),'assigned_user_id',_0x458a('0x58'),_0x458a('0x59'),'date_start','duration_hours','duration_minutes',_0x458a('0x5a'),'parent_type',_0x458a('0x5b'),_0x458a('0x5c')];return db[_0x458a('0x2b')][_0x458a('0x4e')]({'where':{'id':_0x4ea096[_0x458a('0x47')]['id']},'attributes':['id',_0x458a('0x5d'),_0x458a('0x5e'),_0x458a('0x5f')]})[_0x458a('0x44')](handleEntityNotFound(_0x11dedb,null))[_0x458a('0x44')](function(_0x3a9ffc){if(_0x3a9ffc){_0x377c7d=_0x3a9ffc[_0x458a('0x5f')];var _0x5cf49f=_0x377c7d['slice'](-0x1);if(_0x5cf49f==='/'){_0x377c7d=_0x377c7d[_0x458a('0x60')](0x0,_0x377c7d[_0x458a('0x61')](_0x5cf49f));}return rp({'method':_0x458a('0x62'),'uri':util['format'](_0x458a('0x63'),_0x377c7d,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0x458a('0x64'),'input_type':_0x458a('0x65'),'response_type':_0x458a('0x65'),'rest_data':JSON[_0x458a('0x66')]({'user_auth':{'user_name':_0x3a9ffc[_0x458a('0x5d')],'password':_0x3a9ffc['password'],'encryption':_0x458a('0x67')},'application':_0x458a('0x68')})}});}})[_0x458a('0x44')](function(_0x59a6f8){if(_0x59a6f8&&_0x59a6f8[_0x458a('0x27')]!==_0x458a('0x69')&&_0x59a6f8[_0x458a('0x27')]!==_0x458a('0x6a')){return rp({'method':_0x458a('0x62'),'uri':util['format'](_0x458a('0x63'),_0x377c7d,_0x458a('0x6b')),'json':!![],'form':{'method':_0x458a('0x6c'),'input_type':'JSON','response_type':_0x458a('0x65'),'rest_data':JSON[_0x458a('0x66')]({'session':_0x59a6f8['id'],'module_name':_0x458a('0x6d')})}})[_0x458a('0x44')](function(_0x2f1adb){if(_0x2f1adb){var _0x3f88ff=_[_0x458a('0x6e')](_0x2f1adb['module_fields']);_['remove'](_0x3f88ff,function(_0x7ed3a){return _0x3ea53d[_0x458a('0x6f')](_0x7ed3a[_0x458a('0x27')]);});return{'count':_0x3f88ff[_0x458a('0x48')],'rows':_['map'](_0x3f88ff,function(_0x38e40d){return{'id':_0x38e40d[_0x458a('0x27')],'name':_0x38e40d[_0x458a('0x70')],'custom':_[_0x458a('0x71')](_0x38e40d[_0x458a('0x27')],'_c')?!![]:![],'options':_0x38e40d['options']?_[_0x458a('0x2a')](_['values'](_0x38e40d[_0x458a('0x40')]),function(_0xc85e79){return{'name':_0xc85e79[_0x458a('0x72')],'value':_0xc85e79['name']};}):[]};})};}})[_0x458a('0x44')](respondWithResult(_0x11dedb,null))['catch'](function(_0x8fc92b){var _0x2d9518=_0x4ea096['query'][_0x458a('0x73')]?0x1f4:_0x8fc92b[_0x458a('0x74')]||0x1f4;logger[_0x458a('0x25')](_0x458a('0x75'),_0x458a('0x57'),_0x2d9518,JSON['stringify'](_0x8fc92b));delete _0x8fc92b[_0x458a('0x27')];if(_0x2d9518===0x191){_0x2d9518=0x190;}_0x11dedb[_0x458a('0x19')](_0x2d9518)['send'](_0x4ea096[_0x458a('0x31')][_0x458a('0x73')]?{'message':_0x458a('0x76'),'statusCode':_0x8fc92b[_0x458a('0x74')]}:_0x8fc92b);});}else{var _0x43305a=0x1f4;_0x11dedb[_0x458a('0x19')](_0x43305a)[_0x458a('0x28')]({'message':_0x458a('0x76'),'statusCode':0x190});}});};
\ No newline at end of file