Edits history of script submission #20414 for ' Rename image collections (shutterstock)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Shutterstock = {
      token: string;
    };
    /**
     * Rename image collections
     * This endpoint sets a new name for an image collection.
     */
    export async function main(
      auth: Shutterstock,
      id: string,
      body: { name: string },
    ) {
      const url = new URL(
        `https://api.shutterstock.com/v2/images/collections/${id}`,
      );
    
      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.text();
    }
    

    Submitted by hugo697 235 days ago