Skip to content

Commit 4be4cad

Browse files
SubashPradhanSubash PradhanAaronDDM
authored
Scheduler API Support (#252)
This PR adds support to the scheduler API, this includes managing configurations, sessions, and bookings. # License <!-- Your PR comment must contain the following line for us to merge the PR. --> I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner. --------- Co-authored-by: Subash Pradhan <subash.p@macbook-pro.home> Co-authored-by: Aaron de Mello <314152+AaronDDM@users.noreply.github.com>
1 parent 7b99eec commit 4be4cad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2965
-8
lines changed

src/main/kotlin/com/nylas/NylasClient.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ class NylasClient(
151151
*/
152152
fun contacts(): Contacts = Contacts(this)
153153

154+
/**
155+
* Access the Scheduler API
156+
* @return The Scheduler API
157+
*/
158+
fun scheduler(): Scheduler = Scheduler(this)
159+
154160
/**
155161
* Get a URL builder instance for the Nylas API.
156162
*/

src/main/kotlin/com/nylas/models/AvailabilityMethod.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ enum class AvailabilityMethod {
1111

1212
@Json(name = "max-availability")
1313
MAX_AVAILABILITY,
14+
15+
@Json(name = "collective")
16+
COLLECTIVE,
1417
}

src/main/kotlin/com/nylas/models/AvailabilityRules.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data class AvailabilityRules(
1414
/**
1515
* The buffer to add to the start and end of a meeting.
1616
*/
17-
@Json(name = "meeting_buffer")
17+
@Json(name = "buffer")
1818
val buffer: MeetingBuffer? = null,
1919
/**
2020
* A default set of open hours to apply to all participants.
@@ -27,8 +27,8 @@ data class AvailabilityRules(
2727
* The ID on events that Nylas considers when calculating the order of round-robin participants.
2828
* This is used for both max-fairness and max-availability methods.
2929
*/
30-
@Json(name = "round_robin_event_id")
31-
val roundRobinEventId: String? = null,
30+
@Json(name = "round_robin_group_id")
31+
val roundRobinGroupId: String? = null,
3232
) {
3333
/**
3434
* A builder for creating a [AvailabilityRules].
@@ -37,7 +37,7 @@ data class AvailabilityRules(
3737
private var availabilityMethod: AvailabilityMethod? = null
3838
private var buffer: MeetingBuffer? = null
3939
private var defaultOpenHours: List<OpenHours>? = null
40-
private var roundRobinEventId: String? = null
40+
private var roundRobinGroupId: String? = null
4141

4242
/**
4343
* Set the method used to determine availability for a meeting.
@@ -65,10 +65,10 @@ data class AvailabilityRules(
6565
/**
6666
* Set the ID on events that Nylas considers when calculating the order of round-robin participants.
6767
* This is used for both max-fairness and max-availability methods.
68-
* @param roundRobinEventId The ID on events that Nylas considers when calculating the order of round-robin participants.
68+
* @param roundRobinGroupId The ID on events that Nylas considers when calculating the order of round-robin participants.
6969
* @return The builder.
7070
*/
71-
fun roundRobinEventId(roundRobinEventId: String) = apply { this.roundRobinEventId = roundRobinEventId }
71+
fun roundRobinGroupId(roundRobinGroupId: String) = apply { this.roundRobinGroupId = roundRobinGroupId }
7272

7373
/**
7474
* Build the [AvailabilityRules] object.
@@ -78,7 +78,7 @@ data class AvailabilityRules(
7878
availabilityMethod = availabilityMethod,
7979
buffer = buffer,
8080
defaultOpenHours = defaultOpenHours,
81-
roundRobinEventId = roundRobinEventId,
81+
roundRobinGroupId = roundRobinGroupId,
8282
)
8383
}
8484
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Class representation of a booking guest.
7+
*/
8+
data class BookingGuest(
9+
/**
10+
* The email address of the guest.
11+
*/
12+
@Json(name = "email")
13+
val email: String,
14+
/**
15+
* The name of the guest.
16+
*/
17+
@Json(name = "name")
18+
val name: String? = null,
19+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Class representation of a booking organizer.
7+
*/
8+
data class BookingOrganizer(
9+
/**
10+
* The email address of the participant designated as the organizer of the event.
11+
*/
12+
@Json(name = "email")
13+
val email: String,
14+
/**
15+
* The name of the participant designated as the organizer of the event.
16+
*/
17+
@Json(name = "name")
18+
val name: String? = null,
19+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Class representation of a booking reminder.
7+
*/
8+
data class BookingReminder(
9+
/**
10+
* The reminder type.
11+
*/
12+
@Json(name = "type")
13+
val type: String,
14+
/**
15+
* The number of minutes before the event to send the reminder.
16+
*/
17+
@Json(name = "minutes_before_event")
18+
val minutesBeforeEvent: Int,
19+
/**
20+
* The recipient of the reminder.
21+
*/
22+
@Json(name = "recipient")
23+
val recipient: String? = null,
24+
/**
25+
* The subject of the email reminder.
26+
*/
27+
@Json(name = "email_subject")
28+
val emailSubject: String? = null,
29+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Enum for booking statuses.
7+
*/
8+
enum class BookingStatus {
9+
@Json(name = "pending")
10+
PENDING,
11+
12+
@Json(name = "booked")
13+
BOOKED,
14+
15+
@Json(name = "cancelled")
16+
CANCELLED,
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Enum for booking types.
7+
*/
8+
enum class BookingType {
9+
@Json(name = "booking")
10+
BOOKING,
11+
12+
@Json(name = "organizer-confirmation")
13+
ORGANIZER_CONFIRMATION,
14+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Class representation of availability settings.
7+
*/
8+
data class ConfigurationAvailability(
9+
/**
10+
* The total number of minutes the event should last.
11+
*/
12+
@Json(name = "duration_minutes")
13+
val durationMinutes: Int? = null,
14+
/**
15+
* The interval between meetings in minutes.
16+
*/
17+
@Json(name = "interval_minutes")
18+
val intervalMinutes: Int? = null,
19+
/**
20+
* Nylas rounds each time slot to the nearest multiple of this number of minutes.
21+
*/
22+
@Json(name = "round_to")
23+
val roundTo: Int? = null,
24+
/**
25+
* Availability rules for scheduling configuration.
26+
*/
27+
@Json(name = "availability_rules")
28+
val availabilityRules: AvailabilityRules? = null,
29+
) {
30+
class Builder {
31+
private var durationMinutes: Int? = null
32+
private var intervalMinutes: Int? = null
33+
private var roundTo: Int? = null
34+
private var availabilityRules: AvailabilityRules? = null
35+
36+
/**
37+
* Set the duration of the event in minutes.
38+
* @param durationMinutes The duration of the event in minutes.
39+
* @return The builder.
40+
*/
41+
fun durationMinutes(durationMinutes: Int?) = apply { this.durationMinutes = durationMinutes }
42+
43+
/**
44+
* Set the interval between meetings in minutes.
45+
* @param intervalMinutes The interval between meetings in minutes.
46+
* @return The builder.
47+
*/
48+
fun intervalMinutes(intervalMinutes: Int?) = apply { this.intervalMinutes = intervalMinutes }
49+
50+
/**
51+
* Set Nylas rounds each time slot to the nearest multiple of this number of minutes.
52+
* @param roundTo Nylas rounds each time slot to the nearest multiple of this number of minutes.
53+
* @return The builder.
54+
*/
55+
fun roundTo(roundTo: Int?) = apply { this.roundTo = roundTo }
56+
57+
/**
58+
* Set availability rules for scheduling configuration.
59+
* @param availabilityRules Availability rules for scheduling configuration.
60+
* @return The builder.
61+
*/
62+
fun availabilityRules(availabilityRules: AvailabilityRules?) = apply { this.availabilityRules = availabilityRules }
63+
64+
/**
65+
* Build the [ConfigurationAvailability].
66+
* @return The [ConfigurationAvailability].
67+
*/
68+
fun build() = ConfigurationAvailability(
69+
durationMinutes,
70+
intervalMinutes,
71+
roundTo,
72+
availabilityRules,
73+
)
74+
}
75+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.nylas.models
2+
3+
import com.squareup.moshi.Json
4+
5+
/**
6+
* Class representation of a participant in a booking.
7+
*/
8+
9+
data class ConfigurationAvailabilityParticipant(
10+
/**
11+
* @param calendarIds The calendar IDs that the event is created in.
12+
*/
13+
@Json(name = "calendar_ids")
14+
val calendarIds: List<String>? = emptyList(),
15+
/**
16+
* Open hours for this participant. The endpoint searches for free time slots during these open hours.
17+
*/
18+
@Json(name = "open_hours")
19+
val openHours: List<OpenHours>? = null,
20+
) {
21+
/**
22+
* Builder for [ConfigurationAvailabilityParticipant].
23+
*/
24+
class Builder {
25+
private var calendarIds: List<String>? = null
26+
private var openHours: List<OpenHours>? = null
27+
28+
/**
29+
* Set the calendar IDs for this participant.
30+
* @param calendarIds Calendar IDs for this participant.
31+
* @return The builder.
32+
*/
33+
fun calendarIds(calendarIds: List<String>) = apply { this.calendarIds = calendarIds }
34+
35+
/**
36+
* Set the open hours for this participant.
37+
* @param openHours Open hours for this participant.
38+
* @return The builder.
39+
*/
40+
fun openHours(openHours: List<OpenHours>) = apply { this.openHours = openHours }
41+
42+
/**
43+
* Set the open hours for this participant.
44+
* @param openHours Open hours for this participant.
45+
* @return The builder.
46+
*/
47+
fun build() = ConfigurationAvailabilityParticipant(
48+
calendarIds,
49+
openHours,
50+
)
51+
}
52+
}

0 commit comments

Comments
 (0)