Ressource: contacts (Ansprechpartner einer Adresse) #
Kontakte sind eine Unter-Ressource der Adresse (EULANDA-Tabelle Kontakt,
verknüpft über AdresseId). Sie nutzen die Adress-Scopes: Lesen mit
addresses:read, Schreiben mit addresses:write.
Endpunkte #
| Methode | Pfad | Zweck |
|---|---|---|
| GET | /api/v1/addresses/{addressId}/contacts | Liste (limit/offset, q, changedSince, fields) |
| GET | /api/v1/addresses/{addressId}/contacts/{id} | Einzelner Kontakt |
| POST | /api/v1/addresses/{addressId}/contacts | Anlegen (Pflichtfeld lastName) |
| PATCH | /api/v1/addresses/{addressId}/contacts/{id} | Felder ändern (partiell) |
| DELETE | /api/v1/addresses/{addressId}/contacts/{id} | Löschen |
Kontakte sind nur innerhalb ihrer Adresse erreichbar - ein Kontakt einer anderen Adresse liefert 404.
Felder (Glossar Entwurf) #
| API-Feld | DB-Spalte | Typ | Schreibbar |
|---|---|---|---|
id / uid / addressId | id / uid / AdresseId | int/guid/int | nein |
salutation | Anrede | string | ja |
title | Titel | string | ja |
firstName / lastName | Vorname / Nachname | string | ja (lastName Pflicht beim Anlegen) |
department | Abteilung | string | ja |
jobTitle | Funktion | string | ja |
room | Raum | string | ja |
phone / mobile / fax | Tel / Mobil / Fax | string | ja |
email | Email | string | ja |
website | Homepage | string | ja |
language | Sprache | string | ja |
birthday | Geburtstag | datetime | ja |
type | typ | string | ja (Default D = dienstlich) |
initials | Initialen | string | ja |
createdAt / changedAt | CreateDate / ChangeDate | datetime | nein |
Beispiele #
Kontakte listen:
$h = @{ Authorization = "Bearer $key" }
Invoke-RestMethod 'http://localhost:8100/api/v1/addresses/2/contacts' -Headers $h
curl.exe -H "Authorization: Bearer %KEY%" "http://localhost:8100/api/v1/addresses/2/contacts"
Anlegen:
$body = @{ lastName = 'Muster'; firstName = 'Max'; email = 'max@example.com'; jobTitle = 'Einkauf' } | ConvertTo-Json
Invoke-RestMethod 'http://localhost:8100/api/v1/addresses/2/contacts' `
-Method Post -Headers $h -ContentType 'application/json' -Body $body
curl.exe -X POST -H "Authorization: Bearer %KEY%" -H "Content-Type: application/json" -d "{ \"lastName\": \"Muster\", \"firstName\": \"Max\", \"email\": \"max@example.com\" }" "http://localhost:8100/api/v1/addresses/2/contacts"
Ändern und löschen:
$patch = @{ mobile = '0171 1234567' } | ConvertTo-Json
Invoke-RestMethod 'http://localhost:8100/api/v1/addresses/2/contacts/5' -Method Patch -Headers $h -ContentType 'application/json' -Body $patch
Invoke-RestMethod 'http://localhost:8100/api/v1/addresses/2/contacts/5' -Method Delete -Headers $h
curl.exe -X PATCH -H "Authorization: Bearer %KEY%" -H "Content-Type: application/json" -d "{ \"mobile\": \"0171 1234567\" }" "http://localhost:8100/api/v1/addresses/2/contacts/5"
curl.exe -X DELETE -H "Authorization: Bearer %KEY%" "http://localhost:8100/api/v1/addresses/2/contacts/5"
Hinweise #
- Delta-Sync wie bei Adressen über
?changedSince=;ChangeDatewird von der API beim Ändern gesetzt (die Tabelle hat keinen Trigger). - Kontakte haben in EULANDA ebenfalls Bild-Spalten (auch Visitenkarte); Bild-Endpunkte für Kontakte folgen bei Bedarf nach dem Muster der Bilder-Seite.