File tree 2 files changed +64
-0
lines changed
src/lib/api/resources/contacts
2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments