//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Delete Favorite
* Deletes a single favorite from the user's list of favorite items by type and ID.
*/
export async function main(
auth: Smartsheet,
favoriteType:
| "folder"
| "report"
| "sheet"
| "sight"
| "template"
| "workspace",
favoriteId: string,
x_smar_sc_actor_id?: string,
) {
const url = new URL(
`${auth.baseUrl}/favorites/${favoriteType}/${favoriteId}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
...(x_smar_sc_actor_id
? { "x-smar-sc-actor-id": x_smar_sc_actor_id }
: {}),
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