Skip to content

Instantly share code, notes, and snippets.

@jorovipe97
Last active November 22, 2018 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorovipe97/f1bede2f4e2e029ac00fc9c4f73b3c48 to your computer and use it in GitHub Desktop.
Save jorovipe97/f1bede2f4e2e029ac00fc9c4f73b3c48 to your computer and use it in GitHub Desktop.
Test method for tour.telemedellin micrositio
// request generator
function create_req(method, url, bodyObj)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open(method, url);
// Gets the parsed data from the request body. Only for the POST/PUT/DELETE methods.
xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xmlhttp.setRequestHeader('Content-Type', 'text/json; charset=UTF-8');
xmlhttp.onload = function () {
console.log(xmlhttp.responseText);
};
var body = JSON.stringify(bodyObj);
xmlhttp.send(body);
}
// /api/ping/
var body = {
firstname: 'Jose',
lastname: 'Romualdo',
email: 'foo@land.com',
body: 'Hi xd how are you'
};
create_req('GET', '/api/ping/', null);
// /api/contact/
var body = {
firstname: 'Jose',
lastname: 'Romualdo',
email: 'foo@land.com',
body: 'Hi xd how are you'
};
create_req('POST', '/api/contact/', body);
// /api/newsletter/
var body = {
email: 'fooland@email.com'
}
create_req('POST', '/api/newsletter/', body);
// /api/availability/days/{month}/{year}/
create_req('GET', '/api/availability/days/12/2018/', null);
// /api/availability/all/
create_req('GET', '/api/availability/all/', null);
// '/api/availability/'
var body = {
date: (new Date()).toGMTString(),
start: (new Date()).toGMTString(),
capacity: '10'
};
create_req('POST', '/api/availability/', body);
create_req('GET', '/api/availability/delete/some_fake_id/', null);
// '/api/booking/'
// no fields are required
var body = {
availabilityID: '18111915280014hwm0'
};
create_req('POST', '/api/booking/', body);
// '/api/user/'
var body = {
uid: '6969696969',
email: 'foo@email.com'
};
create_req('POST', '/api/user/', body);
create_req('GET', '/api/user/"18042020190002lcw0"/', null);
// The cardcode here is not required
create_req('GET', '/api/user/card/SOMECODE/', null);
// In the following queries the ID is not important because we only want to know whether the server is responding or not
// MAIL
create_req('GET', '/api/user/mail/', null);
create_req('GET', '/api/user/mailok/some_user_id/', null);
// SURVEY
create_req('GET', '/api/user/survey/', null);
create_req('GET', '/api/user/surveyok/some_user_id/', null);
// ASSIST
create_req('GET', '/api/booking/assistusr/', null);
create_req('GET', '/api/booking/assistusrok/some_user_id/', null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment