From a1d02c0d4e5575f5ad66ca48c6221671b5949f49 Mon Sep 17 00:00:00 2001 From: Gulum Date: Sat, 6 Jun 2026 00:07:01 +0200 Subject: [PATCH] FEAT-2: typed CRUD API clients for enclosures + contacts --- gerbil-manager-web/src/api/contacts.ts | 34 ++++++++++++++++++++++++ gerbil-manager-web/src/api/enclosures.ts | 33 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 gerbil-manager-web/src/api/contacts.ts create mode 100644 gerbil-manager-web/src/api/enclosures.ts diff --git a/gerbil-manager-web/src/api/contacts.ts b/gerbil-manager-web/src/api/contacts.ts new file mode 100644 index 0000000..cbfa0be --- /dev/null +++ b/gerbil-manager-web/src/api/contacts.ts @@ -0,0 +1,34 @@ +/** Typed API functions for the Kontakte (Contact) resource. (FEAT-2) */ +import { api, resources } from './client' +import { toQueryString, type GridifyQuery } from './gridify' +import type { Contact, Paged } from './types' + +/** Payload for POST /contacts. */ +export interface CreateContact { + name: string + contactInfo?: string | null + notes?: string | null +} + +/** Payload for PUT /contacts/{id}. */ +export type UpdateContact = Partial + +export function listContactsPaged(query: GridifyQuery): Promise> { + return api.get>(`${resources.contacts}${toQueryString(query)}`) +} + +export function getContact(id: string): Promise { + return api.get(`${resources.contacts}/${id}`) +} + +export function createContact(body: CreateContact): Promise { + return api.post(resources.contacts, body) +} + +export function updateContact(id: string, body: UpdateContact): Promise { + return api.put(`${resources.contacts}/${id}`, body) +} + +export function deleteContact(id: string): Promise { + return api.delete(`${resources.contacts}/${id}`) +} diff --git a/gerbil-manager-web/src/api/enclosures.ts b/gerbil-manager-web/src/api/enclosures.ts new file mode 100644 index 0000000..abd372a --- /dev/null +++ b/gerbil-manager-web/src/api/enclosures.ts @@ -0,0 +1,33 @@ +/** Typed API functions for the Becken (Enclosure) resource. (FEAT-2) */ +import { api, resources } from './client' +import { toQueryString, type GridifyQuery } from './gridify' +import type { Enclosure, Paged } from './types' + +/** Payload for POST /enclosures. */ +export interface CreateEnclosure { + name: string + notes?: string | null +} + +/** Payload for PUT /enclosures/{id}. */ +export type UpdateEnclosure = Partial + +export function listEnclosuresPaged(query: GridifyQuery): Promise> { + return api.get>(`${resources.enclosures}${toQueryString(query)}`) +} + +export function getEnclosure(id: string): Promise { + return api.get(`${resources.enclosures}/${id}`) +} + +export function createEnclosure(body: CreateEnclosure): Promise { + return api.post(resources.enclosures, body) +} + +export function updateEnclosure(id: string, body: UpdateEnclosure): Promise { + return api.put(`${resources.enclosures}/${id}`, body) +} + +export function deleteEnclosure(id: string): Promise { + return api.delete(`${resources.enclosures}/${id}`) +}