Files
discoursejs/docs/sdks/badges/README.md

353 lines
27 KiB
Markdown

# Badges
(*badges*)
## Overview
### Available Operations
* [adminListBadges](#adminlistbadges) - List badges
* [createBadge](#createbadge) - Create badge
* [deleteBadge](#deletebadge) - Delete badge
* [listUserBadges](#listuserbadges) - List badges for a user
* [updateBadge](#updatebadge) - Update badge
## adminListBadges
List badges
### Example Usage
```typescript
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.badges.adminListBadges();
// Handle the result
console.log(result)
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { badgesAdminListBadges } from "@lukehagar/discoursejs/funcs/badgesAdminListBadges.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 badgesAdminListBadges(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 | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[operations.AdminListBadgesResponseBody](../../sdk/models/operations/adminlistbadgesresponsebody.md)\>**
### Errors
| Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx | */* |
## createBadge
Create badge
### Example Usage
```typescript
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.badges.createBadge();
// Handle the result
console.log(result)
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { badgesCreateBadge } from "@lukehagar/discoursejs/funcs/badgesCreateBadge.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 badgesCreateBadge(sdk);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.CreateBadgeRequestBody](../../sdk/models/operations/createbadgerequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[operations.CreateBadgeResponseBody](../../sdk/models/operations/createbadgeresponsebody.md)\>**
### Errors
| Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx | */* |
## deleteBadge
Delete badge
### Example Usage
```typescript
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
await sdk.badges.deleteBadge(32345);
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { badgesDeleteBadge } from "@lukehagar/discoursejs/funcs/badgesDeleteBadge.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 badgesDeleteBadge(sdk, 32345);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id` | *number* | :heavy_check_mark: | N/A |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<void\>**
### Errors
| Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx | */* |
## listUserBadges
List badges for a user
### Example Usage
```typescript
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.badges.listUserBadges("Faustino28");
// Handle the result
console.log(result)
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { badgesListUserBadges } from "@lukehagar/discoursejs/funcs/badgesListUserBadges.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 badgesListUserBadges(sdk, "Faustino28");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `username` | *string* | :heavy_check_mark: | N/A |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[operations.ListUserBadgesResponseBody](../../sdk/models/operations/listuserbadgesresponsebody.md)\>**
### Errors
| Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx | */* |
## updateBadge
Update badge
### Example Usage
```typescript
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.badges.updateBadge(280628);
// Handle the result
console.log(result)
}
run();
```
### Standalone function
The standalone function version of this method:
```typescript
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { badgesUpdateBadge } from "@lukehagar/discoursejs/funcs/badgesUpdateBadge.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 badgesUpdateBadge(sdk, 280628);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
```
### Parameters
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id` | *number* | :heavy_check_mark: | N/A |
| `requestBody` | [operations.UpdateBadgeRequestBody](../../sdk/models/operations/updatebadgerequestbody.md) | :heavy_minus_sign: | N/A |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
### Response
**Promise\<[operations.UpdateBadgeResponseBody](../../sdk/models/operations/updatebadgeresponsebody.md)\>**
### Errors
| Error Object | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.SDKError | 4xx-5xx | */* |