mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 01:13:55 +00:00
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import axios from 'axios';
|
|
import { URLPreset } from 'ontime-types';
|
|
|
|
import { apiEntryUrl } from './constants';
|
|
import type { RequestOptions } from './requestOptions';
|
|
|
|
const urlPresetsPath = `${apiEntryUrl}/url-presets`;
|
|
|
|
/**
|
|
* HTTP request to retrieve all presets
|
|
*/
|
|
export async function getUrlPresets(options?: RequestOptions): Promise<URLPreset[]> {
|
|
const res = await axios.get(urlPresetsPath, { signal: options?.signal });
|
|
return res.data;
|
|
}
|
|
|
|
/**
|
|
* HTTP request to add a preset
|
|
*/
|
|
export async function postUrlPreset(data: URLPreset): Promise<URLPreset[]> {
|
|
return (await axios.post(urlPresetsPath, data)).data;
|
|
}
|
|
|
|
/**
|
|
* HTTP request to edit a preset
|
|
*/
|
|
export async function putUrlPreset(alias: string, data: URLPreset): Promise<URLPreset[]> {
|
|
return (await axios.put(`${urlPresetsPath}/${alias}`, data)).data;
|
|
}
|
|
|
|
/**
|
|
* HTTP request to delete a preset
|
|
*/
|
|
export async function deleteUrlPreset(alias: string): Promise<URLPreset[]> {
|
|
return (await axios.delete(`${urlPresetsPath}/${alias}`)).data;
|
|
}
|