Ziwako ContactGuide développeurSDK @ziwako/contact
Labels
Labels de catégorisation des contacts via @ziwako/contact — CRUD.
La ressource Labels gère les labels de catégorisation des contacts (ex. : « Client »,
« Fournisseur », « Partenaire »). Les labels sont réutilisables : un même label peut être
affecté à plusieurs contacts (voir assignContactLabels).
- Factory :
getLabels()(@ziwako/contact/axios) - Types :
CreateLabelBody,UpdateLabelBody,ListLabels200,CreateLabel201,UpdateLabel200,DeleteLabel200 - Endpoints :
GET /labels,POST /labels,PUT /labels/{id},DELETE /labels/{id}
import { configure, getLabels } from '@ziwako/contact/axios';
configure({ accessToken: '...' });
const labels = getLabels();listLabels
Liste les labels de l'utilisateur.
Signature : listLabels() → Promise<ListLabels200>
const list = await labels.listLabels();
console.log(list.data?.docs);import { useListLabels } from '@ziwako/contact/react-query';
const { data } = useListLabels();createLabel
Crée un label.
Signature : createLabel(createLabelBody?: CreateLabelBody) → Promise<CreateLabel201>
const response = await labels.createLabel({
name: 'VIP',
color: '#1d4ed8',
});
console.log(response.data?.id);import { useCreateLabel } from '@ziwako/contact/react-query';
const mutation = useCreateLabel();
mutation.mutate({ data: { name: 'VIP', color: '#1d4ed8' } });updateLabel
Met à jour un label (nom, couleur).
Signature : updateLabel(id: string, updateLabelBody?: UpdateLabelBody) → Promise<UpdateLabel200>
await labels.updateLabel(labelId, { name: 'Client VIP', color: '#ea580c' });import { useUpdateLabel } from '@ziwako/contact/react-query';
const mutation = useUpdateLabel();
mutation.mutate({ id: labelId, data: { name: 'Client VIP' } });deleteLabel
Supprime un label (les contacts conservent leurs autres labels).
Signature : deleteLabel(id: string) → Promise<DeleteLabel200>
await labels.deleteLabel(labelId);import { useDeleteLabel } from '@ziwako/contact/react-query';
const mutation = useDeleteLabel();
mutation.mutate({ id: labelId });