mirror of
https://github.com/LukeHagar/discoursejs.git
synced 2025-12-06 04:19:37 +00:00
PrivateMessages
(privateMessages)
Overview
Available Operations
- createTopicPostPM - Creates a new topic, a new post, or a private message
- getUserSentPrivateMessages - Get a list of private messages sent for a user
- listUserPrivateMessages - Get a list of private messages for a user
createTopicPostPM
Creates a new topic, a new post, or a private message
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.privateMessages.createTopicPostPM({
archetype: "private_message",
raw: "<value>",
targetRecipients: "blake,sam",
});
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { privateMessagesCreateTopicPostPM } from "@lukehagar/discoursejs/funcs/privateMessagesCreateTopicPostPM.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 privateMessagesCreateTopicPostPM(sdk, {
archetype: "private_message",
raw: "<value>",
targetRecipients: "blake,sam",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateTopicPostPMRequestBody | ✔️ | 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.CreateTopicPostPMResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
getUserSentPrivateMessages
Get a list of private messages sent for a user
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.privateMessages.getUserSentPrivateMessages("Nathanial38");
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { privateMessagesGetUserSentPrivateMessages } from "@lukehagar/discoursejs/funcs/privateMessagesGetUserSentPrivateMessages.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 privateMessagesGetUserSentPrivateMessages(sdk, "Nathanial38");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
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.GetUserSentPrivateMessagesResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |
listUserPrivateMessages
Get a list of private messages for a user
Example Usage
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.privateMessages.listUserPrivateMessages("Liliana_West71");
// Handle the result
console.log(result)
}
run();
Standalone function
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { privateMessagesListUserPrivateMessages } from "@lukehagar/discoursejs/funcs/privateMessagesListUserPrivateMessages.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 privateMessagesListUserPrivateMessages(sdk, "Liliana_West71");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
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.ListUserPrivateMessagesResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4xx-5xx | / |