Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Nylas Java SDK Changelog

## [Unreleased]

### Added
* Added support for `name` attribute in Scheduler Configuration class to allow custom naming of Scheduling Pages

### [2.8.0] - Release 2025-04-30
* Added support for Notetaker APIs
* Added support for Notetaker via the calendar and event APIs
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/com/nylas/models/CreateConfigurationRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ data class CreateConfigurationRequest(
*/
@Json(name = "event_booking")
val eventBooking: ConfigurationEventBooking,
/**
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
*/
@Json(name = "name")
val name: String? = null,
/**
* Unique identifier for the Configuration object.
*/
Expand Down Expand Up @@ -54,10 +59,19 @@ data class CreateConfigurationRequest(
private val eventBooking: ConfigurationEventBooking,
) {
private var requiresSessionAuth: Boolean? = null
private var name: String? = null
private var slug: String? = null
private var scheduler: ConfigurationSchedulerSettings? = null
private var appearance: Map<String, String>? = null

/**
* Set the name of the Scheduling Page.
*
* @param name The name of the Scheduling Page. If not set, it defaults to the organizer's name.
* @return The builder
*/
fun name(name: String) = apply { this.name = name }

/**
* Set the unique identifier for the configuration.
*
Expand Down Expand Up @@ -99,6 +113,7 @@ data class CreateConfigurationRequest(
participants,
availability,
eventBooking,
name,
slug,
requiresSessionAuth,
scheduler,
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/com/nylas/models/Scheduler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ data class Configuration(
*/
@Json(name = "event_booking")
val eventBooking: ConfigurationEventBooking,
/**
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
*/
@Json(name = "name")
val name: String? = null,
/**
* Unique identifier for the Configuration object.
*/
Expand Down
21 changes: 18 additions & 3 deletions src/main/kotlin/com/nylas/models/UpdateConfigurationRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ data class UpdateConfigurationRequest(
*/
@Json(name = "event_booking")
val eventBooking: ConfigurationEventBooking? = null,
/**
* The name of the Scheduling Page. If not set, it defaults to the organizer's name.
*/
@Json(name = "name")
val name: String? = null,
/**
* Unique identifier for the Configuration object.
*/
Expand Down Expand Up @@ -49,6 +54,7 @@ data class UpdateConfigurationRequest(
private var participants: List<ConfigurationParticipant>? = null
private var availability: ConfigurationAvailability? = null
private var eventBooking: ConfigurationEventBooking? = null
private var name: String? = null
private var requiresSessionAuth: Boolean? = null
private var slug: String? = null
private var scheduler: ConfigurationSchedulerSettings? = null
Expand Down Expand Up @@ -76,12 +82,12 @@ data class UpdateConfigurationRequest(
fun eventBooking(eventBooking: ConfigurationEventBooking) = apply { this.eventBooking = eventBooking }

/**
* Set the unique identifier for the configuration.
* Set the name of the Scheduling Page.
*
* @param slug Unique identifier for the Configuration object.
* @param name The name of the Scheduling Page. If not set, it defaults to the organizer's name.
* @return The builder
*/
fun slug(slug: String) = apply { this.slug = slug }
fun name(name: String) = apply { this.name = name }

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

/**
* Set the unique identifier for the configuration.
*
* @param slug Unique identifier for the Configuration object.
* @return The builder
*/
fun slug(slug: String) = apply { this.slug = slug }

/**
* Build the [UpdateConfigurationRequest].
*
Expand All @@ -116,6 +130,7 @@ data class UpdateConfigurationRequest(
participants,
availability,
eventBooking,
name,
slug,
requiresSessionAuth,
scheduler,
Expand Down
78 changes: 78 additions & 0 deletions src/test/kotlin/com/nylas/resources/ConfigurationsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ConfigurationsTest {
"""
{
"id": "abc-123-configuration-id",
"name": "My Scheduling Page",
"slug": null,
"participants": [
{
Expand Down Expand Up @@ -148,6 +149,7 @@ class ConfigurationsTest {
val config = adapter.fromJson(jsonBuffer)!!
assertIs<Configuration>(config)
assertEquals("abc-123-configuration-id", config.id)
assertEquals("My Scheduling Page", config.name)
assertEquals(false, config.requiresSessionAuth)
assertEquals(7, config.scheduler?.availableDaysInFuture)
assertEquals(60, config.scheduler?.minCancellationNotice)
Expand Down Expand Up @@ -262,6 +264,55 @@ class ConfigurationsTest {
assertEquals(adapter.toJson(createConfigurationRequest), requestBodyCaptor.firstValue)
}

@Test
fun `creating a configuration with name calls requests with the correct params`() {
val adapter = JsonHelper.moshi().adapter(CreateConfigurationRequest::class.java)
val participantCalendarIds = ArrayList<String>()
participantCalendarIds.add("primary")

val configurationAvailabilityParticipant = ConfigurationAvailabilityParticipant.Builder().calendarIds(participantCalendarIds).build()

val configurationBookingParticipant = ConfigurationBookingParticipant.Builder().calendarId("primary").build()

val configurationParticipant = ConfigurationParticipant.Builder("test@nylas.com")
.availability(configurationAvailabilityParticipant)
.booking(configurationBookingParticipant)
.name("Test Participant")
.isOrganizer(true)
.build()

val configurationAvailability = ConfigurationAvailability.Builder().intervalMinutes(30).build()

val configurationEventBooking = ConfigurationEventBooking.Builder().title("Test Event Booking").build()

val participants = ArrayList<ConfigurationParticipant>()
participants.add(configurationParticipant)

val createConfigurationRequest = CreateConfigurationRequest.Builder(
participants,
configurationAvailability,
configurationEventBooking,
).name("My Custom Scheduling Page").build()

configurations.create(grantId, createConfigurationRequest)

val pathCaptor = argumentCaptor<String>()
val typeCaptor = argumentCaptor<Type>()
val requestBodyCaptor = argumentCaptor<String>()
val queryParamCaptor = argumentCaptor<ListConfigurationsQueryParams>()
val overrideParamCaptor = argumentCaptor<RequestOverrides>()
verify(mockNylasClient).executePost<Response<Configuration>>(
pathCaptor.capture(),
typeCaptor.capture(),
requestBodyCaptor.capture(),
queryParamCaptor.capture(),
overrideParamCaptor.capture(),
)
assertEquals("v3/grants/$grantId/scheduling/configurations", pathCaptor.firstValue)
assertEquals(Types.newParameterizedType(Response::class.java, Configuration::class.java), typeCaptor.firstValue)
assertEquals(adapter.toJson(createConfigurationRequest), requestBodyCaptor.firstValue)
}

@Test
fun `updating a configuration calls requests with the correct params`() {
val adapter = JsonHelper.moshi().adapter(UpdateConfigurationRequest::class.java)
Expand All @@ -288,6 +339,33 @@ class ConfigurationsTest {
assertEquals(adapter.toJson(updateConfigurationRequest), requestBodyCaptor.firstValue)
}

@Test
fun `updating a configuration with name calls requests with the correct params`() {
val adapter = JsonHelper.moshi().adapter(UpdateConfigurationRequest::class.java)
val configId = "abc-123-configuration-id"
val updateConfigurationRequest = UpdateConfigurationRequest.Builder()
.name("Updated Scheduling Page Name")
.build()

configurations.update(grantId, configId, updateConfigurationRequest)

val pathCaptor = argumentCaptor<String>()
val typeCaptor = argumentCaptor<Type>()
val requestBodyCaptor = argumentCaptor<String>()
val queryParamCaptor = argumentCaptor<ListConfigurationsQueryParams>()
val overrideParamCaptor = argumentCaptor<RequestOverrides>()
verify(mockNylasClient).executePut<Response<Configuration>>(
pathCaptor.capture(),
typeCaptor.capture(),
requestBodyCaptor.capture(),
queryParamCaptor.capture(),
overrideParamCaptor.capture(),
)
assertEquals("v3/grants/$grantId/scheduling/configurations/$configId", pathCaptor.firstValue)
assertEquals(Types.newParameterizedType(Response::class.java, Configuration::class.java), typeCaptor.firstValue)
assertEquals(adapter.toJson(updateConfigurationRequest), requestBodyCaptor.firstValue)
}

@Test
fun `finding a configuration calls requests with the correct params`() {
val configId = "configuration-id"
Expand Down
Loading