//native
type Formstack = {
token: string;
};
/**
* /form/:id
* Update the details of the specified form
*/
export async function main(
auth: Formstack,
id: string,
body: {
name?: string;
db?: false | true;
template?: string;
num_columns?: number;
label_position?: string;
submit_button_title?: string;
password?: string;
use_ssl?: false | true;
timezone?: string;
language?: string;
active?: false | true;
disabled_message?: string;
},
) {
const url = new URL(`https://www.formstack.com/api/v2/form/${id}.json`);
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