FEAT-2: typed CRUD API clients for enclosures + contacts

This commit is contained in:
2026-06-06 00:07:01 +02:00
parent 12e787671c
commit a1d02c0d4e
2 changed files with 67 additions and 0 deletions

View File

@@ -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<CreateContact>
export function listContactsPaged(query: GridifyQuery): Promise<Paged<Contact>> {
return api.get<Paged<Contact>>(`${resources.contacts}${toQueryString(query)}`)
}
export function getContact(id: string): Promise<Contact> {
return api.get<Contact>(`${resources.contacts}/${id}`)
}
export function createContact(body: CreateContact): Promise<Contact> {
return api.post<Contact>(resources.contacts, body)
}
export function updateContact(id: string, body: UpdateContact): Promise<Contact> {
return api.put<Contact>(`${resources.contacts}/${id}`, body)
}
export function deleteContact(id: string): Promise<void> {
return api.delete(`${resources.contacts}/${id}`)
}