const { userID, authType, token, courseName } = inputData;
// Course name
var course = inputData.courseName;
var badgeID = 0;
// What are we using to compare to?
var OSD = "Optical System Design with Zemax OpticStudio";
var Tolerance = "Tolerancing with Zemax OpticStudio";
var Optimization = "Optimization with Zemax OpticStudio";
var Lasers = "Laser & Fiber with Zemax OpticStudio";
var ISL = "Illumination & Stray Light with Zemax OpticStudio";
// Compare course name to badge number to help generate URL
if (course == OSD) {
badgeID = 6;
} else if (course == Tolerance) {
badgeID = 9;
} else if (course == Optimization) {
badgeID = 10;
} else if (course == Lasers) {
badgeID = 8;
} else if (course == ISL) {
badgeID = 7;
}
// Set up authorization for the API request
var auth = inputData.authType + " " + inputData.token;
var URLBadge = 'http://api2-us-west-2.insided.com/user/' + inputData.userID + '/badge/' + badgeID;
console.log(URLBadge);
const userRequest = await fetch(URLBadge, {
method: 'PUT',
headers: {
'Accept': 'application/json',
'Authorization': auth,
'Content-Type': 'application/json'
},
}).then(function(response) {
return response.text();
}).then(function(responsebody) {
var output = {response: responsebody};
callback(null, output);
}).catch(function(error) {
callback(error);
});