-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Messages, Drafts, and Smart Compose APIs support (#166)
# Description This PR adds support for messages, drafts, and smart compose APIs. # 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
1 parent
358dce8
commit d5532ef
Showing
35 changed files
with
2,576 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.nylas.models | ||
|
||
import com.squareup.moshi.Json | ||
|
||
/** | ||
* Class representation of a Nylas attachment object | ||
*/ | ||
data class Attachment( | ||
/** | ||
* Globally unique object identifier. | ||
*/ | ||
@Json(name = "id") | ||
val id: String? = null, | ||
/** | ||
* Nylas grant ID that is now successfully created. | ||
*/ | ||
@Json(name = "grant_id") | ||
val grantId: String? = null, | ||
/** | ||
* The size of the attachment in bytes. | ||
*/ | ||
@Json(name = "size") | ||
val size: Int? = null, | ||
/** | ||
* The filename of the attachment. | ||
*/ | ||
@Json(name = "filename") | ||
val filename: String? = null, | ||
/** | ||
* The content type of the attachment. | ||
*/ | ||
@Json(name = "content_type") | ||
val contentType: String? = null, | ||
/** | ||
* If it's an inline attachment. | ||
*/ | ||
@Json(name = "is_inline") | ||
val isInline: Boolean? = null, | ||
/** | ||
* The content ID of the attachment. | ||
*/ | ||
@Json(name = "content_id") | ||
val contentId: String? = null, | ||
/** | ||
* The content disposition if the attachment is located inline. | ||
*/ | ||
@Json(name = "content_disposition") | ||
val contentDisposition: String? = null, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.nylas.models | ||
|
||
/** | ||
* Class representing a request to compose a message. | ||
*/ | ||
data class ComposeMessageRequest( | ||
/** | ||
* The prompt that smart compose will use to generate a message suggestion. | ||
*/ | ||
val prompt: String, | ||
) |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.nylas.models | ||
|
||
/** | ||
* Class representing a response to a message composition request. | ||
*/ | ||
data class ComposeMessageResponse( | ||
/** | ||
* The message suggestion generated by smart compose. | ||
*/ | ||
val suggestion: String, | ||
) |
97 changes: 97 additions & 0 deletions
97
src/main/kotlin/com/nylas/models/CreateAttachmentRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.nylas.models | ||
|
||
import com.squareup.moshi.Json | ||
import java.io.InputStream | ||
|
||
/** | ||
* Class representing a Nylas attachment object. | ||
*/ | ||
class CreateAttachmentRequest( | ||
/** | ||
* The filename of the attachment. | ||
*/ | ||
@Json(name = "filename") | ||
val filename: String, | ||
/** | ||
* The content type of the attachment. | ||
*/ | ||
@Json(name = "content_type") | ||
val contentType: String, | ||
/** | ||
* The content of the attachment. | ||
*/ | ||
@Transient | ||
val content: InputStream, | ||
/** | ||
* The size of the attachment in bytes. | ||
*/ | ||
@Json(name = "size") | ||
val size: Int, | ||
/** | ||
* If it's an inline attachment. | ||
*/ | ||
@Json(name = "is_inline") | ||
val isInline: Boolean? = null, | ||
/** | ||
* The content ID of the attachment. | ||
*/ | ||
@Json(name = "content_id") | ||
val contentId: String? = null, | ||
/** | ||
* The content disposition if the attachment is located inline. | ||
*/ | ||
@Json(name = "content_disposition") | ||
val contentDisposition: String? = null, | ||
) { | ||
/** | ||
* Builder for [CreateAttachmentRequest]. | ||
* @property filename The filename of the attachment. | ||
* @property contentType The content type of the attachment. | ||
* @property size The size of the attachment in bytes. | ||
*/ | ||
data class Builder( | ||
private val filename: String, | ||
private val contentType: String, | ||
private val content: InputStream, | ||
private val size: Int, | ||
) { | ||
private var isInline: Boolean? = null | ||
private var contentId: String? = null | ||
private var contentDisposition: String? = null | ||
|
||
/** | ||
* Set if the attachment is inline. | ||
* @param isInline If the attachment is inline. | ||
* @return The builder. | ||
*/ | ||
fun isInline(isInline: Boolean) = apply { this.isInline = isInline } | ||
|
||
/** | ||
* Set the content ID of the attachment. | ||
* @param contentId The content ID of the attachment. | ||
* @return The builder. | ||
*/ | ||
fun contentId(contentId: String) = apply { this.contentId = contentId } | ||
|
||
/** | ||
* Set the content disposition of the attachment. | ||
* @param contentDisposition The content disposition of the attachment. | ||
* @return The builder. | ||
*/ | ||
fun contentDisposition(contentDisposition: String) = apply { this.contentDisposition = contentDisposition } | ||
|
||
/** | ||
* Build the [CreateAttachmentRequest]. | ||
* @return The [CreateAttachmentRequest]. | ||
*/ | ||
fun build() = CreateAttachmentRequest( | ||
filename = filename, | ||
contentType = contentType, | ||
content = content, | ||
size = size, | ||
isInline = isInline, | ||
contentId = contentId, | ||
contentDisposition = contentDisposition, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.