mirror of
https://github.com/LukeHagar/discoursejs.git
synced 2025-12-06 04:19:37 +00:00
15 KiB
15 KiB
Invites
(invites)
Overview
Available Operations
- createInvite - Create an invite
- inviteToTopic - Invite to topic
createInvite
Create an invite
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.invites.createInvite("<value>", "<value>", {
email: "not-a-user-yet@example.com",
groupIds: "42,43",
groupNames: "foo,bar",
maxRedemptionsAllowed: 5,
});
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { invitesCreateInvite } from "@lukehagar/discoursejs/funcs/invitesCreateInvite.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 invitesCreateInvite(sdk, "<value>", "<value>", {
email: "not-a-user-yet@example.com",
groupIds: "42,43",
groupNames: "foo,bar",
maxRedemptionsAllowed: 5,
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey |
string | ✔️ | N/A |
apiUsername |
string | ✔️ | N/A |
requestBody |
operations.CreateInviteRequestBody | ➖ | 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.CreateInviteResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
inviteToTopic
Invite to topic
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.invites.inviteToTopic("<value>", "<value>", "<id>");
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { invitesInviteToTopic } from "@lukehagar/discoursejs/funcs/invitesInviteToTopic.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 invitesInviteToTopic(sdk, "<value>", "<value>", "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey |
string | ✔️ | N/A |
apiUsername |
string | ✔️ | N/A |
id |
string | ✔️ | N/A |
requestBody |
operations.InviteToTopicRequestBody | ➖ | 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.InviteToTopicResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |