Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index bbea4fa..ddf930a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfd09=['end','json','count','offset','set','Content-Range','save','update','destroy','sendStatus','stack','name','send','index','SugarcrmAccount','fieldName','key','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','limit','sort','where','pick','merge','type','VIRTUAL','filter','options','include','rows','show','includeAll','find','create','body','getConfigurations','findOne','params','SugarcrmConfiguration','rawAttributes','order','nolimit','AccountId','Subjects','getSubjects','channel','getDescriptions','SugarcrmField','Descriptions','getFields','assigned_user_id','created_by','description','date_start','duration_minutes','parent_type','parent_name','direction','password','remoteUri','substring','format','%s%s','login','JSON','PLAIN','Invalid\x20Login','POST','/service/v4_1/rest.php','Calls','module_fields','includes','label','values','value','statusCode','Wrong\x20credentials','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','http','test','then','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','status'];(function(_0xfd5f37,_0x24a79c){var _0x11bd01=function(_0x4ae9bd){while(--_0x4ae9bd){_0xfd5f37['push'](_0xfd5f37['shift']());}};_0x11bd01(++_0x24a79c);}(_0xfd09,0x1cc));var _0x9fd0=function(_0x4f74a5,_0x1fd979){_0x4f74a5=_0x4f74a5-0x0;var _0x5be8b2=_0xfd09[_0x4f74a5];return _0x5be8b2;};'use strict';var pdf=require(_0x9fd0('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x9fd0('0x1'));var zipdir=require(_0x9fd0('0x2'));var jsonpatch=require(_0x9fd0('0x3'));var rp=require('request-promise');var moment=require(_0x9fd0('0x4'));var BPromise=require(_0x9fd0('0x5'));var Mustache=require('mustache');var util=require(_0x9fd0('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0x9fd0('0x7'));var ejs=require(_0x9fd0('0x8'));var fs=require('fs');var _=require(_0x9fd0('0x9'));var squel=require(_0x9fd0('0xa'));var crypto=require(_0x9fd0('0xb'));var jsforce=require(_0x9fd0('0xc'));var deskjs=require(_0x9fd0('0xd'));var toCsv=require(_0x9fd0('0x7'));var querystring=require(_0x9fd0('0xe'));var Papa=require(_0x9fd0('0xf'));var Redis=require(_0x9fd0('0x10'));var authService=require(_0x9fd0('0x11'));var qs=require(_0x9fd0('0x12'));var as=require(_0x9fd0('0x13'));var hardwareService=require(_0x9fd0('0x14'));var logger=require('../../config/logger')(_0x9fd0('0x15'));var utils=require(_0x9fd0('0x16'));var config=require(_0x9fd0('0x17'));var db=require(_0x9fd0('0x18'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0x9fd0('0x19'));var client=jayson['client'][_0x9fd0('0x1a')]({'port':0x232a});function checkPasswordPattern(_0x160e16,_0x1bad05,_0x11190b){if(_0x11190b){var _0x1154c8=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1154c8[_0x9fd0('0x1b')](_0x1bad05)){return _0x160e16;}else{throw new db['Sequelize']['ValidationError']('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x160e16;}}function respondWithRpcPromise(_0x5d7611,_0x1565b2,_0x2eb189,_0x3350a2){return new BPromise(function(_0x31625a,_0x319f84){var _0x2e7a61=_0x3350a2||client;return _0x2e7a61['request'](_0x5d7611,_0x2eb189)[_0x9fd0('0x1c')](function(_0x4727b2){logger['info'](_0x9fd0('0x1d'),_0x1565b2,_0x9fd0('0x1e'));logger[_0x9fd0('0x1f')](_0x9fd0('0x20'),_0x1565b2,_0x9fd0('0x1e'),JSON[_0x9fd0('0x21')](_0x4727b2));if(_0x4727b2[_0x9fd0('0x22')]){if(_0x4727b2[_0x9fd0('0x22')][_0x9fd0('0x23')]===0x1f4){logger[_0x9fd0('0x22')](_0x9fd0('0x1d'),_0x1565b2,_0x4727b2[_0x9fd0('0x22')][_0x9fd0('0x24')]);return _0x319f84(_0x4727b2['error'][_0x9fd0('0x24')]);}logger[_0x9fd0('0x22')](_0x9fd0('0x1d'),_0x1565b2,_0x4727b2[_0x9fd0('0x22')]['message']);return _0x31625a(_0x4727b2['error']['message']);}else{logger['info'](_0x9fd0('0x1d'),_0x1565b2,'request\x20sent');_0x31625a(_0x4727b2[_0x9fd0('0x25')][_0x9fd0('0x24')]);}})[_0x9fd0('0x26')](function(_0x351ea7){logger[_0x9fd0('0x22')](_0x9fd0('0x1d'),_0x1565b2,_0x351ea7);_0x319f84(_0x351ea7);});});}function respondWithStatusCode(_0x517d88,_0x196273){_0x196273=_0x196273||0xcc;return function(_0x4ecd53){if(_0x4ecd53){return _0x517d88['sendStatus'](_0x196273);}return _0x517d88[_0x9fd0('0x27')](_0x196273)[_0x9fd0('0x28')]();};}function respondWithResult(_0x1cc09c,_0x811b63){_0x811b63=_0x811b63||0xc8;return function(_0x534529){if(_0x534529){return _0x1cc09c['status'](_0x811b63)[_0x9fd0('0x29')](_0x534529);}};}function respondWithFilteredResult(_0x495d2f,_0x4908b5){return function(_0x513b86){if(_0x513b86){var _0x8d9caa=_0x513b86[_0x9fd0('0x2a')],_0x2cd741=_0x4908b5[_0x9fd0('0x2b')],_0x437197=_0x4908b5[_0x9fd0('0x2b')]+_0x4908b5['limit'],_0x47aac5;if(_0x437197>=_0x8d9caa){_0x437197=_0x8d9caa;_0x47aac5=0xc8;}else{_0x47aac5=0xce;}_0x495d2f[_0x9fd0('0x27')](_0x47aac5);return _0x495d2f[_0x9fd0('0x2c')](_0x9fd0('0x2d'),_0x2cd741+'-'+_0x437197+'/'+_0x8d9caa)[_0x9fd0('0x29')](_0x513b86);}return null;};}function patchUpdates(_0x4fbb61){return function(_0x49e1dc){try{jsonpatch['apply'](_0x49e1dc,_0x4fbb61,!![]);}catch(_0x48a164){return BPromise['reject'](_0x48a164);}return _0x49e1dc[_0x9fd0('0x2e')]();};}function saveUpdates(_0x88f9fb,_0x209d4a){return function(_0x1e81a1){if(_0x1e81a1){return _0x1e81a1[_0x9fd0('0x2f')](_0x88f9fb)[_0x9fd0('0x1c')](function(_0x14b4db){return _0x14b4db;});}return null;};}function removeEntity(_0x233e29,_0x2acc9d){return function(_0x5741fd){if(_0x5741fd){return _0x5741fd[_0x9fd0('0x30')]()[_0x9fd0('0x1c')](function(){_0x233e29[_0x9fd0('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4379e3,_0x3149b7){return function(_0x19b652){if(!_0x19b652){_0x4379e3[_0x9fd0('0x31')](0x194);}return _0x19b652;};}function handleError(_0x382087,_0x3e5d76){_0x3e5d76=_0x3e5d76||0x1f4;return function(_0x5273a9){logger[_0x9fd0('0x22')](_0x5273a9[_0x9fd0('0x32')]);if(_0x5273a9[_0x9fd0('0x33')]){delete _0x5273a9['name'];}_0x382087[_0x9fd0('0x27')](_0x3e5d76)[_0x9fd0('0x34')](_0x5273a9);};}exports[_0x9fd0('0x35')]=function(_0x24c088,_0x1ad9d4){var _0x1d9a6d={},_0x1b736e={},_0xb84062={'count':0x0,'rows':[]};var _0x11dc5c=_['map'](db[_0x9fd0('0x36')]['rawAttributes'],function(_0x48245c){return{'name':_0x48245c[_0x9fd0('0x37')],'type':_0x48245c['type'][_0x9fd0('0x38')]};});_0x1b736e['model']=_[_0x9fd0('0x39')](_0x11dc5c,_0x9fd0('0x33'));_0x1b736e[_0x9fd0('0x3a')]=_[_0x9fd0('0x3b')](_0x24c088[_0x9fd0('0x3a')]);_0x1b736e[_0x9fd0('0x3c')]=_[_0x9fd0('0x3d')](_0x1b736e[_0x9fd0('0x3e')],_0x1b736e[_0x9fd0('0x3a')]);_0x1d9a6d['attributes']=_[_0x9fd0('0x3d')](_0x1b736e['model'],qs['fields'](_0x24c088[_0x9fd0('0x3a')][_0x9fd0('0x3f')]));_0x1d9a6d[_0x9fd0('0x40')]=_0x1d9a6d[_0x9fd0('0x40')][_0x9fd0('0x41')]?_0x1d9a6d[_0x9fd0('0x40')]:_0x1b736e[_0x9fd0('0x3e')];if(!_0x24c088[_0x9fd0('0x3a')][_0x9fd0('0x42')]('nolimit')){_0x1d9a6d[_0x9fd0('0x43')]=qs['limit'](_0x24c088[_0x9fd0('0x3a')][_0x9fd0('0x43')]);_0x1d9a6d[_0x9fd0('0x2b')]=qs['offset'](_0x24c088['query'][_0x9fd0('0x2b')]);}_0x1d9a6d['order']=qs[_0x9fd0('0x44')](_0x24c088[_0x9fd0('0x3a')][_0x9fd0('0x44')]);_0x1d9a6d[_0x9fd0('0x45')]=qs[_0x9fd0('0x3c')](_[_0x9fd0('0x46')](_0x24c088[_0x9fd0('0x3a')],_0x1b736e[_0x9fd0('0x3c')]));if(_0x24c088['query']['filter']){_0x1d9a6d['where']=_[_0x9fd0('0x47')](_0x1d9a6d[_0x9fd0('0x45')],{'$or':_[_0x9fd0('0x39')](_0x11dc5c,function(_0x4fc1d0){if(_0x4fc1d0[_0x9fd0('0x48')]!==_0x9fd0('0x49')){var _0x2079f7={};_0x2079f7[_0x4fc1d0[_0x9fd0('0x33')]]={'$like':'%'+_0x24c088['query'][_0x9fd0('0x4a')]+'%'};return _0x2079f7;}})});}_0x1d9a6d=_[_0x9fd0('0x47')]({},_0x1d9a6d,_0x24c088[_0x9fd0('0x4b')]);var _0x2c71a6={'where':_0x1d9a6d['where']};return db[_0x9fd0('0x36')][_0x9fd0('0x2a')](_0x2c71a6)[_0x9fd0('0x1c')](function(_0x12c13a){_0xb84062[_0x9fd0('0x2a')]=_0x12c13a;if(_0x24c088[_0x9fd0('0x3a')]['includeAll']){_0x1d9a6d[_0x9fd0('0x4c')]=[{'all':!![]}];}return db[_0x9fd0('0x36')]['findAll'](_0x1d9a6d);})[_0x9fd0('0x1c')](function(_0x3eba71){_0xb84062[_0x9fd0('0x4d')]=_0x3eba71;return _0xb84062;})[_0x9fd0('0x1c')](respondWithFilteredResult(_0x1ad9d4,_0x1d9a6d))['catch'](handleError(_0x1ad9d4,null));};exports[_0x9fd0('0x4e')]=function(_0x9c58d4,_0x3a0c3b){var _0x450a46={'raw':![],'where':{'id':_0x9c58d4['params']['id']}},_0x3971a5={};_0x3971a5[_0x9fd0('0x3e')]=_['keys'](db[_0x9fd0('0x36')]['rawAttributes']);_0x3971a5[_0x9fd0('0x3a')]=_[_0x9fd0('0x3b')](_0x9c58d4['query']);_0x3971a5[_0x9fd0('0x3c')]=_[_0x9fd0('0x3d')](_0x3971a5[_0x9fd0('0x3e')],_0x3971a5[_0x9fd0('0x3a')]);_0x450a46[_0x9fd0('0x40')]=_[_0x9fd0('0x3d')](_0x3971a5[_0x9fd0('0x3e')],qs[_0x9fd0('0x3f')](_0x9c58d4[_0x9fd0('0x3a')][_0x9fd0('0x3f')]));_0x450a46['attributes']=_0x450a46[_0x9fd0('0x40')][_0x9fd0('0x41')]?_0x450a46[_0x9fd0('0x40')]:_0x3971a5[_0x9fd0('0x3e')];if(_0x9c58d4[_0x9fd0('0x3a')][_0x9fd0('0x4f')]){_0x450a46[_0x9fd0('0x4c')]=[{'all':!![]}];}_0x450a46=_[_0x9fd0('0x47')]({},_0x450a46,_0x9c58d4[_0x9fd0('0x4b')]);return db[_0x9fd0('0x36')][_0x9fd0('0x50')](_0x450a46)[_0x9fd0('0x1c')](handleEntityNotFound(_0x3a0c3b,null))[_0x9fd0('0x1c')](respondWithResult(_0x3a0c3b,null))[_0x9fd0('0x26')](handleError(_0x3a0c3b,null));};exports[_0x9fd0('0x51')]=function(_0x4da696,_0x217493){return db[_0x9fd0('0x36')]['create'](_0x4da696[_0x9fd0('0x52')],{})['then'](respondWithResult(_0x217493,0xc9))[_0x9fd0('0x26')](handleError(_0x217493,null));};exports[_0x9fd0('0x2f')]=function(_0x55a28d,_0x536e9b){if(_0x55a28d[_0x9fd0('0x52')]['id']){delete _0x55a28d[_0x9fd0('0x52')]['id'];}return db[_0x9fd0('0x36')][_0x9fd0('0x50')]({'where':{'id':_0x55a28d['params']['id']}})[_0x9fd0('0x1c')](handleEntityNotFound(_0x536e9b,null))[_0x9fd0('0x1c')](saveUpdates(_0x55a28d[_0x9fd0('0x52')],null))['then'](respondWithResult(_0x536e9b,null))['catch'](handleError(_0x536e9b,null));};exports[_0x9fd0('0x30')]=function(_0xb4c5a6,_0xf8ce0a){return db[_0x9fd0('0x36')][_0x9fd0('0x50')]({'where':{'id':_0xb4c5a6['params']['id']}})['then'](handleEntityNotFound(_0xf8ce0a,null))[_0x9fd0('0x1c')](removeEntity(_0xf8ce0a,null))[_0x9fd0('0x26')](handleError(_0xf8ce0a,null));};exports[_0x9fd0('0x53')]=function(_0x36344f,_0xa453ee,_0x2d3518){var _0x447ac2={};var _0x49b6d4={};var _0x2e70d3;var _0x20e92b;return db[_0x9fd0('0x36')][_0x9fd0('0x54')]({'where':{'id':_0x36344f[_0x9fd0('0x55')]['id']}})[_0x9fd0('0x1c')](handleEntityNotFound(_0xa453ee,null))[_0x9fd0('0x1c')](function(_0x2765ed){if(_0x2765ed){_0x2e70d3=_0x2765ed;_0x49b6d4[_0x9fd0('0x3e')]=_[_0x9fd0('0x3b')](db[_0x9fd0('0x56')][_0x9fd0('0x57')]);_0x49b6d4['query']=_['keys'](_0x36344f[_0x9fd0('0x3a')]);_0x49b6d4[_0x9fd0('0x3c')]=_[_0x9fd0('0x3d')](_0x49b6d4[_0x9fd0('0x3e')],_0x49b6d4[_0x9fd0('0x3a')]);_0x447ac2[_0x9fd0('0x40')]=_[_0x9fd0('0x3d')](_0x49b6d4[_0x9fd0('0x3e')],qs[_0x9fd0('0x3f')](_0x36344f[_0x9fd0('0x3a')][_0x9fd0('0x3f')]));_0x447ac2['attributes']=_0x447ac2[_0x9fd0('0x40')]['length']?_0x447ac2['attributes']:_0x49b6d4[_0x9fd0('0x3e')];_0x447ac2[_0x9fd0('0x58')]=qs[_0x9fd0('0x44')](_0x36344f['query'][_0x9fd0('0x44')]);_0x447ac2[_0x9fd0('0x45')]=qs[_0x9fd0('0x3c')](_[_0x9fd0('0x46')](_0x36344f[_0x9fd0('0x3a')],_0x49b6d4['filters']));if(_0x36344f['query'][_0x9fd0('0x4a')]){_0x447ac2[_0x9fd0('0x45')]=_['merge'](_0x447ac2['where'],{'$or':_[_0x9fd0('0x39')](_0x447ac2[_0x9fd0('0x40')],function(_0x58b93a){var _0x17b018={};_0x17b018[_0x58b93a]={'$like':'%'+_0x36344f[_0x9fd0('0x3a')][_0x9fd0('0x4a')]+'%'};return _0x17b018;})});}_0x447ac2=_['merge']({},_0x447ac2,_0x36344f[_0x9fd0('0x4b')]);return _0x2e70d3[_0x9fd0('0x53')](_0x447ac2);}})[_0x9fd0('0x1c')](function(_0x348324){if(_0x348324){_0x20e92b=_0x348324[_0x9fd0('0x41')];if(!_0x36344f[_0x9fd0('0x3a')][_0x9fd0('0x42')](_0x9fd0('0x59'))){_0x447ac2[_0x9fd0('0x43')]=qs[_0x9fd0('0x43')](_0x36344f[_0x9fd0('0x3a')][_0x9fd0('0x43')]);_0x447ac2['offset']=qs[_0x9fd0('0x2b')](_0x36344f[_0x9fd0('0x3a')][_0x9fd0('0x2b')]);}return _0x2e70d3[_0x9fd0('0x53')](_0x447ac2);}})[_0x9fd0('0x1c')](function(_0xf0cbdd){if(_0xf0cbdd){return _0xf0cbdd?{'count':_0x20e92b,'rows':_0xf0cbdd}:null;}})[_0x9fd0('0x1c')](respondWithResult(_0xa453ee,null))[_0x9fd0('0x26')](handleError(_0xa453ee,null));};exports['addConfiguration']=function(_0x5b3612,_0x3e912e,_0x958578){if(_0x5b3612[_0x9fd0('0x52')]['id']){delete _0x5b3612[_0x9fd0('0x52')]['id'];}return db[_0x9fd0('0x36')][_0x9fd0('0x54')]({'where':{'id':_0x5b3612['params']['id']}})[_0x9fd0('0x1c')](handleEntityNotFound(_0x3e912e,null))[_0x9fd0('0x1c')](function(_0x26b7a1){if(_0x26b7a1){_0x5b3612[_0x9fd0('0x52')][_0x9fd0('0x5a')]=_0x26b7a1['id'];_0x5b3612[_0x9fd0('0x52')][_0x9fd0('0x5b')]=integrations[_0x9fd0('0x5c')](_0x5b3612[_0x9fd0('0x52')][_0x9fd0('0x5d')],_0x5b3612[_0x9fd0('0x52')]['type']);_0x5b3612['body']['Descriptions']=integrations[_0x9fd0('0x5e')](_0x5b3612[_0x9fd0('0x52')][_0x9fd0('0x5d')],_0x5b3612[_0x9fd0('0x52')]['type']);return db[_0x9fd0('0x56')][_0x9fd0('0x51')](_0x5b3612[_0x9fd0('0x52')],{'include':[{'model':db[_0x9fd0('0x5f')],'as':_0x9fd0('0x5b')},{'model':db[_0x9fd0('0x5f')],'as':_0x9fd0('0x60')}]});}return null;})['then'](respondWithResult(_0x3e912e,null))[_0x9fd0('0x26')](handleError(_0x3e912e,null));};exports[_0x9fd0('0x61')]=function(_0x409f34,_0x2d78fd,_0x24ffe2){var _0x418504='';var _0x395ad7=['id',_0x9fd0('0x33'),_0x9fd0('0x62'),_0x9fd0('0x63'),_0x9fd0('0x64'),_0x9fd0('0x65'),'duration_hours',_0x9fd0('0x66'),'parent_id',_0x9fd0('0x67'),_0x9fd0('0x68'),_0x9fd0('0x69')];return db[_0x9fd0('0x36')]['findOne']({'where':{'id':_0x409f34[_0x9fd0('0x55')]['id']},'attributes':['id','username',_0x9fd0('0x6a'),_0x9fd0('0x6b')]})['then'](handleEntityNotFound(_0x2d78fd,null))[_0x9fd0('0x1c')](function(_0x438aff){if(_0x438aff){_0x418504=_0x438aff[_0x9fd0('0x6b')];var _0x17e103=_0x418504['slice'](-0x1);if(_0x17e103==='/'){_0x418504=_0x418504[_0x9fd0('0x6c')](0x0,_0x418504['lastIndexOf'](_0x17e103));}return rp({'method':'POST','uri':util[_0x9fd0('0x6d')](_0x9fd0('0x6e'),_0x418504,'/service/v4_1/rest.php'),'json':!![],'form':{'method':_0x9fd0('0x6f'),'input_type':_0x9fd0('0x70'),'response_type':_0x9fd0('0x70'),'rest_data':JSON[_0x9fd0('0x21')]({'user_auth':{'user_name':_0x438aff['username'],'password':_0x438aff[_0x9fd0('0x6a')],'encryption':_0x9fd0('0x71')},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0x9fd0('0x1c')](function(_0x3c0f1c){if(_0x3c0f1c&&_0x3c0f1c[_0x9fd0('0x33')]!==_0x9fd0('0x72')&&_0x3c0f1c[_0x9fd0('0x33')]!=='Password\x20Expired'){return rp({'method':_0x9fd0('0x73'),'uri':util['format']('%s%s',_0x418504,_0x9fd0('0x74')),'json':!![],'form':{'method':'get_module_fields','input_type':'JSON','response_type':_0x9fd0('0x70'),'rest_data':JSON[_0x9fd0('0x21')]({'session':_0x3c0f1c['id'],'module_name':_0x9fd0('0x75')})}})[_0x9fd0('0x1c')](function(_0x23fe4c){if(_0x23fe4c){var _0x4376af=_['values'](_0x23fe4c[_0x9fd0('0x76')]);_['remove'](_0x4376af,function(_0x4e0fd2){return _0x395ad7[_0x9fd0('0x77')](_0x4e0fd2[_0x9fd0('0x33')]);});return{'count':_0x4376af['length'],'rows':_[_0x9fd0('0x39')](_0x4376af,function(_0x5e4751){return{'id':_0x5e4751[_0x9fd0('0x33')],'name':_0x5e4751[_0x9fd0('0x78')],'custom':_['endsWith'](_0x5e4751[_0x9fd0('0x33')],'_c')?!![]:![],'options':_0x5e4751['options']?_['map'](_[_0x9fd0('0x79')](_0x5e4751['options']),function(_0x883ff9){return{'name':_0x883ff9[_0x9fd0('0x7a')],'value':_0x883ff9[_0x9fd0('0x33')]};}):[]};})};}})[_0x9fd0('0x1c')](respondWithResult(_0x2d78fd,null))[_0x9fd0('0x26')](function(_0x1dff40){var _0x2aab52=_0x409f34[_0x9fd0('0x3a')][_0x9fd0('0x1b')]?0x1f4:_0x1dff40[_0x9fd0('0x7b')]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0x9fd0('0x61'),_0x2aab52,JSON['stringify'](_0x1dff40));delete _0x1dff40[_0x9fd0('0x33')];if(_0x2aab52===0x191){_0x2aab52=0x190;}_0x2d78fd[_0x9fd0('0x27')](_0x2aab52)['send'](_0x409f34[_0x9fd0('0x3a')][_0x9fd0('0x1b')]?{'message':_0x9fd0('0x7c'),'statusCode':_0x1dff40[_0x9fd0('0x7b')]}:_0x1dff40);});}else{var _0x490a6b=0x1f4;_0x2d78fd[_0x9fd0('0x27')](_0x490a6b)['send']({'message':_0x9fd0('0x7c'),'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