0

Get Salesforce order lines by ad account id.

by
Published Dec 20, 2024

Get Salesforce order lines for account id ad_account_id. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Finance, Campaign.

Script pinterest Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Pinterest = {
3
  token: string;
4
};
5
/**
6
 * Get Salesforce order lines by ad account id.
7
 * Get Salesforce order lines for account id ad_account_id.
8
- The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Finance, Campaign.
9
 */
10
export async function main(
11
  auth: Pinterest,
12
  ad_account_id: string,
13
  bookmark: string | undefined,
14
  page_size: string | undefined,
15
  pin_order_id: string | undefined,
16
) {
17
  const url = new URL(
18
    `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ssio/order_lines`,
19
  );
20
  for (const [k, v] of [
21
    ["bookmark", bookmark],
22
    ["page_size", page_size],
23
    ["pin_order_id", pin_order_id],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42