From 12624b7c19bc22e2dd72f34a85c6fe9b3ffa6e90 Mon Sep 17 00:00:00 2001 From: Blag Date: Thu, 25 Jul 2024 03:12:58 -0500 Subject: [PATCH] Fix Revoke OAuth Token Fixed the call to Revoke OAuth Token --- src/main/kotlin/com/nylas/models/TokenParams.kt | 11 +++++++++++ src/main/kotlin/com/nylas/resources/Auth.kt | 6 +++--- src/test/kotlin/com/nylas/resources/AuthTests.kt | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/com/nylas/models/TokenParams.kt diff --git a/src/main/kotlin/com/nylas/models/TokenParams.kt b/src/main/kotlin/com/nylas/models/TokenParams.kt new file mode 100644 index 00000000..cda36cdc --- /dev/null +++ b/src/main/kotlin/com/nylas/models/TokenParams.kt @@ -0,0 +1,11 @@ +package com.nylas.models + +import com.squareup.moshi.Json + +data class TokenParams( + /** + * Token to be revoked. + */ + @Json(name = "token") + val token: String, +) : IQueryParams diff --git a/src/main/kotlin/com/nylas/resources/Auth.kt b/src/main/kotlin/com/nylas/resources/Auth.kt index 12f3a335..4cee6d36 100644 --- a/src/main/kotlin/com/nylas/resources/Auth.kt +++ b/src/main/kotlin/com/nylas/resources/Auth.kt @@ -136,9 +136,9 @@ class Auth(private val client: NylasClient) { */ @Throws(NylasOAuthError::class, NylasSdkTimeoutError::class) @JvmOverloads - fun revoke(token: String, overrides: RequestOverrides? = null): Boolean { - val path = "v3/connect/revoke?token=$token" - client.executePost(path, MutableMap::class.java, overrides = overrides) + fun revoke(token: TokenParams, overrides: RequestOverrides? = null): Boolean { + val path = "v3/connect/revoke" + client.executePost(path, MutableMap::class.java, queryParams = token, overrides = overrides) return true } diff --git a/src/test/kotlin/com/nylas/resources/AuthTests.kt b/src/test/kotlin/com/nylas/resources/AuthTests.kt index 03d6ed08..ac7d2b2c 100644 --- a/src/test/kotlin/com/nylas/resources/AuthTests.kt +++ b/src/test/kotlin/com/nylas/resources/AuthTests.kt @@ -312,7 +312,7 @@ class AuthTests { fun `revoke calls requests with the correct params`() { val token = "user-token" - val res = auth.revoke(token) + val res = auth.revoke(TokenParams(token)) val pathCaptor = argumentCaptor() val typeCaptor = argumentCaptor() @@ -327,7 +327,7 @@ class AuthTests { overrideParamCaptor.capture(), ) - assertEquals("v3/connect/revoke?token=user-token", pathCaptor.firstValue) + assertEquals("v3/connect/revoke", pathCaptor.firstValue) assertNull(requestBodyCaptor.firstValue) assertEquals(true, res) }