Skip to content

Commit

Permalink
Events API Send-RSVP support (#175)
Browse files Browse the repository at this point in the history
- Events API Send-RSVP support

# License
<!-- Your PR comment must contain the following line for us to merge the
PR. -->
I confirm that this contribution is made under the terms of the MIT
license and that I have the authority necessary to make this
contribution on behalf of its copyright owner.
  • Loading branch information
yifanplanet authored Dec 18, 2023
1 parent e3bc843 commit cbf26c7
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
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)
}

}

0 comments on commit cbf26c7

Please sign in to comment.