Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reminders schema and remove contact type enum #200

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

### Changed
* Changed `clientSecret` to optional for token exchange methods; defaults to API Key now
* Updated `reminder` field to reflect the new API schema
* Fixed various issues with the connector API
* Fixed response type for smart compose methods
* Fixed inaccuracies with webhook related models
* Fixed models for creating drafts and sending messages
* Removed `ContactType` enum as the field allows for any string value

## [2.0.0-beta.4] - Released 2024-01-09

Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/com/nylas/models/ContactEmail.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ data class ContactEmail(
@Json(name = "email")
val email: String? = null,
@Json(name = "type")
val type: ContactType? = null,
val type: String? = null,
) {
class Builder {
private var email: String? = null
private var type: ContactType? = null
private var type: String? = null

fun email(email: String) = apply { this.email = email }
fun type(type: ContactType) = apply { this.type = type }

fun type(type: String) = apply { this.type = type }

fun build() = ContactEmail(email, type)
}
}
17 changes: 0 additions & 17 deletions src/main/kotlin/com/nylas/models/ContactType.kt

This file was deleted.

69 changes: 27 additions & 42 deletions src/main/kotlin/com/nylas/models/CreateEventRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,10 @@ data class CreateEventRequest(
@Json(name = "conferencing")
val conferencing: Conferencing? = null,
/**
* The number of minutes before the event start time when a user wants a reminder for this event.
* Reminder minutes need to be entered in the following format: "[20]".
* A list of reminders to send for the event. If left empty or omitted, the event uses the provider defaults.
*/
@Json(name = "reminder_minutes")
val reminderMinutes: String? = null,
/**
* Method to remind the user about the event. (Google only).
*/
@Json(name = "reminder_method")
val reminderMethod: ReminderMethod? = null,
@Json(name = "reminders")
val reminders: Reminders? = null,
/**
* A list of key-value pairs storing additional data.
*/
Expand Down Expand Up @@ -96,7 +90,6 @@ data class CreateEventRequest(
@Json(name = "hide_participant")
val hideParticipant: Boolean? = null,
) {

/**
* This sealed class represents the different types of event time configurations.
*/
Expand Down Expand Up @@ -430,13 +423,12 @@ data class CreateEventRequest(
private var participants: List<Participant>? = null
private var busy: Boolean? = null
private var conferencing: Conferencing? = null
private var reminderMinutes: String? = null
private var reminderMethod: ReminderMethod? = null
private var reminders: Reminders? = null
private var metadata: Map<String, String>? = null
private var recurrence: List<String>? = null
private var calendarId: String? = null
private var readOnly: Boolean? = null
private var visibility: EventVisibility? = EventVisibility.PUBLIC
private var visibility: EventVisibility? = null
private var capacity: Int? = null
private var hideParticipant: Boolean? = null

Expand Down Expand Up @@ -487,19 +479,12 @@ data class CreateEventRequest(
fun conferencing(conferencing: Conferencing) = apply { this.conferencing = conferencing }

/**
* Set the number of minutes before the event start time when a user wants a reminder for this event.
* Reminder minutes need to be entered in the following format: "[20]".
* @param reminderMinutes The number of minutes before the event start time when a user wants a reminder for this event.
* @return The builder.
*/
fun reminderMinutes(reminderMinutes: String) = apply { this.reminderMinutes = reminderMinutes }

/**
* Set the method to remind the user about the event. (Google only).
* @param reminderMethod Method to remind the user about the event.
* Set the event reminders.
* A list of reminders to send for the event. If left empty or omitted, the event uses the provider defaults.
* @param reminders The event reminders.
* @return The builder.
*/
fun reminderMethod(reminderMethod: ReminderMethod) = apply { this.reminderMethod = reminderMethod }
fun reminders(reminders: Reminders) = apply { this.reminders = reminders }

/**
* Set the metadata, which is a key-value pair storing additional data.
Expand Down Expand Up @@ -557,23 +542,23 @@ data class CreateEventRequest(
* Builds the [CreateEventRequest] object.
* @return [CreateEventRequest] object.
*/
fun build() = CreateEventRequest(
whenObj,
title,
description,
location,
participants,
busy,
conferencing,
reminderMinutes,
reminderMethod,
metadata,
recurrence,
calendarId,
readOnly,
visibility,
capacity,
hideParticipant,
)
fun build() =
CreateEventRequest(
whenObj,
title,
description,
location,
participants,
busy,
conferencing,
reminders,
metadata,
recurrence,
calendarId,
readOnly,
visibility,
capacity,
hideParticipant,
)
}
}
10 changes: 5 additions & 5 deletions src/main/kotlin/com/nylas/models/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ data class Event(
*/
@Json(name = "read_only")
val readOnly: Boolean = false,
/**
* Visibility of the event, if the event is private or public.
*/
@Json(name = "visibility")
val visibility: EventVisibility = EventVisibility.DEFAULT,
/**
* Unix timestamp when the event was created.
*/
Expand Down Expand Up @@ -119,11 +124,6 @@ data class Event(
*/
@Json(name = "title")
val title: String? = null,
/**
* Visibility of the event, if the event is private or public.
*/
@Json(name = "visibility")
val visibility: EventVisibility? = null,
/**
* User who created the event.
* Not supported for all providers.
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ data class InstantMessagingAddress(
@Json(name = "im_address")
val imAddress: String? = null,
@Json(name = "type")
val type: ContactType? = null,
val type: String? = null,
) {
class Builder {
private var imAddress: String? = null
private var type: ContactType? = null
private var type: String? = null

fun imAddress(imAddress: String) = apply { this.imAddress = imAddress }
fun type(type: ContactType) = apply { this.type = type }

fun type(type: String) = apply { this.type = type }

fun build() = InstantMessagingAddress(imAddress, type)
}
}
8 changes: 5 additions & 3 deletions src/main/kotlin/com/nylas/models/PhoneNumber.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ data class PhoneNumber(
@Json(name = "number")
val number: String? = null,
@Json(name = "type")
val type: ContactType? = null,
val type: String? = null,
) {
class Builder {
private var number: String? = null
private var type: ContactType? = null
private var type: String? = null

fun number(number: String) = apply { this.number = number }
fun type(type: ContactType) = apply { this.type = type }

fun type(type: String) = apply { this.type = type }

fun build() = PhoneNumber(number, type)
}
}
33 changes: 20 additions & 13 deletions src/main/kotlin/com/nylas/models/PhysicalAddress.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data class PhysicalAddress(
@Json(name = "country")
val country: String? = null,
@Json(name = "type")
val type: ContactType? = null,
val type: String? = null,
) {
class Builder {
private var format: String? = null
Expand All @@ -28,24 +28,31 @@ data class PhysicalAddress(
private var postalCode: String? = null
private var state: String? = null
private var country: String? = null
private var type: ContactType? = null
private var type: String? = null

fun format(format: String) = apply { this.format = format }

fun streetAddress(streetAddress: String) = apply { this.streetAddress = streetAddress }

fun city(city: String) = apply { this.city = city }

fun postalCode(postalCode: String) = apply { this.postalCode = postalCode }

fun state(state: String) = apply { this.state = state }

fun country(country: String) = apply { this.country = country }
fun type(type: ContactType) = apply { this.type = type }

fun build() = PhysicalAddress(
format = format,
streetAddress = streetAddress,
city = city,
postalCode = postalCode,
state = state,
country = country,
type = type,
)

fun type(type: String) = apply { this.type = type }

fun build() =
PhysicalAddress(
format = format,
streetAddress = streetAddress,
city = city,
postalCode = postalCode,
state = state,
country = country,
type = type,
)
}
}
20 changes: 20 additions & 0 deletions src/main/kotlin/com/nylas/models/ReminderOverride.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representing the reminder details for an event.
*/
data class ReminderOverride(
/**
* The number of minutes before the event start time when a user wants a reminder for this event.
* Reminder minutes are in the following format: "[20]".
*/
@Json(name = "reminder_minutes")
val reminderMinutes: Int? = null,
/**
* Method to remind the user about the event. (Google only).
*/
@Json(name = "reminder_method")
val reminderMethod: ReminderMethod? = null,
)
15 changes: 7 additions & 8 deletions src/main/kotlin/com/nylas/models/Reminders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import com.squareup.moshi.Json
*/
data class Reminders(
/**
* The number of minutes before the event start time when a user wants a reminder for this event.
* Reminder minutes are in the following format: "[20]".
* Whether to use the default reminders for the calendar.
* When true, uses the default reminder settings for the calendar
*/
@Json(name = "reminder_minutes")
val reminderMinutes: String? = null,

@Json(name = "use_default")
val useDefault: Boolean,
/**
* Method to remind the user about the event. (Google only).
* list of reminders for the event if useDefault is set to false.
*/
@Json(name = "reminder_method")
val reminderMethod: ReminderMethod? = null,
@Json(name = "overrides")
val overrides: List<ReminderOverride>? = null,
)
Loading
Loading