mirror of
https://github.com/LukeHagar/discoursejs.git
synced 2025-12-06 12:27:48 +00:00
12 KiB
12 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";
async function run() {
const sdk = new SDK();
const res = await sdk.categories.createCategory({
color: "49d9e9",
formTemplateIds: [
"string",
],
name: "string",
permissions: {
"key": "string",
},
textColor: "f0fcfd",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateCategoryRequestBody | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.CreateCategoryResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
getCategory
Show category
Example Usage
import { SDK } from "@lukehagar/discoursejs";
import { GetCategoryRequest } from "@lukehagar/discoursejs/dist/sdk/models/operations";
async function run() {
const sdk = new SDK();
const id: number = 39147;
const res = await sdk.categories.getCategory(id);
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.GetCategoryResponse>
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";
async function run() {
const sdk = new SDK();
const res = await sdk.categories.getSite();
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.GetSiteResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
listCategories
Retrieves a list of categories
Example Usage
import { SDK } from "@lukehagar/discoursejs";
import { ListCategoriesRequest } from "@lukehagar/discoursejs/dist/sdk/models/operations";
async function run() {
const sdk = new SDK();
const includeSubcategories: boolean = false;
const res = await sdk.categories.listCategories(includeSubcategories);
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
includeSubcategories |
boolean | ➖ | N/A |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.ListCategoriesResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
listCategoryTopics
List topics
Example Usage
import { SDK } from "@lukehagar/discoursejs";
import { ListCategoryTopicsRequest } from "@lukehagar/discoursejs/dist/sdk/models/operations";
async function run() {
const sdk = new SDK();
const id: number = 394133;
const slug: string = "string";
const res = await sdk.categories.listCategoryTopics(id, slug);
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
slug |
string | ✔️ | N/A |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.ListCategoryTopicsResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
updateCategory
Updates a category
Example Usage
import { SDK } from "@lukehagar/discoursejs";
import { UpdateCategoryRequest, UpdateCategoryRequestBody } from "@lukehagar/discoursejs/dist/sdk/models/operations";
async function run() {
const sdk = new SDK();
const id: number = 353500;
const requestBody: UpdateCategoryRequestBody = {
color: "49d9e9",
formTemplateIds: [
"string",
],
name: "string",
permissions: {
"key": "string",
},
textColor: "f0fcfd",
};
const res = await sdk.categories.updateCategory(id, requestBody);
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | ✔️ | N/A |
requestBody |
operations.UpdateCategoryRequestBody | ➖ | N/A |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Response
Promise<operations.UpdateCategoryResponse>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |