mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
adapt api endpoint, resolve id parameter passed in api functions
This commit is contained in:
parent
43f3270171
commit
dcd1856ebb
@ -1,18 +1,11 @@
|
|||||||
const
|
|
||||||
locale = 'fr',
|
|
||||||
format = 'json'
|
|
||||||
, accompanying_period_id = window.accompanyingCourseId //tmp
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_person_accompanying_course_api_show
|
* Endpoint v.2 chill_api_single_accompanying_course__entity
|
||||||
* method GET, get AccompanyingCourse Object
|
* method GET/HEAD, get AccompanyingCourse Instance
|
||||||
*
|
*
|
||||||
* @accompanying_period_id___ integer
|
* @id integer - id of accompanyingCourse
|
||||||
* @TODO var is not used but necessary in method signature
|
|
||||||
*/
|
*/
|
||||||
let getAccompanyingCourse = (accompanying_period_id___) => { //tmp
|
let getAccompanyingCourse = (id) => { //tmp
|
||||||
const url = `/${locale}/person/api/1.0/accompanying-course/${accompanying_period_id}/show.${format}`;
|
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@ -24,12 +17,12 @@ let getAccompanyingCourse = (accompanying_period_id___) => { //tmp
|
|||||||
* Endpoint v.2 chill_api_single_accompanying_course_participation,
|
* Endpoint v.2 chill_api_single_accompanying_course_participation,
|
||||||
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
||||||
*
|
*
|
||||||
* @accompanying_period_id integer - id of accompanyingCourse
|
* @id integer - id of accompanyingCourse
|
||||||
* @person_id integer - id of person
|
* @person_id integer - id of person
|
||||||
* @method string - POST or DELETE
|
* @method string - POST or DELETE
|
||||||
*/
|
*/
|
||||||
let postParticipation = (accompanying_period_id, person_id, method) => {
|
let postParticipation = (id, person_id, method) => {
|
||||||
const url = `/api/1.0/person/accompanying-course/${accompanying_period_id}/participation.${format}`
|
const url = `/api/1.0/person/accompanying-course/${id}/participation.json`
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: method,
|
method: method,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -3,8 +3,7 @@ import { createStore } from 'vuex';
|
|||||||
import { getAccompanyingCourse, postParticipation } from '../api';
|
import { getAccompanyingCourse, postParticipation } from '../api';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
const id = window.accompanyingCourseId;
|
||||||
const id = window.accompanyingCourseId; //tmp
|
|
||||||
|
|
||||||
let initPromise = getAccompanyingCourse(id)
|
let initPromise = getAccompanyingCourse(id)
|
||||||
.then(accompanying_course => new Promise((resolve, reject) => {
|
.then(accompanying_course => new Promise((resolve, reject) => {
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
const
|
|
||||||
locale = 'fr',
|
|
||||||
format = 'json'
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_person_search, method GET, get a list of persons
|
* Endpoint chill_person_search
|
||||||
|
* method GET, get a list of persons
|
||||||
*
|
*
|
||||||
* @query string - the query to search for
|
* @query string - the query to search for
|
||||||
*/
|
*/
|
||||||
let searchPersons = ({ query, options }) => {
|
let searchPersons = ({ query, options }) => {
|
||||||
console.log('options 2', options);
|
console.log('options', options);
|
||||||
let url = `/${locale}/search.${format}?name=person_regular&q=${query}`;
|
let url = `/fr/search.json?name=person_regular&q=${query}`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@ -18,4 +14,22 @@ let searchPersons = ({ query, options }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export { searchPersons };
|
/*
|
||||||
|
* Endpoint v.2 chill_main_search_global
|
||||||
|
* method GET, get a list of persons and thirdparty
|
||||||
|
*
|
||||||
|
* NOTE: this is a temporary WIP endpoint, return inconsistent random results
|
||||||
|
* @query string - the query to search for
|
||||||
|
*/
|
||||||
|
let searchPersons_2 = ({ query, options }) => {
|
||||||
|
console.log('options', options);
|
||||||
|
let url = `/api/1.0/search.json?q=${query}`
|
||||||
|
return fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export { searchPersons, searchPersons_2 };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user