Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 56ae98e..a343a69 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbfd3=['remove','includes','endsWith','values','value','statusCode','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../components/integrations/configuration','client','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','end','status','json','count','offset','limit','set','save','update','then','destroy','stack','name','send','index','SugarcrmAccount','rawAttributes','key','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','include','findAll','show','params','find','create','body','findOne','SugarcrmConfiguration','getConfigurations','Subjects','getSubjects','type','Descriptions','getDescriptions','channel','SugarcrmField','getFields','assigned_user_id','created_by','date_start','duration_minutes','parent_id','parent_type','username','password','remoteUri','slice','POST','format','%s%s','login','JSON','PLAIN','xCALLY\x20Motion\x20Integration','Password\x20Expired','get_module_fields','Calls','module_fields'];(function(_0xd21618,_0x1c88fc){var _0x4ad2e5=function(_0x44badf){while(--_0x44badf){_0xd21618['push'](_0xd21618['shift']());}};_0x4ad2e5(++_0x1c88fc);}(_0xbfd3,0x84));var _0x3bfd=function(_0x21edda,_0x4135e9){_0x21edda=_0x21edda-0x0;var _0x19161a=_0xbfd3[_0x21edda];return _0x19161a;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x3bfd('0x0'));var zipdir=require(_0x3bfd('0x1'));var jsonpatch=require(_0x3bfd('0x2'));var rp=require(_0x3bfd('0x3'));var moment=require(_0x3bfd('0x4'));var BPromise=require(_0x3bfd('0x5'));var Mustache=require(_0x3bfd('0x6'));var util=require(_0x3bfd('0x7'));var path=require(_0x3bfd('0x8'));var sox=require(_0x3bfd('0x9'));var csv=require(_0x3bfd('0xa'));var ejs=require(_0x3bfd('0xb'));var fs=require('fs');var _=require(_0x3bfd('0xc'));var squel=require(_0x3bfd('0xd'));var crypto=require(_0x3bfd('0xe'));var jsforce=require(_0x3bfd('0xf'));var deskjs=require(_0x3bfd('0x10'));var toCsv=require(_0x3bfd('0xa'));var querystring=require(_0x3bfd('0x11'));var Papa=require(_0x3bfd('0x12'));var Redis=require(_0x3bfd('0x13'));var authService=require(_0x3bfd('0x14'));var qs=require(_0x3bfd('0x15'));var as=require(_0x3bfd('0x16'));var hardwareService=require(_0x3bfd('0x17'));var logger=require(_0x3bfd('0x18'))(_0x3bfd('0x19'));var utils=require(_0x3bfd('0x1a'));var config=require(_0x3bfd('0x1b'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0x3bfd('0x1c'));var jayson=require('jayson/promise');var client=jayson[_0x3bfd('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x106720,_0x4527dc,_0x1f674f,_0xa149d3){return new BPromise(function(_0x125c3c,_0x1b8ef3){var _0x4baaa7=_0xa149d3||client;return _0x4baaa7['request'](_0x106720,_0x1f674f)['then'](function(_0x4a34e){logger[_0x3bfd('0x1e')](_0x3bfd('0x1f'),_0x4527dc,_0x3bfd('0x20'));logger['debug'](_0x3bfd('0x21'),_0x4527dc,_0x3bfd('0x20'),JSON[_0x3bfd('0x22')](_0x4a34e));if(_0x4a34e[_0x3bfd('0x23')]){if(_0x4a34e[_0x3bfd('0x23')][_0x3bfd('0x24')]===0x1f4){logger[_0x3bfd('0x23')](_0x3bfd('0x1f'),_0x4527dc,_0x4a34e[_0x3bfd('0x23')][_0x3bfd('0x25')]);return _0x1b8ef3(_0x4a34e['error'][_0x3bfd('0x25')]);}logger[_0x3bfd('0x23')](_0x3bfd('0x1f'),_0x4527dc,_0x4a34e[_0x3bfd('0x23')][_0x3bfd('0x25')]);return _0x125c3c(_0x4a34e['error'][_0x3bfd('0x25')]);}else{logger[_0x3bfd('0x1e')](_0x3bfd('0x1f'),_0x4527dc,_0x3bfd('0x20'));_0x125c3c(_0x4a34e['result']['message']);}})[_0x3bfd('0x26')](function(_0x38c2c7){logger[_0x3bfd('0x23')](_0x3bfd('0x1f'),_0x4527dc,_0x38c2c7);_0x1b8ef3(_0x38c2c7);});});}function respondWithStatusCode(_0x11473c,_0x558a63){_0x558a63=_0x558a63||0xcc;return function(_0x471ce8){if(_0x471ce8){return _0x11473c['sendStatus'](_0x558a63);}return _0x11473c['status'](_0x558a63)[_0x3bfd('0x27')]();};}function respondWithResult(_0x3acde9,_0x51ba37){_0x51ba37=_0x51ba37||0xc8;return function(_0x41e4c4){if(_0x41e4c4){return _0x3acde9[_0x3bfd('0x28')](_0x51ba37)[_0x3bfd('0x29')](_0x41e4c4);}};}function respondWithFilteredResult(_0x2f7855,_0x29cd84){return function(_0x55b146){if(_0x55b146){var _0x4ad590=_0x55b146[_0x3bfd('0x2a')],_0x287fa0=_0x29cd84[_0x3bfd('0x2b')],_0x159d40=_0x29cd84['offset']+_0x29cd84[_0x3bfd('0x2c')],_0x5e4fc0;if(_0x159d40>=_0x4ad590){_0x159d40=_0x4ad590;_0x5e4fc0=0xc8;}else{_0x5e4fc0=0xce;}_0x2f7855[_0x3bfd('0x28')](_0x5e4fc0);return _0x2f7855[_0x3bfd('0x2d')]('Content-Range',_0x287fa0+'-'+_0x159d40+'/'+_0x4ad590)[_0x3bfd('0x29')](_0x55b146);}return null;};}function patchUpdates(_0x45aad1){return function(_0x1a809f){try{jsonpatch['apply'](_0x1a809f,_0x45aad1,!![]);}catch(_0x40cd58){return BPromise['reject'](_0x40cd58);}return _0x1a809f[_0x3bfd('0x2e')]();};}function saveUpdates(_0x2740c8,_0x4e4721){return function(_0x2e1994){if(_0x2e1994){return _0x2e1994[_0x3bfd('0x2f')](_0x2740c8)[_0x3bfd('0x30')](function(_0x58ee88){return _0x58ee88;});}return null;};}function removeEntity(_0x5025d8,_0x51f8da){return function(_0x53c9fd){if(_0x53c9fd){return _0x53c9fd[_0x3bfd('0x31')]()[_0x3bfd('0x30')](function(){_0x5025d8[_0x3bfd('0x28')](0xcc)[_0x3bfd('0x27')]();});}};}function handleEntityNotFound(_0x243972,_0x8065cf){return function(_0x5e0851){if(!_0x5e0851){_0x243972['sendStatus'](0x194);}return _0x5e0851;};}function handleError(_0x10c4eb,_0x5aa589){_0x5aa589=_0x5aa589||0x1f4;return function(_0x103bb2){logger[_0x3bfd('0x23')](_0x103bb2[_0x3bfd('0x32')]);if(_0x103bb2[_0x3bfd('0x33')]){delete _0x103bb2[_0x3bfd('0x33')];}_0x10c4eb[_0x3bfd('0x28')](_0x5aa589)[_0x3bfd('0x34')](_0x103bb2);};}exports[_0x3bfd('0x35')]=function(_0x5992f7,_0x151a6d){var _0x5135b5={},_0x3af35c={},_0x29873f={'count':0x0,'rows':[]};var _0x48c1cf=_['map'](db[_0x3bfd('0x36')][_0x3bfd('0x37')],function(_0x239536){return{'name':_0x239536['fieldName'],'type':_0x239536['type'][_0x3bfd('0x38')]};});_0x3af35c[_0x3bfd('0x39')]=_[_0x3bfd('0x3a')](_0x48c1cf,'name');_0x3af35c[_0x3bfd('0x3b')]=_[_0x3bfd('0x3c')](_0x5992f7[_0x3bfd('0x3b')]);_0x3af35c[_0x3bfd('0x3d')]=_[_0x3bfd('0x3e')](_0x3af35c[_0x3bfd('0x39')],_0x3af35c[_0x3bfd('0x3b')]);_0x5135b5[_0x3bfd('0x3f')]=_[_0x3bfd('0x3e')](_0x3af35c[_0x3bfd('0x39')],qs[_0x3bfd('0x40')](_0x5992f7[_0x3bfd('0x3b')]['fields']));_0x5135b5[_0x3bfd('0x3f')]=_0x5135b5[_0x3bfd('0x3f')][_0x3bfd('0x41')]?_0x5135b5[_0x3bfd('0x3f')]:_0x3af35c[_0x3bfd('0x39')];if(!_0x5992f7[_0x3bfd('0x3b')][_0x3bfd('0x42')](_0x3bfd('0x43'))){_0x5135b5[_0x3bfd('0x2c')]=qs[_0x3bfd('0x2c')](_0x5992f7[_0x3bfd('0x3b')][_0x3bfd('0x2c')]);_0x5135b5[_0x3bfd('0x2b')]=qs['offset'](_0x5992f7[_0x3bfd('0x3b')][_0x3bfd('0x2b')]);}_0x5135b5[_0x3bfd('0x44')]=qs['sort'](_0x5992f7['query'][_0x3bfd('0x45')]);_0x5135b5[_0x3bfd('0x46')]=qs[_0x3bfd('0x3d')](_[_0x3bfd('0x47')](_0x5992f7[_0x3bfd('0x3b')],_0x3af35c[_0x3bfd('0x3d')]),_0x48c1cf);if(_0x5992f7[_0x3bfd('0x3b')][_0x3bfd('0x48')]){_0x5135b5[_0x3bfd('0x46')]=_[_0x3bfd('0x49')](_0x5135b5[_0x3bfd('0x46')],{'$or':_['map'](_0x48c1cf,function(_0x680fb){if(_0x680fb['type']!=='VIRTUAL'){var _0x365e6c={};_0x365e6c[_0x680fb[_0x3bfd('0x33')]]={'$like':'%'+_0x5992f7[_0x3bfd('0x3b')][_0x3bfd('0x48')]+'%'};return _0x365e6c;}})});}_0x5135b5=_[_0x3bfd('0x49')]({},_0x5135b5,_0x5992f7[_0x3bfd('0x4a')]);var _0x5380bc={'where':_0x5135b5[_0x3bfd('0x46')]};return db[_0x3bfd('0x36')][_0x3bfd('0x2a')](_0x5380bc)['then'](function(_0x45ca01){_0x29873f['count']=_0x45ca01;if(_0x5992f7[_0x3bfd('0x3b')]['includeAll']){_0x5135b5[_0x3bfd('0x4b')]=[{'all':!![]}];}return db[_0x3bfd('0x36')][_0x3bfd('0x4c')](_0x5135b5);})[_0x3bfd('0x30')](function(_0x31f2fc){_0x29873f['rows']=_0x31f2fc;return _0x29873f;})[_0x3bfd('0x30')](respondWithFilteredResult(_0x151a6d,_0x5135b5))[_0x3bfd('0x26')](handleError(_0x151a6d,null));};exports[_0x3bfd('0x4d')]=function(_0x572697,_0x576d14){var _0x52f53d={'raw':![],'where':{'id':_0x572697[_0x3bfd('0x4e')]['id']}},_0x3eb3cf={};_0x3eb3cf['model']=_['keys'](db[_0x3bfd('0x36')][_0x3bfd('0x37')]);_0x3eb3cf[_0x3bfd('0x3b')]=_[_0x3bfd('0x3c')](_0x572697[_0x3bfd('0x3b')]);_0x3eb3cf[_0x3bfd('0x3d')]=_[_0x3bfd('0x3e')](_0x3eb3cf[_0x3bfd('0x39')],_0x3eb3cf['query']);_0x52f53d[_0x3bfd('0x3f')]=_['intersection'](_0x3eb3cf[_0x3bfd('0x39')],qs[_0x3bfd('0x40')](_0x572697[_0x3bfd('0x3b')][_0x3bfd('0x40')]));_0x52f53d[_0x3bfd('0x3f')]=_0x52f53d[_0x3bfd('0x3f')][_0x3bfd('0x41')]?_0x52f53d[_0x3bfd('0x3f')]:_0x3eb3cf['model'];if(_0x572697[_0x3bfd('0x3b')]['includeAll']){_0x52f53d[_0x3bfd('0x4b')]=[{'all':!![]}];}_0x52f53d=_[_0x3bfd('0x49')]({},_0x52f53d,_0x572697[_0x3bfd('0x4a')]);return db['SugarcrmAccount'][_0x3bfd('0x4f')](_0x52f53d)[_0x3bfd('0x30')](handleEntityNotFound(_0x576d14,null))['then'](respondWithResult(_0x576d14,null))[_0x3bfd('0x26')](handleError(_0x576d14,null));};exports[_0x3bfd('0x50')]=function(_0x1727ff,_0x1050a4){return db[_0x3bfd('0x36')][_0x3bfd('0x50')](_0x1727ff[_0x3bfd('0x51')],{})['then'](respondWithResult(_0x1050a4,0xc9))[_0x3bfd('0x26')](handleError(_0x1050a4,null));};exports[_0x3bfd('0x2f')]=function(_0x35b840,_0x30abf3){if(_0x35b840['body']['id']){delete _0x35b840[_0x3bfd('0x51')]['id'];}return db['SugarcrmAccount'][_0x3bfd('0x4f')]({'where':{'id':_0x35b840[_0x3bfd('0x4e')]['id']}})['then'](handleEntityNotFound(_0x30abf3,null))['then'](saveUpdates(_0x35b840['body'],null))[_0x3bfd('0x30')](respondWithResult(_0x30abf3,null))[_0x3bfd('0x26')](handleError(_0x30abf3,null));};exports[_0x3bfd('0x31')]=function(_0x1a4d09,_0x15d930){return db['SugarcrmAccount']['find']({'where':{'id':_0x1a4d09[_0x3bfd('0x4e')]['id']}})['then'](handleEntityNotFound(_0x15d930,null))[_0x3bfd('0x30')](removeEntity(_0x15d930,null))[_0x3bfd('0x26')](handleError(_0x15d930,null));};exports['getConfigurations']=function(_0x208c2b,_0x1447c8,_0x598f3b){var _0x23f832={};var _0x4740db={};var _0x49b831;var _0x4128e9;return db['SugarcrmAccount'][_0x3bfd('0x52')]({'where':{'id':_0x208c2b[_0x3bfd('0x4e')]['id']}})[_0x3bfd('0x30')](handleEntityNotFound(_0x1447c8,null))['then'](function(_0x33bf5a){if(_0x33bf5a){_0x49b831=_0x33bf5a;_0x4740db['model']=_[_0x3bfd('0x3c')](db[_0x3bfd('0x53')][_0x3bfd('0x37')]);_0x4740db[_0x3bfd('0x3b')]=_[_0x3bfd('0x3c')](_0x208c2b['query']);_0x4740db[_0x3bfd('0x3d')]=_[_0x3bfd('0x3e')](_0x4740db['model'],_0x4740db[_0x3bfd('0x3b')]);_0x23f832['attributes']=_[_0x3bfd('0x3e')](_0x4740db[_0x3bfd('0x39')],qs[_0x3bfd('0x40')](_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x40')]));_0x23f832['attributes']=_0x23f832[_0x3bfd('0x3f')][_0x3bfd('0x41')]?_0x23f832[_0x3bfd('0x3f')]:_0x4740db[_0x3bfd('0x39')];_0x23f832[_0x3bfd('0x44')]=qs['sort'](_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x45')]);_0x23f832[_0x3bfd('0x46')]=qs[_0x3bfd('0x3d')](_[_0x3bfd('0x47')](_0x208c2b['query'],_0x4740db[_0x3bfd('0x3d')]));if(_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x48')]){_0x23f832[_0x3bfd('0x46')]=_['merge'](_0x23f832[_0x3bfd('0x46')],{'$or':_[_0x3bfd('0x3a')](_0x23f832['attributes'],function(_0x3423fc){var _0x4c0b46={};_0x4c0b46[_0x3423fc]={'$like':'%'+_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x48')]+'%'};return _0x4c0b46;})});}_0x23f832=_['merge']({},_0x23f832,_0x208c2b[_0x3bfd('0x4a')]);return _0x49b831[_0x3bfd('0x54')](_0x23f832);}})[_0x3bfd('0x30')](function(_0x526b54){if(_0x526b54){_0x4128e9=_0x526b54[_0x3bfd('0x41')];if(!_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x42')](_0x3bfd('0x43'))){_0x23f832[_0x3bfd('0x2c')]=qs[_0x3bfd('0x2c')](_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x2c')]);_0x23f832[_0x3bfd('0x2b')]=qs[_0x3bfd('0x2b')](_0x208c2b[_0x3bfd('0x3b')][_0x3bfd('0x2b')]);}return _0x49b831['getConfigurations'](_0x23f832);}})['then'](function(_0x12b58a){if(_0x12b58a){return _0x12b58a?{'count':_0x4128e9,'rows':_0x12b58a}:null;}})['then'](respondWithResult(_0x1447c8,null))[_0x3bfd('0x26')](handleError(_0x1447c8,null));};exports['addConfiguration']=function(_0x3fbe7d,_0xa7484a,_0x19105c){if(_0x3fbe7d[_0x3bfd('0x51')]['id']){delete _0x3fbe7d['body']['id'];}return db[_0x3bfd('0x36')][_0x3bfd('0x52')]({'where':{'id':_0x3fbe7d['params']['id']}})['then'](handleEntityNotFound(_0xa7484a,null))[_0x3bfd('0x30')](function(_0x145c38){if(_0x145c38){_0x3fbe7d['body']['AccountId']=_0x145c38['id'];_0x3fbe7d[_0x3bfd('0x51')][_0x3bfd('0x55')]=integrations[_0x3bfd('0x56')](_0x3fbe7d[_0x3bfd('0x51')]['channel'],_0x3fbe7d[_0x3bfd('0x51')][_0x3bfd('0x57')]);_0x3fbe7d[_0x3bfd('0x51')][_0x3bfd('0x58')]=integrations[_0x3bfd('0x59')](_0x3fbe7d[_0x3bfd('0x51')][_0x3bfd('0x5a')],_0x3fbe7d[_0x3bfd('0x51')]['type']);return db['SugarcrmConfiguration'][_0x3bfd('0x50')](_0x3fbe7d[_0x3bfd('0x51')],{'include':[{'model':db[_0x3bfd('0x5b')],'as':_0x3bfd('0x55')},{'model':db['SugarcrmField'],'as':_0x3bfd('0x58')}]});}return null;})[_0x3bfd('0x30')](respondWithResult(_0xa7484a,null))[_0x3bfd('0x26')](handleError(_0xa7484a,null));};exports[_0x3bfd('0x5c')]=function(_0x42c9a0,_0x2e0f35,_0x449b21){var _0x25477e='';var _0x2a8ad7=['id',_0x3bfd('0x33'),_0x3bfd('0x5d'),_0x3bfd('0x5e'),'description',_0x3bfd('0x5f'),'duration_hours',_0x3bfd('0x60'),_0x3bfd('0x61'),_0x3bfd('0x62'),'parent_name','direction'];return db[_0x3bfd('0x36')][_0x3bfd('0x52')]({'where':{'id':_0x42c9a0[_0x3bfd('0x4e')]['id']},'attributes':['id',_0x3bfd('0x63'),_0x3bfd('0x64'),'remoteUri']})['then'](handleEntityNotFound(_0x2e0f35,null))[_0x3bfd('0x30')](function(_0x48d8c6){if(_0x48d8c6){_0x25477e=_0x48d8c6[_0x3bfd('0x65')];var _0x4e3cc5=_0x25477e[_0x3bfd('0x66')](-0x1);if(_0x4e3cc5==='/'){_0x25477e=_0x25477e['substring'](0x0,_0x25477e['lastIndexOf'](_0x4e3cc5));}return rp({'method':_0x3bfd('0x67'),'uri':util[_0x3bfd('0x68')](_0x3bfd('0x69'),_0x25477e,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0x3bfd('0x6a'),'input_type':_0x3bfd('0x6b'),'response_type':_0x3bfd('0x6b'),'rest_data':JSON[_0x3bfd('0x22')]({'user_auth':{'user_name':_0x48d8c6[_0x3bfd('0x63')],'password':_0x48d8c6[_0x3bfd('0x64')],'encryption':_0x3bfd('0x6c')},'application':_0x3bfd('0x6d')})}});}})[_0x3bfd('0x30')](function(_0x2971c0){if(_0x2971c0&&_0x2971c0['name']!=='Invalid\x20Login'&&_0x2971c0[_0x3bfd('0x33')]!==_0x3bfd('0x6e')){return rp({'method':'POST','uri':util[_0x3bfd('0x68')](_0x3bfd('0x69'),_0x25477e,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0x3bfd('0x6f'),'input_type':_0x3bfd('0x6b'),'response_type':_0x3bfd('0x6b'),'rest_data':JSON[_0x3bfd('0x22')]({'session':_0x2971c0['id'],'module_name':_0x3bfd('0x70')})}})['then'](function(_0x1678ff){if(_0x1678ff){var _0x382a8b=_['values'](_0x1678ff[_0x3bfd('0x71')]);_[_0x3bfd('0x72')](_0x382a8b,function(_0x18c6f1){return _0x2a8ad7[_0x3bfd('0x73')](_0x18c6f1['name']);});return{'count':_0x382a8b[_0x3bfd('0x41')],'rows':_[_0x3bfd('0x3a')](_0x382a8b,function(_0x57df68){return{'id':_0x57df68[_0x3bfd('0x33')],'name':_0x57df68['label'],'custom':_[_0x3bfd('0x74')](_0x57df68[_0x3bfd('0x33')],'_c')?!![]:![],'options':_0x57df68[_0x3bfd('0x4a')]?_[_0x3bfd('0x3a')](_[_0x3bfd('0x75')](_0x57df68['options']),function(_0x4fd887){return{'name':_0x4fd887[_0x3bfd('0x76')],'value':_0x4fd887[_0x3bfd('0x33')]};}):[]};})};}})[_0x3bfd('0x30')](respondWithResult(_0x2e0f35,null))[_0x3bfd('0x26')](function(_0x4f64bd){var _0x298520=_0x42c9a0[_0x3bfd('0x3b')]['test']?0x1f4:_0x4f64bd[_0x3bfd('0x77')]||0x1f4;logger[_0x3bfd('0x23')](_0x3bfd('0x78'),'getFields',_0x298520,JSON['stringify'](_0x4f64bd));delete _0x4f64bd[_0x3bfd('0x33')];if(_0x298520===0x191){_0x298520=0x190;}_0x2e0f35[_0x3bfd('0x28')](_0x298520)[_0x3bfd('0x34')](_0x42c9a0[_0x3bfd('0x3b')][_0x3bfd('0x79')]?{'message':_0x3bfd('0x7a'),'statusCode':_0x4f64bd['statusCode']}:_0x4f64bd);});}else{var _0x260121=0x1f4;_0x2e0f35[_0x3bfd('0x28')](_0x260121)[_0x3bfd('0x34')]({'message':'Wrong\x20credentials','statusCode':0x190});}});};
\ No newline at end of file
+var _0xbae0=['includes','label','values','test','getFields,\x20%s,\x20%s,\x20%s','statusCode','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','sendStatus','stack','name','send','index','map','SugarcrmAccount','rawAttributes','fieldName','type','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','sort','pick','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','params','find','catch','create','body','update','findOne','SugarcrmConfiguration','order','getConfigurations','AccountId','Subjects','channel','Descriptions','getDescriptions','SugarcrmField','getFields','created_by','duration_hours','duration_minutes','parent_id','parent_type','direction','username','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','login','JSON','stringify','password','PLAIN','xCALLY\x20Motion\x20Integration','Invalid\x20Login','Password\x20Expired','Calls','module_fields','remove'];(function(_0x251969,_0x4a4547){var _0x59268a=function(_0x186f3a){while(--_0x186f3a){_0x251969['push'](_0x251969['shift']());}};_0x59268a(++_0x4a4547);}(_0xbae0,0x16f));var _0x0bae=function(_0x1e175d,_0x41ff45){_0x1e175d=_0x1e175d-0x0;var _0x3a3ce5=_0xbae0[_0x1e175d];return _0x3a3ce5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0bae('0x0'));var zipdir=require(_0x0bae('0x1'));var jsonpatch=require(_0x0bae('0x2'));var rp=require(_0x0bae('0x3'));var moment=require(_0x0bae('0x4'));var BPromise=require(_0x0bae('0x5'));var Mustache=require(_0x0bae('0x6'));var util=require(_0x0bae('0x7'));var path=require('path');var sox=require(_0x0bae('0x8'));var csv=require(_0x0bae('0x9'));var ejs=require(_0x0bae('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0bae('0xb'));var squel=require(_0x0bae('0xc'));var crypto=require(_0x0bae('0xd'));var jsforce=require(_0x0bae('0xe'));var deskjs=require(_0x0bae('0xf'));var toCsv=require(_0x0bae('0x9'));var querystring=require(_0x0bae('0x10'));var Papa=require('papaparse');var Redis=require(_0x0bae('0x11'));var authService=require(_0x0bae('0x12'));var qs=require(_0x0bae('0x13'));var as=require(_0x0bae('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0bae('0x15'))(_0x0bae('0x16'));var utils=require('../../config/utils');var config=require(_0x0bae('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x0bae('0x18'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x49c2a6,_0x3bf46f){_0x3bf46f=_0x3bf46f||0xcc;return function(_0x5b124d){if(_0x5b124d){return _0x49c2a6['sendStatus'](_0x3bf46f);}return _0x49c2a6[_0x0bae('0x19')](_0x3bf46f)[_0x0bae('0x1a')]();};}function respondWithResult(_0x5597f3,_0x247f95){_0x247f95=_0x247f95||0xc8;return function(_0x3bd8fc){if(_0x3bd8fc){return _0x5597f3[_0x0bae('0x19')](_0x247f95)[_0x0bae('0x1b')](_0x3bd8fc);}};}function respondWithFilteredResult(_0x40e7a9,_0xd2715a){return function(_0x22039e){if(_0x22039e){var _0x4695b2=typeof _0xd2715a[_0x0bae('0x1c')]===_0x0bae('0x1d')&&typeof _0xd2715a[_0x0bae('0x1e')]===_0x0bae('0x1d');var _0x5806b2=_0x22039e[_0x0bae('0x1f')];var _0x2001d0=_0x4695b2?0x0:_0xd2715a['offset'];var _0x33e5d0=_0x4695b2?_0x22039e[_0x0bae('0x1f')]:_0xd2715a[_0x0bae('0x1c')]+_0xd2715a[_0x0bae('0x1e')];var _0x13bade;if(_0x33e5d0>=_0x5806b2){_0x33e5d0=_0x5806b2;_0x13bade=0xc8;}else{_0x13bade=0xce;}_0x40e7a9['status'](_0x13bade);return _0x40e7a9[_0x0bae('0x20')](_0x0bae('0x21'),_0x2001d0+'-'+_0x33e5d0+'/'+_0x5806b2)[_0x0bae('0x1b')](_0x22039e);}return null;};}function patchUpdates(_0x5976ff){return function(_0x32caa5){try{jsonpatch[_0x0bae('0x22')](_0x32caa5,_0x5976ff,!![]);}catch(_0x2df36d){return BPromise[_0x0bae('0x23')](_0x2df36d);}return _0x32caa5[_0x0bae('0x24')]();};}function saveUpdates(_0x189077,_0x573af6){return function(_0x96b72a){if(_0x96b72a){return _0x96b72a['update'](_0x189077)[_0x0bae('0x25')](function(_0x4ed2b6){return _0x4ed2b6;});}return null;};}function removeEntity(_0x4b15a5,_0x10ee0d){return function(_0x4111f7){if(_0x4111f7){return _0x4111f7[_0x0bae('0x26')]()[_0x0bae('0x25')](function(){_0x4b15a5[_0x0bae('0x19')](0xcc)[_0x0bae('0x1a')]();});}};}function handleEntityNotFound(_0x27ef77,_0x4ccb86){return function(_0x3b4954){if(!_0x3b4954){_0x27ef77[_0x0bae('0x27')](0x194);}return _0x3b4954;};}function handleError(_0x527969,_0x279c24){_0x279c24=_0x279c24||0x1f4;return function(_0x18509a){logger['error'](_0x18509a[_0x0bae('0x28')]);if(_0x18509a[_0x0bae('0x29')]){delete _0x18509a[_0x0bae('0x29')];}_0x527969[_0x0bae('0x19')](_0x279c24)[_0x0bae('0x2a')](_0x18509a);};}exports[_0x0bae('0x2b')]=function(_0x3a14f1,_0xa8e50b){var _0x1c936f={},_0x303dec={},_0x40cb9c={'count':0x0,'rows':[]};var _0x49547d=_[_0x0bae('0x2c')](db[_0x0bae('0x2d')][_0x0bae('0x2e')],function(_0x8b9ffb){return{'name':_0x8b9ffb[_0x0bae('0x2f')],'type':_0x8b9ffb[_0x0bae('0x30')]['key']};});_0x303dec[_0x0bae('0x31')]=_['map'](_0x49547d,_0x0bae('0x29'));_0x303dec['query']=_[_0x0bae('0x32')](_0x3a14f1[_0x0bae('0x33')]);_0x303dec[_0x0bae('0x34')]=_[_0x0bae('0x35')](_0x303dec['model'],_0x303dec[_0x0bae('0x33')]);_0x1c936f[_0x0bae('0x36')]=_[_0x0bae('0x35')](_0x303dec['model'],qs[_0x0bae('0x37')](_0x3a14f1['query'][_0x0bae('0x37')]));_0x1c936f[_0x0bae('0x36')]=_0x1c936f[_0x0bae('0x36')][_0x0bae('0x38')]?_0x1c936f[_0x0bae('0x36')]:_0x303dec['model'];if(!_0x3a14f1['query'][_0x0bae('0x39')]('nolimit')){_0x1c936f[_0x0bae('0x1e')]=qs[_0x0bae('0x1e')](_0x3a14f1['query'][_0x0bae('0x1e')]);_0x1c936f[_0x0bae('0x1c')]=qs['offset'](_0x3a14f1[_0x0bae('0x33')][_0x0bae('0x1c')]);}_0x1c936f['order']=qs[_0x0bae('0x3a')](_0x3a14f1[_0x0bae('0x33')][_0x0bae('0x3a')]);_0x1c936f['where']=qs[_0x0bae('0x34')](_[_0x0bae('0x3b')](_0x3a14f1['query'],_0x303dec[_0x0bae('0x34')]),_0x49547d);if(_0x3a14f1[_0x0bae('0x33')][_0x0bae('0x3c')]){_0x1c936f[_0x0bae('0x3d')]=_['merge'](_0x1c936f[_0x0bae('0x3d')],{'$or':_[_0x0bae('0x2c')](_0x49547d,function(_0x55441c){if(_0x55441c[_0x0bae('0x30')]!==_0x0bae('0x3e')){var _0x191f87={};_0x191f87[_0x55441c[_0x0bae('0x29')]]={'$like':'%'+_0x3a14f1['query']['filter']+'%'};return _0x191f87;}})});}_0x1c936f=_[_0x0bae('0x3f')]({},_0x1c936f,_0x3a14f1[_0x0bae('0x40')]);var _0xc702e2={'where':_0x1c936f[_0x0bae('0x3d')]};return db[_0x0bae('0x2d')][_0x0bae('0x1f')](_0xc702e2)[_0x0bae('0x25')](function(_0x505ae1){_0x40cb9c[_0x0bae('0x1f')]=_0x505ae1;if(_0x3a14f1[_0x0bae('0x33')][_0x0bae('0x41')]){_0x1c936f[_0x0bae('0x42')]=[{'all':!![]}];}return db['SugarcrmAccount'][_0x0bae('0x43')](_0x1c936f);})['then'](function(_0x45ec93){_0x40cb9c[_0x0bae('0x44')]=_0x45ec93;return _0x40cb9c;})[_0x0bae('0x25')](respondWithFilteredResult(_0xa8e50b,_0x1c936f))['catch'](handleError(_0xa8e50b,null));};exports[_0x0bae('0x45')]=function(_0x180bdd,_0xf4b70f){var _0x1d52f9={'raw':![],'where':{'id':_0x180bdd[_0x0bae('0x46')]['id']}},_0x1a9920={};_0x1a9920[_0x0bae('0x31')]=_[_0x0bae('0x32')](db[_0x0bae('0x2d')][_0x0bae('0x2e')]);_0x1a9920[_0x0bae('0x33')]=_[_0x0bae('0x32')](_0x180bdd['query']);_0x1a9920['filters']=_[_0x0bae('0x35')](_0x1a9920[_0x0bae('0x31')],_0x1a9920[_0x0bae('0x33')]);_0x1d52f9['attributes']=_[_0x0bae('0x35')](_0x1a9920['model'],qs[_0x0bae('0x37')](_0x180bdd[_0x0bae('0x33')][_0x0bae('0x37')]));_0x1d52f9[_0x0bae('0x36')]=_0x1d52f9['attributes'][_0x0bae('0x38')]?_0x1d52f9['attributes']:_0x1a9920[_0x0bae('0x31')];if(_0x180bdd[_0x0bae('0x33')]['includeAll']){_0x1d52f9['include']=[{'all':!![]}];}_0x1d52f9=_['merge']({},_0x1d52f9,_0x180bdd[_0x0bae('0x40')]);return db[_0x0bae('0x2d')][_0x0bae('0x47')](_0x1d52f9)[_0x0bae('0x25')](handleEntityNotFound(_0xf4b70f,null))['then'](respondWithResult(_0xf4b70f,null))[_0x0bae('0x48')](handleError(_0xf4b70f,null));};exports[_0x0bae('0x49')]=function(_0x50c1c8,_0x17eb11){return db[_0x0bae('0x2d')]['create'](_0x50c1c8[_0x0bae('0x4a')],{})[_0x0bae('0x25')](respondWithResult(_0x17eb11,0xc9))[_0x0bae('0x48')](handleError(_0x17eb11,null));};exports[_0x0bae('0x4b')]=function(_0x1fca66,_0x38ac44){if(_0x1fca66[_0x0bae('0x4a')]['id']){delete _0x1fca66[_0x0bae('0x4a')]['id'];}return db[_0x0bae('0x2d')][_0x0bae('0x47')]({'where':{'id':_0x1fca66[_0x0bae('0x46')]['id']}})[_0x0bae('0x25')](handleEntityNotFound(_0x38ac44,null))['then'](saveUpdates(_0x1fca66[_0x0bae('0x4a')],null))['then'](respondWithResult(_0x38ac44,null))[_0x0bae('0x48')](handleError(_0x38ac44,null));};exports[_0x0bae('0x26')]=function(_0xd490ae,_0x2eaa82){return db[_0x0bae('0x2d')][_0x0bae('0x47')]({'where':{'id':_0xd490ae[_0x0bae('0x46')]['id']}})['then'](handleEntityNotFound(_0x2eaa82,null))['then'](removeEntity(_0x2eaa82,null))[_0x0bae('0x48')](handleError(_0x2eaa82,null));};exports['getConfigurations']=function(_0x940e46,_0x4e342d,_0x30afb1){var _0x5a63e9={};var _0x1c4b8d={};var _0x22ba19;var _0x492130;return db[_0x0bae('0x2d')][_0x0bae('0x4c')]({'where':{'id':_0x940e46['params']['id']}})['then'](handleEntityNotFound(_0x4e342d,null))[_0x0bae('0x25')](function(_0x3e2bd2){if(_0x3e2bd2){_0x22ba19=_0x3e2bd2;_0x1c4b8d['model']=_[_0x0bae('0x32')](db[_0x0bae('0x4d')][_0x0bae('0x2e')]);_0x1c4b8d['query']=_['keys'](_0x940e46[_0x0bae('0x33')]);_0x1c4b8d[_0x0bae('0x34')]=_[_0x0bae('0x35')](_0x1c4b8d['model'],_0x1c4b8d[_0x0bae('0x33')]);_0x5a63e9[_0x0bae('0x36')]=_[_0x0bae('0x35')](_0x1c4b8d[_0x0bae('0x31')],qs[_0x0bae('0x37')](_0x940e46['query']['fields']));_0x5a63e9[_0x0bae('0x36')]=_0x5a63e9[_0x0bae('0x36')][_0x0bae('0x38')]?_0x5a63e9['attributes']:_0x1c4b8d['model'];_0x5a63e9[_0x0bae('0x4e')]=qs[_0x0bae('0x3a')](_0x940e46['query'][_0x0bae('0x3a')]);_0x5a63e9[_0x0bae('0x3d')]=qs[_0x0bae('0x34')](_['pick'](_0x940e46[_0x0bae('0x33')],_0x1c4b8d['filters']));if(_0x940e46[_0x0bae('0x33')][_0x0bae('0x3c')]){_0x5a63e9[_0x0bae('0x3d')]=_[_0x0bae('0x3f')](_0x5a63e9[_0x0bae('0x3d')],{'$or':_[_0x0bae('0x2c')](_0x5a63e9[_0x0bae('0x36')],function(_0x278666){var _0xcbe45f={};_0xcbe45f[_0x278666]={'$like':'%'+_0x940e46[_0x0bae('0x33')][_0x0bae('0x3c')]+'%'};return _0xcbe45f;})});}_0x5a63e9=_[_0x0bae('0x3f')]({},_0x5a63e9,_0x940e46[_0x0bae('0x40')]);return _0x22ba19[_0x0bae('0x4f')](_0x5a63e9);}})[_0x0bae('0x25')](function(_0x41bf6a){if(_0x41bf6a){_0x492130=_0x41bf6a['length'];if(!_0x940e46[_0x0bae('0x33')][_0x0bae('0x39')]('nolimit')){_0x5a63e9[_0x0bae('0x1e')]=qs[_0x0bae('0x1e')](_0x940e46[_0x0bae('0x33')][_0x0bae('0x1e')]);_0x5a63e9[_0x0bae('0x1c')]=qs[_0x0bae('0x1c')](_0x940e46[_0x0bae('0x33')][_0x0bae('0x1c')]);}return _0x22ba19[_0x0bae('0x4f')](_0x5a63e9);}})[_0x0bae('0x25')](function(_0x5b54b8){if(_0x5b54b8){return _0x5b54b8?{'count':_0x492130,'rows':_0x5b54b8}:null;}})['then'](respondWithResult(_0x4e342d,null))[_0x0bae('0x48')](handleError(_0x4e342d,null));};exports['addConfiguration']=function(_0x306046,_0x16c7bf,_0x4c2feb){if(_0x306046[_0x0bae('0x4a')]['id']){delete _0x306046['body']['id'];}return db['SugarcrmAccount'][_0x0bae('0x4c')]({'where':{'id':_0x306046['params']['id']}})[_0x0bae('0x25')](handleEntityNotFound(_0x16c7bf,null))[_0x0bae('0x25')](function(_0x3809e7){if(_0x3809e7){_0x306046[_0x0bae('0x4a')][_0x0bae('0x50')]=_0x3809e7['id'];_0x306046[_0x0bae('0x4a')][_0x0bae('0x51')]=integrations['getSubjects'](_0x306046[_0x0bae('0x4a')][_0x0bae('0x52')],_0x306046[_0x0bae('0x4a')][_0x0bae('0x30')]);_0x306046['body'][_0x0bae('0x53')]=integrations[_0x0bae('0x54')](_0x306046['body'][_0x0bae('0x52')],_0x306046[_0x0bae('0x4a')][_0x0bae('0x30')]);return db[_0x0bae('0x4d')][_0x0bae('0x49')](_0x306046['body'],{'include':[{'model':db[_0x0bae('0x55')],'as':_0x0bae('0x51')},{'model':db[_0x0bae('0x55')],'as':_0x0bae('0x53')}]});}return null;})[_0x0bae('0x25')](respondWithResult(_0x16c7bf,null))[_0x0bae('0x48')](handleError(_0x16c7bf,null));};exports[_0x0bae('0x56')]=function(_0x5dce6d,_0x12c035,_0x4611f2){var _0x34a9d2='';var _0x5c103b=['id','name','assigned_user_id',_0x0bae('0x57'),'description','date_start',_0x0bae('0x58'),_0x0bae('0x59'),_0x0bae('0x5a'),_0x0bae('0x5b'),'parent_name',_0x0bae('0x5c')];return db['SugarcrmAccount']['findOne']({'where':{'id':_0x5dce6d['params']['id']},'attributes':['id',_0x0bae('0x5d'),'password',_0x0bae('0x5e')]})[_0x0bae('0x25')](handleEntityNotFound(_0x12c035,null))[_0x0bae('0x25')](function(_0x262bc5){if(_0x262bc5){_0x34a9d2=_0x262bc5[_0x0bae('0x5e')];var _0x2da70b=_0x34a9d2[_0x0bae('0x5f')](-0x1);if(_0x2da70b==='/'){_0x34a9d2=_0x34a9d2[_0x0bae('0x60')](0x0,_0x34a9d2[_0x0bae('0x61')](_0x2da70b));}return rp({'method':_0x0bae('0x62'),'uri':util[_0x0bae('0x63')](_0x0bae('0x64'),_0x34a9d2,_0x0bae('0x65')),'json':!![],'form':{'method':_0x0bae('0x66'),'input_type':_0x0bae('0x67'),'response_type':'JSON','rest_data':JSON[_0x0bae('0x68')]({'user_auth':{'user_name':_0x262bc5[_0x0bae('0x5d')],'password':_0x262bc5[_0x0bae('0x69')],'encryption':_0x0bae('0x6a')},'application':_0x0bae('0x6b')})}});}})[_0x0bae('0x25')](function(_0x50c5c0){if(_0x50c5c0&&_0x50c5c0[_0x0bae('0x29')]!==_0x0bae('0x6c')&&_0x50c5c0['name']!==_0x0bae('0x6d')){return rp({'method':_0x0bae('0x62'),'uri':util[_0x0bae('0x63')](_0x0bae('0x64'),_0x34a9d2,_0x0bae('0x65')),'json':!![],'form':{'method':'get_module_fields','input_type':_0x0bae('0x67'),'response_type':_0x0bae('0x67'),'rest_data':JSON['stringify']({'session':_0x50c5c0['id'],'module_name':_0x0bae('0x6e')})}})['then'](function(_0x65f3d5){if(_0x65f3d5){var _0x505e97=_['values'](_0x65f3d5[_0x0bae('0x6f')]);_[_0x0bae('0x70')](_0x505e97,function(_0x11f8a5){return _0x5c103b[_0x0bae('0x71')](_0x11f8a5['name']);});return{'count':_0x505e97[_0x0bae('0x38')],'rows':_[_0x0bae('0x2c')](_0x505e97,function(_0x2a93c3){return{'id':_0x2a93c3[_0x0bae('0x29')],'name':_0x2a93c3[_0x0bae('0x72')],'custom':_['endsWith'](_0x2a93c3[_0x0bae('0x29')],'_c')?!![]:![],'options':_0x2a93c3[_0x0bae('0x40')]?_[_0x0bae('0x2c')](_[_0x0bae('0x73')](_0x2a93c3[_0x0bae('0x40')]),function(_0x33f06b){return{'name':_0x33f06b['value'],'value':_0x33f06b['name']};}):[]};})};}})[_0x0bae('0x25')](respondWithResult(_0x12c035,null))['catch'](function(_0x2a1773){var _0x104705=_0x5dce6d[_0x0bae('0x33')][_0x0bae('0x74')]?0x1f4:_0x2a1773['statusCode']||0x1f4;logger['error'](_0x0bae('0x75'),_0x0bae('0x56'),_0x104705,JSON[_0x0bae('0x68')](_0x2a1773));delete _0x2a1773[_0x0bae('0x29')];if(_0x104705===0x191){_0x104705=0x190;}_0x12c035[_0x0bae('0x19')](_0x104705)[_0x0bae('0x2a')](_0x5dce6d[_0x0bae('0x33')]['test']?{'message':'Wrong\x20credentials','statusCode':_0x2a1773[_0x0bae('0x76')]}:_0x2a1773);});}else{var _0x438bdb=0x1f4;_0x12c035['status'](_0x438bdb)[_0x0bae('0x2a')]({'message':_0x0bae('0x77'),'statusCode':0x190});}});};
\ No newline at end of file