From 623b67259fd2bb93b778a6229b6583aab3518c8b Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Thu, 17 Aug 2023 10:21:14 -0400 Subject: [PATCH] v2.0.0-beta.1 Release (#161) # Description This PR is for releasing the first beta of v2 on maven central. # License 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. --- CHANGELOG.md | 20 +++++--- build.gradle.kts | 48 +++++++++++++++++++ .../com/nylas/models/AvailabilityMethod.kt | 3 +- .../kotlin/com/nylas/models/EventStatus.kt | 4 +- .../nylas/models/GetAvailabilityRequest.kt | 8 ++-- .../com/nylas/models/ListGrantsQueryParams.kt | 1 - src/main/kotlin/com/nylas/models/TimeSlot.kt | 2 +- .../com/nylas/models/UpdateGrantRequest.kt | 1 - src/main/kotlin/com/nylas/models/Webhook.kt | 2 +- .../kotlin/com/nylas/models/WebhookStatus.kt | 5 +- .../com/nylas/models/WebhookTriggers.kt | 13 ++++- .../kotlin/com/nylas/resources/Calendars.kt | 2 +- .../kotlin/com/nylas/resources/Webhooks.kt | 2 +- 13 files changed, 91 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b7fef3..64196f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,28 @@ # Nylas Java SDK Changelog -## [Unreleased] +## [2.0.0-beta.1] - Released 2023-08-16 -This section contains changes that have been committed but not yet released. +### BREAKING CHANGES + +* Renamed artifact from `nylas-java-sdk` to `nylas`. +* Nylas SDK v2 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3. +* Removed all REST calls from models and moved them directly into resources ### Added -### Changed +* Full Kotlin support +* Created models for all API resources and endpoints, for all HTTP methods to reduce confusion on which fields are available for each endpoint +* Created error classes for the different API errors as well as SDK-specific errors -### Deprecated +### Changed -### Fixed +* Leveraged Moshi annotations for JSON serialization/deserialization as opposed to manually writing JSON maps +* Removed all REST calls from models and moved them directly into resources ### Removed -### Security +* Non-builder ways for initializing `NylasClient` +* Local Webhook development support is removed due to incompatibility with the new API version ## [1.21.0] - Released 2023-02-14 diff --git a/build.gradle.kts b/build.gradle.kts index e639c555..331e97ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,10 @@ plugins { kotlin("jvm") version "1.8.21" id("org.jmailen.kotlinter") version "3.15.0" id("org.jetbrains.dokka") version "1.8.20" + `maven-publish` + `java-library` application + signing } repositories { @@ -12,6 +15,8 @@ repositories { java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + withJavadocJar() + withSourcesJar() } kotlin { @@ -58,3 +63,46 @@ tasks.register("uberJar") { configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } }) } + +publishing { + publications { + create("mavenJava") { + from(components["java"]) + pom { + name.set("Nylas SDK for Kotlin & Java") + description.set("Kotlin & Java SDK for the Nylas Communication Platform") + url.set("https://github.com/nylas/nylas-java") + licenses { + license { + name.set("MIT") + url.set("http://www.opensource.org/licenses/mit-license.php") + } + } + developers { + developer { + id.set("mrashed-dev") + name.set("Mostafa Rashed") + organization.set("Nylas") + organizationUrl.set("https://www.nylas.com/") + } + } + scm { + url.set("https://github.com/nylas/nylas-java") + connection.set("scm:git:https://github.com/nylas/nylas-java.git") + developerConnection.set("scm:git:https://github.com/nylas/nylas-java.git") + } + } + } + } + repositories { + maven { + name = "ossrh" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") + credentials(PasswordCredentials::class) + } + } +} + +signing { + sign(publishing.publications["mavenJava"]) +} diff --git a/src/main/kotlin/com/nylas/models/AvailabilityMethod.kt b/src/main/kotlin/com/nylas/models/AvailabilityMethod.kt index ef2e38f7..f0283a0c 100644 --- a/src/main/kotlin/com/nylas/models/AvailabilityMethod.kt +++ b/src/main/kotlin/com/nylas/models/AvailabilityMethod.kt @@ -8,6 +8,7 @@ import com.squareup.moshi.Json enum class AvailabilityMethod { @Json(name = "max-fairness") MAX_FAIRNESS, + @Json(name = "max-availability") MAX_AVAILABILITY, -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/nylas/models/EventStatus.kt b/src/main/kotlin/com/nylas/models/EventStatus.kt index 32d3fbd2..8c86995e 100644 --- a/src/main/kotlin/com/nylas/models/EventStatus.kt +++ b/src/main/kotlin/com/nylas/models/EventStatus.kt @@ -8,8 +8,10 @@ import com.squareup.moshi.Json enum class EventStatus { @Json(name = "confirmed") CONFIRMED, + @Json(name = "tentative") TENTATIVE, + @Json(name = "cancelled") CANCELLED, -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/nylas/models/GetAvailabilityRequest.kt b/src/main/kotlin/com/nylas/models/GetAvailabilityRequest.kt index a3760381..f5e37313 100644 --- a/src/main/kotlin/com/nylas/models/GetAvailabilityRequest.kt +++ b/src/main/kotlin/com/nylas/models/GetAvailabilityRequest.kt @@ -54,8 +54,8 @@ data class GetAvailabilityRequest( * @param durationMinutes The total number of minutes the event should last. */ data class Builder( - private val startTime: String, - private val endTime: String, + private val startTime: Int, + private val endTime: Int, private val participants: List, private val durationMinutes: Int, ) { @@ -98,7 +98,7 @@ data class GetAvailabilityRequest( durationMinutes, intervalMinutes, roundTo30Minutes, - availabilityRules + availabilityRules, ) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/nylas/models/ListGrantsQueryParams.kt b/src/main/kotlin/com/nylas/models/ListGrantsQueryParams.kt index 00ddb60d..ce45687b 100644 --- a/src/main/kotlin/com/nylas/models/ListGrantsQueryParams.kt +++ b/src/main/kotlin/com/nylas/models/ListGrantsQueryParams.kt @@ -132,7 +132,6 @@ data class ListGrantsQueryParams( */ fun provider(provider: AuthProvider?) = apply { this.provider = provider } - /** * Builds a [ListGrantsQueryParams] instance. * @return The [ListGrantsQueryParams] instance. diff --git a/src/main/kotlin/com/nylas/models/TimeSlot.kt b/src/main/kotlin/com/nylas/models/TimeSlot.kt index faae1f79..5d154d9d 100644 --- a/src/main/kotlin/com/nylas/models/TimeSlot.kt +++ b/src/main/kotlin/com/nylas/models/TimeSlot.kt @@ -21,4 +21,4 @@ data class TimeSlot( */ @Json(name = "end_time") val endTime: Int, -) \ No newline at end of file +) diff --git a/src/main/kotlin/com/nylas/models/UpdateGrantRequest.kt b/src/main/kotlin/com/nylas/models/UpdateGrantRequest.kt index 5f85f8a4..72e52762 100644 --- a/src/main/kotlin/com/nylas/models/UpdateGrantRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateGrantRequest.kt @@ -38,7 +38,6 @@ data class UpdateGrantRequest( */ fun scopes(scopes: List) = apply { this.scopes = scopes } - /** * Build the [UpdateGrantRequest]. * @return The built [UpdateGrantRequest] diff --git a/src/main/kotlin/com/nylas/models/Webhook.kt b/src/main/kotlin/com/nylas/models/Webhook.kt index 5ecff3b7..3d47c722 100644 --- a/src/main/kotlin/com/nylas/models/Webhook.kt +++ b/src/main/kotlin/com/nylas/models/Webhook.kt @@ -51,4 +51,4 @@ data class Webhook( */ @Json(name = "notification_email_address") val notificationEmailAddress: String? = null, -) \ No newline at end of file +) diff --git a/src/main/kotlin/com/nylas/models/WebhookStatus.kt b/src/main/kotlin/com/nylas/models/WebhookStatus.kt index c7c94bdd..a14cd45a 100644 --- a/src/main/kotlin/com/nylas/models/WebhookStatus.kt +++ b/src/main/kotlin/com/nylas/models/WebhookStatus.kt @@ -8,10 +8,13 @@ import com.squareup.moshi.Json enum class WebhookStatus { @Json(name = "active") ACTIVE, + @Json(name = "failing") FAILING, + @Json(name = "failed") FAILED, + @Json(name = "paused") PAUSE, -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/nylas/models/WebhookTriggers.kt b/src/main/kotlin/com/nylas/models/WebhookTriggers.kt index abde3fbc..a4581674 100644 --- a/src/main/kotlin/com/nylas/models/WebhookTriggers.kt +++ b/src/main/kotlin/com/nylas/models/WebhookTriggers.kt @@ -8,26 +8,37 @@ import com.squareup.moshi.Json enum class WebhookTriggers { @Json(name = "calendar.created") CALENDAR_CREATED, + @Json(name = "calendar.updated") CALENDAR_UPDATED, + @Json(name = "calendar.deleted") CALENDAR_DELETED, + @Json(name = "event.created") EVENT_CREATED, + @Json(name = "event.updated") EVENT_UPDATED, + @Json(name = "event.deleted") EVENT_DELETED, + @Json(name = "grant.created") GRANT_CREATED, + @Json(name = "grant.updated") GRANT_UPDATED, + @Json(name = "grant.deleted") GRANT_DELETED, + @Json(name = "grant.expired") GRANT_EXPIRED, + @Json(name = "message.send_success") MESSAGE_SEND_SUCCESS, + @Json(name = "message.send_failed") MESSAGE_SEND_FAILED, -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/nylas/resources/Calendars.kt b/src/main/kotlin/com/nylas/resources/Calendars.kt index 2b4124cd..73cc0aeb 100644 --- a/src/main/kotlin/com/nylas/resources/Calendars.kt +++ b/src/main/kotlin/com/nylas/resources/Calendars.kt @@ -89,7 +89,7 @@ class Calendars(client: NylasClient) : Resource(client, Calendar::clas val serializedRequestBody = JsonHelper.moshi() .adapter(GetAvailabilityRequest::class.java) - .toJson(request); + .toJson(request) return client.executePost(path, GetAvailabilityResponse::class.java, serializedRequestBody) } diff --git a/src/main/kotlin/com/nylas/resources/Webhooks.kt b/src/main/kotlin/com/nylas/resources/Webhooks.kt index 1d1cd603..485cbd31 100644 --- a/src/main/kotlin/com/nylas/resources/Webhooks.kt +++ b/src/main/kotlin/com/nylas/resources/Webhooks.kt @@ -111,4 +111,4 @@ class Webhooks(client: NylasClient) : Resource(client, Webhook::class.j return challengeParameter } -} \ No newline at end of file +}