//native
type Linode = {
token: string;
};
/**
* Acknowledge agreements
* Accept required agreements by setting them to `true`.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
body: {
billing_agreement?: false | true;
eu_model?: false | true;
master_service_agreement?: false | true;
privacy_policy?: false | true;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/account/agreements`,
);
const response = await fetch(url, {
method: "POST",
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