Files
discoursejs/docs/sdks/categories

Categories

(categories)

Overview

Available Operations

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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesCreateCategory } from "@lukehagar/discoursejs/funcs/categoriesCreateCategory.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesCreateCategory(sdk, {
    color: "49d9e9",
    name: "<value>",
    permissions: {
      everyone: 1,
    },
    textColor: "f0fcfd",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesGetCategory } from "@lukehagar/discoursejs/funcs/categoriesGetCategory.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesGetCategory(sdk, 687295);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesGetSite } from "@lukehagar/discoursejs/funcs/categoriesGetSite.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesGetSite(sdk);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesListCategories } from "@lukehagar/discoursejs/funcs/categoriesListCategories.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesListCategories(sdk);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesListCategoryTopics } from "@lukehagar/discoursejs/funcs/categoriesListCategoryTopics.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesListCategoryTopics(sdk, 671891, "<value>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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();

Standalone function

The standalone function version of this method:

import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { categoriesUpdateCategory } from "@lukehagar/discoursejs/funcs/categoriesUpdateCategory.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();

async function run() {
  const res = await categoriesUpdateCategory(sdk, 999337, {
    color: "49d9e9",
    name: "<value>",
    permissions: {
      everyone: 1,
    },
    textColor: "f0fcfd",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // 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 /