README
2sucres-api
Installation
yarn add 2sucres-api
Utilisation
const apiFactory = require('2sucres-api')
const api = apiFactory(cookies, csrfToken)
const TOPIC_ID = 1
const MESSAGE_ID = 1
/**
* Récupère le nombre de messages d'un topic
* et l'indique dans le message original du topic
*/
async function run () {
const topic = await api.getTopic(TOPIC_ID)
const messageCount = topic.messageCount
await api.editMessage(MESSAGE_ID, `Le topic contient ${messageCount} message(s)`)
}
run().catch(err => {
// global error handling
console.error(err.stack)
process.exit(1)
})
API
Functions
- clearNotifications()
Supprime les notifications
- deleteTopic(topicId)
Supprime un topic
- editMessage(messageId, content)
Édite un message
- getMessage(messageId) ⇒
message
Récupère les informations d'un message par son id
- getMessages(topicId, page) ⇒
Array.<message>
Retourne la liste des messages d'une page d'un topic
- getNotifications(clear)
Récupère la liste des notifications
- getTopicEnd(topicId)
Récupère la fin du topic
- getTopic(topicId, page) ⇒
topic
Récupère les informations d'un topic
- getTopics(page, forumId) ⇒
Array.<topic>
Récupère la liste des topics
- lockTopic(topicId)
Lock un topic
- postMessage(topicId, content)
Poste un message
- postTopic(title, content, options)
Poste un topic
- unlockTopic(topicId)
Délock un topic
- updateTitle(topicId, title)
Met à jour le titre d'un topic
clearNotifications()
Supprime les notifications
deleteTopic(topicId)
Supprime un topic
Kind: global function
Param | Type |
---|---|
topicId | number |
editMessage(messageId, content)
Édite un message
Kind: global function
Param | Type |
---|---|
messageId | number |
content | string |
message
getMessage(messageId) ⇒ Récupère les informations d'un message par son id
Kind: global function
Param | Type |
---|---|
messageId | number |
Array.<message>
getMessages(topicId, page) ⇒ Retourne la liste des messages d'une page d'un topic
Kind: global function
Param | Type | Default |
---|---|---|
topicId | number |
|
page | number |
1 |
getNotifications(clear)
Récupère la liste des notifications
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
clear | boolean |
false |
si vrai, supprime les notifications après les avoir récupérées |
getTopicEnd(topicId)
Récupère la fin du topic
Kind: global function
Param | Type |
---|---|
topicId | number |
topic
getTopic(topicId, page) ⇒ Récupère les informations d'un topic
Kind: global function
Param | Type | Default |
---|---|---|
topicId | number |
|
page | number |
1 |
Array.<topic>
getTopics(page, forumId) ⇒ Récupère la liste des topics
Kind: global function
Param | Type | Default |
---|---|---|
page | number |
1 |
forumId | number |
1 |
lockTopic(topicId)
Lock un topic
Kind: global function
Param | Type |
---|---|
topicId | number |
postMessage(topicId, content)
Poste un message
Kind: global function
Param | Type |
---|---|
topicId | number |
content | string |
postTopic(title, content, options)
Poste un topic
Kind: global function
Param | Type |
---|---|
title | string |
content | string |
options | object |
unlockTopic(topicId)
Délock un topic
Kind: global function
Param | Type |
---|---|
topicId | number |
updateTitle(topicId, title)
Met à jour le titre d'un topic
Kind: global function
Param | Type |
---|---|
topicId | number |
title | string |