//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* List All Automation Rules
* Returns all automation rules associated with the specified sheet.
Multistep workflows are not returned via the API.
Instead, you'll see an error 400 - 1266: This rule is not accessible through the API.
Only single-action notifications, approval requests, or update requests qualify.
For users of Smartsheet for Slack, note that Slack notifications are not returned.
*/
export async function main(
auth: Smartsheet,
sheetId: string,
includeAll: string | undefined,
page: string | undefined,
pageSize: string | undefined,
) {
const url = new URL(
`${auth.baseUrl}/sheets/${sheetId}/automationrules`,
);
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