From b0069d61153865d74a482329eefea2eb3dc80782 Mon Sep 17 00:00:00 2001 From: YIFAN WU Date: Tue, 5 Dec 2023 20:14:03 -0500 Subject: [PATCH 1/4] Events API Send-RSVP support --- .../com/nylas/models/SendRSVPQueryParams.kt | 28 +++++++++++++++++++ .../com/nylas/models/SendRSVPRequest.kt | 14 ++++++++++ src/main/kotlin/com/nylas/resources/Events.kt | 17 +++++++++++ 3 files changed, 59 insertions(+) create mode 100644 src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt create mode 100644 src/main/kotlin/com/nylas/models/SendRSVPRequest.kt diff --git a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt new file mode 100644 index 00000000..3dd6c941 --- /dev/null +++ b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt @@ -0,0 +1,28 @@ +package com.nylas.models + +import com.squareup.moshi.Json + +/** + * Class representation of the query parameters for sending RSVP. + */ +data class SendRsvpQueryParams( + /** + * The RSVP status for the event. Must be yes, no, or maybe + */ + @Json(name = "status") + val status: String +) : IQueryParams { + + /** + * Builder for [SendRsvpQueryParams]. + * @param status The RSVP status for the event. Must be yes, no, or maybe + */ + data class Builder(private val status: String) { + + /** + * Builds a [SendRsvpQueryParams] instance. + * @return The [SendRsvpQueryParams] instance. + */ + fun build() = SendRsvpQueryParams(status) + } +} diff --git a/src/main/kotlin/com/nylas/models/SendRSVPRequest.kt b/src/main/kotlin/com/nylas/models/SendRSVPRequest.kt new file mode 100644 index 00000000..c5affed3 --- /dev/null +++ b/src/main/kotlin/com/nylas/models/SendRSVPRequest.kt @@ -0,0 +1,14 @@ +package com.nylas.models + +import com.squareup.moshi.Json + +/** + * Class representation of a Nylas send-rsvp request + */ +data class SendRsvpRequest( + /** + * RSVP status. must be yes, no, or maybe + */ + @Json(name = "status") + val status: String, +) diff --git a/src/main/kotlin/com/nylas/resources/Events.kt b/src/main/kotlin/com/nylas/resources/Events.kt index d9735aef..c26f5788 100644 --- a/src/main/kotlin/com/nylas/resources/Events.kt +++ b/src/main/kotlin/com/nylas/resources/Events.kt @@ -80,4 +80,21 @@ class Events(client: NylasClient) : Resource(client, Event::class.java) { val path = String.format("v3/grants/%s/events/%s", identifier, eventId) return destroyResource(path, queryParams) } + + /** + * Send RSVP. Allows users to respond to events they have been added to as an attendee. + * @param identifier The identifier of the grant to act upon + * @param eventId The id of the Event to update. + * @param requestBody The values to send the RSVP with + * @param queryParams The query parameters to include in the request + * @return The send-rsvp response + */ + @Throws(NylasApiError::class, NylasSdkTimeoutError::class) + fun sendRsvp(identifier: String, requestBody: SendRsvpRequest, queryParams: SendRsvpQueryParams): Response { + val path = String.format("v3/grants/%s/events/%s/send-rsvp", identifier, eventId) + val adapter = JsonHelper.moshi().adapter(SendRsvpRequest::class.java) + val serializedRequestBody = adapter.toJson(requestBody) + return createResource(path, serializedRequestBody, queryParams) + } + } From 559b47e879944c785e118a9d46f93b0de85f2720 Mon Sep 17 00:00:00 2001 From: YIFAN WU Date: Tue, 5 Dec 2023 21:22:42 -0500 Subject: [PATCH 2/4] Update enum --- .../com/nylas/models/SendRSVPQueryParams.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt index 3dd6c941..3d350e2d 100644 --- a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt +++ b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt @@ -2,6 +2,19 @@ package com.nylas.models import com.squareup.moshi.Json +/** + * Enum representing the allowed RSVP status values. + */ +enum class RsvpStatus(val value: String) { + YES("yes"), + NO("no"), + MAYBE("maybe"); + + override fun toString(): String { + return value + } +} + /** * Class representation of the query parameters for sending RSVP. */ @@ -10,14 +23,14 @@ data class SendRsvpQueryParams( * The RSVP status for the event. Must be yes, no, or maybe */ @Json(name = "status") - val status: String + val status: RsvpStatus ) : IQueryParams { /** * Builder for [SendRsvpQueryParams]. * @param status The RSVP status for the event. Must be yes, no, or maybe */ - data class Builder(private val status: String) { + data class Builder(private val status: RsvpStatus) { /** * Builds a [SendRsvpQueryParams] instance. From acc41c265a3fc0d49a92b82f8b34e645d496239b Mon Sep 17 00:00:00 2001 From: YIFAN WU Date: Mon, 18 Dec 2023 16:03:02 -0500 Subject: [PATCH 3/4] Update to PR review requests --- src/main/kotlin/com/nylas/models/RsvpStatus.kt | 17 +++++++++++++++++ .../com/nylas/models/SendRSVPQueryParams.kt | 13 ------------- src/main/kotlin/com/nylas/resources/Events.kt | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 src/main/kotlin/com/nylas/models/RsvpStatus.kt diff --git a/src/main/kotlin/com/nylas/models/RsvpStatus.kt b/src/main/kotlin/com/nylas/models/RsvpStatus.kt new file mode 100644 index 00000000..1c2d1540 --- /dev/null +++ b/src/main/kotlin/com/nylas/models/RsvpStatus.kt @@ -0,0 +1,17 @@ +package com.nylas.models + +import com.squareup.moshi.Json + +/** + * Enum representing the allowed RSVP status values. + */ +enum class ParticipantStatus { + @Json(name = "yes") + YES, + + @Json(name = "no") + NO, + + @Json(name = "maybe") + MAYBE, +} diff --git a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt index 3d350e2d..345f1c28 100644 --- a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt +++ b/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt @@ -2,19 +2,6 @@ package com.nylas.models import com.squareup.moshi.Json -/** - * Enum representing the allowed RSVP status values. - */ -enum class RsvpStatus(val value: String) { - YES("yes"), - NO("no"), - MAYBE("maybe"); - - override fun toString(): String { - return value - } -} - /** * Class representation of the query parameters for sending RSVP. */ diff --git a/src/main/kotlin/com/nylas/resources/Events.kt b/src/main/kotlin/com/nylas/resources/Events.kt index c26f5788..bf80e7a1 100644 --- a/src/main/kotlin/com/nylas/resources/Events.kt +++ b/src/main/kotlin/com/nylas/resources/Events.kt @@ -90,7 +90,7 @@ class Events(client: NylasClient) : Resource(client, Event::class.java) { * @return The send-rsvp response */ @Throws(NylasApiError::class, NylasSdkTimeoutError::class) - fun sendRsvp(identifier: String, requestBody: SendRsvpRequest, queryParams: SendRsvpQueryParams): Response { + fun sendRsvp(identifier: String, requestBody: SendRsvpRequest, queryParams: SendRsvpQueryParams): DeleteResponse{ val path = String.format("v3/grants/%s/events/%s/send-rsvp", identifier, eventId) val adapter = JsonHelper.moshi().adapter(SendRsvpRequest::class.java) val serializedRequestBody = adapter.toJson(requestBody) From c7708e799b64e62a2e7415501fd299420a2ba322 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:12:07 -0500 Subject: [PATCH 4/4] quick fixes --- src/main/kotlin/com/nylas/models/RsvpStatus.kt | 2 +- .../models/{SendRSVPQueryParams.kt => SendRsvpQueryParams.kt} | 0 .../com/nylas/models/{SendRSVPRequest.kt => SendRsvpRequest.kt} | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/main/kotlin/com/nylas/models/{SendRSVPQueryParams.kt => SendRsvpQueryParams.kt} (100%) rename src/main/kotlin/com/nylas/models/{SendRSVPRequest.kt => SendRsvpRequest.kt} (89%) diff --git a/src/main/kotlin/com/nylas/models/RsvpStatus.kt b/src/main/kotlin/com/nylas/models/RsvpStatus.kt index 1c2d1540..ec38e076 100644 --- a/src/main/kotlin/com/nylas/models/RsvpStatus.kt +++ b/src/main/kotlin/com/nylas/models/RsvpStatus.kt @@ -5,7 +5,7 @@ import com.squareup.moshi.Json /** * Enum representing the allowed RSVP status values. */ -enum class ParticipantStatus { +enum class RsvpStatus { @Json(name = "yes") YES, diff --git a/src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt b/src/main/kotlin/com/nylas/models/SendRsvpQueryParams.kt similarity index 100% rename from src/main/kotlin/com/nylas/models/SendRSVPQueryParams.kt rename to src/main/kotlin/com/nylas/models/SendRsvpQueryParams.kt diff --git a/src/main/kotlin/com/nylas/models/SendRSVPRequest.kt b/src/main/kotlin/com/nylas/models/SendRsvpRequest.kt similarity index 89% rename from src/main/kotlin/com/nylas/models/SendRSVPRequest.kt rename to src/main/kotlin/com/nylas/models/SendRsvpRequest.kt index c5affed3..bbdccf70 100644 --- a/src/main/kotlin/com/nylas/models/SendRSVPRequest.kt +++ b/src/main/kotlin/com/nylas/models/SendRsvpRequest.kt @@ -10,5 +10,5 @@ data class SendRsvpRequest( * RSVP status. must be yes, no, or maybe */ @Json(name = "status") - val status: String, + val status: RsvpStatus, )