Skip to content

Commit 9d72614

Browse files
authored
feat: add name attribute support to Scheduler Configuration (#277)
# What did you do? - Add name field to Configuration, CreateConfigurationRequest, and UpdateConfigurationRequest models - Add builder support for name attribute in both create and update request classes - Add comprehensive tests for name attribute serialization and builder functionality - Name field is optional and defaults to organizer's name when not set - Fully backward compatible implementation # 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.
1 parent fd84619 commit 9d72614

File tree

5 files changed

+121
-3
lines changed

5 files changed

+121
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Nylas Java SDK Changelog
22

3+
## [Unreleased]
4+
5+
### Added
6+
* Added support for `name` attribute in Scheduler Configuration class to allow custom naming of Scheduling Pages
7+
38
### [2.8.0] - Release 2025-04-30
49
* Added support for Notetaker APIs
510
* Added support for Notetaker via the calendar and event APIs

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ data class CreateConfigurationRequest(
2121
*/
2222
@Json(name = "event_booking")
2323
val eventBooking: ConfigurationEventBooking,
24+
/**
25+
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
26+
*/
27+
@Json(name = "name")
28+
val name: String? = null,
2429
/**
2530
* Unique identifier for the Configuration object.
2631
*/
@@ -54,10 +59,19 @@ data class CreateConfigurationRequest(
5459
private val eventBooking: ConfigurationEventBooking,
5560
) {
5661
private var requiresSessionAuth: Boolean? = null
62+
private var name: String? = null
5763
private var slug: String? = null
5864
private var scheduler: ConfigurationSchedulerSettings? = null
5965
private var appearance: Map<String, String>? = null
6066

67+
/**
68+
* Set the name of the Scheduling Page.
69+
*
70+
* @param name The name of the Scheduling Page. If not set, it defaults to the organizer's name.
71+
* @return The builder
72+
*/
73+
fun name(name: String) = apply { this.name = name }
74+
6175
/**
6276
* Set the unique identifier for the configuration.
6377
*
@@ -99,6 +113,7 @@ data class CreateConfigurationRequest(
99113
participants,
100114
availability,
101115
eventBooking,
116+
name,
102117
slug,
103118
requiresSessionAuth,
104119
scheduler,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ data class Configuration(
2626
*/
2727
@Json(name = "event_booking")
2828
val eventBooking: ConfigurationEventBooking,
29+
/**
30+
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
31+
*/
32+
@Json(name = "name")
33+
val name: String? = null,
2934
/**
3035
* Unique identifier for the Configuration object.
3136
*/

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ data class UpdateConfigurationRequest(
2121
*/
2222
@Json(name = "event_booking")
2323
val eventBooking: ConfigurationEventBooking? = null,
24+
/**
25+
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
26+
*/
27+
@Json(name = "name")
28+
val name: String? = null,
2429
/**
2530
* Unique identifier for the Configuration object.
2631
*/
@@ -49,6 +54,7 @@ data class UpdateConfigurationRequest(
4954
private var participants: List<ConfigurationParticipant>? = null
5055
private var availability: ConfigurationAvailability? = null
5156
private var eventBooking: ConfigurationEventBooking? = null
57+
private var name: String? = null
5258
private var requiresSessionAuth: Boolean? = null
5359
private var slug: String? = null
5460
private var scheduler: ConfigurationSchedulerSettings? = null
@@ -76,12 +82,12 @@ data class UpdateConfigurationRequest(
7682
fun eventBooking(eventBooking: ConfigurationEventBooking) = apply { this.eventBooking = eventBooking }
7783

7884
/**
79-
* Set the unique identifier for the configuration.
85+
* Set the name of the Scheduling Page.
8086
*
81-
* @param slug Unique identifier for the Configuration object.
87+
* @param name The name of the Scheduling Page. If not set, it defaults to the organizer's name.
8288
* @return The builder
8389
*/
84-
fun slug(slug: String) = apply { this.slug = slug }
90+
fun name(name: String) = apply { this.name = name }
8591

8692
/**
8793
* Set if scheduling Availability and Bookings endpoints require a valid session ID.
@@ -107,6 +113,14 @@ data class UpdateConfigurationRequest(
107113
*/
108114
fun appearance(appearance: Map<String, String>) = apply { this.appearance = appearance }
109115

116+
/**
117+
* Set the unique identifier for the configuration.
118+
*
119+
* @param slug Unique identifier for the Configuration object.
120+
* @return The builder
121+
*/
122+
fun slug(slug: String) = apply { this.slug = slug }
123+
110124
/**
111125
* Build the [UpdateConfigurationRequest].
112126
*
@@ -116,6 +130,7 @@ data class UpdateConfigurationRequest(
116130
participants,
117131
availability,
118132
eventBooking,
133+
name,
119134
slug,
120135
requiresSessionAuth,
121136
scheduler,

src/test/kotlin/com/nylas/resources/ConfigurationsTest.kt

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ConfigurationsTest {
4545
"""
4646
{
4747
"id": "abc-123-configuration-id",
48+
"name": "My Scheduling Page",
4849
"slug": null,
4950
"participants": [
5051
{
@@ -148,6 +149,7 @@ class ConfigurationsTest {
148149
val config = adapter.fromJson(jsonBuffer)!!
149150
assertIs<Configuration>(config)
150151
assertEquals("abc-123-configuration-id", config.id)
152+
assertEquals("My Scheduling Page", config.name)
151153
assertEquals(false, config.requiresSessionAuth)
152154
assertEquals(7, config.scheduler?.availableDaysInFuture)
153155
assertEquals(60, config.scheduler?.minCancellationNotice)
@@ -262,6 +264,55 @@ class ConfigurationsTest {
262264
assertEquals(adapter.toJson(createConfigurationRequest), requestBodyCaptor.firstValue)
263265
}
264266

267+
@Test
268+
fun `creating a configuration with name calls requests with the correct params`() {
269+
val adapter = JsonHelper.moshi().adapter(CreateConfigurationRequest::class.java)
270+
val participantCalendarIds = ArrayList<String>()
271+
participantCalendarIds.add("primary")
272+
273+
val configurationAvailabilityParticipant = ConfigurationAvailabilityParticipant.Builder().calendarIds(participantCalendarIds).build()
274+
275+
val configurationBookingParticipant = ConfigurationBookingParticipant.Builder().calendarId("primary").build()
276+
277+
val configurationParticipant = ConfigurationParticipant.Builder("[email protected]")
278+
.availability(configurationAvailabilityParticipant)
279+
.booking(configurationBookingParticipant)
280+
.name("Test Participant")
281+
.isOrganizer(true)
282+
.build()
283+
284+
val configurationAvailability = ConfigurationAvailability.Builder().intervalMinutes(30).build()
285+
286+
val configurationEventBooking = ConfigurationEventBooking.Builder().title("Test Event Booking").build()
287+
288+
val participants = ArrayList<ConfigurationParticipant>()
289+
participants.add(configurationParticipant)
290+
291+
val createConfigurationRequest = CreateConfigurationRequest.Builder(
292+
participants,
293+
configurationAvailability,
294+
configurationEventBooking,
295+
).name("My Custom Scheduling Page").build()
296+
297+
configurations.create(grantId, createConfigurationRequest)
298+
299+
val pathCaptor = argumentCaptor<String>()
300+
val typeCaptor = argumentCaptor<Type>()
301+
val requestBodyCaptor = argumentCaptor<String>()
302+
val queryParamCaptor = argumentCaptor<ListConfigurationsQueryParams>()
303+
val overrideParamCaptor = argumentCaptor<RequestOverrides>()
304+
verify(mockNylasClient).executePost<Response<Configuration>>(
305+
pathCaptor.capture(),
306+
typeCaptor.capture(),
307+
requestBodyCaptor.capture(),
308+
queryParamCaptor.capture(),
309+
overrideParamCaptor.capture(),
310+
)
311+
assertEquals("v3/grants/$grantId/scheduling/configurations", pathCaptor.firstValue)
312+
assertEquals(Types.newParameterizedType(Response::class.java, Configuration::class.java), typeCaptor.firstValue)
313+
assertEquals(adapter.toJson(createConfigurationRequest), requestBodyCaptor.firstValue)
314+
}
315+
265316
@Test
266317
fun `updating a configuration calls requests with the correct params`() {
267318
val adapter = JsonHelper.moshi().adapter(UpdateConfigurationRequest::class.java)
@@ -288,6 +339,33 @@ class ConfigurationsTest {
288339
assertEquals(adapter.toJson(updateConfigurationRequest), requestBodyCaptor.firstValue)
289340
}
290341

342+
@Test
343+
fun `updating a configuration with name calls requests with the correct params`() {
344+
val adapter = JsonHelper.moshi().adapter(UpdateConfigurationRequest::class.java)
345+
val configId = "abc-123-configuration-id"
346+
val updateConfigurationRequest = UpdateConfigurationRequest.Builder()
347+
.name("Updated Scheduling Page Name")
348+
.build()
349+
350+
configurations.update(grantId, configId, updateConfigurationRequest)
351+
352+
val pathCaptor = argumentCaptor<String>()
353+
val typeCaptor = argumentCaptor<Type>()
354+
val requestBodyCaptor = argumentCaptor<String>()
355+
val queryParamCaptor = argumentCaptor<ListConfigurationsQueryParams>()
356+
val overrideParamCaptor = argumentCaptor<RequestOverrides>()
357+
verify(mockNylasClient).executePut<Response<Configuration>>(
358+
pathCaptor.capture(),
359+
typeCaptor.capture(),
360+
requestBodyCaptor.capture(),
361+
queryParamCaptor.capture(),
362+
overrideParamCaptor.capture(),
363+
)
364+
assertEquals("v3/grants/$grantId/scheduling/configurations/$configId", pathCaptor.firstValue)
365+
assertEquals(Types.newParameterizedType(Response::class.java, Configuration::class.java), typeCaptor.firstValue)
366+
assertEquals(adapter.toJson(updateConfigurationRequest), requestBodyCaptor.firstValue)
367+
}
368+
291369
@Test
292370
fun `finding a configuration calls requests with the correct params`() {
293371
val configId = "configuration-id"

0 commit comments

Comments
 (0)