gancio-upstream/plugins/api.js

37 lines
844 B
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],
* limit: (default )
* }
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: {
start: params.start,
end: params.end,
places: params.places && params.places.join(','),
2021-01-11 00:17:56 +01:00
tags: params.tags && params.tags.join(','),
2021-04-14 01:33:01 +02:00
show_recurrent: !!params.show_recurrent
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
}