Topics
Sujets de discussion via @ziwako/message — création, abonnement, messages, tendances.
La ressource Topic gère les sujets de discussion (threads thématiques) : création, liste, tendances, envoi de messages dans un sujet, abonnement et archivage.
- Factory :
getTopic()(@ziwako/message/axios) - Types :
CreateTopicBody,SendTopicMessageBody,SubscribeBody,ArchiveTopicBody,CreateTopic200,ListTopics200,GetTopicTrend200,SendTopicMessage200,Subscribe200,ArchiveTopic200 - Endpoints :
POST /topics,GET /topics,GET /topics/trending,POST /topics/{topicId}/messages,POST /topics/{topicId}/subscribe,GET /topics/{topicId}/archive
import { configure, getTopic } from '@ziwako/message/axios';
configure({ accessToken: '...' });
const topic = getTopic();createTopic
Crée un topic (sujet de discussion).
Signature : createTopic(createTopicBody?: CreateTopicBody) → Promise<CreateTopic200>
const response = await topic.createTopic({
name: 'Entraide devs RDC',
description: 'Discussions techniques pour les développeurs congolais',
owner: profilId,
});
console.log(response.data?.id);import { useCreateTopic } from '@ziwako/message/react-query';
const mutation = useCreateTopic();
mutation.mutate({ data: { name: 'Entraide devs RDC', owner: profilId } });listTopics
Liste les topics.
Signature : listTopics() → Promise<ListTopics200>
const list = await topic.listTopics();
console.log(list.data?.docs);import { useListTopics } from '@ziwako/message/react-query';
const { data } = useListTopics();getTopicTrend
Liste les topics tendances.
Signature : getTopicTrend() → Promise<GetTopicTrend200>
const trends = await topic.getTopicTrend();
console.log(trends.data);import { useGetTopicTrend } from '@ziwako/message/react-query';
const { data } = useGetTopicTrend();sendTopicMessage
Envoie un message dans un topic.
Signature : sendTopicMessage(topicId: string, sendTopicMessageBody?: SendTopicMessageBody) → Promise<SendTopicMessage200>
await topic.sendTopicMessage(topicId, {
title: 'Question rapide',
body: 'Quelqu\'un a déjà utilisé l\'API de paiement mobile ?',
type: 'chat',
owner: profilId,
});import { useSendTopicMessage } from '@ziwako/message/react-query';
const mutation = useSendTopicMessage();
mutation.mutate({
topicId,
data: { title: 'Question rapide', body: 'Question sur le paiement mobile ?', type: 'chat', owner: profilId },
});subscribe
Abonne un profil à un topic.
Signature : subscribe(topicId: string, subscribeBody?: SubscribeBody) → Promise<Subscribe200>
await topic.subscribe(topicId, { profilId: '64b8f2...' });import { useSubscribe } from '@ziwako/message/react-query';
const mutation = useSubscribe();
mutation.mutate({ topicId, data: { profilId: '64b8f2...' } });archiveTopic
Archive un topic (désactivation).
Signature : archiveTopic(topicId: string, archiveTopicBody?: ArchiveTopicBody) → Promise<ArchiveTopic200>
await topic.archiveTopic(topicId, { profilId: '64b8f2...' });import { useArchiveTopic } from '@ziwako/message/react-query';
const mutation = useArchiveTopic();
mutation.mutate({ topicId, data: { profilId: '64b8f2...' } });