From 403ca89705879ea2246b93ec41c45d1af94aa102 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:05:22 -0500 Subject: [PATCH 1/4] TW-2476 Fix fromJson error --- src/main/kotlin/com/nylas/util/CreateConnectorAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/nylas/util/CreateConnectorAdapter.kt b/src/main/kotlin/com/nylas/util/CreateConnectorAdapter.kt index 9c59ac07..ae06468b 100644 --- a/src/main/kotlin/com/nylas/util/CreateConnectorAdapter.kt +++ b/src/main/kotlin/com/nylas/util/CreateConnectorAdapter.kt @@ -10,7 +10,7 @@ import com.squareup.moshi.* class CreateConnectorAdapter { @FromJson @Throws(UnsupportedOperationException::class) - fun fromJson(reader: JsonReader): CreateEventRequest.Conferencing? { + fun fromJson(reader: JsonReader): CreateConnectorRequest? { throw UnsupportedOperationException("CreateConnectorRequest is only used for serialization") } From 49cc9263338b39f8cf0f7bcac45cf9ee07b4bcc4 Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:05:54 -0500 Subject: [PATCH 2/4] TW-2475 Annotate WebhookDeleteResponse --- src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt b/src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt index 15e330e6..6e7adff3 100644 --- a/src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt +++ b/src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a Nylas webhook delete response. */ @@ -7,10 +9,12 @@ data class WebhookDeleteResponse( /** * ID of the request. */ + @Json(name = "request_id") val requestId: String, /** * Object containing the webhook deletion status. */ + @Json(name = "data") val data: DataWebhookDeleteData? = null, ) { /** @@ -20,6 +24,7 @@ data class WebhookDeleteResponse( /** * The status of the webhook deletion. */ - val status: Boolean, + @Json(name = "status") + val status: String, ) } From 1eb73af437c48cc820c0ea0c266115fd698cd3de Mon Sep 17 00:00:00 2001 From: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:17:28 -0500 Subject: [PATCH 3/4] Add missing annotations --- .../kotlin/com/nylas/models/ComposeMessageRequest.kt | 3 +++ .../kotlin/com/nylas/models/ComposeMessageResponse.kt | 3 +++ src/main/kotlin/com/nylas/models/ContactEmail.kt | 4 ++++ src/main/kotlin/com/nylas/models/ContactGroup.kt | 8 ++++++++ src/main/kotlin/com/nylas/models/ContactGroupId.kt | 6 ++++++ src/main/kotlin/com/nylas/models/CreateFolderRequest.kt | 6 ++++++ src/main/kotlin/com/nylas/models/EmailName.kt | 4 ++++ .../kotlin/com/nylas/models/FindMessageQueryParams.kt | 3 +++ .../kotlin/com/nylas/models/InstantMessagingAddress.kt | 4 ++++ src/main/kotlin/com/nylas/models/MessageHeaders.kt | 4 ++++ src/main/kotlin/com/nylas/models/PKCEAuthURL.kt | 5 +++++ src/main/kotlin/com/nylas/models/PhoneNumber.kt | 4 ++++ src/main/kotlin/com/nylas/models/PhysicalAddress.kt | 9 +++++++++ src/main/kotlin/com/nylas/models/ScheduledMessage.kt | 5 +++++ .../kotlin/com/nylas/models/ScheduledMessageStatus.kt | 4 ++++ .../kotlin/com/nylas/models/ScheduledMessagesList.kt | 3 +++ .../com/nylas/models/StopScheduledMessageResponse.kt | 3 +++ .../kotlin/com/nylas/models/UpdateConnectorRequest.kt | 5 +++++ .../kotlin/com/nylas/models/UpdateCredentialRequest.kt | 4 ++++ src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt | 6 ++++++ 20 files changed, 93 insertions(+) diff --git a/src/main/kotlin/com/nylas/models/ComposeMessageRequest.kt b/src/main/kotlin/com/nylas/models/ComposeMessageRequest.kt index 625f18f5..f4c17feb 100644 --- a/src/main/kotlin/com/nylas/models/ComposeMessageRequest.kt +++ b/src/main/kotlin/com/nylas/models/ComposeMessageRequest.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a request to compose a message. */ @@ -7,5 +9,6 @@ data class ComposeMessageRequest( /** * The prompt that smart compose will use to generate a message suggestion. */ + @Json(name = "prompt") val prompt: String, ) diff --git a/src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt b/src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt index e94e7aad..f3c0304a 100644 --- a/src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt +++ b/src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a response to a message composition request. */ @@ -7,5 +9,6 @@ data class ComposeMessageResponse( /** * The message suggestion generated by smart compose. */ + @Json(name = "suggestion") val suggestion: String, ) diff --git a/src/main/kotlin/com/nylas/models/ContactEmail.kt b/src/main/kotlin/com/nylas/models/ContactEmail.kt index 1cf4188f..6106ac01 100644 --- a/src/main/kotlin/com/nylas/models/ContactEmail.kt +++ b/src/main/kotlin/com/nylas/models/ContactEmail.kt @@ -1,10 +1,14 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Interface for email addresses in a contact. */ data class ContactEmail( + @Json(name = "email") val email: String? = null, + @Json(name = "type") val type: ContactType? = null, ) { class Builder { diff --git a/src/main/kotlin/com/nylas/models/ContactGroup.kt b/src/main/kotlin/com/nylas/models/ContactGroup.kt index b4fc571d..2dc9fca6 100644 --- a/src/main/kotlin/com/nylas/models/ContactGroup.kt +++ b/src/main/kotlin/com/nylas/models/ContactGroup.kt @@ -1,14 +1,22 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a contact group. */ data class ContactGroup( + @Json(name = "id") val id: String, + @Json(name = "grant_id") val grantId: String? = null, + @Json(name="group_type") val groupType: GroupType? = null, + @Json(name = "name") val name: String? = null, + @Json(name = "path") val path: String? = null, + @Json(name = "object") private val obj: String = "contact_group", ) { fun getObject() = obj diff --git a/src/main/kotlin/com/nylas/models/ContactGroupId.kt b/src/main/kotlin/com/nylas/models/ContactGroupId.kt index 4db33a7a..85e050e7 100644 --- a/src/main/kotlin/com/nylas/models/ContactGroupId.kt +++ b/src/main/kotlin/com/nylas/models/ContactGroupId.kt @@ -1,8 +1,14 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing an object that points to a contact group ID. */ data class ContactGroupId( + /** + * The ID of the contact group. + */ + @Json(name = "id") val id: String, ) diff --git a/src/main/kotlin/com/nylas/models/CreateFolderRequest.kt b/src/main/kotlin/com/nylas/models/CreateFolderRequest.kt index 5f7a5644..f5e41226 100644 --- a/src/main/kotlin/com/nylas/models/CreateFolderRequest.kt +++ b/src/main/kotlin/com/nylas/models/CreateFolderRequest.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representation of the Nylas folder creation request. */ @@ -7,18 +9,22 @@ data class CreateFolderRequest( /** * The name of the folder. */ + @Json(name = "name") val name: String, /** * The parent ID of the folder. (Microsoft only) */ + @Json(name = "parent_id") val parentId: String? = null, /** * The background color of the folder. (Google only) */ + @Json(name = "background_color") val backgroundColor: String? = null, /** * The text color of the folder. (Google only) */ + @Json(name = "text_color") val textColor: String? = null, ) { /** diff --git a/src/main/kotlin/com/nylas/models/EmailName.kt b/src/main/kotlin/com/nylas/models/EmailName.kt index 6c4c87ae..f4eb280d 100644 --- a/src/main/kotlin/com/nylas/models/EmailName.kt +++ b/src/main/kotlin/com/nylas/models/EmailName.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing an email address and optional name. */ @@ -7,9 +9,11 @@ data class EmailName( /** * Email address. */ + @Json(name = "email") val email: String, /** * Full name. */ + @Json(name = "name") val name: String? = null, ) diff --git a/src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt b/src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt index b830c079..5b1e0e0d 100644 --- a/src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt +++ b/src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing the query parameters for finding a message. */ @@ -7,5 +9,6 @@ data class FindMessageQueryParams( /** * Allows you to specify to the message with headers included. */ + @Json(name = "fields") val fields: MessageFields? = null, ) diff --git a/src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt b/src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt index 6db3b788..f05d9711 100644 --- a/src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt +++ b/src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt @@ -1,10 +1,14 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representation for an IM address in a contact. */ data class InstantMessagingAddress( + @Json(name = "im_address") val imAddress: String? = null, + @Json(name = "type") val type: ContactType? = null, ) { class Builder { diff --git a/src/main/kotlin/com/nylas/models/MessageHeaders.kt b/src/main/kotlin/com/nylas/models/MessageHeaders.kt index 5789123b..375543b7 100644 --- a/src/main/kotlin/com/nylas/models/MessageHeaders.kt +++ b/src/main/kotlin/com/nylas/models/MessageHeaders.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a message header. */ @@ -7,9 +9,11 @@ data class MessageHeaders( /** * The header name. */ + @Json(name = "name") val name: String, /** * The header value. */ + @Json(name = "value") val value: String, ) diff --git a/src/main/kotlin/com/nylas/models/PKCEAuthURL.kt b/src/main/kotlin/com/nylas/models/PKCEAuthURL.kt index 05ffd57b..62ac617b 100644 --- a/src/main/kotlin/com/nylas/models/PKCEAuthURL.kt +++ b/src/main/kotlin/com/nylas/models/PKCEAuthURL.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing the object containing the OAuth 2.0 URL as well as the hashed secret. */ @@ -7,13 +9,16 @@ data class PKCEAuthURL( /** * The URL for hosted authentication */ + @Json(name = "url") val url: String, /** * Server-side challenge used in the OAuth 2.0 flow */ + @Json(name = "secret") val secret: String, /** * SHA-256 hash of the secret */ + @Json(name = "secret_hash") val secretHash: String, ) diff --git a/src/main/kotlin/com/nylas/models/PhoneNumber.kt b/src/main/kotlin/com/nylas/models/PhoneNumber.kt index bd4d8719..845dc7a4 100644 --- a/src/main/kotlin/com/nylas/models/PhoneNumber.kt +++ b/src/main/kotlin/com/nylas/models/PhoneNumber.kt @@ -1,10 +1,14 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representation for phone numbers in a contact. */ data class PhoneNumber( + @Json(name = "number") val number: String? = null, + @Json(name = "type") val type: ContactType? = null, ) { class Builder { diff --git a/src/main/kotlin/com/nylas/models/PhysicalAddress.kt b/src/main/kotlin/com/nylas/models/PhysicalAddress.kt index 3479e47c..891f017b 100644 --- a/src/main/kotlin/com/nylas/models/PhysicalAddress.kt +++ b/src/main/kotlin/com/nylas/models/PhysicalAddress.kt @@ -1,15 +1,24 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representation for a physical address in a contact. */ data class PhysicalAddress( + @Json(name = "format") val format: String? = null, + @Json(name = "street_address") val streetAddress: String? = null, + @Json(name = "city") val city: String? = null, + @Json(name = "postal_code") val postalCode: String? = null, + @Json(name = "state") val state: String? = null, + @Json(name = "country") val country: String? = null, + @Json(name = "type") val type: ContactType? = null, ) { class Builder { diff --git a/src/main/kotlin/com/nylas/models/ScheduledMessage.kt b/src/main/kotlin/com/nylas/models/ScheduledMessage.kt index 0e1d8a3c..79a18255 100644 --- a/src/main/kotlin/com/nylas/models/ScheduledMessage.kt +++ b/src/main/kotlin/com/nylas/models/ScheduledMessage.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing information about a scheduled message. */ @@ -7,13 +9,16 @@ data class ScheduledMessage( /** * The unique identifier for the scheduled message. */ + @Json(name = "scheduled_id") val scheduleId: Int, /** * The status of the scheduled message. */ + @Json(name = "status") val status: ScheduledMessageStatus, /** * The time the message was sent or failed to send, in epoch time. */ + @Json(name = "close_time") val closeTime: Int?, ) diff --git a/src/main/kotlin/com/nylas/models/ScheduledMessageStatus.kt b/src/main/kotlin/com/nylas/models/ScheduledMessageStatus.kt index c4ebaaca..591da80e 100644 --- a/src/main/kotlin/com/nylas/models/ScheduledMessageStatus.kt +++ b/src/main/kotlin/com/nylas/models/ScheduledMessageStatus.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a scheduled message status. */ @@ -7,9 +9,11 @@ data class ScheduledMessageStatus( /** * The status code the describes the state of the scheduled message */ + @Json(name = "code") val code: String, /** * A description of the status of the scheduled message */ + @Json(name = "description") val description: String, ) diff --git a/src/main/kotlin/com/nylas/models/ScheduledMessagesList.kt b/src/main/kotlin/com/nylas/models/ScheduledMessagesList.kt index 03d7137c..730e6aa4 100644 --- a/src/main/kotlin/com/nylas/models/ScheduledMessagesList.kt +++ b/src/main/kotlin/com/nylas/models/ScheduledMessagesList.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a list of scheduled messages. */ @@ -7,5 +9,6 @@ data class ScheduledMessagesList( /** * The list of scheduled messages. */ + @Json(name = "schedules") val schedules: List, ) diff --git a/src/main/kotlin/com/nylas/models/StopScheduledMessageResponse.kt b/src/main/kotlin/com/nylas/models/StopScheduledMessageResponse.kt index 71ba4bb2..5f02b90a 100644 --- a/src/main/kotlin/com/nylas/models/StopScheduledMessageResponse.kt +++ b/src/main/kotlin/com/nylas/models/StopScheduledMessageResponse.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a response after stopping a scheduled message. */ @@ -7,5 +9,6 @@ data class StopScheduledMessageResponse( /** * A message describing the result of the request. */ + @Json(name = "message") val message: String, ) diff --git a/src/main/kotlin/com/nylas/models/UpdateConnectorRequest.kt b/src/main/kotlin/com/nylas/models/UpdateConnectorRequest.kt index 91838b90..a4527f19 100644 --- a/src/main/kotlin/com/nylas/models/UpdateConnectorRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateConnectorRequest.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a Nylas update connector request. */ @@ -7,13 +9,16 @@ data class UpdateConnectorRequest( /** * Custom name of the connector */ + @Json(name = "name") val name: String?, /** * The OAuth provider credentials and settings */ + @Json(name = "settings") val settings: Map?, /** * The OAuth scopes */ + @Json(name = "scope") val scope: List?, ) diff --git a/src/main/kotlin/com/nylas/models/UpdateCredentialRequest.kt b/src/main/kotlin/com/nylas/models/UpdateCredentialRequest.kt index 8ea98948..61f3491d 100644 --- a/src/main/kotlin/com/nylas/models/UpdateCredentialRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateCredentialRequest.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representing a request to update a credential */ @@ -7,10 +9,12 @@ data class UpdateCredentialRequest( /** * Unique name of this credential */ + @Json(name = "name") val name: String?, /** * Data that specifies some special data required for this credential */ + @Json(name = "credential_data") val credentialData: CredentialData?, ) { /** diff --git a/src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt b/src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt index 29fe7bc1..dec9f246 100644 --- a/src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt +++ b/src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt @@ -1,5 +1,7 @@ package com.nylas.models +import com.squareup.moshi.Json + /** * Class representation of the Nylas folder update request. */ @@ -7,18 +9,22 @@ data class UpdateFolderRequest( /** * The name of the folder. */ + @Json(name = "name") val name: String? = null, /** * The parent ID of the folder. (Microsoft only) */ + @Json(name = "parent_id") val parentId: String? = null, /** * The background color of the folder. (Google only) */ + @Json(name = "background_color") val backgroundColor: String? = null, /** * The text color of the folder. (Google only) */ + @Json(name = "text_color") val textColor: String? = null, ) { /** From 71cfaf6a74a7849fdd5db69aaf61e01ac39588a3 Mon Sep 17 00:00:00 2001 From: Blag Date: Wed, 10 Jan 2024 22:53:57 -0500 Subject: [PATCH 4/4] Update ContactGroup.tk Add extra space to be compliant with the Linter --- src/main/kotlin/com/nylas/models/ContactGroup.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/nylas/models/ContactGroup.kt b/src/main/kotlin/com/nylas/models/ContactGroup.kt index 2dc9fca6..67cab6c8 100644 --- a/src/main/kotlin/com/nylas/models/ContactGroup.kt +++ b/src/main/kotlin/com/nylas/models/ContactGroup.kt @@ -10,7 +10,7 @@ data class ContactGroup( val id: String, @Json(name = "grant_id") val grantId: String? = null, - @Json(name="group_type") + @Json(name = "group_type") val groupType: GroupType? = null, @Json(name = "name") val name: String? = null,