-
Notifications
You must be signed in to change notification settings - Fork 115
/
events.ts
203 lines (191 loc) · 4.92 KB
/
events.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { Overrides } from '../config.js';
import {
CreateEventQueryParams,
CreateEventRequest,
DestroyEventQueryParams,
Event,
FindEventQueryParams,
ListEventQueryParams,
SendRsvpQueryParams,
SendRsvpRequest,
SendRsvpResponse,
UpdateEventQueryParams,
UpdateEventRequest,
} from '../models/events.js';
import {
NylasBaseResponse,
NylasResponse,
NylasListResponse,
} from '../models/response.js';
import { AsyncListResponse, Resource } from './resource.js';
/**
* @property eventId The id of the Event to retrieve.
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
export interface FindEventParams {
identifier: string;
eventId: string;
queryParams: FindEventQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
export interface ListEventParams {
identifier: string;
queryParams: ListEventQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
* @property requestBody The values to create the Event with
*/
export interface CreateEventParams {
identifier: string;
requestBody: CreateEventRequest;
queryParams: CreateEventQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property eventId The id of the Event to retrieve.
* @property requestBody The values to update the Event with
* @property queryParams The query parameters to include in the request
*/
export interface UpdateEventParams {
identifier: string;
eventId: string;
requestBody: UpdateEventRequest;
queryParams: UpdateEventQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property eventId The id of the Event to retrieve.
* @property queryParams The query parameters to include in the request
*/
export interface DestroyEventParams {
identifier: string;
eventId: string;
queryParams: DestroyEventQueryParams;
}
/**
* @property identifier The identifier of the grant to act upon
* @property eventId The id of the Event to update.
* @property queryParams The query parameters to include in the request
* @property requestBody The values to send the RSVP with
*/
interface SendRsvpParams {
identifier: string;
eventId: string;
queryParams: SendRsvpQueryParams;
requestBody: SendRsvpRequest;
}
/**
* Nylas Events API
*
* The Nylas Events API allows you to create, update, and delete events on user calendars.
*/
export class Events extends Resource {
/**
* Return all Events
* @return The list of Events
*/
public list({
identifier,
queryParams,
overrides,
}: ListEventParams & Overrides): AsyncListResponse<NylasListResponse<Event>> {
return super._list({
queryParams,
path: `/v3/grants/${identifier}/events`,
overrides,
});
}
/**
* Return an Event
* @return The Event
*/
public find({
identifier,
eventId,
queryParams,
overrides,
}: FindEventParams & Overrides): Promise<NylasResponse<Event>> {
return super._find({
path: `/v3/grants/${identifier}/events/${eventId}`,
queryParams,
overrides,
});
}
/**
* Create an Event
* @return The created Event
*/
public create({
identifier,
requestBody,
queryParams,
overrides,
}: CreateEventParams & Overrides): Promise<NylasResponse<Event>> {
return super._create({
path: `/v3/grants/${identifier}/events`,
queryParams,
requestBody,
overrides,
});
}
/**
* Update an Event
* @return The updated Event
*/
public update({
identifier,
eventId,
requestBody,
queryParams,
overrides,
}: UpdateEventParams & Overrides): Promise<NylasResponse<Event>> {
return super._update({
path: `/v3/grants/${identifier}/events/${eventId}`,
queryParams,
requestBody,
overrides,
});
}
/**
* Delete an Event
* @return The deletion response
*/
public destroy({
identifier,
eventId,
queryParams,
overrides,
}: DestroyEventParams & Overrides): Promise<NylasBaseResponse> {
return super._destroy({
path: `/v3/grants/${identifier}/events/${eventId}`,
queryParams,
overrides,
});
}
/**
* Send RSVP. Allows users to respond to events they have been added to as an attendee.
* You cannot send RSVP as an event owner/organizer.
* You cannot directly update events as an invitee, since you are not the owner/organizer.
* @return The send-rsvp response
*/
public sendRsvp({
identifier,
eventId,
requestBody,
queryParams,
overrides,
}: SendRsvpParams & Overrides): Promise<SendRsvpResponse> {
return super._create({
path: `/v3/grants/${identifier}/events/${eventId}/send-rsvp`,
queryParams,
requestBody,
overrides,
});
}
}