const locale = 'fr', format = 'json' , accompanying_period_id = window.accompanyingCourseId //tmp ; /* * Endpoint chill_person_accompanying_course_api_show * method GET, get AccompanyingCourse Object * * @accompanying_period_id___ integer * @TODO var is not used but necessary in method signature */ let getAccompanyingCourse = (accompanying_period_id___) => { //tmp const url = `/${locale}/person/api/1.0/accompanying-course/${accompanying_period_id}/show.${format}`; return fetch(url) .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 * * @accompanying_period_id integer - id of accompanyingCourse * @person_id integer - id of person * @method string - POST or DELETE */ let postParticipation = (accompanying_period_id, person_id, method) => { const url = `/api/1.0/person/accompanying-course/${accompanying_period_id}/participation.${format}` return fetch(url, { method: method, headers: { 'Content-Type': 'application/json;charset=utf-8' }, body: JSON.stringify({id: person_id}) }) .then(response => { if (response.ok) { return response.json(); } throw Error('Error with request resource response'); }); }; export { getAccompanyingCourse, postParticipation };