gancio-upstream/plugins/api.js

41 lines
1 KiB
JavaScript
Raw Normal View History

2020-10-17 00:41:21 +02:00
2021-09-27 11:11:25 +02:00
export default ({ $axios }, inject) => {
2020-10-17 00:41:21 +02:00
const api = {
/**
* Get events
2020-11-13 00:13:44 +01:00
*
2020-10-17 00:41:21 +02:00
* filter: {
* start_datetime: unix_timestamp (default now)
* end_datetime: unix_timestamp
* tags: [tag, list],
* places: [place_id],
2022-05-31 15:29:52 +02:00
* max: (default )
2020-10-17 00:41:21 +02:00
* }
2020-11-13 00:13:44 +01:00
*
2020-10-17 00:41:21 +02:00
*/
async getEvents (params) {
try {
2020-11-13 00:13:44 +01:00
const events = await $axios.$get('/events', {
params: {
...params,
// start: params.start,
// end: params.end,
2020-11-13 00:13:44 +01:00
places: params.places && params.places.join(','),
2021-01-11 00:17:56 +01:00
tags: params.tags && params.tags.join(','),
// ...(params.show_recurrent !== && {show_recurrent: !!params.show_recurrent}),
// show_multidate: !!params.show_multidate,
// query: params.query,
// max: params.maxs
2020-11-13 00:13:44 +01:00
}
})
2021-01-11 00:17:56 +01:00
return events.map(e => Object.freeze(e))
2020-10-17 00:41:21 +02:00
} catch (e) {
console.error(e)
return []
}
}
}
inject('api', api)
2020-11-13 00:13:44 +01:00
}