//native
type Shutterstock = {
token: string;
};
/**
* Update collection metadata
* This endpoint updates the metadata of a catalog collection.
*/
export async function main(
auth: Shutterstock,
collection_id: string,
body: {
name?: string;
visibility?: "private" | "public";
cover_asset?: { id: string };
},
) {
const url = new URL(
`https://api.shutterstock.com/v2/catalog/collections/${collection_id}`,
);
const response = await fetch(url, {
method: "PATCH",
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