-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy patheverything.ts
More file actions
42 lines (34 loc) · 1.11 KB
/
everything.ts
File metadata and controls
42 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { MailtrapClient } from "mailtrap";
const TOKEN = "<YOUR-TOKEN-HERE>";
const ACCOUNT_ID = "<YOUR-ACCOUNT-ID-HERE>"
const client = new MailtrapClient({
token: TOKEN,
accountId: ACCOUNT_ID,
});
async function contactFieldsExample() {
try {
// Get all contact fields
const fields = await client.contactFields.getList();
console.log("All contact fields:", fields);
// Use the first field from the list for operations
const firstField = (fields as any)[0];
if (!firstField) {
console.log("No contact fields found");
return;
}
// Get a specific contact field
const field = await client.contactFields.get(firstField.id);
console.log("Retrieved field:", field);
// Update a contact field
const updatedField = await client.contactFields.update(firstField.id, {
name: "Updated First Name",
});
console.log("Updated field:", updatedField);
// Delete a contact field
await client.contactFields.delete(firstField.id);
console.log("Field deleted successfully");
} catch (error) {
console.error("Error:", error);
}
}
contactFieldsExample();