Built motion from commit (unavailable).|2.5.29
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index fa71030..7cc2cca 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8a10=['SugarcrmAccount,\x20%s,\x20%s','message','info','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','index','map','SugarcrmAccount','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','show','keys','find','create','body','params','findOne','pick','getConfigurations','addConfiguration','Subjects','getSubjects','channel','SugarcrmConfiguration','SugarcrmField','Descriptions','assigned_user_id','created_by','description','date_start','duration_minutes','parent_id','parent_type','parent_name','direction','username','password','remoteUri','substring','lastIndexOf','POST','format','%s%s','JSON','PLAIN','/service/v4_1/rest.php','get_module_fields','Calls','values','module_fields','includes','label','endsWith','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','send','test','Wrong\x20credentials','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/environment','../../config/license/util','../../components/integrations/configuration','jayson/promise','client','http','request','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x2c624c,_0x515217){var _0x40edac=function(_0x3bea90){while(--_0x3bea90){_0x2c624c['push'](_0x2c624c['shift']());}};_0x40edac(++_0x515217);}(_0x8a10,0x1e2));var _0x08a1=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x8a10[_0x20a584];return _0x4b41a8;};'use strict';var pdf=require(_0x08a1('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x08a1('0x1'));var zipdir=require(_0x08a1('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x08a1('0x3'));var moment=require(_0x08a1('0x4'));var BPromise=require(_0x08a1('0x5'));var Mustache=require(_0x08a1('0x6'));var util=require(_0x08a1('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x08a1('0x8'));var squel=require(_0x08a1('0x9'));var crypto=require(_0x08a1('0xa'));var jsforce=require(_0x08a1('0xb'));var deskjs=require(_0x08a1('0xc'));var toCsv=require(_0x08a1('0xd'));var querystring=require(_0x08a1('0xe'));var Papa=require(_0x08a1('0xf'));var Redis=require(_0x08a1('0x10'));var authService=require(_0x08a1('0x11'));var qs=require(_0x08a1('0x12'));var as=require(_0x08a1('0x13'));var hardwareService=require(_0x08a1('0x14'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x08a1('0x15'));var licenseUtil=require(_0x08a1('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0x08a1('0x17'));var jayson=require(_0x08a1('0x18'));var client=jayson[_0x08a1('0x19')][_0x08a1('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x4cdff9,_0x5de9ff,_0x62372f,_0x1985fe){return new BPromise(function(_0x51a2cf,_0xd5cf92){var _0x2b3ee5=_0x1985fe||client;return _0x2b3ee5[_0x08a1('0x1b')](_0x4cdff9,_0x62372f)['then'](function(_0xfdcf85){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x5de9ff,_0x08a1('0x1c'));logger[_0x08a1('0x1d')](_0x08a1('0x1e'),_0x5de9ff,_0x08a1('0x1c'),JSON[_0x08a1('0x1f')](_0xfdcf85));if(_0xfdcf85[_0x08a1('0x20')]){if(_0xfdcf85[_0x08a1('0x20')][_0x08a1('0x21')]===0x1f4){logger[_0x08a1('0x20')](_0x08a1('0x22'),_0x5de9ff,_0xfdcf85[_0x08a1('0x20')][_0x08a1('0x23')]);return _0xd5cf92(_0xfdcf85[_0x08a1('0x20')][_0x08a1('0x23')]);}logger[_0x08a1('0x20')]('SugarcrmAccount,\x20%s,\x20%s',_0x5de9ff,_0xfdcf85['error'][_0x08a1('0x23')]);return _0x51a2cf(_0xfdcf85[_0x08a1('0x20')][_0x08a1('0x23')]);}else{logger[_0x08a1('0x24')](_0x08a1('0x22'),_0x5de9ff,_0x08a1('0x1c'));_0x51a2cf(_0xfdcf85['result'][_0x08a1('0x23')]);}})[_0x08a1('0x25')](function(_0x17b4a3){logger['error'](_0x08a1('0x22'),_0x5de9ff,_0x17b4a3);_0xd5cf92(_0x17b4a3);});});}function respondWithStatusCode(_0x3ed979,_0x15c5a9){_0x15c5a9=_0x15c5a9||0xcc;return function(_0x34d407){if(_0x34d407){return _0x3ed979[_0x08a1('0x26')](_0x15c5a9);}return _0x3ed979[_0x08a1('0x27')](_0x15c5a9)['end']();};}function respondWithResult(_0x5ef8ef,_0x520cd7){_0x520cd7=_0x520cd7||0xc8;return function(_0x5366e8){if(_0x5366e8){return _0x5ef8ef[_0x08a1('0x27')](_0x520cd7)[_0x08a1('0x28')](_0x5366e8);}};}function respondWithFilteredResult(_0x351bb8,_0x352b30){return function(_0x303abc){if(_0x303abc){var _0x3c7bba=_0x303abc[_0x08a1('0x29')],_0x37ff52=_0x352b30[_0x08a1('0x2a')],_0x57d34d=_0x352b30[_0x08a1('0x2a')]+_0x352b30[_0x08a1('0x2b')],_0x2875eb;if(_0x57d34d>=_0x3c7bba){_0x57d34d=_0x3c7bba;_0x2875eb=0xc8;}else{_0x2875eb=0xce;}_0x351bb8[_0x08a1('0x27')](_0x2875eb);return _0x351bb8[_0x08a1('0x2c')](_0x08a1('0x2d'),_0x37ff52+'-'+_0x57d34d+'/'+_0x3c7bba)['json'](_0x303abc);}return null;};}function patchUpdates(_0x2a5ea6){return function(_0x5363ac){try{jsonpatch[_0x08a1('0x2e')](_0x5363ac,_0x2a5ea6,!![]);}catch(_0x5ca419){return BPromise[_0x08a1('0x2f')](_0x5ca419);}return _0x5363ac[_0x08a1('0x30')]();};}function saveUpdates(_0x58e5cf,_0x218027){return function(_0x328c4c){if(_0x328c4c){return _0x328c4c[_0x08a1('0x31')](_0x58e5cf)[_0x08a1('0x32')](function(_0x3b18c3){return _0x3b18c3;});}return null;};}function removeEntity(_0x34227d,_0x1a5357){return function(_0x1776ac){if(_0x1776ac){return _0x1776ac[_0x08a1('0x33')]()[_0x08a1('0x32')](function(){_0x34227d[_0x08a1('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x53c871,_0x3230fb){return function(_0x4b522c){if(!_0x4b522c){_0x53c871[_0x08a1('0x26')](0x194);}return _0x4b522c;};}function handleError(_0x42f463,_0x29ccb1){_0x29ccb1=_0x29ccb1||0x1f4;return function(_0x509cd5){logger[_0x08a1('0x20')](_0x509cd5[_0x08a1('0x34')]);if(_0x509cd5[_0x08a1('0x35')]){delete _0x509cd5[_0x08a1('0x35')];}_0x42f463['status'](_0x29ccb1)['send'](_0x509cd5);};}exports[_0x08a1('0x36')]=function(_0x1d93c2,_0x1f2935){var _0x168070={},_0x12109a={},_0x269083={'count':0x0,'rows':[]};var _0x5184ca=_[_0x08a1('0x37')](db[_0x08a1('0x38')][_0x08a1('0x39')],function(_0x150735){return{'name':_0x150735[_0x08a1('0x3a')],'type':_0x150735[_0x08a1('0x3b')][_0x08a1('0x3c')]};});_0x12109a[_0x08a1('0x3d')]=_['map'](_0x5184ca,_0x08a1('0x35'));_0x12109a[_0x08a1('0x3e')]=_['keys'](_0x1d93c2[_0x08a1('0x3e')]);_0x12109a[_0x08a1('0x3f')]=_[_0x08a1('0x40')](_0x12109a[_0x08a1('0x3d')],_0x12109a['query']);_0x168070[_0x08a1('0x41')]=_[_0x08a1('0x40')](_0x12109a[_0x08a1('0x3d')],qs[_0x08a1('0x42')](_0x1d93c2[_0x08a1('0x3e')]['fields']));_0x168070[_0x08a1('0x41')]=_0x168070[_0x08a1('0x41')][_0x08a1('0x43')]?_0x168070[_0x08a1('0x41')]:_0x12109a[_0x08a1('0x3d')];if(!_0x1d93c2[_0x08a1('0x3e')][_0x08a1('0x44')](_0x08a1('0x45'))){_0x168070['limit']=qs[_0x08a1('0x2b')](_0x1d93c2[_0x08a1('0x3e')]['limit']);_0x168070[_0x08a1('0x2a')]=qs['offset'](_0x1d93c2[_0x08a1('0x3e')]['offset']);}_0x168070[_0x08a1('0x46')]=qs[_0x08a1('0x47')](_0x1d93c2[_0x08a1('0x3e')][_0x08a1('0x47')]);_0x168070['where']=qs['filters'](_['pick'](_0x1d93c2['query'],_0x12109a[_0x08a1('0x3f')]),_0x5184ca);if(_0x1d93c2['query'][_0x08a1('0x48')]){_0x168070[_0x08a1('0x49')]=_[_0x08a1('0x4a')](_0x168070[_0x08a1('0x49')],{'$or':_['map'](_0x5184ca,function(_0x445134){if(_0x445134[_0x08a1('0x3b')]!==_0x08a1('0x4b')){var _0x5a1c61={};_0x5a1c61[_0x445134[_0x08a1('0x35')]]={'$like':'%'+_0x1d93c2[_0x08a1('0x3e')][_0x08a1('0x48')]+'%'};return _0x5a1c61;}})});}_0x168070=_[_0x08a1('0x4a')]({},_0x168070,_0x1d93c2[_0x08a1('0x4c')]);var _0x15ea2e={'where':_0x168070[_0x08a1('0x49')]};return db[_0x08a1('0x38')][_0x08a1('0x29')](_0x15ea2e)[_0x08a1('0x32')](function(_0x4e9f42){_0x269083['count']=_0x4e9f42;if(_0x1d93c2[_0x08a1('0x3e')][_0x08a1('0x4d')]){_0x168070[_0x08a1('0x4e')]=[{'all':!![]}];}return db[_0x08a1('0x38')][_0x08a1('0x4f')](_0x168070);})[_0x08a1('0x32')](function(_0x4e4e64){_0x269083['rows']=_0x4e4e64;return _0x269083;})['then'](respondWithFilteredResult(_0x1f2935,_0x168070))[_0x08a1('0x25')](handleError(_0x1f2935,null));};exports[_0x08a1('0x50')]=function(_0x10d23f,_0x5c98ce){var _0x437cbf={'raw':![],'where':{'id':_0x10d23f['params']['id']}},_0x5ac72d={};_0x5ac72d['model']=_[_0x08a1('0x51')](db[_0x08a1('0x38')][_0x08a1('0x39')]);_0x5ac72d[_0x08a1('0x3e')]=_[_0x08a1('0x51')](_0x10d23f['query']);_0x5ac72d[_0x08a1('0x3f')]=_[_0x08a1('0x40')](_0x5ac72d[_0x08a1('0x3d')],_0x5ac72d[_0x08a1('0x3e')]);_0x437cbf[_0x08a1('0x41')]=_[_0x08a1('0x40')](_0x5ac72d[_0x08a1('0x3d')],qs['fields'](_0x10d23f['query'][_0x08a1('0x42')]));_0x437cbf[_0x08a1('0x41')]=_0x437cbf[_0x08a1('0x41')]['length']?_0x437cbf[_0x08a1('0x41')]:_0x5ac72d['model'];if(_0x10d23f[_0x08a1('0x3e')][_0x08a1('0x4d')]){_0x437cbf[_0x08a1('0x4e')]=[{'all':!![]}];}_0x437cbf=_[_0x08a1('0x4a')]({},_0x437cbf,_0x10d23f[_0x08a1('0x4c')]);return db[_0x08a1('0x38')][_0x08a1('0x52')](_0x437cbf)[_0x08a1('0x32')](handleEntityNotFound(_0x5c98ce,null))[_0x08a1('0x32')](respondWithResult(_0x5c98ce,null))['catch'](handleError(_0x5c98ce,null));};exports[_0x08a1('0x53')]=function(_0x2b9531,_0x23b5ff){return db[_0x08a1('0x38')][_0x08a1('0x53')](_0x2b9531[_0x08a1('0x54')],{})['then'](respondWithResult(_0x23b5ff,0xc9))[_0x08a1('0x25')](handleError(_0x23b5ff,null));};exports[_0x08a1('0x31')]=function(_0x3fe4dd,_0x44c528){if(_0x3fe4dd[_0x08a1('0x54')]['id']){delete _0x3fe4dd['body']['id'];}return db[_0x08a1('0x38')][_0x08a1('0x52')]({'where':{'id':_0x3fe4dd[_0x08a1('0x55')]['id']}})['then'](handleEntityNotFound(_0x44c528,null))[_0x08a1('0x32')](saveUpdates(_0x3fe4dd['body'],null))[_0x08a1('0x32')](respondWithResult(_0x44c528,null))[_0x08a1('0x25')](handleError(_0x44c528,null));};exports[_0x08a1('0x33')]=function(_0x100630,_0x1e4783){return db['SugarcrmAccount'][_0x08a1('0x52')]({'where':{'id':_0x100630[_0x08a1('0x55')]['id']}})[_0x08a1('0x32')](handleEntityNotFound(_0x1e4783,null))[_0x08a1('0x32')](removeEntity(_0x1e4783,null))[_0x08a1('0x25')](handleError(_0x1e4783,null));};exports['getConfigurations']=function(_0xc8d88,_0x1fff6e,_0x1bdf44){var _0x2d7dff={};var _0x362501={};var _0x1f3dce;var _0x5545c5;return db[_0x08a1('0x38')][_0x08a1('0x56')]({'where':{'id':_0xc8d88[_0x08a1('0x55')]['id']}})[_0x08a1('0x32')](handleEntityNotFound(_0x1fff6e,null))[_0x08a1('0x32')](function(_0x5589b1){if(_0x5589b1){_0x1f3dce=_0x5589b1;_0x362501[_0x08a1('0x3d')]=_[_0x08a1('0x51')](db['SugarcrmConfiguration'][_0x08a1('0x39')]);_0x362501[_0x08a1('0x3e')]=_[_0x08a1('0x51')](_0xc8d88[_0x08a1('0x3e')]);_0x362501[_0x08a1('0x3f')]=_[_0x08a1('0x40')](_0x362501[_0x08a1('0x3d')],_0x362501[_0x08a1('0x3e')]);_0x2d7dff['attributes']=_['intersection'](_0x362501[_0x08a1('0x3d')],qs['fields'](_0xc8d88[_0x08a1('0x3e')][_0x08a1('0x42')]));_0x2d7dff[_0x08a1('0x41')]=_0x2d7dff[_0x08a1('0x41')]['length']?_0x2d7dff['attributes']:_0x362501[_0x08a1('0x3d')];_0x2d7dff[_0x08a1('0x46')]=qs[_0x08a1('0x47')](_0xc8d88[_0x08a1('0x3e')][_0x08a1('0x47')]);_0x2d7dff[_0x08a1('0x49')]=qs['filters'](_[_0x08a1('0x57')](_0xc8d88[_0x08a1('0x3e')],_0x362501[_0x08a1('0x3f')]));if(_0xc8d88['query'][_0x08a1('0x48')]){_0x2d7dff[_0x08a1('0x49')]=_[_0x08a1('0x4a')](_0x2d7dff[_0x08a1('0x49')],{'$or':_[_0x08a1('0x37')](_0x2d7dff[_0x08a1('0x41')],function(_0x2b8d9c){var _0x333178={};_0x333178[_0x2b8d9c]={'$like':'%'+_0xc8d88['query']['filter']+'%'};return _0x333178;})});}_0x2d7dff=_['merge']({},_0x2d7dff,_0xc8d88[_0x08a1('0x4c')]);return _0x1f3dce[_0x08a1('0x58')](_0x2d7dff);}})[_0x08a1('0x32')](function(_0xb0e04b){if(_0xb0e04b){_0x5545c5=_0xb0e04b[_0x08a1('0x43')];if(!_0xc8d88[_0x08a1('0x3e')][_0x08a1('0x44')](_0x08a1('0x45'))){_0x2d7dff[_0x08a1('0x2b')]=qs[_0x08a1('0x2b')](_0xc8d88['query']['limit']);_0x2d7dff[_0x08a1('0x2a')]=qs['offset'](_0xc8d88[_0x08a1('0x3e')][_0x08a1('0x2a')]);}return _0x1f3dce[_0x08a1('0x58')](_0x2d7dff);}})[_0x08a1('0x32')](function(_0x1a14d4){if(_0x1a14d4){return _0x1a14d4?{'count':_0x5545c5,'rows':_0x1a14d4}:null;}})[_0x08a1('0x32')](respondWithResult(_0x1fff6e,null))['catch'](handleError(_0x1fff6e,null));};exports[_0x08a1('0x59')]=function(_0x196a95,_0x5079e2,_0x13d62c){if(_0x196a95[_0x08a1('0x54')]['id']){delete _0x196a95['body']['id'];}return db[_0x08a1('0x38')][_0x08a1('0x56')]({'where':{'id':_0x196a95[_0x08a1('0x55')]['id']}})[_0x08a1('0x32')](handleEntityNotFound(_0x5079e2,null))[_0x08a1('0x32')](function(_0x6055f1){if(_0x6055f1){_0x196a95[_0x08a1('0x54')]['AccountId']=_0x6055f1['id'];_0x196a95[_0x08a1('0x54')][_0x08a1('0x5a')]=integrations[_0x08a1('0x5b')](_0x196a95[_0x08a1('0x54')][_0x08a1('0x5c')],_0x196a95[_0x08a1('0x54')][_0x08a1('0x3b')]);_0x196a95[_0x08a1('0x54')]['Descriptions']=integrations['getDescriptions'](_0x196a95[_0x08a1('0x54')][_0x08a1('0x5c')],_0x196a95[_0x08a1('0x54')][_0x08a1('0x3b')]);return db[_0x08a1('0x5d')][_0x08a1('0x53')](_0x196a95[_0x08a1('0x54')],{'include':[{'model':db[_0x08a1('0x5e')],'as':_0x08a1('0x5a')},{'model':db[_0x08a1('0x5e')],'as':_0x08a1('0x5f')}]});}return null;})[_0x08a1('0x32')](respondWithResult(_0x5079e2,null))[_0x08a1('0x25')](handleError(_0x5079e2,null));};exports['getFields']=function(_0x5057fb,_0x455e90,_0x144232){var _0x6bc6a7='';var _0x28a67f=['id',_0x08a1('0x35'),_0x08a1('0x60'),_0x08a1('0x61'),_0x08a1('0x62'),_0x08a1('0x63'),'duration_hours',_0x08a1('0x64'),_0x08a1('0x65'),_0x08a1('0x66'),_0x08a1('0x67'),_0x08a1('0x68')];return db[_0x08a1('0x38')]['findOne']({'where':{'id':_0x5057fb[_0x08a1('0x55')]['id']},'attributes':['id',_0x08a1('0x69'),_0x08a1('0x6a'),_0x08a1('0x6b')]})[_0x08a1('0x32')](handleEntityNotFound(_0x455e90,null))[_0x08a1('0x32')](function(_0x1d55b8){if(_0x1d55b8){_0x6bc6a7=_0x1d55b8[_0x08a1('0x6b')];var _0x15a054=_0x6bc6a7['slice'](-0x1);if(_0x15a054==='/'){_0x6bc6a7=_0x6bc6a7[_0x08a1('0x6c')](0x0,_0x6bc6a7[_0x08a1('0x6d')](_0x15a054));}return rp({'method':_0x08a1('0x6e'),'uri':util[_0x08a1('0x6f')](_0x08a1('0x70'),_0x6bc6a7,'/service/v4_1/rest.php'),'json':!![],'form':{'method':'login','input_type':_0x08a1('0x71'),'response_type':_0x08a1('0x71'),'rest_data':JSON[_0x08a1('0x1f')]({'user_auth':{'user_name':_0x1d55b8[_0x08a1('0x69')],'password':_0x1d55b8['password'],'encryption':_0x08a1('0x72')},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0x08a1('0x32')](function(_0x4df38a){if(_0x4df38a&&_0x4df38a[_0x08a1('0x35')]!=='Invalid\x20Login'&&_0x4df38a[_0x08a1('0x35')]!=='Password\x20Expired'){return rp({'method':'POST','uri':util[_0x08a1('0x6f')]('%s%s',_0x6bc6a7,_0x08a1('0x73')),'json':!![],'form':{'method':_0x08a1('0x74'),'input_type':_0x08a1('0x71'),'response_type':_0x08a1('0x71'),'rest_data':JSON[_0x08a1('0x1f')]({'session':_0x4df38a['id'],'module_name':_0x08a1('0x75')})}})[_0x08a1('0x32')](function(_0x24cabd){if(_0x24cabd){var _0x1d47d9=_[_0x08a1('0x76')](_0x24cabd[_0x08a1('0x77')]);_['remove'](_0x1d47d9,function(_0x4a37ac){return _0x28a67f[_0x08a1('0x78')](_0x4a37ac[_0x08a1('0x35')]);});return{'count':_0x1d47d9[_0x08a1('0x43')],'rows':_[_0x08a1('0x37')](_0x1d47d9,function(_0x3f773d){return{'id':_0x3f773d[_0x08a1('0x35')],'name':_0x3f773d[_0x08a1('0x79')],'custom':_[_0x08a1('0x7a')](_0x3f773d[_0x08a1('0x35')],'_c')?!![]:![],'options':_0x3f773d['options']?_[_0x08a1('0x37')](_[_0x08a1('0x76')](_0x3f773d[_0x08a1('0x4c')]),function(_0x1c690e){return{'name':_0x1c690e['value'],'value':_0x1c690e[_0x08a1('0x35')]};}):[]};})};}})['then'](respondWithResult(_0x455e90,null))[_0x08a1('0x25')](function(_0x49b1fc){var _0x48d53d=_0x5057fb[_0x08a1('0x3e')]['test']?0x1f4:_0x49b1fc[_0x08a1('0x7b')]||0x1f4;logger['error'](_0x08a1('0x7c'),_0x08a1('0x7d'),_0x48d53d,JSON[_0x08a1('0x1f')](_0x49b1fc));delete _0x49b1fc[_0x08a1('0x35')];if(_0x48d53d===0x191){_0x48d53d=0x190;}_0x455e90['status'](_0x48d53d)[_0x08a1('0x7e')](_0x5057fb[_0x08a1('0x3e')][_0x08a1('0x7f')]?{'message':_0x08a1('0x80'),'statusCode':_0x49b1fc[_0x08a1('0x7b')]}:_0x49b1fc);});}else{var _0x39a9c5=0x1f4;_0x455e90['status'](_0x39a9c5)[_0x08a1('0x7e')]({'message':_0x08a1('0x80'),'statusCode':0x190});}});};
\ No newline at end of file
+var _0x83ce=['offset','undefined','limit','set','json','apply','reject','update','stack','name','send','map','SugarcrmAccount','rawAttributes','type','key','model','query','keys','filters','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','find','create','body','destroy','getConfigurations','findOne','SugarcrmConfiguration','addConfiguration','getSubjects','channel','getDescriptions','SugarcrmField','Subjects','Descriptions','getFields','created_by','description','date_start','remoteUri','substring','format','JSON','username','password','PLAIN','Invalid\x20Login','Password\x20Expired','POST','%s%s','/service/v4_1/rest.php','Calls','module_fields','remove','includes','endsWith','values','value','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','jayson/promise','client','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end'];(function(_0x4a30b3,_0x3ddbdb){var _0x161079=function(_0x507543){while(--_0x507543){_0x4a30b3['push'](_0x4a30b3['shift']());}};_0x161079(++_0x3ddbdb);}(_0x83ce,0x149));var _0xe83c=function(_0x4b6e43,_0x19feb1){_0x4b6e43=_0x4b6e43-0x0;var _0x55faa2=_0x83ce[_0x4b6e43];return _0x55faa2;};'use strict';var emlformat=require(_0xe83c('0x0'));var rimraf=require(_0xe83c('0x1'));var zipdir=require(_0xe83c('0x2'));var jsonpatch=require(_0xe83c('0x3'));var rp=require(_0xe83c('0x4'));var moment=require(_0xe83c('0x5'));var BPromise=require(_0xe83c('0x6'));var Mustache=require(_0xe83c('0x7'));var util=require(_0xe83c('0x8'));var path=require(_0xe83c('0x9'));var sox=require(_0xe83c('0xa'));var csv=require(_0xe83c('0xb'));var ejs=require(_0xe83c('0xc'));var fs=require('fs');var fs_extra=require(_0xe83c('0xd'));var _=require(_0xe83c('0xe'));var squel=require('squel');var crypto=require(_0xe83c('0xf'));var jsforce=require('jsforce');var deskjs=require(_0xe83c('0x10'));var toCsv=require(_0xe83c('0xb'));var querystring=require(_0xe83c('0x11'));var Papa=require(_0xe83c('0x12'));var Redis=require('ioredis');var authService=require(_0xe83c('0x13'));var qs=require(_0xe83c('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe83c('0x15'));var logger=require(_0xe83c('0x16'))(_0xe83c('0x17'));var utils=require(_0xe83c('0x18'));var config=require(_0xe83c('0x19'));var licenseUtil=require(_0xe83c('0x1a'));var db=require('../../mysqldb')['db'];var integrations=require(_0xe83c('0x1b'));var jayson=require(_0xe83c('0x1c'));var client=jayson[_0xe83c('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x12e819,_0x327515,_0x3ac1b9,_0x1bc68a){return new BPromise(function(_0x295cd9,_0x2b3ad0){var _0xfb788c=_0x1bc68a||client;return _0xfb788c[_0xe83c('0x1e')](_0x12e819,_0x3ac1b9)[_0xe83c('0x1f')](function(_0x391aea){logger[_0xe83c('0x20')](_0xe83c('0x21'),_0x327515,_0xe83c('0x22'));logger[_0xe83c('0x23')](_0xe83c('0x24'),_0x327515,_0xe83c('0x22'),JSON[_0xe83c('0x25')](_0x391aea));if(_0x391aea['error']){if(_0x391aea[_0xe83c('0x26')][_0xe83c('0x27')]===0x1f4){logger[_0xe83c('0x26')](_0xe83c('0x21'),_0x327515,_0x391aea[_0xe83c('0x26')][_0xe83c('0x28')]);return _0x2b3ad0(_0x391aea[_0xe83c('0x26')][_0xe83c('0x28')]);}logger[_0xe83c('0x26')](_0xe83c('0x21'),_0x327515,_0x391aea[_0xe83c('0x26')][_0xe83c('0x28')]);return _0x295cd9(_0x391aea[_0xe83c('0x26')][_0xe83c('0x28')]);}else{logger['info'](_0xe83c('0x21'),_0x327515,_0xe83c('0x22'));_0x295cd9(_0x391aea[_0xe83c('0x29')]['message']);}})[_0xe83c('0x2a')](function(_0x76e23f){logger[_0xe83c('0x26')](_0xe83c('0x21'),_0x327515,_0x76e23f);_0x2b3ad0(_0x76e23f);});});}function respondWithStatusCode(_0xb3ab60,_0x33a959){_0x33a959=_0x33a959||0xcc;return function(_0x298322){if(_0x298322){return _0xb3ab60[_0xe83c('0x2b')](_0x33a959);}return _0xb3ab60[_0xe83c('0x2c')](_0x33a959)[_0xe83c('0x2d')]();};}function respondWithResult(_0xd4ac98,_0x411feb){_0x411feb=_0x411feb||0xc8;return function(_0x10cd1e){if(_0x10cd1e){return _0xd4ac98[_0xe83c('0x2c')](_0x411feb)['json'](_0x10cd1e);}};}function respondWithFilteredResult(_0x590805,_0x47a536){return function(_0x5a213c){if(_0x5a213c){var _0x4fd66c=typeof _0x47a536[_0xe83c('0x2e')]==='undefined'&&typeof _0x47a536['limit']===_0xe83c('0x2f');var _0x45c73d=_0x5a213c['count'];var _0x1687ea=_0x4fd66c?0x0:_0x47a536[_0xe83c('0x2e')];var _0x296612=_0x4fd66c?_0x5a213c['count']:_0x47a536[_0xe83c('0x2e')]+_0x47a536[_0xe83c('0x30')];var _0x1ba789;if(_0x296612>=_0x45c73d){_0x296612=_0x45c73d;_0x1ba789=0xc8;}else{_0x1ba789=0xce;}_0x590805[_0xe83c('0x2c')](_0x1ba789);return _0x590805[_0xe83c('0x31')]('Content-Range',_0x1687ea+'-'+_0x296612+'/'+_0x45c73d)[_0xe83c('0x32')](_0x5a213c);}return null;};}function patchUpdates(_0x3a267d){return function(_0x3f4ff5){try{jsonpatch[_0xe83c('0x33')](_0x3f4ff5,_0x3a267d,!![]);}catch(_0x38950a){return BPromise[_0xe83c('0x34')](_0x38950a);}return _0x3f4ff5['save']();};}function saveUpdates(_0x42dbae,_0x58901e){return function(_0x126c1a){if(_0x126c1a){return _0x126c1a[_0xe83c('0x35')](_0x42dbae)[_0xe83c('0x1f')](function(_0x1d0a4e){return _0x1d0a4e;});}return null;};}function removeEntity(_0x35bc9c,_0x4bdd15){return function(_0x2e7fb6){if(_0x2e7fb6){return _0x2e7fb6['destroy']()[_0xe83c('0x1f')](function(){_0x35bc9c[_0xe83c('0x2c')](0xcc)[_0xe83c('0x2d')]();});}};}function handleEntityNotFound(_0x334510,_0x4d0c57){return function(_0x3cb2a6){if(!_0x3cb2a6){_0x334510[_0xe83c('0x2b')](0x194);}return _0x3cb2a6;};}function handleError(_0x1be65e,_0x1a56b3){_0x1a56b3=_0x1a56b3||0x1f4;return function(_0x1292fa){logger[_0xe83c('0x26')](_0x1292fa[_0xe83c('0x36')]);if(_0x1292fa[_0xe83c('0x37')]){delete _0x1292fa['name'];}_0x1be65e[_0xe83c('0x2c')](_0x1a56b3)[_0xe83c('0x38')](_0x1292fa);};}exports['index']=function(_0x13ae3d,_0x5ce927){var _0x3af56e={},_0x1401be={},_0x92790a={'count':0x0,'rows':[]};var _0x391d17=_[_0xe83c('0x39')](db[_0xe83c('0x3a')][_0xe83c('0x3b')],function(_0x2b87ce){return{'name':_0x2b87ce['fieldName'],'type':_0x2b87ce[_0xe83c('0x3c')][_0xe83c('0x3d')]};});_0x1401be[_0xe83c('0x3e')]=_[_0xe83c('0x39')](_0x391d17,_0xe83c('0x37'));_0x1401be[_0xe83c('0x3f')]=_[_0xe83c('0x40')](_0x13ae3d['query']);_0x1401be[_0xe83c('0x41')]=_['intersection'](_0x1401be[_0xe83c('0x3e')],_0x1401be[_0xe83c('0x3f')]);_0x3af56e[_0xe83c('0x42')]=_[_0xe83c('0x43')](_0x1401be[_0xe83c('0x3e')],qs[_0xe83c('0x44')](_0x13ae3d[_0xe83c('0x3f')][_0xe83c('0x44')]));_0x3af56e[_0xe83c('0x42')]=_0x3af56e['attributes'][_0xe83c('0x45')]?_0x3af56e[_0xe83c('0x42')]:_0x1401be[_0xe83c('0x3e')];if(!_0x13ae3d[_0xe83c('0x3f')]['hasOwnProperty'](_0xe83c('0x46'))){_0x3af56e[_0xe83c('0x30')]=qs[_0xe83c('0x30')](_0x13ae3d[_0xe83c('0x3f')][_0xe83c('0x30')]);_0x3af56e[_0xe83c('0x2e')]=qs[_0xe83c('0x2e')](_0x13ae3d[_0xe83c('0x3f')]['offset']);}_0x3af56e[_0xe83c('0x47')]=qs['sort'](_0x13ae3d[_0xe83c('0x3f')][_0xe83c('0x48')]);_0x3af56e[_0xe83c('0x49')]=qs[_0xe83c('0x41')](_[_0xe83c('0x4a')](_0x13ae3d['query'],_0x1401be[_0xe83c('0x41')]),_0x391d17);if(_0x13ae3d['query'][_0xe83c('0x4b')]){_0x3af56e[_0xe83c('0x49')]=_[_0xe83c('0x4c')](_0x3af56e[_0xe83c('0x49')],{'$or':_[_0xe83c('0x39')](_0x391d17,function(_0x12bc6b){if(_0x12bc6b[_0xe83c('0x3c')]!==_0xe83c('0x4d')){var _0x1db4e0={};_0x1db4e0[_0x12bc6b[_0xe83c('0x37')]]={'$like':'%'+_0x13ae3d['query'][_0xe83c('0x4b')]+'%'};return _0x1db4e0;}})});}_0x3af56e=_[_0xe83c('0x4c')]({},_0x3af56e,_0x13ae3d[_0xe83c('0x4e')]);var _0x41d0e1={'where':_0x3af56e['where']};return db[_0xe83c('0x3a')]['count'](_0x41d0e1)[_0xe83c('0x1f')](function(_0x10ac7e){_0x92790a['count']=_0x10ac7e;if(_0x13ae3d[_0xe83c('0x3f')][_0xe83c('0x4f')]){_0x3af56e[_0xe83c('0x50')]=[{'all':!![]}];}return db[_0xe83c('0x3a')][_0xe83c('0x51')](_0x3af56e);})[_0xe83c('0x1f')](function(_0x36fb5f){_0x92790a[_0xe83c('0x52')]=_0x36fb5f;return _0x92790a;})[_0xe83c('0x1f')](respondWithFilteredResult(_0x5ce927,_0x3af56e))[_0xe83c('0x2a')](handleError(_0x5ce927,null));};exports['show']=function(_0x4200af,_0x2c0ab9){var _0x5cfa02={'raw':![],'where':{'id':_0x4200af[_0xe83c('0x53')]['id']}},_0x252160={};_0x252160['model']=_[_0xe83c('0x40')](db[_0xe83c('0x3a')][_0xe83c('0x3b')]);_0x252160[_0xe83c('0x3f')]=_[_0xe83c('0x40')](_0x4200af['query']);_0x252160[_0xe83c('0x41')]=_[_0xe83c('0x43')](_0x252160[_0xe83c('0x3e')],_0x252160[_0xe83c('0x3f')]);_0x5cfa02[_0xe83c('0x42')]=_[_0xe83c('0x43')](_0x252160[_0xe83c('0x3e')],qs[_0xe83c('0x44')](_0x4200af['query']['fields']));_0x5cfa02[_0xe83c('0x42')]=_0x5cfa02[_0xe83c('0x42')][_0xe83c('0x45')]?_0x5cfa02['attributes']:_0x252160[_0xe83c('0x3e')];if(_0x4200af[_0xe83c('0x3f')][_0xe83c('0x4f')]){_0x5cfa02[_0xe83c('0x50')]=[{'all':!![]}];}_0x5cfa02=_[_0xe83c('0x4c')]({},_0x5cfa02,_0x4200af[_0xe83c('0x4e')]);return db['SugarcrmAccount'][_0xe83c('0x54')](_0x5cfa02)[_0xe83c('0x1f')](handleEntityNotFound(_0x2c0ab9,null))[_0xe83c('0x1f')](respondWithResult(_0x2c0ab9,null))[_0xe83c('0x2a')](handleError(_0x2c0ab9,null));};exports['create']=function(_0x592233,_0xf65a79){return db[_0xe83c('0x3a')][_0xe83c('0x55')](_0x592233[_0xe83c('0x56')],{})[_0xe83c('0x1f')](respondWithResult(_0xf65a79,0xc9))['catch'](handleError(_0xf65a79,null));};exports[_0xe83c('0x35')]=function(_0x3d0c89,_0x282711){if(_0x3d0c89['body']['id']){delete _0x3d0c89[_0xe83c('0x56')]['id'];}return db[_0xe83c('0x3a')][_0xe83c('0x54')]({'where':{'id':_0x3d0c89[_0xe83c('0x53')]['id']}})[_0xe83c('0x1f')](handleEntityNotFound(_0x282711,null))['then'](saveUpdates(_0x3d0c89[_0xe83c('0x56')],null))['then'](respondWithResult(_0x282711,null))[_0xe83c('0x2a')](handleError(_0x282711,null));};exports[_0xe83c('0x57')]=function(_0x379c99,_0x118111){return db[_0xe83c('0x3a')][_0xe83c('0x54')]({'where':{'id':_0x379c99['params']['id']}})[_0xe83c('0x1f')](handleEntityNotFound(_0x118111,null))[_0xe83c('0x1f')](removeEntity(_0x118111,null))[_0xe83c('0x2a')](handleError(_0x118111,null));};exports[_0xe83c('0x58')]=function(_0x5d51c4,_0x5ba7c8,_0x35f98a){var _0x4355ac={};var _0x22cc72={};var _0x1b9302;var _0x55d0d3;return db[_0xe83c('0x3a')][_0xe83c('0x59')]({'where':{'id':_0x5d51c4[_0xe83c('0x53')]['id']}})[_0xe83c('0x1f')](handleEntityNotFound(_0x5ba7c8,null))[_0xe83c('0x1f')](function(_0x1214cc){if(_0x1214cc){_0x1b9302=_0x1214cc;_0x22cc72[_0xe83c('0x3e')]=_[_0xe83c('0x40')](db[_0xe83c('0x5a')][_0xe83c('0x3b')]);_0x22cc72[_0xe83c('0x3f')]=_['keys'](_0x5d51c4[_0xe83c('0x3f')]);_0x22cc72['filters']=_[_0xe83c('0x43')](_0x22cc72['model'],_0x22cc72['query']);_0x4355ac[_0xe83c('0x42')]=_[_0xe83c('0x43')](_0x22cc72[_0xe83c('0x3e')],qs[_0xe83c('0x44')](_0x5d51c4[_0xe83c('0x3f')][_0xe83c('0x44')]));_0x4355ac['attributes']=_0x4355ac[_0xe83c('0x42')]['length']?_0x4355ac[_0xe83c('0x42')]:_0x22cc72[_0xe83c('0x3e')];_0x4355ac[_0xe83c('0x47')]=qs[_0xe83c('0x48')](_0x5d51c4[_0xe83c('0x3f')]['sort']);_0x4355ac['where']=qs[_0xe83c('0x41')](_[_0xe83c('0x4a')](_0x5d51c4[_0xe83c('0x3f')],_0x22cc72[_0xe83c('0x41')]));if(_0x5d51c4[_0xe83c('0x3f')]['filter']){_0x4355ac[_0xe83c('0x49')]=_['merge'](_0x4355ac[_0xe83c('0x49')],{'$or':_['map'](_0x4355ac[_0xe83c('0x42')],function(_0x7f7247){var _0x2d6a55={};_0x2d6a55[_0x7f7247]={'$like':'%'+_0x5d51c4[_0xe83c('0x3f')][_0xe83c('0x4b')]+'%'};return _0x2d6a55;})});}_0x4355ac=_[_0xe83c('0x4c')]({},_0x4355ac,_0x5d51c4[_0xe83c('0x4e')]);return _0x1b9302[_0xe83c('0x58')](_0x4355ac);}})[_0xe83c('0x1f')](function(_0x5027ed){if(_0x5027ed){_0x55d0d3=_0x5027ed[_0xe83c('0x45')];if(!_0x5d51c4[_0xe83c('0x3f')]['hasOwnProperty'](_0xe83c('0x46'))){_0x4355ac[_0xe83c('0x30')]=qs[_0xe83c('0x30')](_0x5d51c4[_0xe83c('0x3f')][_0xe83c('0x30')]);_0x4355ac[_0xe83c('0x2e')]=qs[_0xe83c('0x2e')](_0x5d51c4[_0xe83c('0x3f')][_0xe83c('0x2e')]);}return _0x1b9302[_0xe83c('0x58')](_0x4355ac);}})[_0xe83c('0x1f')](function(_0x24093f){if(_0x24093f){return _0x24093f?{'count':_0x55d0d3,'rows':_0x24093f}:null;}})[_0xe83c('0x1f')](respondWithResult(_0x5ba7c8,null))['catch'](handleError(_0x5ba7c8,null));};exports[_0xe83c('0x5b')]=function(_0x5d6ae1,_0x58d6a6,_0x1588a2){if(_0x5d6ae1[_0xe83c('0x56')]['id']){delete _0x5d6ae1[_0xe83c('0x56')]['id'];}return db['SugarcrmAccount'][_0xe83c('0x59')]({'where':{'id':_0x5d6ae1[_0xe83c('0x53')]['id']}})[_0xe83c('0x1f')](handleEntityNotFound(_0x58d6a6,null))['then'](function(_0x2d2aed){if(_0x2d2aed){_0x5d6ae1[_0xe83c('0x56')]['AccountId']=_0x2d2aed['id'];_0x5d6ae1[_0xe83c('0x56')]['Subjects']=integrations[_0xe83c('0x5c')](_0x5d6ae1[_0xe83c('0x56')][_0xe83c('0x5d')],_0x5d6ae1['body'][_0xe83c('0x3c')]);_0x5d6ae1[_0xe83c('0x56')]['Descriptions']=integrations[_0xe83c('0x5e')](_0x5d6ae1[_0xe83c('0x56')]['channel'],_0x5d6ae1['body'][_0xe83c('0x3c')]);return db[_0xe83c('0x5a')][_0xe83c('0x55')](_0x5d6ae1['body'],{'include':[{'model':db[_0xe83c('0x5f')],'as':_0xe83c('0x60')},{'model':db[_0xe83c('0x5f')],'as':_0xe83c('0x61')}]});}return null;})[_0xe83c('0x1f')](respondWithResult(_0x58d6a6,null))[_0xe83c('0x2a')](handleError(_0x58d6a6,null));};exports[_0xe83c('0x62')]=function(_0x214d4e,_0x512477,_0x483d0e){var _0x2637bd='';var _0xde029a=['id','name','assigned_user_id',_0xe83c('0x63'),_0xe83c('0x64'),_0xe83c('0x65'),'duration_hours','duration_minutes','parent_id','parent_type','parent_name','direction'];return db[_0xe83c('0x3a')]['findOne']({'where':{'id':_0x214d4e[_0xe83c('0x53')]['id']},'attributes':['id','username','password',_0xe83c('0x66')]})[_0xe83c('0x1f')](handleEntityNotFound(_0x512477,null))[_0xe83c('0x1f')](function(_0x465015){if(_0x465015){_0x2637bd=_0x465015[_0xe83c('0x66')];var _0x2d7606=_0x2637bd['slice'](-0x1);if(_0x2d7606==='/'){_0x2637bd=_0x2637bd[_0xe83c('0x67')](0x0,_0x2637bd['lastIndexOf'](_0x2d7606));}return rp({'method':'POST','uri':util[_0xe83c('0x68')]('%s%s',_0x2637bd,'/service/v4_1/rest.php'),'json':!![],'form':{'method':'login','input_type':_0xe83c('0x69'),'response_type':_0xe83c('0x69'),'rest_data':JSON[_0xe83c('0x25')]({'user_auth':{'user_name':_0x465015[_0xe83c('0x6a')],'password':_0x465015[_0xe83c('0x6b')],'encryption':_0xe83c('0x6c')},'application':'xCALLY\x20Motion\x20Integration'})}});}})['then'](function(_0x11a8b3){if(_0x11a8b3&&_0x11a8b3[_0xe83c('0x37')]!==_0xe83c('0x6d')&&_0x11a8b3[_0xe83c('0x37')]!==_0xe83c('0x6e')){return rp({'method':_0xe83c('0x6f'),'uri':util[_0xe83c('0x68')](_0xe83c('0x70'),_0x2637bd,_0xe83c('0x71')),'json':!![],'form':{'method':'get_module_fields','input_type':_0xe83c('0x69'),'response_type':_0xe83c('0x69'),'rest_data':JSON['stringify']({'session':_0x11a8b3['id'],'module_name':_0xe83c('0x72')})}})['then'](function(_0x13d2e9){if(_0x13d2e9){var _0x4c1d7d=_['values'](_0x13d2e9[_0xe83c('0x73')]);_[_0xe83c('0x74')](_0x4c1d7d,function(_0x3e55b0){return _0xde029a[_0xe83c('0x75')](_0x3e55b0['name']);});return{'count':_0x4c1d7d[_0xe83c('0x45')],'rows':_[_0xe83c('0x39')](_0x4c1d7d,function(_0x4063a0){return{'id':_0x4063a0['name'],'name':_0x4063a0['label'],'custom':_[_0xe83c('0x76')](_0x4063a0[_0xe83c('0x37')],'_c')?!![]:![],'options':_0x4063a0[_0xe83c('0x4e')]?_[_0xe83c('0x39')](_[_0xe83c('0x77')](_0x4063a0[_0xe83c('0x4e')]),function(_0x503792){return{'name':_0x503792[_0xe83c('0x78')],'value':_0x503792[_0xe83c('0x37')]};}):[]};})};}})[_0xe83c('0x1f')](respondWithResult(_0x512477,null))['catch'](function(_0x3705bb){var _0x3aea1e=_0x214d4e[_0xe83c('0x3f')][_0xe83c('0x79')]?0x1f4:_0x3705bb[_0xe83c('0x7a')]||0x1f4;logger[_0xe83c('0x26')](_0xe83c('0x7b'),_0xe83c('0x62'),_0x3aea1e,JSON[_0xe83c('0x25')](_0x3705bb));delete _0x3705bb[_0xe83c('0x37')];if(_0x3aea1e===0x191){_0x3aea1e=0x190;}_0x512477[_0xe83c('0x2c')](_0x3aea1e)[_0xe83c('0x38')](_0x214d4e[_0xe83c('0x3f')][_0xe83c('0x79')]?{'message':_0xe83c('0x7c'),'statusCode':_0x3705bb[_0xe83c('0x7a')]}:_0x3705bb);});}else{var _0x4abacb=0x1f4;_0x512477[_0xe83c('0x2c')](_0x4abacb)[_0xe83c('0x38')]({'message':_0xe83c('0x7c'),'statusCode':0x190});}});};
\ No newline at end of file