mirror of
https://github.com/LukeHagar/discoursejs.git
synced 2025-12-06 04:19:37 +00:00
30 KiB
30 KiB
Categories
(categories)
Available Operations
- createCategory - Creates a category
- getCategory - Show category
- getSite - Get site info
- listCategories - Retrieves a list of categories
- listCategoryTopics - List topics
- updateCategory - Updates a category
createCategory
Creates a category
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.createCategory({
color: "49d9e9",
name: "<value>",
permissions: {
everyone: 1,
},
textColor: "f0fcfd",
});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateCategoryRequestBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.CreateCategoryResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
getCategory
Show category
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.getCategory(39147);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.GetCategoryResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
getSite
Can be used to fetch all categories and subcategories
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.getSite();
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.GetSiteResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
listCategories
Retrieves a list of categories
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.listCategories();
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
includeSubcategories |
boolean | ➖ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListCategoriesResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
listCategoryTopics
List topics
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.listCategoryTopics(394133, "<value>");
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
slug |
string | ✔️ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.ListCategoryTopicsResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
updateCategory
Updates a category
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.categories.updateCategory(353500, {
color: "49d9e9",
name: "<value>",
permissions: {
everyone: 1,
},
textColor: "f0fcfd",
});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
requestBody |
operations.UpdateCategoryRequestBody | ➖ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<operations.UpdateCategoryResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |