22520649a60490698dcd8ad1ff0b3b224f34490c
[motion2.git] / server / api / intDynamics365Account / intDynamics365Account.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x6b0e=['Label','Value','DisplayName','UserLocalizedLabel',')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata?$select=DisplayName,LogicalName&$expand=OptionSet($select=FalseOption,\x20TrueOption)','true','FalseOption',')/Microsoft.Dynamics.CRM.','?$select=DisplayName,LogicalName','request-promise','util','lodash','../../config/logger','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','count','set','Content-Range','then','destroy','end','sendStatus','error','stack','name','send','index','map','Dynamics365Account','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','pick','filter','where','merge','VIRTUAL','includeAll','rows','catch','show','params','include','options','find','create','body','update','getConfigurations','findOne','Dynamics365Configuration','order','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','Dynamics365Field','Descriptions','slice','substring','lastIndexOf','format','%s/api/data/v9.0/','getFields','ticketType','incident','Incident','PhoneCall','title','description','customerid','caseorigincode','subject','phonenumber','directioncode','phonecall_activity_parties','accountidname','accountidyominame','actualserviceunits','billedserviceunits','contactidname','contactidyominame','contractdetailidname','createdbyexternalpartyname','createdbyexternalpartyyominame','createdbyname','createdbyyominame','createdon','createdonbehalfbyyominame','customeridname','customeridtype','customeridyominame','entityimage_timestamp','entityimage_url','escalatedon','exchangerate','firstresponsebykpiidname','importsequencenumber','influencescore','kbarticleidname','lastonholdtime','masteridname','modifiedbyexternalpartyname','modifiedbyexternalpartyyominame','modifiedbyname','modifiedbyyominame','modifiedon','modifiedonbehalfbyyominame','msdyn_iotalertname','onholdtime','owneridname','owneridtype','owneridyominame','parentcaseidname','primarycontactidyominame','prioritycodename','productserialnumber','responseby','sentimentvalue','slainvokedidname','socialprofileidname','statecode','statuscode','subjectidname','timezoneruleversionnumber','transactioncurrencyidname','traversedpath','utcconversiontimezonecode','versionnumber','concat','username','password','remoteUri','tenantId','clientId','clientSecret','modernAuthentication','CloudProvider','data5','data7','access_token','/oauth2/token','GET','Bearer\x20','4.0','MetadataId','EntityDefinitions(','Attributes','remove','includes','LogicalName','forEach','@odata.type','push','isNil','BooleanAttributeMetadata','all','BigIntAttributeMetadata','IntegerAttributeMetadata','MemoAttributeMetadata','DateTimeAttributeMetadata','StatusAttributeMetadata','EntityNameAttributeMetadata','StateAttributeMetadata','DecimalAttributeMetadata','test','statusCode',')/Attributes(',')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?','$select=DisplayName,LogicalName&$expand=OptionSet($select=Options)','OptionSet','Options'];(function(_0x2b5eae,_0x55010d){var _0x5f3ac9=function(_0x397bfc){while(--_0x397bfc){_0x2b5eae['push'](_0x2b5eae['shift']());}};_0x5f3ac9(++_0x55010d);}(_0x6b0e,0x185));var _0xe6b0=function(_0x379062,_0x25a617){_0x379062=_0x379062-0x0;var _0x4f9acd=_0x6b0e[_0x379062];return _0x4f9acd;};'use strict';var rp=require(_0xe6b0('0x0'));var util=require(_0xe6b0('0x1'));var _=require(_0xe6b0('0x2'));var qs=require('../../components/parsers/qs');var logger=require(_0xe6b0('0x3'))('api');var db=require(_0xe6b0('0x4'))['db'];var integrations=require(_0xe6b0('0x5'));function respondWithResult(_0x4b472e,_0x10dd4d){_0x10dd4d=_0x10dd4d||0xc8;return function(_0x178af2){if(_0x178af2){return _0x4b472e[_0xe6b0('0x6')](_0x10dd4d)[_0xe6b0('0x7')](_0x178af2);}};}function respondWithFilteredResult(_0x1eb26c,_0x5d719e){return function(_0x4f9e4a){if(_0x4f9e4a){var _0x3c88bc=typeof _0x5d719e[_0xe6b0('0x8')]===_0xe6b0('0x9')&&typeof _0x5d719e['limit']===_0xe6b0('0x9');var _0x51739e=_0x4f9e4a[_0xe6b0('0xa')];var _0x57a51d=_0x3c88bc?0x0:_0x5d719e[_0xe6b0('0x8')];var _0x110477=_0x3c88bc?_0x4f9e4a[_0xe6b0('0xa')]:_0x5d719e['offset']+_0x5d719e['limit'];var _0x41cc7a;if(_0x110477>=_0x51739e){_0x110477=_0x51739e;_0x41cc7a=0xc8;}else{_0x41cc7a=0xce;}_0x1eb26c['status'](_0x41cc7a);return _0x1eb26c[_0xe6b0('0xb')](_0xe6b0('0xc'),_0x57a51d+'-'+_0x110477+'/'+_0x51739e)[_0xe6b0('0x7')](_0x4f9e4a);}return null;};}function saveUpdates(_0x77c755){return function(_0xa2f4bc){if(_0xa2f4bc){return _0xa2f4bc['update'](_0x77c755)[_0xe6b0('0xd')](function(_0x124722){return _0x124722;});}return null;};}function removeEntity(_0x21ba83){return function(_0x31c3e5){if(_0x31c3e5){return _0x31c3e5[_0xe6b0('0xe')]()['then'](function(){_0x21ba83[_0xe6b0('0x6')](0xcc)[_0xe6b0('0xf')]();});}};}function handleEntityNotFound(_0x360e49){return function(_0x2b2af7){if(!_0x2b2af7){_0x360e49[_0xe6b0('0x10')](0x194);}return _0x2b2af7;};}function handleError(_0x37d4ad,_0x424ac3){_0x424ac3=_0x424ac3||0x1f4;return function(_0x3069e0){logger[_0xe6b0('0x11')](_0x3069e0[_0xe6b0('0x12')]);if(_0x3069e0[_0xe6b0('0x13')]){delete _0x3069e0[_0xe6b0('0x13')];}_0x37d4ad[_0xe6b0('0x6')](_0x424ac3)[_0xe6b0('0x14')](_0x3069e0);};}exports[_0xe6b0('0x15')]=function(_0x156d4e,_0x467673){var _0x40f5db={},_0x427bfb={},_0x3ca422={'count':0x0,'rows':[]};var _0x467cbf=_[_0xe6b0('0x16')](db[_0xe6b0('0x17')][_0xe6b0('0x18')],function(_0x53c090){return{'name':_0x53c090['fieldName'],'type':_0x53c090[_0xe6b0('0x19')][_0xe6b0('0x1a')]};});_0x427bfb[_0xe6b0('0x1b')]=_[_0xe6b0('0x16')](_0x467cbf,_0xe6b0('0x13'));_0x427bfb[_0xe6b0('0x1c')]=_[_0xe6b0('0x1d')](_0x156d4e[_0xe6b0('0x1c')]);_0x427bfb[_0xe6b0('0x1e')]=_[_0xe6b0('0x1f')](_0x427bfb[_0xe6b0('0x1b')],_0x427bfb[_0xe6b0('0x1c')]);_0x40f5db[_0xe6b0('0x20')]=_[_0xe6b0('0x1f')](_0x427bfb[_0xe6b0('0x1b')],qs[_0xe6b0('0x21')](_0x156d4e['query']['fields']));_0x40f5db[_0xe6b0('0x20')]=_0x40f5db[_0xe6b0('0x20')][_0xe6b0('0x22')]?_0x40f5db[_0xe6b0('0x20')]:_0x427bfb['model'];if(!_0x156d4e['query'][_0xe6b0('0x23')](_0xe6b0('0x24'))){_0x40f5db[_0xe6b0('0x25')]=qs[_0xe6b0('0x25')](_0x156d4e[_0xe6b0('0x1c')]['limit']);_0x40f5db[_0xe6b0('0x8')]=qs['offset'](_0x156d4e[_0xe6b0('0x1c')][_0xe6b0('0x8')]);}_0x40f5db['order']=qs[_0xe6b0('0x26')](_0x156d4e[_0xe6b0('0x1c')][_0xe6b0('0x26')]);_0x40f5db['where']=qs[_0xe6b0('0x1e')](_[_0xe6b0('0x27')](_0x156d4e[_0xe6b0('0x1c')],_0x427bfb[_0xe6b0('0x1e')]),_0x467cbf);if(_0x156d4e[_0xe6b0('0x1c')][_0xe6b0('0x28')]){_0x40f5db[_0xe6b0('0x29')]=_[_0xe6b0('0x2a')](_0x40f5db[_0xe6b0('0x29')],{'$or':_[_0xe6b0('0x16')](_0x467cbf,function(_0x4ebaf8){if(_0x4ebaf8[_0xe6b0('0x19')]!==_0xe6b0('0x2b')){var _0xf50eb7={};_0xf50eb7[_0x4ebaf8[_0xe6b0('0x13')]]={'$like':'%'+_0x156d4e[_0xe6b0('0x1c')]['filter']+'%'};return _0xf50eb7;}})});}_0x40f5db=_['merge']({},_0x40f5db,_0x156d4e['options']);var _0x17309c={'where':_0x40f5db[_0xe6b0('0x29')]};return db[_0xe6b0('0x17')][_0xe6b0('0xa')](_0x17309c)[_0xe6b0('0xd')](function(_0x37dfa8){_0x3ca422['count']=_0x37dfa8;if(_0x156d4e[_0xe6b0('0x1c')][_0xe6b0('0x2c')]){_0x40f5db['include']=[{'all':!![]}];}return db['Dynamics365Account']['findAll'](_0x40f5db);})[_0xe6b0('0xd')](function(_0x142816){_0x3ca422[_0xe6b0('0x2d')]=_0x142816;return _0x3ca422;})[_0xe6b0('0xd')](respondWithFilteredResult(_0x467673,_0x40f5db))[_0xe6b0('0x2e')](handleError(_0x467673,null));};exports[_0xe6b0('0x2f')]=function(_0x37c6b1,_0xaed73){var _0x5454d={'raw':![],'where':{'id':_0x37c6b1[_0xe6b0('0x30')]['id']}},_0x5f1a97={};_0x5f1a97['model']=_[_0xe6b0('0x1d')](db[_0xe6b0('0x17')][_0xe6b0('0x18')]);_0x5f1a97[_0xe6b0('0x1c')]=_[_0xe6b0('0x1d')](_0x37c6b1['query']);_0x5f1a97[_0xe6b0('0x1e')]=_[_0xe6b0('0x1f')](_0x5f1a97[_0xe6b0('0x1b')],_0x5f1a97['query']);_0x5454d[_0xe6b0('0x20')]=_[_0xe6b0('0x1f')](_0x5f1a97['model'],qs[_0xe6b0('0x21')](_0x37c6b1['query'][_0xe6b0('0x21')]));_0x5454d[_0xe6b0('0x20')]=_0x5454d[_0xe6b0('0x20')][_0xe6b0('0x22')]?_0x5454d['attributes']:_0x5f1a97[_0xe6b0('0x1b')];if(_0x37c6b1[_0xe6b0('0x1c')][_0xe6b0('0x2c')]){_0x5454d[_0xe6b0('0x31')]=[{'all':!![]}];}_0x5454d=_[_0xe6b0('0x2a')]({},_0x5454d,_0x37c6b1[_0xe6b0('0x32')]);return db[_0xe6b0('0x17')][_0xe6b0('0x33')](_0x5454d)[_0xe6b0('0xd')](handleEntityNotFound(_0xaed73,null))['then'](respondWithResult(_0xaed73,null))[_0xe6b0('0x2e')](handleError(_0xaed73,null));};exports[_0xe6b0('0x34')]=function(_0x3f40f8,_0x468df3){return db[_0xe6b0('0x17')][_0xe6b0('0x34')](_0x3f40f8[_0xe6b0('0x35')],{})['then'](respondWithResult(_0x468df3,0xc9))[_0xe6b0('0x2e')](handleError(_0x468df3,null));};exports[_0xe6b0('0x36')]=function(_0x26bb76,_0xc4c8c9){if(_0x26bb76[_0xe6b0('0x35')]['id']){delete _0x26bb76[_0xe6b0('0x35')]['id'];}return db[_0xe6b0('0x17')][_0xe6b0('0x33')]({'where':{'id':_0x26bb76[_0xe6b0('0x30')]['id']}})[_0xe6b0('0xd')](handleEntityNotFound(_0xc4c8c9,null))[_0xe6b0('0xd')](saveUpdates(_0x26bb76[_0xe6b0('0x35')],null))[_0xe6b0('0xd')](respondWithResult(_0xc4c8c9,null))[_0xe6b0('0x2e')](handleError(_0xc4c8c9,null));};exports['destroy']=function(_0x1736ac,_0x44104a){return db[_0xe6b0('0x17')][_0xe6b0('0x33')]({'where':{'id':_0x1736ac[_0xe6b0('0x30')]['id']}})['then'](handleEntityNotFound(_0x44104a,null))[_0xe6b0('0xd')](removeEntity(_0x44104a,null))[_0xe6b0('0x2e')](handleError(_0x44104a,null));};exports[_0xe6b0('0x37')]=function(_0x3cdceb,_0x4245cc){var _0x55be18={};var _0xb83eb5={};var _0x296d5b;var _0x24b780;return db['Dynamics365Account'][_0xe6b0('0x38')]({'where':{'id':_0x3cdceb['params']['id']}})['then'](handleEntityNotFound(_0x4245cc,null))[_0xe6b0('0xd')](function(_0x5afce5){if(_0x5afce5){_0x296d5b=_0x5afce5;_0xb83eb5['model']=_[_0xe6b0('0x1d')](db[_0xe6b0('0x39')][_0xe6b0('0x18')]);_0xb83eb5[_0xe6b0('0x1c')]=_[_0xe6b0('0x1d')](_0x3cdceb['query']);_0xb83eb5[_0xe6b0('0x1e')]=_[_0xe6b0('0x1f')](_0xb83eb5[_0xe6b0('0x1b')],_0xb83eb5['query']);_0x55be18[_0xe6b0('0x20')]=_[_0xe6b0('0x1f')](_0xb83eb5[_0xe6b0('0x1b')],qs[_0xe6b0('0x21')](_0x3cdceb[_0xe6b0('0x1c')]['fields']));_0x55be18[_0xe6b0('0x20')]=_0x55be18['attributes'][_0xe6b0('0x22')]?_0x55be18['attributes']:_0xb83eb5['model'];_0x55be18[_0xe6b0('0x3a')]=qs[_0xe6b0('0x26')](_0x3cdceb[_0xe6b0('0x1c')][_0xe6b0('0x26')]);_0x55be18[_0xe6b0('0x29')]=qs[_0xe6b0('0x1e')](_[_0xe6b0('0x27')](_0x3cdceb['query'],_0xb83eb5[_0xe6b0('0x1e')]));if(_0x3cdceb['query'][_0xe6b0('0x28')]){_0x55be18['where']=_[_0xe6b0('0x2a')](_0x55be18['where'],{'$or':_[_0xe6b0('0x16')](_0x55be18[_0xe6b0('0x20')],function(_0x2cb2c8){var _0x5e1f8f={};_0x5e1f8f[_0x2cb2c8]={'$like':'%'+_0x3cdceb[_0xe6b0('0x1c')]['filter']+'%'};return _0x5e1f8f;})});}_0x55be18=_[_0xe6b0('0x2a')]({},_0x55be18,_0x3cdceb[_0xe6b0('0x32')]);return _0x296d5b[_0xe6b0('0x37')](_0x55be18);}})[_0xe6b0('0xd')](function(_0x23fa64){if(_0x23fa64){_0x24b780=_0x23fa64[_0xe6b0('0x22')];if(!_0x3cdceb[_0xe6b0('0x1c')][_0xe6b0('0x23')](_0xe6b0('0x24'))){_0x55be18['limit']=qs[_0xe6b0('0x25')](_0x3cdceb[_0xe6b0('0x1c')]['limit']);_0x55be18[_0xe6b0('0x8')]=qs[_0xe6b0('0x8')](_0x3cdceb[_0xe6b0('0x1c')]['offset']);}return _0x296d5b[_0xe6b0('0x37')](_0x55be18);}})[_0xe6b0('0xd')](function(_0x3f9d3f){if(_0x3f9d3f){return _0x3f9d3f?{'count':_0x24b780,'rows':_0x3f9d3f}:null;}})['then'](respondWithResult(_0x4245cc,null))['catch'](handleError(_0x4245cc,null));};exports[_0xe6b0('0x3b')]=function(_0x18658a,_0x1cf152){if(_0x18658a['body']['id']){delete _0x18658a['body']['id'];}return db['Dynamics365Account'][_0xe6b0('0x38')]({'where':{'id':_0x18658a[_0xe6b0('0x30')]['id']}})[_0xe6b0('0xd')](handleEntityNotFound(_0x1cf152,null))[_0xe6b0('0xd')](function(_0x3804f9){if(_0x3804f9){_0x18658a['body'][_0xe6b0('0x3c')]=_0x3804f9['id'];_0x18658a[_0xe6b0('0x35')][_0xe6b0('0x3d')]=integrations[_0xe6b0('0x3e')](_0x18658a[_0xe6b0('0x35')][_0xe6b0('0x3f')],_0x18658a['body']['type']);_0x18658a[_0xe6b0('0x35')]['Descriptions']=integrations[_0xe6b0('0x40')](_0x18658a[_0xe6b0('0x35')][_0xe6b0('0x3f')],_0x18658a[_0xe6b0('0x35')]['type']);return db[_0xe6b0('0x39')][_0xe6b0('0x34')](_0x18658a['body'],{'include':[{'model':db[_0xe6b0('0x41')],'as':_0xe6b0('0x3d')},{'model':db[_0xe6b0('0x41')],'as':_0xe6b0('0x42')}]});}return null;})[_0xe6b0('0xd')](respondWithResult(_0x1cf152,null))[_0xe6b0('0x2e')](handleError(_0x1cf152,null));};function sanitizeRemoteUri(_0xd343fc){var _0x12f6cb=_0xd343fc[_0xe6b0('0x43')](-0x1);if(_0x12f6cb==='/')return _0xd343fc[_0xe6b0('0x44')](0x0,_0xd343fc[_0xe6b0('0x45')](_0x12f6cb));return _0xd343fc;}function getWebApiUrl(_0x5a870b){return util[_0xe6b0('0x46')](_0xe6b0('0x47'),_0x5a870b);}exports[_0xe6b0('0x48')]=function(_0x5b1dc6,_0x55d0f8){var _0x187bfe=_0x5b1dc6[_0xe6b0('0x1c')][_0xe6b0('0x49')];var _0x493e9c=_0x187bfe===_0xe6b0('0x4a')?_0xe6b0('0x4b'):_0xe6b0('0x4c');var _0x1ee6ad='';var _0x300713='';var _0x5d6571='';var _0x13b9f4='';var _0x1abbf4='';var _0x4884bd='';var _0x86c056='';var _0x4c8882='';var _0x5686f0=[_0xe6b0('0x4d'),_0xe6b0('0x4e'),_0xe6b0('0x4f'),'ownerid',_0xe6b0('0x50'),_0xe6b0('0x51'),_0xe6b0('0x52'),'regardingobjectid',_0xe6b0('0x53'),_0xe6b0('0x54')];var _0x3e3ae7=[_0xe6b0('0x55'),_0xe6b0('0x56'),_0xe6b0('0x57'),_0xe6b0('0x58'),_0xe6b0('0x59'),_0xe6b0('0x5a'),_0xe6b0('0x5b'),'contractidname',_0xe6b0('0x5c'),_0xe6b0('0x5d'),_0xe6b0('0x5e'),_0xe6b0('0x5f'),_0xe6b0('0x60'),'createdonbehalfbyname',_0xe6b0('0x61'),_0xe6b0('0x62'),_0xe6b0('0x63'),_0xe6b0('0x64'),'emailaddress','entitlementidname',_0xe6b0('0x65'),_0xe6b0('0x66'),_0xe6b0('0x67'),_0xe6b0('0x68'),_0xe6b0('0x69'),'followupby',_0xe6b0('0x6a'),_0xe6b0('0x6b'),_0xe6b0('0x6c'),_0xe6b0('0x6d'),_0xe6b0('0x6e'),_0xe6b0('0x6f'),_0xe6b0('0x70'),_0xe6b0('0x71'),_0xe6b0('0x72'),_0xe6b0('0x73'),'modifiedonbehalfbyname',_0xe6b0('0x74'),'msdyn_incidenttypename',_0xe6b0('0x75'),'numberofchildincidents',_0xe6b0('0x76'),'overriddencreatedon',_0xe6b0('0x77'),_0xe6b0('0x78'),_0xe6b0('0x79'),_0xe6b0('0x7a'),'primarycontactidname',_0xe6b0('0x7b'),_0xe6b0('0x7c'),'productidname',_0xe6b0('0x7d'),'resolveby','resolvebykpiidname',_0xe6b0('0x7e'),'responsiblecontactidname','responsiblecontactidyominame',_0xe6b0('0x7f'),_0xe6b0('0x80'),'slaname',_0xe6b0('0x81'),_0xe6b0('0x82'),_0xe6b0('0x83'),_0xe6b0('0x84'),'ticketnumber',_0xe6b0('0x85'),_0xe6b0('0x86'),_0xe6b0('0x87'),_0xe6b0('0x88'),_0xe6b0('0x89')];var _0x31a7d6=_0x5686f0[_0xe6b0('0x8a')](_0x3e3ae7);return db[_0xe6b0('0x17')]['findOne']({'where':{'id':_0x5b1dc6[_0xe6b0('0x30')]['id']},'attributes':['id',_0xe6b0('0x8b'),_0xe6b0('0x8c'),_0xe6b0('0x8d'),_0xe6b0('0x8e'),_0xe6b0('0x8f'),_0xe6b0('0x90'),_0xe6b0('0x91')],'include':[{'model':db[_0xe6b0('0x92')],'as':_0xe6b0('0x92'),'attributes':['id',_0xe6b0('0x93'),_0xe6b0('0x94')]}]})[_0xe6b0('0xd')](handleEntityNotFound(_0x55d0f8,null))['then'](function(_0x19d9c5){if(_0x19d9c5){if(_0x19d9c5[_0xe6b0('0x91')]){_0x19d9c5[_0xe6b0('0x95')]=_0x19d9c5[_0xe6b0('0x92')][_0xe6b0('0x93')];_0x4c8882=sanitizeRemoteUri(_0x19d9c5[_0xe6b0('0x92')]['data7']);_0x86c056=getWebApiUrl(_0x4c8882);return _0x19d9c5;}_0x4c8882=sanitizeRemoteUri(_0x19d9c5[_0xe6b0('0x8d')]);_0x86c056=getWebApiUrl(_0x4c8882);var _0x46c3f2={'method':'POST','uri':'https://login.microsoftonline.com/'+_0x19d9c5[_0xe6b0('0x8e')]+_0xe6b0('0x96'),'form':{'client_id':_0x19d9c5[_0xe6b0('0x8f')],'resource':_0x4c8882,'username':_0x19d9c5[_0xe6b0('0x8b')],'password':_0x19d9c5['password'],'grant_type':_0xe6b0('0x8c'),'client_secret':_0x19d9c5[_0xe6b0('0x90')]},'json':!![]};return rp(_0x46c3f2);}})[_0xe6b0('0xd')](function(_0x56e137){_0x4884bd=_0x56e137[_0xe6b0('0x95')];var _0x4dca18={'method':_0xe6b0('0x97'),'uri':encodeURI(_0x86c056+'EntityDefinitions?$select=DisplayName,EntitySetName&$filter=SchemaName\x20eq\x20\x27'+_0x493e9c+'\x27'),'headers':{'Authorization':_0xe6b0('0x98')+_0x4884bd,'If-None-Match':null,'OData-Version':_0xe6b0('0x99')},'json':!![]};return rp(_0x4dca18);})[_0xe6b0('0xd')](function(_0x49dbe8){var _0x54eec0=_0x49dbe8['value'][0x0];var _0xb951da=_0x54eec0[_0xe6b0('0x9a')];var _0x5d7fe5={'method':_0xe6b0('0x97'),'uri':_0x86c056+_0xe6b0('0x9b')+_0xb951da+')?$select=LogicalName&$expand=Attributes($select=LogicalName)','headers':{'Authorization':_0xe6b0('0x98')+_0x4884bd,'If-None-Match':null,'OData-Version':_0xe6b0('0x99')},'json':!![]};return rp(_0x5d7fe5);})['then'](function(_0x25dc01){_0x1ee6ad=_0x25dc01;_0x300713=_0x1ee6ad[_0xe6b0('0x9c')];_0x300713=_[_0xe6b0('0x9d')](_0x300713,function(_0x2a9907){return!_0x31a7d6[_0xe6b0('0x9e')](_0x2a9907[_0xe6b0('0x9f')]);});var _0x338898=[];var _0x5025e4=[];_0x300713[_0xe6b0('0xa0')](function(_0x295432){if(_0x295432[_0xe6b0('0xa1')]){var _0x2fc61c=_0x295432[_0xe6b0('0xa1')][_0xe6b0('0x44')](_0x295432[_0xe6b0('0xa1')]['lastIndexOf']('.')+0x1);if(_0x2fc61c==='PicklistAttributeMetadata'){_0x338898[_0xe6b0('0xa2')](getSelectList(_0x86c056,_0x187bfe,_0x5025e4,_0x1ee6ad[_0xe6b0('0x9a')],_0x295432[_0xe6b0('0x9a')],_0x4884bd));}}});return Promise['all'](_0x338898);})[_0xe6b0('0xd')](function(_0x203ac7){_0x5d6571=_0x203ac7[0x0];var _0x2a7e3d=[];var _0xca45e4=[];_0x300713[_0xe6b0('0xa0')](function(_0x104015){if(!_[_0xe6b0('0xa3')](_0x104015[_0xe6b0('0xa1')])){var _0x383827=_0x104015['@odata.type'][_0xe6b0('0x44')](_0x104015[_0xe6b0('0xa1')][_0xe6b0('0x45')]('.')+0x1);if(_0x383827===_0xe6b0('0xa4')){_0x2a7e3d[_0xe6b0('0xa2')](getBooleanList(_0x86c056,_0x187bfe,_0xca45e4,_0x1ee6ad['MetadataId'],_0x104015[_0xe6b0('0x9a')],_0x4884bd));}}});return Promise[_0xe6b0('0xa5')](_0x2a7e3d);})[_0xe6b0('0xd')](function(_0x2ece3d){_0x13b9f4=_0x2ece3d[0x0];var _0x18d23f=[];var _0x3727ce=[];_0x300713['forEach'](function(_0x468db2){if(_0x468db2['@odata.type']){var _0x561e73=_0x468db2['@odata.type'][_0xe6b0('0x44')](_0x468db2['@odata.type'][_0xe6b0('0x45')]('.')+0x1);if(_0x561e73==='StringAttributeMetadata'||_0x561e73==='DoubleAttributeMetadata'||_0x561e73===_0xe6b0('0xa6')||_0x561e73===_0xe6b0('0xa7')||_0x561e73===_0xe6b0('0xa8')||_0x561e73===_0xe6b0('0xa9')||_0x561e73===_0xe6b0('0xaa')||_0x561e73===_0xe6b0('0xab')||_0x561e73===_0xe6b0('0xac')||_0x561e73===_0xe6b0('0xad')){_0x18d23f['push'](getInputList(_0x86c056,_0x187bfe,_0x561e73,_0x3727ce,_0x1ee6ad[_0xe6b0('0x9a')],_0x468db2[_0xe6b0('0x9a')],_0x4884bd));}}});return Promise[_0xe6b0('0xa5')](_0x18d23f);})[_0xe6b0('0xd')](function(_0x2b0004){_0x1abbf4=_0x2b0004[0x0];var _0x21fdc4=_0x5d6571['concat'](_0x13b9f4)[_0xe6b0('0x8a')](_0x1abbf4);var _0x434d99={'count':_0x21fdc4['length'],'rows':_0x21fdc4};return _0x434d99;})[_0xe6b0('0xd')](respondWithResult(_0x55d0f8,null))['catch'](function(_0x47d57a){var _0x3f6d85=_0x5b1dc6[_0xe6b0('0x1c')][_0xe6b0('0xae')]?0x1f4:_0x47d57a[_0xe6b0('0xaf')]||0x1f4;logger['error'](_0x47d57a[_0xe6b0('0x12')]);delete _0x47d57a[_0xe6b0('0x13')];if(_0x3f6d85===0x191){_0x3f6d85=0x190;}_0x55d0f8[_0xe6b0('0x6')](_0x3f6d85)['send'](_0x5b1dc6[_0xe6b0('0x1c')][_0xe6b0('0xae')]?{'message':'Wrong\x20credentials','statusCode':_0x47d57a[_0xe6b0('0xaf')]}:_0x47d57a);});};function getSelectList(_0x52fa42,_0x557c25,_0x542777,_0x51d41c,_0x3a9bef,_0x3d188e){var _0x3d5600={'method':_0xe6b0('0x97'),'uri':_0x52fa42+_0xe6b0('0x9b')+_0x51d41c+_0xe6b0('0xb0')+_0x3a9bef+_0xe6b0('0xb1')+_0xe6b0('0xb2'),'headers':{'Authorization':_0xe6b0('0x98')+_0x3d188e,'If-None-Match':null,'OData-Version':_0xe6b0('0x99')},'json':!![]};return rp(_0x3d5600)[_0xe6b0('0xd')](function(_0x1e3c39){var _0x21898b=[];var _0x29e536=_0x1e3c39[_0xe6b0('0xb3')][_0xe6b0('0xb4')];_0x29e536['forEach'](function(_0x19268a){_0x21898b[_0xe6b0('0xa2')]({'name':_0x19268a[_0xe6b0('0xb5')]['UserLocalizedLabel'][_0xe6b0('0xb5')],'value':String(_0x19268a[_0xe6b0('0xb6')])});});var _0x29881e={'id':_0x557c25+'_'+_0x1e3c39[_0xe6b0('0x9f')],'name':_0x1e3c39[_0xe6b0('0xb7')][_0xe6b0('0xb8')][_0xe6b0('0xb5')],'custom':![],'options':_0x21898b};_0x542777[_0xe6b0('0xa2')](_0x29881e);return _0x542777;});}function getBooleanList(_0x4cacc2,_0x346667,_0x3a1533,_0x53e182,_0x4d90b5,_0x5ab339){var _0x42cc09={'method':_0xe6b0('0x97'),'uri':_0x4cacc2+_0xe6b0('0x9b')+_0x53e182+_0xe6b0('0xb0')+_0x4d90b5+_0xe6b0('0xb9'),'headers':{'Authorization':_0xe6b0('0x98')+_0x5ab339,'If-None-Match':null,'OData-Version':_0xe6b0('0x99')},'json':!![]};return rp(_0x42cc09)[_0xe6b0('0xd')](function(_0x380266){var _0x3f55c9=[];_0x3f55c9[_0xe6b0('0xa2')]({'name':_0x380266[_0xe6b0('0xb3')]['TrueOption'][_0xe6b0('0xb5')]['UserLocalizedLabel'][_0xe6b0('0xb5')],'value':_0xe6b0('0xba')},{'name':_0x380266['OptionSet'][_0xe6b0('0xbb')]['Label'][_0xe6b0('0xb8')][_0xe6b0('0xb5')],'value':'false'});var _0x143f4a={'id':_0x346667+'_'+_0x380266['LogicalName'],'name':_0x380266[_0xe6b0('0xb7')][_0xe6b0('0xb8')][_0xe6b0('0xb5')],'custom':![],'options':_0x3f55c9};_0x3a1533['push'](_0x143f4a);return _0x3a1533;});}function getInputList(_0x45632a,_0x5a1bbd,_0x18045a,_0x516fd2,_0x20c6c1,_0x3a9478,_0xc4f981){var _0x2d1836={'method':_0xe6b0('0x97'),'uri':_0x45632a+_0xe6b0('0x9b')+_0x20c6c1+_0xe6b0('0xb0')+_0x3a9478+_0xe6b0('0xbc')+_0x18045a+_0xe6b0('0xbd'),'headers':{'Authorization':'Bearer\x20'+_0xc4f981,'If-None-Match':null,'OData-Version':'4.0'},'json':!![]};return rp(_0x2d1836)[_0xe6b0('0xd')](function(_0x5c1cf7){var _0x2ceb66={'id':_0x5a1bbd+'_'+_0x5c1cf7['LogicalName'],'name':_0x5c1cf7['DisplayName'][_0xe6b0('0xb8')]?_0x5c1cf7['DisplayName']['UserLocalizedLabel']['Label']:_0x5c1cf7[_0xe6b0('0x9f')],'custom':![],'options':[]};_0x516fd2['push'](_0x2ceb66);return _0x516fd2;});}