//native
type Shutterstock = {
token: string;
};
/**
* Download images
* This endpoint redownloads images that you have already received a license for. The download links in the response are valid for 8 hours.
*/
export async function main(
auth: Shutterstock,
id: string,
body: {
auth_cookie?: { name: string; value: string };
show_modal?: false | true;
size?: "small" | "medium" | "huge" | "supersize" | "vector";
verification_code?: string;
},
) {
const url = new URL(
`https://api.shutterstock.com/v2/images/licenses/${id}/downloads`,
);
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