-
Notifications
You must be signed in to change notification settings - Fork 115
/
contacts.ts
177 lines (165 loc) · 3.91 KB
/
contacts.ts
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import { Overrides } from '../config.js';
import {
CreateContactRequest,
Contact,
ListContactQueryParams,
FindContactQueryParams,
UpdateContactRequest,
ContactGroup,
} from '../models/contacts.js';
import {
NylasResponse,
NylasListResponse,
NylasBaseResponse,
} from '../models/response.js';
import { AsyncListResponse, Resource } from './resource.js';
/**
* @property contactId The id of the Contact to retrieve.
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
interface FindContactParams {
identifier: string;
contactId: string;
queryParams: FindContactQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
interface ListContactParams {
identifier: string;
queryParams: ListContactQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property requestBody The values to create the Contact with
*/
interface CreateContactParams {
identifier: string;
requestBody: CreateContactRequest;
}
/**
* @property identifier The identifier of the grant to act upon
* @property contactId The id of the Contact to retrieve.
* @property requestBody The values to update the Contact with
*/
interface UpdateContactParams {
identifier: string;
contactId: string;
requestBody: UpdateContactRequest;
}
/**
* @property identifier The identifier of the grant to act upon
* @property contactId The id of the Contact to retrieve.
*/
interface DestroyContactParams {
identifier: string;
contactId: string;
}
/**
* @property identifier The identifier of the grant to act upon
*/
interface ListContactGroupParams {
identifier: string;
}
/**
* Nylas Contacts API
*
* The Nylas Contacts API allows you to create, update, and delete contacts.
*/
export class Contacts extends Resource {
/**
* Return all Contacts
* @return The list of Contacts
*/
public list({
identifier,
queryParams,
overrides,
}: ListContactParams & Overrides): AsyncListResponse<
NylasListResponse<Contact>
> {
return super._list({
queryParams,
path: `/v3/grants/${identifier}/contacts`,
overrides,
});
}
/**
* Return a Contact
* @return The Contact
*/
public find({
identifier,
contactId,
queryParams,
overrides,
}: FindContactParams & Overrides): Promise<NylasResponse<Contact>> {
return super._find({
path: `/v3/grants/${identifier}/contacts/${contactId}`,
queryParams,
overrides,
});
}
/**
* Create a Contact
* @return The created Contact
*/
public create({
identifier,
requestBody,
overrides,
}: CreateContactParams & Overrides): Promise<NylasResponse<Contact>> {
return super._create({
path: `/v3/grants/${identifier}/contacts`,
requestBody,
overrides,
});
}
/**
* Update a Contact
* @return The updated Contact
*/
public update({
identifier,
contactId,
requestBody,
overrides,
}: UpdateContactParams & Overrides): Promise<NylasResponse<Contact>> {
return super._update({
path: `/v3/grants/${identifier}/contacts/${contactId}`,
requestBody,
overrides,
});
}
/**
* Delete a Contact
* @return The deletion response
*/
public destroy({
identifier,
contactId,
overrides,
}: DestroyContactParams & Overrides): Promise<NylasBaseResponse> {
return super._destroy({
path: `/v3/grants/${identifier}/contacts/${contactId}`,
overrides,
});
}
/**
* Return a Contact Group
* @return The list of Contact Groups
*/
public groups({
identifier,
overrides,
}: ListContactGroupParams & Overrides): Promise<
NylasListResponse<ContactGroup>
> {
return super._list({
path: `/v3/grants/${identifier}/contacts/groups`,
overrides,
});
}
}