-
Notifications
You must be signed in to change notification settings - Fork 119
/
calendars.ts
213 lines (199 loc) · 5.49 KB
/
calendars.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
204
205
206
207
208
209
210
211
212
213
import { Overrides } from '../config.js';
import {
Calendar,
CreateCalenderRequest,
ListCalendersQueryParams,
UpdateCalenderRequest,
} from '../models/calendars.js';
import {
NylasBaseResponse,
NylasResponse,
NylasListResponse,
} from '../models/response.js';
import { Resource, AsyncListResponse } from './resource.js';
import {
GetAvailabilityRequest,
GetAvailabilityResponse,
} from '../models/availability.js';
import { GetFreeBusyRequest, GetFreeBusyResponse } from '../models/freeBusy.js';
/**
* The parameters for the {@link Calendars.find} method
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
* @property identifier The identifier of the grant to act upon
*/
export interface FindCalendarParams {
identifier: string;
calendarId: string;
}
/**
* The parameters for the {@link Calendars.list} method
* @property identifier The identifier of the grant to act upon
* @property queryParams The query parameters to include in the request
*/
export interface ListCalendersParams {
identifier: string;
queryParams?: ListCalendersQueryParams;
}
/**
* The parameters for the {@link Calendars.create} method
* @property identifier The identifier of the grant to act upon
* @property requestBody The request body to create a calendar
*/
export interface CreateCalendarParams {
identifier: string;
requestBody: CreateCalenderRequest;
}
/**
* The parameters for the {@link Calendars.update} method
* @property identifier The identifier of the grant to act upon
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
*/
export interface UpdateCalendarParams {
identifier: string;
calendarId: string;
requestBody: UpdateCalenderRequest;
}
/**
* The parameters for the {@link Calendars.destroy} method
* @property identifier The identifier of the grant to act upon
* @property calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
*/
export interface DestroyCalendarParams {
identifier: string;
calendarId: string;
}
/**
* The parameters for the {@link Calendars.getAvailability} method
* @property requestBody The availability request
*/
export interface GetAvailabilityParams {
requestBody: GetAvailabilityRequest;
}
/**
* The parameters for the {@link Calendars.getFreeBusy} method
* @property identifier The identifier of the grant to act upon
* @property requestBody The free busy request
*/
export interface GetFreeBusyParams {
identifier: string;
requestBody: GetFreeBusyRequest;
}
/**
* Nylas Calendar API
*
* The Nylas calendar API allows you to create new calendars or manage existing ones.
* A calendar can be accessed by one, or several people, and can contain events.
*/
export class Calendars extends Resource {
/**
* Return all Calendars
* @return A list of calendars
*/
public list({
identifier,
queryParams,
overrides,
}: ListCalendersParams &
ListCalendersQueryParams &
Overrides): AsyncListResponse<NylasListResponse<Calendar>> {
return super._list<NylasListResponse<Calendar>>({
queryParams,
overrides,
path: `/v3/grants/${identifier}/calendars`,
});
}
/**
* Return a Calendar
* @return The calendar
*/
public find({
identifier,
calendarId,
overrides,
}: FindCalendarParams & Overrides): Promise<NylasResponse<Calendar>> {
return super._find({
path: `/v3/grants/${identifier}/calendars/${calendarId}`,
overrides,
});
}
/**
* Create a Calendar
* @return The created calendar
*/
public create({
identifier,
requestBody,
overrides,
}: CreateCalendarParams & Overrides): Promise<NylasResponse<Calendar>> {
return super._create({
path: `/v3/grants/${identifier}/calendars`,
requestBody,
overrides,
});
}
/**
* Update a Calendar
* @return The updated Calendar
*/
public update({
calendarId,
identifier,
requestBody,
overrides,
}: UpdateCalendarParams & Overrides): Promise<NylasResponse<Calendar>> {
return super._update({
path: `/v3/grants/${identifier}/calendars/${calendarId}`,
requestBody,
overrides,
});
}
/**
* Delete a Calendar
* @return The deleted Calendar
*/
public destroy({
identifier,
calendarId,
overrides,
}: DestroyCalendarParams & Overrides): Promise<NylasBaseResponse> {
return super._destroy({
path: `/v3/grants/${identifier}/calendars/${calendarId}`,
overrides,
});
}
/**
* Get Availability for a given account / accounts
* @return The availability response
*/
public getAvailability({
requestBody,
overrides,
}: GetAvailabilityParams & Overrides): Promise<
NylasResponse<GetAvailabilityResponse>
> {
return this.apiClient.request<NylasResponse<GetAvailabilityResponse>>({
method: 'POST',
path: `/v3/calendars/availability`,
body: requestBody,
overrides,
});
}
/**
* Get the free/busy schedule for a list of email addresses
* @return The free/busy response
*/
public getFreeBusy({
identifier,
requestBody,
overrides,
}: GetFreeBusyParams & Overrides): Promise<
NylasResponse<GetFreeBusyResponse[]>
> {
return this.apiClient.request<NylasResponse<GetFreeBusyResponse[]>>({
method: 'POST',
path: `/v3/grants/${identifier}/calendars/free-busy`,
body: requestBody,
overrides,
});
}
}