hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import { client } from "../client"; |
| 2 | import type { Page, PageParams } from "../client"; |
| 3 | import type { Message, MessageFolder } from "../client"; |
| 4 | |
| 5 | export 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 | } |