Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
"Bash(/usr/libexec/java_home:*)",
"Bash(./gradlew clean test:*)",
"Bash(./gradlew:*)",
"Bash(./gradlew build:*)"
"Bash(./gradlew build:*)",
"mcp__claude_ai_Slack__slack_read_thread",
"WebFetch(domain:developer.nylas.com)",
"mcp__claude_ai_Atlassian__getAccessibleAtlassianResources",
"mcp__claude_ai_Atlassian__getJiraIssue",
"WebSearch"
]
}
}
18 changes: 18 additions & 0 deletions src/main/kotlin/com/nylas/NylasClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ open class NylasClient(
*/
open fun notetakers(): Notetakers = Notetakers(this)

/**
* Access the Policies API
* @return The Policies API
*/
open fun policies(): Policies = Policies(this)

/**
* Access the Rules API
* @return The Rules API
*/
open fun rules(): Rules = Rules(this)

/**
* Access the Lists API
* @return The Lists API
*/
open fun lists(): NylasLists = NylasLists(this)

/**
* Get a URL builder instance for the Nylas API.
*/
Expand Down
49 changes: 49 additions & 0 deletions src/main/kotlin/com/nylas/models/CreateNylasListRequest.kt
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 create list request.
*/
data class CreateNylasListRequest(
/**
* Name of the list (1–256 characters).
*/
@Json(name = "name")
val name: String,
/**
* The type of values this list will hold. Immutable after creation.
*/
@Json(name = "type")
val type: NylasListType,
/**
* Optional description of the list.
*/
@Json(name = "description")
val description: String? = null,
) {
/**
* Builder for [CreateNylasListRequest].
* @param name Name of the list.
* @param type The type of values this list will hold.
*/
data class Builder(
private val name: String,
private val type: NylasListType,
) {
private var description: String? = null

/**
* Set the description of the list.
* @param description Optional description of the list.
* @return The builder.
*/
fun description(description: String) = apply { this.description = description }

/**
* Build the [CreateNylasListRequest].
* @return A [CreateNylasListRequest] with the provided values.
*/
fun build() = CreateNylasListRequest(name, type, description)
}
}
81 changes: 81 additions & 0 deletions src/main/kotlin/com/nylas/models/CreatePolicyRequest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a Nylas create policy request.
*/
data class CreatePolicyRequest(
/**
* Name of the policy.
*/
@Json(name = "name")
val name: String,
/**
* Optional mailbox and behavior settings.
*/
@Json(name = "options")
val options: PolicyOptions? = null,
/**
* Resource and rate limits for agent accounts using this policy.
*/
@Json(name = "limits")
val limits: PolicyLimits? = null,
/**
* IDs of rules to link to this policy.
*/
@Json(name = "rules")
val rules: List<String>? = null,
/**
* Spam detection configuration.
*/
@Json(name = "spam_detection")
val spamDetection: PolicySpamDetection? = null,
) {
/**
* Builder for [CreatePolicyRequest].
* @param name Name of the policy.
*/
data class Builder(
private val name: String,
) {
private var options: PolicyOptions? = null
private var limits: PolicyLimits? = null
private var rules: List<String>? = null
private var spamDetection: PolicySpamDetection? = null

/**
* Set the mailbox and behavior settings.
* @param options Optional mailbox and behavior settings.
* @return The builder.
*/
fun options(options: PolicyOptions) = apply { this.options = options }

/**
* Set the resource and rate limits.
* @param limits Resource and rate limits for agent accounts using this policy.
* @return The builder.
*/
fun limits(limits: PolicyLimits) = apply { this.limits = limits }

/**
* Set the IDs of rules to link to this policy.
* @param rules IDs of rules to link to this policy.
* @return The builder.
*/
fun rules(rules: List<String>) = apply { this.rules = rules }

/**
* Set the spam detection configuration.
* @param spamDetection Spam detection configuration.
* @return The builder.
*/
fun spamDetection(spamDetection: PolicySpamDetection) = apply { this.spamDetection = spamDetection }

/**
* Build the [CreatePolicyRequest].
* @return A [CreatePolicyRequest] with the provided values.
*/
fun build() = CreatePolicyRequest(name, options, limits, rules, spamDetection)
}
}
89 changes: 89 additions & 0 deletions src/main/kotlin/com/nylas/models/CreateRuleRequest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a Nylas create rule request.
*/
data class CreateRuleRequest(
/**
* Name of the rule.
*/
@Json(name = "name")
val name: String,
/**
* When this rule is evaluated.
*/
@Json(name = "trigger")
val trigger: RuleTrigger,
/**
* The match conditions for this rule.
*/
@Json(name = "match")
val match: RuleMatch,
/**
* The actions to perform when conditions are met.
*/
@Json(name = "actions")
val actions: List<RuleAction>,
/**
* Optional description of the rule.
*/
@Json(name = "description")
val description: String? = null,
/**
* Evaluation order — lower numbers run first. Range 0–1000, default 10.
*/
@Json(name = "priority")
val priority: Int? = null,
/**
* Whether the rule is active. Defaults to true.
*/
@Json(name = "enabled")
val enabled: Boolean? = null,
) {
/**
* Builder for [CreateRuleRequest].
* @param name Name of the rule.
* @param trigger When this rule is evaluated.
* @param match The match conditions.
* @param actions The actions to perform.
*/
data class Builder(
private val name: String,
private val trigger: RuleTrigger,
private val match: RuleMatch,
private val actions: List<RuleAction>,
) {
private var description: String? = null
private var priority: Int? = null
private var enabled: Boolean? = null

/**
* Set the description of the rule.
* @param description Optional description of the rule.
* @return The builder.
*/
fun description(description: String) = apply { this.description = description }

/**
* Set the evaluation priority.
* @param priority Evaluation order — lower numbers run first. Range 0–1000.
* @return The builder.
*/
fun priority(priority: Int) = apply { this.priority = priority }

/**
* Set whether the rule is active.
* @param enabled Whether the rule is active.
* @return The builder.
*/
fun enabled(enabled: Boolean) = apply { this.enabled = enabled }

/**
* Build the [CreateRuleRequest].
* @return A [CreateRuleRequest] with the provided values.
*/
fun build() = CreateRuleRequest(name, trigger, match, actions, description, priority, enabled)
}
}
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nylas/models/ListItemsRequest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of a request to add or remove items in a Nylas list.
*/
data class ListItemsRequest(
/**
* The values to add or remove. Max 1000 items per request.
*/
@Json(name = "items")
val items: List<String>,
)
32 changes: 32 additions & 0 deletions src/main/kotlin/com/nylas/models/ListNylasListItemsQueryParams.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of the query parameters for listing items in a Nylas list.
*/
data class ListNylasListItemsQueryParams(
/**
* The maximum number of objects to return.
*/
@Json(name = "limit")
val limit: Int? = null,
/**
* Cursor for pagination. Pass the value of [ListResponse.nextCursor] to get the next page.
*/
@Json(name = "page_token")
val pageToken: String? = null,
) : IQueryParams {
/**
* Builder for [ListNylasListItemsQueryParams].
*/
class Builder {
private var limit: Int? = null
private var pageToken: String? = null

fun limit(limit: Int) = apply { this.limit = limit }
fun pageToken(pageToken: String) = apply { this.pageToken = pageToken }

fun build() = ListNylasListItemsQueryParams(limit, pageToken)
}
}
32 changes: 32 additions & 0 deletions src/main/kotlin/com/nylas/models/ListNylasListsQueryParams.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of the query parameters for listing Nylas lists.
*/
data class ListNylasListsQueryParams(
/**
* The maximum number of objects to return.
*/
@Json(name = "limit")
val limit: Int? = null,
/**
* Cursor for pagination. Pass the value of [ListResponse.nextCursor] to get the next page.
*/
@Json(name = "page_token")
val pageToken: String? = null,
) : IQueryParams {
/**
* Builder for [ListNylasListsQueryParams].
*/
class Builder {
private var limit: Int? = null
private var pageToken: String? = null

fun limit(limit: Int) = apply { this.limit = limit }
fun pageToken(pageToken: String) = apply { this.pageToken = pageToken }

fun build() = ListNylasListsQueryParams(limit, pageToken)
}
}
32 changes: 32 additions & 0 deletions src/main/kotlin/com/nylas/models/ListPoliciesQueryParams.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.nylas.models

import com.squareup.moshi.Json

/**
* Class representation of the query parameters for listing policies.
*/
data class ListPoliciesQueryParams(
/**
* The maximum number of objects to return.
*/
@Json(name = "limit")
val limit: Int? = null,
/**
* Cursor for pagination. Pass the value of [ListResponse.nextCursor] to get the next page.
*/
@Json(name = "page_token")
val pageToken: String? = null,
) : IQueryParams {
/**
* Builder for [ListPoliciesQueryParams].
*/
class Builder {
private var limit: Int? = null
private var pageToken: String? = null

fun limit(limit: Int) = apply { this.limit = limit }
fun pageToken(pageToken: String) = apply { this.pageToken = pageToken }

fun build() = ListPoliciesQueryParams(limit, pageToken)
}
}
Loading
Loading