Skip to content

Commit

Permalink
minor fixes for reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
mrashed-dev committed Feb 1, 2024
1 parent 10dddb3 commit 0d6f321
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/ReminderOverride.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class ReminderOverride(
* Reminder minutes are in the following format: "[20]".
*/
@Json(name = "reminder_minutes")
val reminderMinutes: String? = null,
val reminderMinutes: Int? = null,
/**
* Method to remind the user about the event. (Google only).
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/nylas/models/Reminders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ data class Reminders(
/**
* list of reminders for the event if useDefault is set to false.
*/
@Json(name = "override")
val override: List<ReminderOverride>? = null,
@Json(name = "overrides")
val overrides: List<ReminderOverride>? = null,
)
106 changes: 62 additions & 44 deletions src/test/kotlin/com/nylas/resources/EventsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class EventsTests {
@Test
fun `Event serializes properly`() {
val adapter = JsonHelper.moshi().adapter(Event::class.java)
val jsonBuffer = Buffer().writeUtf8(
"""
val jsonBuffer =
Buffer().writeUtf8(
"""
{
"busy": true,
"calendar_id": "7d93zl2palhxqdy6e5qinsakt",
Expand Down Expand Up @@ -103,8 +104,8 @@ class EventsTests {
"object": "timespan"
}
}
""".trimIndent(),
)
""".trimIndent(),
)

val event = adapter.fromJson(jsonBuffer)!!
assertIs<Event>(event)
Expand All @@ -120,7 +121,10 @@ class EventsTests {
assertEquals("Description of my new calendar", event.description)
assertEquals(false, event.hideParticipants)
assertEquals("41009df5-bf11-4c97-aa18-b285b5f2e386", event.grantId)
assertEquals("https://www.google.com/calendar/event?eid=bTMzcGJrNW4yYjk4bjk3OWE4Ef3feD2VuM29fMjAyMjA2MjdUMjIwMDAwWiBoYWxsYUBueWxhcy5jb20", event.htmlLink)
assertEquals(
"https://www.google.com/calendar/event?eid=bTMzcGJrNW4yYjk4bjk3OWE4Ef3feD2VuM29fMjAyMjA2MjdUMjIwMDAwWiBoYWxsYUBueWxhcy5jb20",
event.htmlLink,
)
assertEquals("5d3qmne77v32r8l4phyuksl2x", event.id)
assertEquals("Roller Rink", event.location)
assertEquals(mapOf("your_key" to "your_value"), event.metadata)
Expand All @@ -134,6 +138,10 @@ class EventsTests {
assertEquals("+1 23456778", event.participants[0].phoneNumber)
assertEquals(ParticipantStatus.MAYBE, event.participants[0].status)
assertEquals(false, event.readOnly)
assertEquals(false, event.reminders?.useDefault)
assertEquals(1, event.reminders?.overrides?.size)
assertEquals(10, event.reminders?.overrides?.get(0)?.reminderMinutes)
assertEquals(ReminderMethod.EMAIL, event.reminders?.overrides?.get(0)?.reminderMethod)
assertEquals(2, event.recurrence?.size)
assertEquals("RRULE:FREQ=WEEKLY;BYDAY=MO", event.recurrence?.get(0))
assertEquals("EXDATE:20211011T000000Z", event.recurrence?.get(1))
Expand Down Expand Up @@ -165,9 +173,10 @@ class EventsTests {

@Test
fun `listing events calls requests with the correct params`() {
val listEventQueryParams = ListEventQueryParams(
calendarId = "calendar-id",
)
val listEventQueryParams =
ListEventQueryParams(
calendarId = "calendar-id",
)

events.list(grantId, listEventQueryParams)

Expand All @@ -187,9 +196,10 @@ class EventsTests {
@Test
fun `finding a event calls requests with the correct params`() {
val eventId = "event-123"
val findEventQueryParams = FindEventQueryParams(
calendarId = "calendar-id",
)
val findEventQueryParams =
FindEventQueryParams(
calendarId = "calendar-id",
)

events.find(grantId, eventId, findEventQueryParams)

Expand All @@ -209,21 +219,24 @@ class EventsTests {
@Test
fun `creating a event calls requests with the correct params`() {
val adapter = JsonHelper.moshi().adapter(CreateEventRequest::class.java)
val createEventRequest = CreateEventRequest(
whenObj = CreateEventRequest.When.Timespan(
startTime = 1620000000,
endTime = 1620000000,
startTimezone = "America/Los_Angeles",
endTimezone = "America/Los_Angeles",
),
description = "Description of my new event",
location = "Los Angeles, CA",
metadata = mapOf("your-key" to "value"),
)
val createEventQueryParams = CreateEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)
val createEventRequest =
CreateEventRequest(
whenObj =
CreateEventRequest.When.Timespan(
startTime = 1620000000,
endTime = 1620000000,
startTimezone = "America/Los_Angeles",
endTimezone = "America/Los_Angeles",
),
description = "Description of my new event",
location = "Los Angeles, CA",
metadata = mapOf("your-key" to "value"),
)
val createEventQueryParams =
CreateEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)

events.create(grantId, createEventRequest, createEventQueryParams)
val pathCaptor = argumentCaptor<String>()
Expand All @@ -246,14 +259,16 @@ class EventsTests {
fun `updating a event calls requests with the correct params`() {
val eventId = "event-123"
val adapter = JsonHelper.moshi().adapter(UpdateEventRequest::class.java)
val updateEventRequest = UpdateEventRequest(
description = "Description of my new event",
location = "Los Angeles, CA",
)
val updateEventQueryParams = UpdateEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)
val updateEventRequest =
UpdateEventRequest(
description = "Description of my new event",
location = "Los Angeles, CA",
)
val updateEventQueryParams =
UpdateEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)

events.update(grantId, eventId, updateEventRequest, updateEventQueryParams)
val pathCaptor = argumentCaptor<String>()
Expand All @@ -275,10 +290,11 @@ class EventsTests {
@Test
fun `destroying a event calls requests with the correct params`() {
val eventId = "event-123"
val destroyEventQueryParams = DestroyEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)
val destroyEventQueryParams =
DestroyEventQueryParams(
calendarId = "calendar-id",
notifyParticipants = true,
)

events.destroy(grantId, eventId, destroyEventQueryParams)
val pathCaptor = argumentCaptor<String>()
Expand Down Expand Up @@ -312,12 +328,14 @@ class EventsTests {
fun `sending RSVP calls requests with the correct params`() {
val eventId = "event-123"
val adapter = JsonHelper.moshi().adapter(SendRsvpRequest::class.java)
val sendRsvpRequest = SendRsvpRequest(
status = RsvpStatus.YES,
)
val sendRsvpQueryParams = SendRsvpQueryParams(
calendarId = "calendar-id",
)
val sendRsvpRequest =
SendRsvpRequest(
status = RsvpStatus.YES,
)
val sendRsvpQueryParams =
SendRsvpQueryParams(
calendarId = "calendar-id",
)

events.sendRsvp(grantId, eventId, sendRsvpRequest, sendRsvpQueryParams)
val pathCaptor = argumentCaptor<String>()
Expand Down

0 comments on commit 0d6f321

Please sign in to comment.