Skip to content

Commit

Permalink
v2.1 Changes to fields (#215)
Browse files Browse the repository at this point in the history
# Description
* Added support for `roundTo` field in availability response model
* Added support for `attributes` field in folder model
* Added support for icloud as an auth provider
* Removed `clientId` from `detectProvider`

# 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
mrashed-dev authored Feb 23, 2024
1 parent 3da0b81 commit 1dac6ec
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Nylas Java SDK Changelog

## Unreleased

### Added
* Added support for `roundTo` field in availability response
* Added support for `attributes` field in folder model
* Added support for icloud as an auth provider
* Removed unnecessary `clientId` from detectProvider params

## [2.1.0] - Released 2024-02-12

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/nylas/models/AuthProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ enum class AuthProvider(val value: String) {

@Json(name = "virtual-calendar")
VIRTUAL_CALENDAR("virtual-calendar"),

@Json(name = "icloud")
ICLOUD("icloud"),
}
8 changes: 8 additions & 0 deletions src/main/kotlin/com/nylas/models/Folder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ data class Folder(
*/
@Json(name = "total_count")
val totalCount: Int? = null,
/**
* Common attribute descriptors shared by system folders across providers.
* For example, Sent email folders have the `["\\Sent"]` attribute.
* For IMAP grants, IMAP providers provide the attributes.
* For Google and Microsoft Graph, Nylas matches system folders to a set of common attributes.
*/
@Json(name = "attributes")
val attributes: List<String>? = null,
) {
/**
* Get the type of object.
Expand Down
22 changes: 22 additions & 0 deletions src/main/kotlin/com/nylas/models/GetAvailabilityRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ data class GetAvailabilityRequest(
* When set to true, the availability time slots will start at 30 minutes past or on the hour.
* For example, a free slot starting at 16:10 is considered available only from 16:30.
*/
@Deprecated("Use roundTo instead")
@Json(name = "round_to_30_minutes")
val roundTo30Minutes: Boolean? = null,
/**
* The rules to apply when checking availability.
*/
@Json(name = "availability_rules")
val availabilityRules: AvailabilityRules? = null,
/**
* The number of minutes to round the time slots to.
* This allows for rounding to any multiple of 5 minutes, up to a maximum of 60 minutes.
* The default value is set to 15 minutes.
* When this variable is assigned a value, it overrides the behavior of the [roundTo30Minutes] flag, if it was set.
*/
@Json(name = "round_to")
val roundTo: Int? = null,
) {
/**
* A builder for creating a [GetAvailabilityRequest].
Expand All @@ -62,6 +71,7 @@ data class GetAvailabilityRequest(
private var intervalMinutes: Int? = null
private var roundTo30Minutes: Boolean? = null
private var availabilityRules: AvailabilityRules? = null
private var roundTo: Int? = null

/**
* Set the Nylas checks from the nearest interval of the passed [startTime].
Expand All @@ -78,6 +88,7 @@ data class GetAvailabilityRequest(
* @param roundTo30Minutes When set to true, the availability time slots will start at 30 minutes past or on the hour.
* @return The builder.
*/
@Deprecated("Use roundTo instead")
fun roundTo30Minutes(roundTo30Minutes: Boolean) = apply { this.roundTo30Minutes = roundTo30Minutes }

/**
Expand All @@ -87,6 +98,16 @@ data class GetAvailabilityRequest(
*/
fun availabilityRules(availabilityRules: AvailabilityRules) = apply { this.availabilityRules = availabilityRules }

/**
* Set the number of minutes to round the time slots to.
* This allows for rounding to any multiple of 5 minutes, up to a maximum of 60 minutes.
* The default value is set to 15 minutes.
* When this variable is assigned a value, it overrides the behavior of the [roundTo30Minutes] flag, if it was set.
* @param roundTo The number of minutes to round the time slots to.
* @return The builder.
*/
fun roundTo(roundTo: Int) = apply { this.roundTo = roundTo }

/**
* Build the [GetAvailabilityRequest].
* @return The [GetAvailabilityRequest].
Expand All @@ -99,6 +120,7 @@ data class GetAvailabilityRequest(
intervalMinutes,
roundTo30Minutes,
availabilityRules,
roundTo,
)
}
}
8 changes: 0 additions & 8 deletions src/main/kotlin/com/nylas/models/ProviderDetectParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ data class ProviderDetectParams(
*/
@Json(name = "email")
val email: String,
/**
* Client ID of the Nylas application.
*/
@Json(name = "client_id")
var clientId: String,
/**
* Search by all providers regardless of created integrations. If unset, defaults to false.
*/
Expand All @@ -25,11 +20,9 @@ data class ProviderDetectParams(
/**
* Builder for [ProviderDetectParams].
* @property email Email address to detect the provider for.
* @property clientId Client ID of the Nylas application.
*/
data class Builder(
private val email: String,
private val clientId: String,
) {
private var allProviderTypes: Boolean? = null

Expand All @@ -47,7 +40,6 @@ data class ProviderDetectParams(
*/
fun build() = ProviderDetectParams(
email,
clientId,
allProviderTypes,
)
}
Expand Down
1 change: 0 additions & 1 deletion src/test/kotlin/com/nylas/resources/AuthTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ class AuthTests {
fun `detectProvider calls requests with the correct params`() {
val request = ProviderDetectParams(
email = "[email protected]",
clientId = "abc-123",
allProviderTypes = true,
)

Expand Down
4 changes: 3 additions & 1 deletion src/test/kotlin/com/nylas/resources/FoldersTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class FoldersTests {
"parent_id": "ascsf21412",
"background_color": "#039BE5",
"text_color": "#039BE5",
"total_count": 0
"total_count": 0,
"attributes": ["\\SENT"]
}
""".trimIndent(),
)
Expand All @@ -72,6 +73,7 @@ class FoldersTests {
assertEquals("#039BE5", folder.backgroundColor)
assertEquals("#039BE5", folder.textColor)
assertEquals(0, folder.totalCount)
assertEquals(listOf("\\SENT"), folder.attributes)
}
}

Expand Down

0 comments on commit 1dac6ec

Please sign in to comment.