Edits history of script submission #11200 for ' Accept or decline an invite/request (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Accept or decline an invite/request
     * Accept or decline invites or requests.
     */
    export async function main(
      auth: Pinterest,
      body: {
        invites: {
          action: { accept_invite: false | true; asset_id_to_permissions?: {} };
          invite_id: string;
        }[];
      },
    ) {
      const url = new URL(`https://api.pinterest.com/v5/businesses/invites`);
    
      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 536 days ago