//native
type Box = {
token: string;
};
/**
* Copy file request
* Copies an existing file request that is already present on one folder,
and applies it to another folder.
*/
export async function main(
auth: Box,
file_request_id: string,
body: {
title?: string;
description?: string;
status?: "active" | "inactive";
is_email_required?: false | true;
is_description_required?: false | true;
expires_at?: string;
} & { folder?: { type?: "folder"; id: string } },
) {
const url = new URL(
`https://api.box.com/2.0/file_requests/${file_request_id}/copy`,
);
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