2022-08-21 22:27:31 +02:00
|
|
|
import { request } from './request'
|
|
|
|
|
|
|
|
|
|
export type SensorInfo = {
|
2022-08-28 11:56:03 +02:00
|
|
|
id: number
|
|
|
|
|
name: string
|
|
|
|
|
authKey: string
|
2022-08-21 22:27:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getSensors = () => request<SensorInfo[]>('/api/sensors')
|
2022-08-28 11:56:03 +02:00
|
|
|
|
|
|
|
|
export const createSensor = (name: string) =>
|
|
|
|
|
request<SensorInfo>('/api/sensors', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'content-type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ name }),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export const updateSensor = (id: number, name: string) =>
|
|
|
|
|
request<SensorInfo>(`/api/sensors/${id}`, {
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
headers: { 'content-type': 'application/json' },
|
|
|
|
|
body: JSON.stringify({ name }),
|
|
|
|
|
})
|