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

Events API Send-RSVP support #175

Merged
merged 4 commits into from
Dec 18, 2023
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
17 changes: 17 additions & 0 deletions src/main/kotlin/com/nylas/models/RsvpStatus.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 representing the allowed RSVP status values.
*/
enum class RsvpStatus {
@Json(name = "yes")
YES,

@Json(name = "no")
NO,

@Json(name = "maybe")
MAYBE,
}
28 changes: 28 additions & 0 deletions src/main/kotlin/com/nylas/models/SendRsvpQueryParams.kt
Original file line number Diff line number Diff line change
@@ -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: 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: RsvpStatus) {

/**
* Builds a [SendRsvpQueryParams] instance.
* @return The [SendRsvpQueryParams] instance.
*/
fun build() = SendRsvpQueryParams(status)
}
}
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nylas/models/SendRsvpRequest.kt
Original file line number Diff line number Diff line change
@@ -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: RsvpStatus,
)
17 changes: 17 additions & 0 deletions src/main/kotlin/com/nylas/resources/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,21 @@ class Events(client: NylasClient) : Resource<Event>(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): 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)
return createResource(path, serializedRequestBody, queryParams)
}

}
Loading