//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Set Dashboard Publish Status
* Publishes or unpublishes a dashboard.
*/
export async function main(
auth: Smartsheet,
sightId: string,
body: {
readOnlyFullAccessibleBy?: "ALL" | "ORG";
readOnlyFullEnabled: false | true;
readOnlyFullUrl?: string;
},
) {
const url = new URL(`${auth.baseUrl}/sights/${sightId}/publish`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago