//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Update Sheet
* Updates the sheet specified in the URL.
To modify sheet contents, see Add Rows, Update Rows, Add Columns, and Update Column.
This operation can be used to update an individual user's sheet settings. If the request body contains only the **userSettings** attribute, this operation may be performed even if the user only has read-only access to the sheet (for example, the user has viewer permissions or the sheet is read-only).
*/
export async function main(
auth: Smartsheet,
sheetId: string,
accessApiLevel: string | undefined,
body: {
name?: string;
projectSettings?: {
lengthOfDay?: number;
nonWorkingDays?: string[];
workingDays?:
| "MONDAY"
| "TUESDAY"
| "WEDNESDAY"
| "THURSDAY"
| "FRIDAY"
| "SATURDAY"
| "SUNDAY"[];
};
userSettings?: {
criticalPathEnabled?: false | true;
displaySummaryTasks?: false | true;
};
},
) {
const url = new URL(`${auth.baseUrl}/sheets/${sheetId}`);
for (const [k, v] of [["accessApiLevel", accessApiLevel]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
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