Edits history of script submission #11204 for ' Cancel invites/requests (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Cancel invites/requests
     * Cancel membership/partnership invites and/or requests.
     */
    export async function main(
      auth: Pinterest,
      business_id: string,
      body: { invite_ids: string[] },
    ) {
      const url = new URL(
        `https://api.pinterest.com/v5/businesses/${business_id}/invites`,
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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 536 days ago