# 2sucres-api

> Wrapper Node.JS autour de l'API 2sucres

Latest version **1.1.2** (published 2018-12-31) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install 2sucres-api
pnpm add 2sucres-api
yarn add 2sucres-api
bun add 2sucres-api
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-12-31 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 258.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | taigah.dev |

## Links

- npm: https://www.npmjs.com/package/2sucres-api
- Repository: https://github.com/taigah/2sucres-api
- npm.io page: https://npm.io/package/2sucres-api

## Dependencies (4)

- [ow](https://npm.io/package/ow.md) ^0.8.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [request](https://npm.io/package/request.md) ^2.88.0
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.5

## Recent versions

- 1.1.2 (latest) — 2018-12-31
- 1.1.1 — 2018-12-31
- 1.1.0 — 2018-12-29
- 1.0.3 — 2018-12-19
- 1.0.2 — 2018-12-18
- 1.0.1 — 2018-12-18
- 1.0.0 — 2018-12-18
- 0.0.2 — 2018-12-17
- 0.0.1 — 2018-07-22

## README

# 2sucres-api

## Installation

```bash
yarn add 2sucres-api
```

## Utilisation

```javascript
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

<dl>
<dt><a href="#clearNotifications">clearNotifications()</a></dt>
<dd><p>Supprime les notifications</p>
</dd>
<dt><a href="#deleteTopic">deleteTopic(topicId)</a></dt>
<dd><p>Supprime un topic</p>
</dd>
<dt><a href="#editMessage">editMessage(messageId, content)</a></dt>
<dd><p>Édite un message</p>
</dd>
<dt><a href="#getMessage">getMessage(messageId)</a> ⇒ <code>message</code></dt>
<dd><p>Récupère les informations d&#39;un message par son id</p>
</dd>
<dt><a href="#getMessages">getMessages(topicId, page)</a> ⇒ <code>Array.&lt;message&gt;</code></dt>
<dd><p>Retourne la liste des messages d&#39;une page d&#39;un topic</p>
</dd>
<dt><a href="#getNotifications">getNotifications(clear)</a></dt>
<dd><p>Récupère la liste des notifications</p>
</dd>
<dt><a href="#getTopicEnd">getTopicEnd(topicId)</a></dt>
<dd><p>Récupère la fin du topic</p>
</dd>
<dt><a href="#getTopic">getTopic(topicId, page)</a> ⇒ <code>topic</code></dt>
<dd><p>Récupère les informations d&#39;un topic</p>
</dd>
<dt><a href="#getTopics">getTopics(page, forumId)</a> ⇒ <code>Array.&lt;topic&gt;</code></dt>
<dd><p>Récupère la liste des topics</p>
</dd>
<dt><a href="#lockTopic">lockTopic(topicId)</a></dt>
<dd><p>Lock un topic</p>
</dd>
<dt><a href="#postMessage">postMessage(topicId, content)</a></dt>
<dd><p>Poste un message</p>
</dd>
<dt><a href="#postTopic">postTopic(title, content, options)</a></dt>
<dd><p>Poste un topic</p>
</dd>
<dt><a href="#unlockTopic">unlockTopic(topicId)</a></dt>
<dd><p>Délock un topic</p>
</dd>
<dt><a href="#updateTitle">updateTitle(topicId, title)</a></dt>
<dd><p>Met à jour le titre d&#39;un topic</p>
</dd>
</dl>

<a name="clearNotifications"></a>

## clearNotifications()
Supprime les notifications

**Kind**: global function  
<a name="deleteTopic"></a>

## deleteTopic(topicId)
Supprime un topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 

<a name="editMessage"></a>

## editMessage(messageId, content)
Édite un message

**Kind**: global function  

| Param | Type |
| --- | --- |
| messageId | <code>number</code> | 
| content | <code>string</code> | 

<a name="getMessage"></a>

## getMessage(messageId) ⇒ <code>message</code>
Récupère les informations d'un message par son id

**Kind**: global function  

| Param | Type |
| --- | --- |
| messageId | <code>number</code> | 

<a name="getMessages"></a>

## getMessages(topicId, page) ⇒ <code>Array.&lt;message&gt;</code>
Retourne la liste des messages d'une page d'un topic

**Kind**: global function  

| Param | Type | Default |
| --- | --- | --- |
| topicId | <code>number</code> |  | 
| page | <code>number</code> | <code>1</code> | 

<a name="getNotifications"></a>

## getNotifications(clear)
Récupère la liste des notifications

**Kind**: global function  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| clear | <code>boolean</code> | <code>false</code> | si vrai, supprime les notifications après les avoir récupérées |

<a name="getTopicEnd"></a>

## getTopicEnd(topicId)
Récupère la fin du topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 

<a name="getTopic"></a>

## getTopic(topicId, page) ⇒ <code>topic</code>
Récupère les informations d'un topic

**Kind**: global function  

| Param | Type | Default |
| --- | --- | --- |
| topicId | <code>number</code> |  | 
| page | <code>number</code> | <code>1</code> | 

<a name="getTopics"></a>

## getTopics(page, forumId) ⇒ <code>Array.&lt;topic&gt;</code>
Récupère la liste des topics

**Kind**: global function  

| Param | Type | Default |
| --- | --- | --- |
| page | <code>number</code> | <code>1</code> | 
| forumId | <code>number</code> | <code>1</code> | 

<a name="lockTopic"></a>

## lockTopic(topicId)
Lock un topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 

<a name="postMessage"></a>

## postMessage(topicId, content)
Poste un message

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 
| content | <code>string</code> | 

<a name="postTopic"></a>

## postTopic(title, content, options)
Poste un topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| title | <code>string</code> | 
| content | <code>string</code> | 
| options | <code>object</code> | 

<a name="unlockTopic"></a>

## unlockTopic(topicId)
Délock un topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 

<a name="updateTitle"></a>

## updateTitle(topicId, title)
Met à jour le titre d'un topic

**Kind**: global function  

| Param | Type |
| --- | --- |
| topicId | <code>number</code> | 
| title | <code>string</code> |

---
_Source: https://npm.io/package/2sucres-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
