add: getArchivedThreads

This commit is contained in:
ITOH
2021-05-02 18:20:57 +02:00
parent 28e407ca03
commit f0ea01b502
@@ -0,0 +1,24 @@
import { rest } from "../../../rest/rest.ts";
import { ListPublicArchivedThreads } from "../../../types/channels/threads/list_public_archived_threads.ts";
import { endpoints } from "../../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../../util/utils.ts";
export async function getArchivedThreads(
channelId: string,
options?: ListPublicArchivedThreads & {
type?: "public" | "private" | "privateJoinedThreads";
},
) {
// TODO(threads): perm check
// TODO(threads): check if this works
return await rest.runMethod(
"get",
options?.type === "privateJoinedThreads"
? endpoints.THREAD_ARCHIVED_PRIVATE_JOINED(channelId)
: options?.type === "private"
? endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
: endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
camelKeysToSnakeCase(options ?? {}),
);
}