//native
/**
* Get Thread
* Get a whole Gmail conversation by thread ID (the `threadId` on any message), with every message in order. Use the `metadata` format to skip message bodies on long threads.
*/
export async function main(
auth: RT.Gmail,
thread_id: string,
format: "full" | "metadata" | "minimal" = "full"
) {
const url = new URL(
`https://gmail.googleapis.com/gmail/v1/users/me/threads/${thread_id}`
)
url.searchParams.append("format", format)
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago