0

Accept or decline an invite/request

by
Published Dec 20, 2024

Accept or decline invites or requests.

Script pinterest Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Pinterest = {
3
  token: string;
4
};
5
/**
6
 * Accept or decline an invite/request
7
 * Accept or decline invites or requests.
8
 */
9
export async function main(
10
  auth: Pinterest,
11
  body: {
12
    invites: {
13
      action: { accept_invite: false | true; asset_id_to_permissions?: {} };
14
      invite_id: string;
15
    }[];
16
  },
17
) {
18
  const url = new URL(`https://api.pinterest.com/v5/businesses/invites`);
19

20
  const response = await fetch(url, {
21
    method: "PATCH",
22
    headers: {
23
      "Content-Type": "application/json",
24
      Authorization: "Bearer " + auth.token,
25
    },
26
    body: JSON.stringify(body),
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34