Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index a5ce4d6..ddf930a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9f5e=['pick','filter','where','merge','options','includeAll','include','findAll','then','rows','catch','show','keys','find','create','body','destroy','params','getConfigurations','findOne','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','SugarcrmConfiguration','SugarcrmField','Descriptions','assigned_user_id','created_by','description','date_start','duration_hours','parent_id','parent_type','parent_name','direction','username','password','remoteUri','slice','POST','format','/service/v4_1/rest.php','login','JSON','stringify','PLAIN','Password\x20Expired','%s%s','get_module_fields','Calls','values','module_fields','remove','includes','label','endsWith','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','Wrong\x20credentials','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','to-csv','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','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','error','name','send','index','map','SugarcrmAccount','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','order','sort'];(function(_0x502c7d,_0x2f1285){var _0x30b7ed=function(_0x2d92f3){while(--_0x2d92f3){_0x502c7d['push'](_0x502c7d['shift']());}};_0x30b7ed(++_0x2f1285);}(_0x9f5e,0x13b));var _0xe9f5=function(_0x3a7da8,_0x3bf2b0){_0x3a7da8=_0x3a7da8-0x0;var _0x3580cf=_0x9f5e[_0x3a7da8];return _0x3580cf;};'use strict';var emlformat=require(_0xe9f5('0x0'));var rimraf=require(_0xe9f5('0x1'));var zipdir=require(_0xe9f5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe9f5('0x3'));var moment=require(_0xe9f5('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xe9f5('0x5'));var util=require(_0xe9f5('0x6'));var path=require(_0xe9f5('0x7'));var sox=require('sox');var csv=require(_0xe9f5('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xe9f5('0x9'));var squel=require(_0xe9f5('0xa'));var crypto=require(_0xe9f5('0xb'));var jsforce=require(_0xe9f5('0xc'));var deskjs=require(_0xe9f5('0xd'));var toCsv=require(_0xe9f5('0x8'));var querystring=require(_0xe9f5('0xe'));var Papa=require(_0xe9f5('0xf'));var Redis=require(_0xe9f5('0x10'));var authService=require(_0xe9f5('0x11'));var qs=require(_0xe9f5('0x12'));var as=require(_0xe9f5('0x13'));var hardwareService=require(_0xe9f5('0x14'));var logger=require(_0xe9f5('0x15'))(_0xe9f5('0x16'));var utils=require(_0xe9f5('0x17'));var config=require(_0xe9f5('0x18'));var licenseUtil=require(_0xe9f5('0x19'));var db=require(_0xe9f5('0x1a'))['db'];var integrations=require(_0xe9f5('0x1b'));function respondWithStatusCode(_0x3efdd6,_0x3d6840){_0x3d6840=_0x3d6840||0xcc;return function(_0x5a924e){if(_0x5a924e){return _0x3efdd6[_0xe9f5('0x1c')](_0x3d6840);}return _0x3efdd6[_0xe9f5('0x1d')](_0x3d6840)[_0xe9f5('0x1e')]();};}function respondWithResult(_0xf4d4cc,_0x184be4){_0x184be4=_0x184be4||0xc8;return function(_0x15c318){if(_0x15c318){return _0xf4d4cc[_0xe9f5('0x1d')](_0x184be4)[_0xe9f5('0x1f')](_0x15c318);}};}function respondWithFilteredResult(_0x403566,_0x2f1b06){return function(_0x5ea730){if(_0x5ea730){var _0x57f6d4=typeof _0x2f1b06[_0xe9f5('0x20')]===_0xe9f5('0x21')&&typeof _0x2f1b06[_0xe9f5('0x22')]===_0xe9f5('0x21');var _0x5d178a=_0x5ea730[_0xe9f5('0x23')];var _0x131007=_0x57f6d4?0x0:_0x2f1b06[_0xe9f5('0x20')];var _0x5c1acd=_0x57f6d4?_0x5ea730[_0xe9f5('0x23')]:_0x2f1b06['offset']+_0x2f1b06[_0xe9f5('0x22')];var _0x445bcc;if(_0x5c1acd>=_0x5d178a){_0x5c1acd=_0x5d178a;_0x445bcc=0xc8;}else{_0x445bcc=0xce;}_0x403566['status'](_0x445bcc);return _0x403566[_0xe9f5('0x24')](_0xe9f5('0x25'),_0x131007+'-'+_0x5c1acd+'/'+_0x5d178a)[_0xe9f5('0x1f')](_0x5ea730);}return null;};}function patchUpdates(_0x2a7b81){return function(_0x42f7ec){try{jsonpatch[_0xe9f5('0x26')](_0x42f7ec,_0x2a7b81,!![]);}catch(_0x619d50){return BPromise[_0xe9f5('0x27')](_0x619d50);}return _0x42f7ec[_0xe9f5('0x28')]();};}function saveUpdates(_0x258197,_0xa755a0){return function(_0x548d17){if(_0x548d17){return _0x548d17[_0xe9f5('0x29')](_0x258197)['then'](function(_0x53a471){return _0x53a471;});}return null;};}function removeEntity(_0x2c2355,_0x334f5e){return function(_0x58cd7f){if(_0x58cd7f){return _0x58cd7f['destroy']()['then'](function(){_0x2c2355['status'](0xcc)[_0xe9f5('0x1e')]();});}};}function handleEntityNotFound(_0x4b95a,_0x312204){return function(_0x9321f1){if(!_0x9321f1){_0x4b95a[_0xe9f5('0x1c')](0x194);}return _0x9321f1;};}function handleError(_0x4c8446,_0x4eb5f2){_0x4eb5f2=_0x4eb5f2||0x1f4;return function(_0x47e37c){logger[_0xe9f5('0x2a')](_0x47e37c['stack']);if(_0x47e37c[_0xe9f5('0x2b')]){delete _0x47e37c['name'];}_0x4c8446[_0xe9f5('0x1d')](_0x4eb5f2)[_0xe9f5('0x2c')](_0x47e37c);};}exports[_0xe9f5('0x2d')]=function(_0x573a87,_0x53f779){var _0x14f0eb={},_0xbc0e6c={},_0xfa1538={'count':0x0,'rows':[]};var _0x4d2230=_[_0xe9f5('0x2e')](db[_0xe9f5('0x2f')][_0xe9f5('0x30')],function(_0x4a1666){return{'name':_0x4a1666[_0xe9f5('0x31')],'type':_0x4a1666[_0xe9f5('0x32')]['key']};});_0xbc0e6c[_0xe9f5('0x33')]=_[_0xe9f5('0x2e')](_0x4d2230,'name');_0xbc0e6c[_0xe9f5('0x34')]=_['keys'](_0x573a87[_0xe9f5('0x34')]);_0xbc0e6c[_0xe9f5('0x35')]=_[_0xe9f5('0x36')](_0xbc0e6c['model'],_0xbc0e6c['query']);_0x14f0eb[_0xe9f5('0x37')]=_['intersection'](_0xbc0e6c[_0xe9f5('0x33')],qs[_0xe9f5('0x38')](_0x573a87[_0xe9f5('0x34')][_0xe9f5('0x38')]));_0x14f0eb['attributes']=_0x14f0eb['attributes'][_0xe9f5('0x39')]?_0x14f0eb[_0xe9f5('0x37')]:_0xbc0e6c[_0xe9f5('0x33')];if(!_0x573a87['query']['hasOwnProperty']('nolimit')){_0x14f0eb[_0xe9f5('0x22')]=qs[_0xe9f5('0x22')](_0x573a87['query'][_0xe9f5('0x22')]);_0x14f0eb[_0xe9f5('0x20')]=qs['offset'](_0x573a87[_0xe9f5('0x34')]['offset']);}_0x14f0eb[_0xe9f5('0x3a')]=qs[_0xe9f5('0x3b')](_0x573a87[_0xe9f5('0x34')][_0xe9f5('0x3b')]);_0x14f0eb['where']=qs[_0xe9f5('0x35')](_[_0xe9f5('0x3c')](_0x573a87['query'],_0xbc0e6c[_0xe9f5('0x35')]),_0x4d2230);if(_0x573a87[_0xe9f5('0x34')][_0xe9f5('0x3d')]){_0x14f0eb[_0xe9f5('0x3e')]=_[_0xe9f5('0x3f')](_0x14f0eb[_0xe9f5('0x3e')],{'$or':_[_0xe9f5('0x2e')](_0x4d2230,function(_0x25d2ad){if(_0x25d2ad[_0xe9f5('0x32')]!=='VIRTUAL'){var _0x45744={};_0x45744[_0x25d2ad[_0xe9f5('0x2b')]]={'$like':'%'+_0x573a87['query'][_0xe9f5('0x3d')]+'%'};return _0x45744;}})});}_0x14f0eb=_[_0xe9f5('0x3f')]({},_0x14f0eb,_0x573a87[_0xe9f5('0x40')]);var _0x1f8945={'where':_0x14f0eb[_0xe9f5('0x3e')]};return db[_0xe9f5('0x2f')][_0xe9f5('0x23')](_0x1f8945)['then'](function(_0x1a8261){_0xfa1538[_0xe9f5('0x23')]=_0x1a8261;if(_0x573a87[_0xe9f5('0x34')][_0xe9f5('0x41')]){_0x14f0eb[_0xe9f5('0x42')]=[{'all':!![]}];}return db[_0xe9f5('0x2f')][_0xe9f5('0x43')](_0x14f0eb);})[_0xe9f5('0x44')](function(_0x5ce474){_0xfa1538[_0xe9f5('0x45')]=_0x5ce474;return _0xfa1538;})[_0xe9f5('0x44')](respondWithFilteredResult(_0x53f779,_0x14f0eb))[_0xe9f5('0x46')](handleError(_0x53f779,null));};exports[_0xe9f5('0x47')]=function(_0x2bda11,_0x4b0c80){var _0x538ace={'raw':![],'where':{'id':_0x2bda11['params']['id']}},_0x5d1cc9={};_0x5d1cc9[_0xe9f5('0x33')]=_[_0xe9f5('0x48')](db[_0xe9f5('0x2f')][_0xe9f5('0x30')]);_0x5d1cc9[_0xe9f5('0x34')]=_['keys'](_0x2bda11[_0xe9f5('0x34')]);_0x5d1cc9['filters']=_['intersection'](_0x5d1cc9[_0xe9f5('0x33')],_0x5d1cc9[_0xe9f5('0x34')]);_0x538ace[_0xe9f5('0x37')]=_[_0xe9f5('0x36')](_0x5d1cc9[_0xe9f5('0x33')],qs['fields'](_0x2bda11[_0xe9f5('0x34')][_0xe9f5('0x38')]));_0x538ace[_0xe9f5('0x37')]=_0x538ace['attributes'][_0xe9f5('0x39')]?_0x538ace[_0xe9f5('0x37')]:_0x5d1cc9['model'];if(_0x2bda11[_0xe9f5('0x34')][_0xe9f5('0x41')]){_0x538ace['include']=[{'all':!![]}];}_0x538ace=_[_0xe9f5('0x3f')]({},_0x538ace,_0x2bda11[_0xe9f5('0x40')]);return db[_0xe9f5('0x2f')][_0xe9f5('0x49')](_0x538ace)[_0xe9f5('0x44')](handleEntityNotFound(_0x4b0c80,null))[_0xe9f5('0x44')](respondWithResult(_0x4b0c80,null))['catch'](handleError(_0x4b0c80,null));};exports[_0xe9f5('0x4a')]=function(_0x555b46,_0x353fa4){return db[_0xe9f5('0x2f')][_0xe9f5('0x4a')](_0x555b46[_0xe9f5('0x4b')],{})[_0xe9f5('0x44')](respondWithResult(_0x353fa4,0xc9))[_0xe9f5('0x46')](handleError(_0x353fa4,null));};exports[_0xe9f5('0x29')]=function(_0x3984fd,_0x122f7b){if(_0x3984fd[_0xe9f5('0x4b')]['id']){delete _0x3984fd[_0xe9f5('0x4b')]['id'];}return db[_0xe9f5('0x2f')][_0xe9f5('0x49')]({'where':{'id':_0x3984fd['params']['id']}})[_0xe9f5('0x44')](handleEntityNotFound(_0x122f7b,null))[_0xe9f5('0x44')](saveUpdates(_0x3984fd[_0xe9f5('0x4b')],null))[_0xe9f5('0x44')](respondWithResult(_0x122f7b,null))['catch'](handleError(_0x122f7b,null));};exports[_0xe9f5('0x4c')]=function(_0x95fb65,_0x4d069a){return db[_0xe9f5('0x2f')][_0xe9f5('0x49')]({'where':{'id':_0x95fb65[_0xe9f5('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4d069a,null))['then'](removeEntity(_0x4d069a,null))[_0xe9f5('0x46')](handleError(_0x4d069a,null));};exports[_0xe9f5('0x4e')]=function(_0x5f0700,_0x41c744,_0x37cbbf){var _0x4fb8a9={};var _0x401b78={};var _0x3ac02b;var _0x5dc14d;return db[_0xe9f5('0x2f')][_0xe9f5('0x4f')]({'where':{'id':_0x5f0700['params']['id']}})[_0xe9f5('0x44')](handleEntityNotFound(_0x41c744,null))[_0xe9f5('0x44')](function(_0x32e1ea){if(_0x32e1ea){_0x3ac02b=_0x32e1ea;_0x401b78[_0xe9f5('0x33')]=_['keys'](db['SugarcrmConfiguration'][_0xe9f5('0x30')]);_0x401b78[_0xe9f5('0x34')]=_['keys'](_0x5f0700[_0xe9f5('0x34')]);_0x401b78[_0xe9f5('0x35')]=_[_0xe9f5('0x36')](_0x401b78[_0xe9f5('0x33')],_0x401b78[_0xe9f5('0x34')]);_0x4fb8a9[_0xe9f5('0x37')]=_[_0xe9f5('0x36')](_0x401b78[_0xe9f5('0x33')],qs[_0xe9f5('0x38')](_0x5f0700[_0xe9f5('0x34')]['fields']));_0x4fb8a9['attributes']=_0x4fb8a9['attributes'][_0xe9f5('0x39')]?_0x4fb8a9[_0xe9f5('0x37')]:_0x401b78[_0xe9f5('0x33')];_0x4fb8a9[_0xe9f5('0x3a')]=qs['sort'](_0x5f0700[_0xe9f5('0x34')][_0xe9f5('0x3b')]);_0x4fb8a9[_0xe9f5('0x3e')]=qs[_0xe9f5('0x35')](_[_0xe9f5('0x3c')](_0x5f0700[_0xe9f5('0x34')],_0x401b78['filters']));if(_0x5f0700[_0xe9f5('0x34')][_0xe9f5('0x3d')]){_0x4fb8a9[_0xe9f5('0x3e')]=_[_0xe9f5('0x3f')](_0x4fb8a9['where'],{'$or':_[_0xe9f5('0x2e')](_0x4fb8a9[_0xe9f5('0x37')],function(_0x36ac09){var _0x3ffa85={};_0x3ffa85[_0x36ac09]={'$like':'%'+_0x5f0700[_0xe9f5('0x34')][_0xe9f5('0x3d')]+'%'};return _0x3ffa85;})});}_0x4fb8a9=_[_0xe9f5('0x3f')]({},_0x4fb8a9,_0x5f0700[_0xe9f5('0x40')]);return _0x3ac02b[_0xe9f5('0x4e')](_0x4fb8a9);}})[_0xe9f5('0x44')](function(_0xaccdec){if(_0xaccdec){_0x5dc14d=_0xaccdec['length'];if(!_0x5f0700['query'][_0xe9f5('0x50')]('nolimit')){_0x4fb8a9[_0xe9f5('0x22')]=qs[_0xe9f5('0x22')](_0x5f0700['query']['limit']);_0x4fb8a9[_0xe9f5('0x20')]=qs[_0xe9f5('0x20')](_0x5f0700[_0xe9f5('0x34')][_0xe9f5('0x20')]);}return _0x3ac02b['getConfigurations'](_0x4fb8a9);}})[_0xe9f5('0x44')](function(_0x4d064a){if(_0x4d064a){return _0x4d064a?{'count':_0x5dc14d,'rows':_0x4d064a}:null;}})[_0xe9f5('0x44')](respondWithResult(_0x41c744,null))[_0xe9f5('0x46')](handleError(_0x41c744,null));};exports[_0xe9f5('0x51')]=function(_0x276471,_0x2a7c81,_0x478b97){if(_0x276471[_0xe9f5('0x4b')]['id']){delete _0x276471['body']['id'];}return db[_0xe9f5('0x2f')][_0xe9f5('0x4f')]({'where':{'id':_0x276471['params']['id']}})[_0xe9f5('0x44')](handleEntityNotFound(_0x2a7c81,null))[_0xe9f5('0x44')](function(_0x230582){if(_0x230582){_0x276471[_0xe9f5('0x4b')][_0xe9f5('0x52')]=_0x230582['id'];_0x276471[_0xe9f5('0x4b')][_0xe9f5('0x53')]=integrations[_0xe9f5('0x54')](_0x276471[_0xe9f5('0x4b')][_0xe9f5('0x55')],_0x276471['body'][_0xe9f5('0x32')]);_0x276471[_0xe9f5('0x4b')]['Descriptions']=integrations[_0xe9f5('0x56')](_0x276471[_0xe9f5('0x4b')][_0xe9f5('0x55')],_0x276471[_0xe9f5('0x4b')][_0xe9f5('0x32')]);return db[_0xe9f5('0x57')]['create'](_0x276471[_0xe9f5('0x4b')],{'include':[{'model':db[_0xe9f5('0x58')],'as':_0xe9f5('0x53')},{'model':db[_0xe9f5('0x58')],'as':_0xe9f5('0x59')}]});}return null;})[_0xe9f5('0x44')](respondWithResult(_0x2a7c81,null))[_0xe9f5('0x46')](handleError(_0x2a7c81,null));};exports['getFields']=function(_0x633d3b,_0x5bd631,_0x8feff2){var _0x373372='';var _0x2eb38d=['id',_0xe9f5('0x2b'),_0xe9f5('0x5a'),_0xe9f5('0x5b'),_0xe9f5('0x5c'),_0xe9f5('0x5d'),_0xe9f5('0x5e'),'duration_minutes',_0xe9f5('0x5f'),_0xe9f5('0x60'),_0xe9f5('0x61'),_0xe9f5('0x62')];return db[_0xe9f5('0x2f')][_0xe9f5('0x4f')]({'where':{'id':_0x633d3b[_0xe9f5('0x4d')]['id']},'attributes':['id',_0xe9f5('0x63'),_0xe9f5('0x64'),'remoteUri']})[_0xe9f5('0x44')](handleEntityNotFound(_0x5bd631,null))[_0xe9f5('0x44')](function(_0x437bf9){if(_0x437bf9){_0x373372=_0x437bf9[_0xe9f5('0x65')];var _0x50c881=_0x373372[_0xe9f5('0x66')](-0x1);if(_0x50c881==='/'){_0x373372=_0x373372['substring'](0x0,_0x373372['lastIndexOf'](_0x50c881));}return rp({'method':_0xe9f5('0x67'),'uri':util[_0xe9f5('0x68')]('%s%s',_0x373372,_0xe9f5('0x69')),'json':!![],'form':{'method':_0xe9f5('0x6a'),'input_type':'JSON','response_type':_0xe9f5('0x6b'),'rest_data':JSON[_0xe9f5('0x6c')]({'user_auth':{'user_name':_0x437bf9[_0xe9f5('0x63')],'password':_0x437bf9['password'],'encryption':_0xe9f5('0x6d')},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0xe9f5('0x44')](function(_0x1c50c7){if(_0x1c50c7&&_0x1c50c7[_0xe9f5('0x2b')]!=='Invalid\x20Login'&&_0x1c50c7[_0xe9f5('0x2b')]!==_0xe9f5('0x6e')){return rp({'method':_0xe9f5('0x67'),'uri':util['format'](_0xe9f5('0x6f'),_0x373372,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0xe9f5('0x70'),'input_type':'JSON','response_type':_0xe9f5('0x6b'),'rest_data':JSON[_0xe9f5('0x6c')]({'session':_0x1c50c7['id'],'module_name':_0xe9f5('0x71')})}})[_0xe9f5('0x44')](function(_0x2d23f7){if(_0x2d23f7){var _0x4fd78a=_[_0xe9f5('0x72')](_0x2d23f7[_0xe9f5('0x73')]);_[_0xe9f5('0x74')](_0x4fd78a,function(_0x29656a){return _0x2eb38d[_0xe9f5('0x75')](_0x29656a[_0xe9f5('0x2b')]);});return{'count':_0x4fd78a[_0xe9f5('0x39')],'rows':_['map'](_0x4fd78a,function(_0x2ff7a7){return{'id':_0x2ff7a7[_0xe9f5('0x2b')],'name':_0x2ff7a7[_0xe9f5('0x76')],'custom':_[_0xe9f5('0x77')](_0x2ff7a7[_0xe9f5('0x2b')],'_c')?!![]:![],'options':_0x2ff7a7[_0xe9f5('0x40')]?_['map'](_[_0xe9f5('0x72')](_0x2ff7a7[_0xe9f5('0x40')]),function(_0x132c5f){return{'name':_0x132c5f['value'],'value':_0x132c5f['name']};}):[]};})};}})[_0xe9f5('0x44')](respondWithResult(_0x5bd631,null))[_0xe9f5('0x46')](function(_0x2628c2){var _0x1ec1bf=_0x633d3b['query'][_0xe9f5('0x78')]?0x1f4:_0x2628c2[_0xe9f5('0x79')]||0x1f4;logger[_0xe9f5('0x2a')](_0xe9f5('0x7a'),_0xe9f5('0x7b'),_0x1ec1bf,JSON[_0xe9f5('0x6c')](_0x2628c2));delete _0x2628c2['name'];if(_0x1ec1bf===0x191){_0x1ec1bf=0x190;}_0x5bd631[_0xe9f5('0x1d')](_0x1ec1bf)[_0xe9f5('0x2c')](_0x633d3b[_0xe9f5('0x34')]['test']?{'message':_0xe9f5('0x7c'),'statusCode':_0x2628c2[_0xe9f5('0x79')]}:_0x2628c2);});}else{var _0xcbff43=0x1f4;_0x5bd631['status'](_0xcbff43)[_0xe9f5('0x2c')]({'message':'Wrong\x20credentials','statusCode':0x190});}});};
\ No newline at end of file
+var _0x5ad0=['get_module_fields','stringify','Calls','values','module_fields','remove','includes','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','undefined','count','offset','limit','set','apply','save','then','destroy','error','stack','name','index','map','fieldName','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','pick','filters','filter','merge','type','VIRTUAL','SugarcrmAccount','includeAll','include','findAll','rows','catch','show','params','rawAttributes','options','find','create','body','update','getConfigurations','findOne','order','sort','addConfiguration','AccountId','Subjects','getSubjects','getDescriptions','Descriptions','getFields','assigned_user_id','created_by','description','date_start','duration_hours','duration_minutes','parent_id','parent_name','direction','username','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','login','JSON','password','PLAIN','xCALLY\x20Motion\x20Integration','Invalid\x20Login'];(function(_0x6925fa,_0x4e6100){var _0x56d211=function(_0x59fe6d){while(--_0x59fe6d){_0x6925fa['push'](_0x6925fa['shift']());}};_0x56d211(++_0x4e6100);}(_0x5ad0,0x180));var _0x05ad=function(_0x73cc50,_0xad8fea){_0x73cc50=_0x73cc50-0x0;var _0x56859f=_0x5ad0[_0x73cc50];return _0x56859f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x05ad('0x0'));var zipdir=require(_0x05ad('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x05ad('0x2'));var moment=require(_0x05ad('0x3'));var BPromise=require(_0x05ad('0x4'));var Mustache=require(_0x05ad('0x5'));var util=require(_0x05ad('0x6'));var path=require(_0x05ad('0x7'));var sox=require('sox');var csv=require(_0x05ad('0x8'));var ejs=require(_0x05ad('0x9'));var fs=require('fs');var fs_extra=require(_0x05ad('0xa'));var _=require(_0x05ad('0xb'));var squel=require(_0x05ad('0xc'));var crypto=require(_0x05ad('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x05ad('0xe'));var toCsv=require(_0x05ad('0x8'));var querystring=require(_0x05ad('0xf'));var Papa=require(_0x05ad('0x10'));var Redis=require(_0x05ad('0x11'));var authService=require(_0x05ad('0x12'));var qs=require(_0x05ad('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x05ad('0x14'));var logger=require(_0x05ad('0x15'))(_0x05ad('0x16'));var utils=require(_0x05ad('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x05ad('0x18'));var db=require(_0x05ad('0x19'))['db'];var integrations=require(_0x05ad('0x1a'));function respondWithStatusCode(_0xf53f0d,_0x1d176c){_0x1d176c=_0x1d176c||0xcc;return function(_0x43981b){if(_0x43981b){return _0xf53f0d[_0x05ad('0x1b')](_0x1d176c);}return _0xf53f0d[_0x05ad('0x1c')](_0x1d176c)[_0x05ad('0x1d')]();};}function respondWithResult(_0x1dc69e,_0x1b233f){_0x1b233f=_0x1b233f||0xc8;return function(_0x1b0335){if(_0x1b0335){return _0x1dc69e[_0x05ad('0x1c')](_0x1b233f)[_0x05ad('0x1e')](_0x1b0335);}};}function respondWithFilteredResult(_0x217fb6,_0x4c0fd8){return function(_0x20adfa){if(_0x20adfa){var _0x312493=typeof _0x4c0fd8['offset']===_0x05ad('0x1f')&&typeof _0x4c0fd8['limit']===_0x05ad('0x1f');var _0x46f97c=_0x20adfa[_0x05ad('0x20')];var _0x539203=_0x312493?0x0:_0x4c0fd8[_0x05ad('0x21')];var _0x2d820f=_0x312493?_0x20adfa[_0x05ad('0x20')]:_0x4c0fd8[_0x05ad('0x21')]+_0x4c0fd8[_0x05ad('0x22')];var _0x20d204;if(_0x2d820f>=_0x46f97c){_0x2d820f=_0x46f97c;_0x20d204=0xc8;}else{_0x20d204=0xce;}_0x217fb6[_0x05ad('0x1c')](_0x20d204);return _0x217fb6[_0x05ad('0x23')]('Content-Range',_0x539203+'-'+_0x2d820f+'/'+_0x46f97c)[_0x05ad('0x1e')](_0x20adfa);}return null;};}function patchUpdates(_0x236ab8){return function(_0x550534){try{jsonpatch[_0x05ad('0x24')](_0x550534,_0x236ab8,!![]);}catch(_0x231a2f){return BPromise['reject'](_0x231a2f);}return _0x550534[_0x05ad('0x25')]();};}function saveUpdates(_0x67b7c4,_0xfc86d4){return function(_0x3baf30){if(_0x3baf30){return _0x3baf30['update'](_0x67b7c4)[_0x05ad('0x26')](function(_0x56be3d){return _0x56be3d;});}return null;};}function removeEntity(_0x449b0f,_0x5a4806){return function(_0x4fdbc1){if(_0x4fdbc1){return _0x4fdbc1[_0x05ad('0x27')]()[_0x05ad('0x26')](function(){_0x449b0f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5c5fd1,_0x5ebfd9){return function(_0x97ea61){if(!_0x97ea61){_0x5c5fd1[_0x05ad('0x1b')](0x194);}return _0x97ea61;};}function handleError(_0x52a10a,_0xa76b7){_0xa76b7=_0xa76b7||0x1f4;return function(_0x52fa0a){logger[_0x05ad('0x28')](_0x52fa0a[_0x05ad('0x29')]);if(_0x52fa0a[_0x05ad('0x2a')]){delete _0x52fa0a['name'];}_0x52a10a['status'](_0xa76b7)['send'](_0x52fa0a);};}exports[_0x05ad('0x2b')]=function(_0x22b071,_0x5b653c){var _0x1d769c={},_0x11ee81={},_0x577d01={'count':0x0,'rows':[]};var _0x5b5ff7=_[_0x05ad('0x2c')](db['SugarcrmAccount']['rawAttributes'],function(_0x29b021){return{'name':_0x29b021[_0x05ad('0x2d')],'type':_0x29b021['type'][_0x05ad('0x2e')]};});_0x11ee81[_0x05ad('0x2f')]=_[_0x05ad('0x2c')](_0x5b5ff7,_0x05ad('0x2a'));_0x11ee81[_0x05ad('0x30')]=_[_0x05ad('0x31')](_0x22b071[_0x05ad('0x30')]);_0x11ee81['filters']=_[_0x05ad('0x32')](_0x11ee81['model'],_0x11ee81['query']);_0x1d769c[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x11ee81['model'],qs['fields'](_0x22b071[_0x05ad('0x30')][_0x05ad('0x34')]));_0x1d769c['attributes']=_0x1d769c[_0x05ad('0x33')][_0x05ad('0x35')]?_0x1d769c[_0x05ad('0x33')]:_0x11ee81['model'];if(!_0x22b071[_0x05ad('0x30')][_0x05ad('0x36')](_0x05ad('0x37'))){_0x1d769c[_0x05ad('0x22')]=qs[_0x05ad('0x22')](_0x22b071[_0x05ad('0x30')][_0x05ad('0x22')]);_0x1d769c[_0x05ad('0x21')]=qs['offset'](_0x22b071[_0x05ad('0x30')][_0x05ad('0x21')]);}_0x1d769c['order']=qs['sort'](_0x22b071[_0x05ad('0x30')]['sort']);_0x1d769c[_0x05ad('0x38')]=qs['filters'](_[_0x05ad('0x39')](_0x22b071['query'],_0x11ee81[_0x05ad('0x3a')]),_0x5b5ff7);if(_0x22b071[_0x05ad('0x30')][_0x05ad('0x3b')]){_0x1d769c['where']=_[_0x05ad('0x3c')](_0x1d769c[_0x05ad('0x38')],{'$or':_['map'](_0x5b5ff7,function(_0x19f8c3){if(_0x19f8c3[_0x05ad('0x3d')]!==_0x05ad('0x3e')){var _0x1f1f51={};_0x1f1f51[_0x19f8c3['name']]={'$like':'%'+_0x22b071[_0x05ad('0x30')][_0x05ad('0x3b')]+'%'};return _0x1f1f51;}})});}_0x1d769c=_[_0x05ad('0x3c')]({},_0x1d769c,_0x22b071['options']);var _0x17655f={'where':_0x1d769c[_0x05ad('0x38')]};return db[_0x05ad('0x3f')][_0x05ad('0x20')](_0x17655f)['then'](function(_0x59b5b2){_0x577d01[_0x05ad('0x20')]=_0x59b5b2;if(_0x22b071[_0x05ad('0x30')][_0x05ad('0x40')]){_0x1d769c[_0x05ad('0x41')]=[{'all':!![]}];}return db[_0x05ad('0x3f')][_0x05ad('0x42')](_0x1d769c);})[_0x05ad('0x26')](function(_0x4a41a8){_0x577d01[_0x05ad('0x43')]=_0x4a41a8;return _0x577d01;})[_0x05ad('0x26')](respondWithFilteredResult(_0x5b653c,_0x1d769c))[_0x05ad('0x44')](handleError(_0x5b653c,null));};exports[_0x05ad('0x45')]=function(_0x4d196d,_0x36c199){var _0x4c05d8={'raw':![],'where':{'id':_0x4d196d[_0x05ad('0x46')]['id']}},_0x2f6f2a={};_0x2f6f2a[_0x05ad('0x2f')]=_['keys'](db[_0x05ad('0x3f')][_0x05ad('0x47')]);_0x2f6f2a[_0x05ad('0x30')]=_['keys'](_0x4d196d[_0x05ad('0x30')]);_0x2f6f2a[_0x05ad('0x3a')]=_[_0x05ad('0x32')](_0x2f6f2a[_0x05ad('0x2f')],_0x2f6f2a[_0x05ad('0x30')]);_0x4c05d8[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x2f6f2a[_0x05ad('0x2f')],qs['fields'](_0x4d196d[_0x05ad('0x30')]['fields']));_0x4c05d8['attributes']=_0x4c05d8[_0x05ad('0x33')][_0x05ad('0x35')]?_0x4c05d8['attributes']:_0x2f6f2a['model'];if(_0x4d196d['query']['includeAll']){_0x4c05d8[_0x05ad('0x41')]=[{'all':!![]}];}_0x4c05d8=_[_0x05ad('0x3c')]({},_0x4c05d8,_0x4d196d[_0x05ad('0x48')]);return db[_0x05ad('0x3f')][_0x05ad('0x49')](_0x4c05d8)['then'](handleEntityNotFound(_0x36c199,null))[_0x05ad('0x26')](respondWithResult(_0x36c199,null))[_0x05ad('0x44')](handleError(_0x36c199,null));};exports[_0x05ad('0x4a')]=function(_0x4cdac0,_0x204b27){return db[_0x05ad('0x3f')][_0x05ad('0x4a')](_0x4cdac0[_0x05ad('0x4b')],{})['then'](respondWithResult(_0x204b27,0xc9))[_0x05ad('0x44')](handleError(_0x204b27,null));};exports[_0x05ad('0x4c')]=function(_0x3c6bb6,_0xdd10c2){if(_0x3c6bb6[_0x05ad('0x4b')]['id']){delete _0x3c6bb6[_0x05ad('0x4b')]['id'];}return db['SugarcrmAccount']['find']({'where':{'id':_0x3c6bb6[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0xdd10c2,null))[_0x05ad('0x26')](saveUpdates(_0x3c6bb6[_0x05ad('0x4b')],null))[_0x05ad('0x26')](respondWithResult(_0xdd10c2,null))[_0x05ad('0x44')](handleError(_0xdd10c2,null));};exports[_0x05ad('0x27')]=function(_0x342482,_0x14cb81){return db[_0x05ad('0x3f')][_0x05ad('0x49')]({'where':{'id':_0x342482[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x14cb81,null))['then'](removeEntity(_0x14cb81,null))[_0x05ad('0x44')](handleError(_0x14cb81,null));};exports[_0x05ad('0x4d')]=function(_0x4f924d,_0x35b4de,_0x4b1416){var _0x32044c={};var _0x266768={};var _0x1f7a30;var _0x42d153;return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x4f924d[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x35b4de,null))[_0x05ad('0x26')](function(_0x5a756d){if(_0x5a756d){_0x1f7a30=_0x5a756d;_0x266768['model']=_[_0x05ad('0x31')](db['SugarcrmConfiguration'][_0x05ad('0x47')]);_0x266768[_0x05ad('0x30')]=_[_0x05ad('0x31')](_0x4f924d[_0x05ad('0x30')]);_0x266768['filters']=_[_0x05ad('0x32')](_0x266768['model'],_0x266768['query']);_0x32044c[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x266768[_0x05ad('0x2f')],qs[_0x05ad('0x34')](_0x4f924d[_0x05ad('0x30')][_0x05ad('0x34')]));_0x32044c['attributes']=_0x32044c[_0x05ad('0x33')]['length']?_0x32044c[_0x05ad('0x33')]:_0x266768[_0x05ad('0x2f')];_0x32044c[_0x05ad('0x4f')]=qs[_0x05ad('0x50')](_0x4f924d[_0x05ad('0x30')][_0x05ad('0x50')]);_0x32044c[_0x05ad('0x38')]=qs[_0x05ad('0x3a')](_[_0x05ad('0x39')](_0x4f924d['query'],_0x266768[_0x05ad('0x3a')]));if(_0x4f924d[_0x05ad('0x30')][_0x05ad('0x3b')]){_0x32044c[_0x05ad('0x38')]=_[_0x05ad('0x3c')](_0x32044c[_0x05ad('0x38')],{'$or':_[_0x05ad('0x2c')](_0x32044c[_0x05ad('0x33')],function(_0x5dc4f1){var _0x581688={};_0x581688[_0x5dc4f1]={'$like':'%'+_0x4f924d[_0x05ad('0x30')]['filter']+'%'};return _0x581688;})});}_0x32044c=_[_0x05ad('0x3c')]({},_0x32044c,_0x4f924d[_0x05ad('0x48')]);return _0x1f7a30[_0x05ad('0x4d')](_0x32044c);}})[_0x05ad('0x26')](function(_0x80b2bd){if(_0x80b2bd){_0x42d153=_0x80b2bd[_0x05ad('0x35')];if(!_0x4f924d[_0x05ad('0x30')][_0x05ad('0x36')]('nolimit')){_0x32044c[_0x05ad('0x22')]=qs[_0x05ad('0x22')](_0x4f924d['query'][_0x05ad('0x22')]);_0x32044c['offset']=qs[_0x05ad('0x21')](_0x4f924d['query']['offset']);}return _0x1f7a30[_0x05ad('0x4d')](_0x32044c);}})[_0x05ad('0x26')](function(_0x5838df){if(_0x5838df){return _0x5838df?{'count':_0x42d153,'rows':_0x5838df}:null;}})['then'](respondWithResult(_0x35b4de,null))[_0x05ad('0x44')](handleError(_0x35b4de,null));};exports[_0x05ad('0x51')]=function(_0x5d4928,_0x27da03,_0x4b63e7){if(_0x5d4928['body']['id']){delete _0x5d4928[_0x05ad('0x4b')]['id'];}return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x5d4928['params']['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x27da03,null))[_0x05ad('0x26')](function(_0x33601a){if(_0x33601a){_0x5d4928['body'][_0x05ad('0x52')]=_0x33601a['id'];_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x53')]=integrations[_0x05ad('0x54')](_0x5d4928[_0x05ad('0x4b')]['channel'],_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x3d')]);_0x5d4928[_0x05ad('0x4b')]['Descriptions']=integrations[_0x05ad('0x55')](_0x5d4928[_0x05ad('0x4b')]['channel'],_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x3d')]);return db['SugarcrmConfiguration']['create'](_0x5d4928['body'],{'include':[{'model':db['SugarcrmField'],'as':_0x05ad('0x53')},{'model':db['SugarcrmField'],'as':_0x05ad('0x56')}]});}return null;})[_0x05ad('0x26')](respondWithResult(_0x27da03,null))[_0x05ad('0x44')](handleError(_0x27da03,null));};exports[_0x05ad('0x57')]=function(_0x2a5d42,_0x3ad660,_0x2a1e77){var _0x24d4b5='';var _0xeeedc0=['id',_0x05ad('0x2a'),_0x05ad('0x58'),_0x05ad('0x59'),_0x05ad('0x5a'),_0x05ad('0x5b'),_0x05ad('0x5c'),_0x05ad('0x5d'),_0x05ad('0x5e'),'parent_type',_0x05ad('0x5f'),_0x05ad('0x60')];return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x2a5d42['params']['id']},'attributes':['id',_0x05ad('0x61'),'password','remoteUri']})[_0x05ad('0x26')](handleEntityNotFound(_0x3ad660,null))[_0x05ad('0x26')](function(_0x5a0cb5){if(_0x5a0cb5){_0x24d4b5=_0x5a0cb5[_0x05ad('0x62')];var _0xfa71c9=_0x24d4b5[_0x05ad('0x63')](-0x1);if(_0xfa71c9==='/'){_0x24d4b5=_0x24d4b5[_0x05ad('0x64')](0x0,_0x24d4b5[_0x05ad('0x65')](_0xfa71c9));}return rp({'method':_0x05ad('0x66'),'uri':util[_0x05ad('0x67')](_0x05ad('0x68'),_0x24d4b5,_0x05ad('0x69')),'json':!![],'form':{'method':_0x05ad('0x6a'),'input_type':'JSON','response_type':_0x05ad('0x6b'),'rest_data':JSON['stringify']({'user_auth':{'user_name':_0x5a0cb5['username'],'password':_0x5a0cb5[_0x05ad('0x6c')],'encryption':_0x05ad('0x6d')},'application':_0x05ad('0x6e')})}});}})[_0x05ad('0x26')](function(_0x536895){if(_0x536895&&_0x536895[_0x05ad('0x2a')]!==_0x05ad('0x6f')&&_0x536895['name']!=='Password\x20Expired'){return rp({'method':'POST','uri':util[_0x05ad('0x67')](_0x05ad('0x68'),_0x24d4b5,_0x05ad('0x69')),'json':!![],'form':{'method':_0x05ad('0x70'),'input_type':_0x05ad('0x6b'),'response_type':_0x05ad('0x6b'),'rest_data':JSON[_0x05ad('0x71')]({'session':_0x536895['id'],'module_name':_0x05ad('0x72')})}})[_0x05ad('0x26')](function(_0x2039ba){if(_0x2039ba){var _0x49b089=_[_0x05ad('0x73')](_0x2039ba[_0x05ad('0x74')]);_[_0x05ad('0x75')](_0x49b089,function(_0x471a6f){return _0xeeedc0[_0x05ad('0x76')](_0x471a6f[_0x05ad('0x2a')]);});return{'count':_0x49b089[_0x05ad('0x35')],'rows':_[_0x05ad('0x2c')](_0x49b089,function(_0x174f68){return{'id':_0x174f68['name'],'name':_0x174f68[_0x05ad('0x77')],'custom':_['endsWith'](_0x174f68[_0x05ad('0x2a')],'_c')?!![]:![],'options':_0x174f68[_0x05ad('0x48')]?_[_0x05ad('0x2c')](_[_0x05ad('0x73')](_0x174f68[_0x05ad('0x48')]),function(_0x4e2994){return{'name':_0x4e2994['value'],'value':_0x4e2994[_0x05ad('0x2a')]};}):[]};})};}})[_0x05ad('0x26')](respondWithResult(_0x3ad660,null))[_0x05ad('0x44')](function(_0x2d32aa){var _0xa45d80=_0x2a5d42[_0x05ad('0x30')]['test']?0x1f4:_0x2d32aa[_0x05ad('0x78')]||0x1f4;logger['error'](_0x05ad('0x79'),_0x05ad('0x57'),_0xa45d80,JSON[_0x05ad('0x71')](_0x2d32aa));delete _0x2d32aa[_0x05ad('0x2a')];if(_0xa45d80===0x191){_0xa45d80=0x190;}_0x3ad660[_0x05ad('0x1c')](_0xa45d80)[_0x05ad('0x7a')](_0x2a5d42['query']['test']?{'message':'Wrong\x20credentials','statusCode':_0x2d32aa[_0x05ad('0x78')]}:_0x2d32aa);});}else{var _0xb1f42d=0x1f4;_0x3ad660[_0x05ad('0x1c')](_0xb1f42d)[_0x05ad('0x7a')]({'message':_0x05ad('0x7b'),'statusCode':0x190});}});};
\ No newline at end of file