Skip to content

Commit

Permalink
Merge branch 'main' into devin/1733935169-make-nylasclient-mockable
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDDM authored Dec 13, 2024
2 parents 9d7facb + 4be4cad commit 4394b6c
Show file tree
Hide file tree
Showing 41 changed files with 2,965 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/main/kotlin/com/nylas/NylasClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ open class NylasClient(
*/
open fun contacts(): Contacts = Contacts(this)

/**
* Access the Scheduler API
* @return The Scheduler API
*/
fun scheduler(): Scheduler = Scheduler(this)

/**
* Get a URL builder instance for the Nylas API.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/nylas/models/AvailabilityMethod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ enum class AvailabilityMethod {

@Json(name = "max-availability")
MAX_AVAILABILITY,

@Json(name = "collective")
COLLECTIVE,
}
14 changes: 7 additions & 7 deletions src/main/kotlin/com/nylas/models/AvailabilityRules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class AvailabilityRules(
/**
* The buffer to add to the start and end of a meeting.
*/
@Json(name = "meeting_buffer")
@Json(name = "buffer")
val buffer: MeetingBuffer? = null,
/**
* A default set of open hours to apply to all participants.
Expand All @@ -27,8 +27,8 @@ data class AvailabilityRules(
* The ID on events that Nylas considers when calculating the order of round-robin participants.
* This is used for both max-fairness and max-availability methods.
*/
@Json(name = "round_robin_event_id")
val roundRobinEventId: String? = null,
@Json(name = "round_robin_group_id")
val roundRobinGroupId: String? = null,
) {
/**
* A builder for creating a [AvailabilityRules].
Expand All @@ -37,7 +37,7 @@ data class AvailabilityRules(
private var availabilityMethod: AvailabilityMethod? = null
private var buffer: MeetingBuffer? = null
private var defaultOpenHours: List<OpenHours>? = null
private var roundRobinEventId: String? = null
private var roundRobinGroupId: String? = null

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

/**
* Build the [AvailabilityRules] object.
Expand All @@ -78,7 +78,7 @@ data class AvailabilityRules(
availabilityMethod = availabilityMethod,
buffer = buffer,
defaultOpenHours = defaultOpenHours,
roundRobinEventId = roundRobinEventId,
roundRobinGroupId = roundRobinGroupId,
)
}
}
19 changes: 19 additions & 0 deletions src/main/kotlin/com/nylas/models/BookingGuest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a booking guest.
*/
data class BookingGuest(
/**
* The email address of the guest.
*/
@Json(name = "email")
val email: String,
/**
* The name of the guest.
*/
@Json(name = "name")
val name: String? = null,
)
19 changes: 19 additions & 0 deletions src/main/kotlin/com/nylas/models/BookingOrganizer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a booking organizer.
*/
data class BookingOrganizer(
/**
* The email address of the participant designated as the organizer of the event.
*/
@Json(name = "email")
val email: String,
/**
* The name of the participant designated as the organizer of the event.
*/
@Json(name = "name")
val name: String? = null,
)
29 changes: 29 additions & 0 deletions src/main/kotlin/com/nylas/models/BookingReminder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a booking reminder.
*/
data class BookingReminder(
/**
* The reminder type.
*/
@Json(name = "type")
val type: String,
/**
* The number of minutes before the event to send the reminder.
*/
@Json(name = "minutes_before_event")
val minutesBeforeEvent: Int,
/**
* The recipient of the reminder.
*/
@Json(name = "recipient")
val recipient: String? = null,
/**
* The subject of the email reminder.
*/
@Json(name = "email_subject")
val emailSubject: String? = null,
)
17 changes: 17 additions & 0 deletions src/main/kotlin/com/nylas/models/BookingStatus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Enum for booking statuses.
*/
enum class BookingStatus {
@Json(name = "pending")
PENDING,

@Json(name = "booked")
BOOKED,

@Json(name = "cancelled")
CANCELLED,
}
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nylas/models/BookingType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Enum for booking types.
*/
enum class BookingType {
@Json(name = "booking")
BOOKING,

@Json(name = "organizer-confirmation")
ORGANIZER_CONFIRMATION,
}
75 changes: 75 additions & 0 deletions src/main/kotlin/com/nylas/models/ConfigurationAvailability.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of availability settings.
*/
data class ConfigurationAvailability(
/**
* The total number of minutes the event should last.
*/
@Json(name = "duration_minutes")
val durationMinutes: Int? = null,
/**
* The interval between meetings in minutes.
*/
@Json(name = "interval_minutes")
val intervalMinutes: Int? = null,
/**
* Nylas rounds each time slot to the nearest multiple of this number of minutes.
*/
@Json(name = "round_to")
val roundTo: Int? = null,
/**
* Availability rules for scheduling configuration.
*/
@Json(name = "availability_rules")
val availabilityRules: AvailabilityRules? = null,
) {
class Builder {
private var durationMinutes: Int? = null
private var intervalMinutes: Int? = null
private var roundTo: Int? = null
private var availabilityRules: AvailabilityRules? = null

/**
* Set the duration of the event in minutes.
* @param durationMinutes The duration of the event in minutes.
* @return The builder.
*/
fun durationMinutes(durationMinutes: Int?) = apply { this.durationMinutes = durationMinutes }

/**
* Set the interval between meetings in minutes.
* @param intervalMinutes The interval between meetings in minutes.
* @return The builder.
*/
fun intervalMinutes(intervalMinutes: Int?) = apply { this.intervalMinutes = intervalMinutes }

/**
* Set Nylas rounds each time slot to the nearest multiple of this number of minutes.
* @param roundTo Nylas rounds each time slot to the nearest multiple of this number of minutes.
* @return The builder.
*/
fun roundTo(roundTo: Int?) = apply { this.roundTo = roundTo }

/**
* Set availability rules for scheduling configuration.
* @param availabilityRules Availability rules for scheduling configuration.
* @return The builder.
*/
fun availabilityRules(availabilityRules: AvailabilityRules?) = apply { this.availabilityRules = availabilityRules }

/**
* Build the [ConfigurationAvailability].
* @return The [ConfigurationAvailability].
*/
fun build() = ConfigurationAvailability(
durationMinutes,
intervalMinutes,
roundTo,
availabilityRules,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a participant in a booking.
*/

data class ConfigurationAvailabilityParticipant(
/**
* @param calendarIds The calendar IDs that the event is created in.
*/
@Json(name = "calendar_ids")
val calendarIds: List<String>? = emptyList(),
/**
* Open hours for this participant. The endpoint searches for free time slots during these open hours.
*/
@Json(name = "open_hours")
val openHours: List<OpenHours>? = null,
) {
/**
* Builder for [ConfigurationAvailabilityParticipant].
*/
class Builder {
private var calendarIds: List<String>? = null
private var openHours: List<OpenHours>? = null

/**
* Set the calendar IDs for this participant.
* @param calendarIds Calendar IDs for this participant.
* @return The builder.
*/
fun calendarIds(calendarIds: List<String>) = apply { this.calendarIds = calendarIds }

/**
* Set the open hours for this participant.
* @param openHours Open hours for this participant.
* @return The builder.
*/
fun openHours(openHours: List<OpenHours>) = apply { this.openHours = openHours }

/**
* Set the open hours for this participant.
* @param openHours Open hours for this participant.
* @return The builder.
*/
fun build() = ConfigurationAvailabilityParticipant(
calendarIds,
openHours,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a participant in a booking.
*/
data class ConfigurationBookingParticipant(
/**
* The calendar ID that the event is created in.
*/
@Json(name = "calendar_id")
val calendarId: String? = null,
) {
/**
* Builder for [ConfigurationBookingParticipant].
*/
class Builder {
private var calendarId: String? = null

/**
* Set the calendar ID for this participant.
* @param calendarId The calendar ID for this participant.
* @return The builder.
*/
fun calendarId(calendarId: String?) = apply { this.calendarId = calendarId }

/**
* Builds a [ConfigurationBookingParticipant] instance.
* @return The [ConfigurationBookingParticipant] instance.
*/
fun build() = ConfigurationBookingParticipant(calendarId)
}
}
Loading

0 comments on commit 4394b6c

Please sign in to comment.