requestor logic, is_anonymous patch request

This commit is contained in:
2021-05-12 14:49:26 +02:00
parent 0d6a339b53
commit 4fb487dcef
3 changed files with 67 additions and 26 deletions

View File

@@ -13,6 +13,29 @@ const getAccompanyingCourse = (id) => {
});
};
/*
* Endpoint v.2 chill_api_single_accompanying_course__entity
* method PATCH, patch AccompanyingCourse Instance
*
* @id integer - id of accompanyingCourse
* @body Object - dictionary with changes to post
*/
const patchAccompanyingCourse = (id, body) => {
console.log('body', body);
const url = `/api/1.0/person/accompanying-course/${id}.json`;
return fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
})
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
* Endpoint v.2 chill_api_single_accompanying_course_participation,
* method POST/DELETE, add/close a participation to the accompanyingCourse
@@ -50,7 +73,7 @@ const postRequestor = (id, payload, method) => {
const typeId = `${payload.result.type}_id`;
body[typeId] = payload.result[typeId];
};
console.log(body);
console.log('body', body);
const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`;
return fetch(url, {
method: method,
@@ -66,7 +89,8 @@ const postRequestor = (id, payload, method) => {
};
export {
getAccompanyingCourse,
getAccompanyingCourse,
patchAccompanyingCourse,
postParticipation,
postRequestor
};