Skip to content

Commit 497f1c5

Browse files
feat: add ContactLists API class for managing contact lists
1 parent ebc3855 commit 497f1c5

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { AxiosInstance } from "axios";
2+
3+
import CONFIG from "../../../../config";
4+
5+
const { CLIENT_SETTINGS } = CONFIG;
6+
const { GENERAL_ENDPOINT } = CLIENT_SETTINGS;
7+
8+
export default class ContactListsApi {
9+
private client: AxiosInstance;
10+
11+
private contactListsURL: string;
12+
13+
constructor(client: AxiosInstance, accountId?: number) {
14+
this.client = client;
15+
this.contactListsURL = `${GENERAL_ENDPOINT}/api/accounts/${accountId}/contacts/lists`;
16+
}
17+
18+
/**
19+
* Lists all contact lists for the account.
20+
*/
21+
public async list() {
22+
return this.client.get(this.contactListsURL);
23+
}
24+
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { AxiosInstance } from "axios";
2+
3+
import CONFIG from "../../../../config";
4+
5+
const { CLIENT_SETTINGS } = CONFIG;
6+
const { GENERAL_ENDPOINT } = CLIENT_SETTINGS;
7+
8+
export default class ContactsApi {
9+
private client: AxiosInstance;
10+
11+
private contactsURL: string;
12+
13+
constructor(client: AxiosInstance, accountId?: number) {
14+
this.client = client;
15+
this.contactsURL = `${GENERAL_ENDPOINT}/api/accounts/${accountId}/contacts`;
16+
}
17+
18+
/**
19+
* Creates a new contact.
20+
*/
21+
public async create(data: any) {
22+
return this.client.post(this.contactsURL, data);
23+
}
24+
25+
/**
26+
* Updates an existing contact.
27+
*/
28+
public async update(id: number, data: any) {
29+
const url = `${this.contactsURL}/${id}`;
30+
return this.client.patch(url, data);
31+
}
32+
33+
/**
34+
* Deletes a contact.
35+
*/
36+
public async delete(id: number) {
37+
const url = `${this.contactsURL}/${id}`;
38+
return this.client.delete(url);
39+
}
40+
}

0 commit comments

Comments
 (0)