rdv: edit calendar ranges: add delete + doc swagger

This commit is contained in:
nobohan
2021-08-31 14:16:42 +02:00
parent bcb36ddc11
commit 25b85fcc68
8 changed files with 137 additions and 28 deletions

View File

@@ -38,12 +38,12 @@ const fetchCalendar = (mainUserId) => {
/*
* Endpoint chill_api_single_calendar_range__entity_create
* method POST or DELETE, post CalendarRange entity
* method POST, post CalendarRange entity
*/
const postCalendarRange = (body, method) => {
const postCalendarRange = (body) => {
const url = `/api/1.0/calendar/calendar-range.json?`;
return fetch(url, {
method: method,
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
@@ -73,11 +73,44 @@ const patchCalendarRange = (id, body) => {
});
};
/*
* Endpoint chill_api_single_calendar_range__entity
* method DELETE, delete CalendarRange entity
*/
const deleteCalendarRange = (id) => {
const url = `/api/1.0/calendar/calendar-range/${id}.json`;
return fetch(url, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
}).then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
// const deleteCalendarRange = (id) => {
// const url = `/api/1.0/calendar/calendar-range.json`;
// return fetch(url, {
// method: 'DELETE',
// headers: {
// 'Content-Type': 'application/json;charset=utf-8'
// },
// body: JSON.stringify({
// id: id
// })
// }).then(response => {
// if (response.ok) { return response.json(); }
// throw Error('Error with request resource response');
// });
// };
export {
fetchCalendarRanges,
fetchCalendar,
fetchCalendarRangesByUser,
postCalendarRange,
patchCalendarRange
patchCalendarRange,
deleteCalendarRange
};