Show Compliance Deletion Statuses

Returns the GDPR status for each user per area of compliance. A Zendesk area of compliance is typically a product like "support/explore" but can be more fine-grained for areas within the product lines. If the user is not in the account, the request returns a 404 status. ```http Status: 404 { "error":"RecordNotFound", "description":"Not found" } ``` #### Allowed For * Agents, with restrictions

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Show Compliance Deletion Statuses
8
 * Returns the GDPR status for each user per area of compliance. A Zendesk area of compliance is typically a product like "support/explore" but can be more fine-grained for areas within the product lines.
9

10
If the user is not in the account, the request returns a 404 status.
11

12
```http
13
Status: 404
14
{
15
  "error":"RecordNotFound",
16
  "description":"Not found"
17
}
18
```
19

20
#### Allowed For
21

22
* Agents, with restrictions
23

24
 */
25
export async function main(
26
  auth: Zendesk,
27
  user_id: string,
28
  application: string | undefined
29
) {
30
  const url = new URL(
31
    `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/compliance_deletion_statuses`
32
  );
33
  for (const [k, v] of [["application", application]]) {
34
    if (v !== undefined && v !== "") {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "GET",
40
    headers: {
41
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
42
    },
43
    body: undefined,
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51