Skip to content

Commit 24e272c

Browse files
authored
Merge branch 'v7.0.0-beta' into AV-817-3-0-beta-node-sdk-beta-test-coverage
2 parents 797682c + f21c496 commit 24e272c

File tree

3 files changed

+121
-3
lines changed

3 files changed

+121
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changelog
22

33
### 7.0.0-beta.3 / TBD
4+
* Added support for the free-busy endpoint
5+
* Fix `getAvailability` response type
46
* Fix path for destroying a redirect URI
5-
* Fix model for updating an Event
7+
* Fix model for updating an Event
68

79
### 7.0.0-beta.2 / 2023-08-21
810
* Fix issue with getting the current Nylas SDK package version

src/models/freeBusy.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* Interface representation of a Nylas free-busy time slot object.
3+
*/
4+
export interface FreeBusyTimeSlot {
5+
/**
6+
* Unix timestamp for the start of the slot.
7+
*/
8+
startTime: number;
9+
/**
10+
* Unix timestamp for the end of the slot.
11+
*/
12+
endTime: number;
13+
/**
14+
* The status of the time slot.
15+
*/
16+
status: string;
17+
}
18+
19+
/**
20+
* Class representation of a Nylas get free-busy request
21+
*/
22+
export interface GetFreeBusyRequest {
23+
/**
24+
* Unix timestamp representing the start of the time block for assessing the account's free/busy schedule.
25+
*/
26+
startTime: number;
27+
/**
28+
* Unix timestamp representing the end of the time block for assessing the account's free/busy schedule.
29+
*/
30+
endTime: number;
31+
/**
32+
* A list of email addresses to check the free/busy schedules for.
33+
*/
34+
emails: string[];
35+
}
36+
37+
/**
38+
* Enum representing the type of free/busy information returned for a calendar.
39+
*/
40+
export enum FreeBusyType {
41+
FREE_BUSY = 'free_busy',
42+
ERROR = 'error',
43+
}
44+
45+
/**
46+
* Union type of the possible Nylas get free busy response.
47+
*/
48+
export type GetFreeBusyResponse = FreeBusy | FreeBusyError;
49+
50+
/**
51+
* This interface represents a successful free-busy response.
52+
*/
53+
export interface FreeBusy {
54+
/**
55+
* The participant's email address.
56+
*/
57+
email: string;
58+
/**
59+
* A list of busy time slots.
60+
*/
61+
timeSlots: FreeBusyTimeSlot[];
62+
/**
63+
* The type of the response.
64+
*/
65+
object: FreeBusyType.FREE_BUSY;
66+
}
67+
68+
/**
69+
* This interface represents a failed free-busy response.
70+
*/
71+
export interface FreeBusyError {
72+
/**
73+
* The participant's email address.
74+
*/
75+
email: string;
76+
/**
77+
* Description of the error fetching data for this participant.
78+
*/
79+
error: string;
80+
/**
81+
* The type of the response.
82+
*/
83+
object: FreeBusyType.ERROR;
84+
}

src/resources/calendars.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GetAvailabilityRequest,
1616
GetAvailabilityResponse,
1717
} from '../models/availability.js';
18+
import { GetFreeBusyRequest, GetFreeBusyResponse } from '../models/freeBusy.js';
1819

1920
/**
2021
* The parameters for the {@link Calendars.find} method
@@ -75,6 +76,16 @@ interface GetAvailabilityParams {
7576
requestBody: GetAvailabilityRequest;
7677
}
7778

79+
/**
80+
* The parameters for the {@link Calendars.getFreeBusy} method
81+
* @property identifier The identifier of the grant to act upon
82+
* @property requestBody The free busy request
83+
*/
84+
interface GetFreeBusyParams {
85+
identifier: string;
86+
requestBody: GetFreeBusyRequest;
87+
}
88+
7889
/**
7990
* Nylas Calendar API
8091
*
@@ -170,12 +181,33 @@ export class Calendars extends Resource {
170181
public getAvailability({
171182
requestBody,
172183
overrides,
173-
}: GetAvailabilityParams & Overrides): Promise<GetAvailabilityResponse> {
174-
return this.apiClient.request<GetAvailabilityResponse>({
184+
}: GetAvailabilityParams & Overrides): Promise<
185+
NylasResponse<GetAvailabilityResponse>
186+
> {
187+
return this.apiClient.request<NylasResponse<GetAvailabilityResponse>>({
175188
method: 'POST',
176189
path: `/v3/calendars/availability`,
177190
body: requestBody,
178191
overrides,
179192
});
180193
}
194+
195+
/**
196+
* Get the free/busy schedule for a list of email addresses
197+
* @return The free/busy response
198+
*/
199+
public getFreeBusy({
200+
identifier,
201+
requestBody,
202+
overrides,
203+
}: GetFreeBusyParams & Overrides): Promise<
204+
NylasResponse<GetFreeBusyResponse[]>
205+
> {
206+
return this.apiClient.request<NylasResponse<GetFreeBusyResponse[]>>({
207+
method: 'POST',
208+
path: `/v3/grants/${identifier}/calendars/free-busy`,
209+
body: requestBody,
210+
overrides,
211+
});
212+
}
181213
}

0 commit comments

Comments
 (0)