//native
type Attio = {
token: string;
};
/**
* List threads
* List threads of comments on a record or list entry.
To view threads on records, you will need the `object_configuration:read` and `record_permission:read` scopes.
To view threads on list entries, you will need the `list_configuration:read` and `list_entry:read` scopes.
Required scopes: `comment:read`.
*/
export async function main(
auth: Attio,
record_id: string | undefined,
object: string | undefined,
entry_id: string | undefined,
list: string | undefined,
limit: string | undefined,
offset: string | undefined,
) {
const url = new URL(`https://api.attio.com/v2/threads`);
for (const [k, v] of [
["record_id", record_id],
["object", object],
["entry_id", entry_id],
["list", list],
["limit", limit],
["offset", offset],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago