//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* List Webhooks
* Gets the list of all *webhooks* that the user owns (if a user-generated token was used to make the request) or the list of all webhooks associated with the third-party app (if a third-party app made the request). Items in the response are ordered by API cient name > webhook name > creation date.
*/
export async function main(
auth: Smartsheet,
includeAll: string | undefined,
page: string | undefined,
pageSize: string | undefined,
) {
const url = new URL(`${auth.baseUrl}/webhooks`);
for (const [k, v] of [
["includeAll", includeAll],
["page", page],
["pageSize", pageSize],
]) {
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