forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

getMessages.ts18 lines, 716 bytesHistoryRawDownload
1import { client } from "../client";
2import type { Page, PageParams } from "../client";
3import type { Message, MessageFolder } from "../client";
4
5export function getMessages(
6 folder: MessageFolder = "inbox",
7 options?: PageParams & { read?: boolean }
8): Promise<Page<Message>> {
9 const params = new URLSearchParams();
10 params.set("folder", folder);
11 if (options?.read !== undefined) params.set("read", String(options.read));
12 if (options?.limit !== undefined) params.set("limit", String(options.limit));
13 if (options?.offset !== undefined) params.set("offset", String(options.offset));
14
15 const q = params.toString();
16 const url = q ? `/messages?${q}` : `/messages`;
17 return client<Page<Message>>(url);
18}