Skip to content

Conversation

AaronDDM
Copy link
Collaborator

@AaronDDM AaronDDM commented Sep 2, 2025

License

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.

- Add select parameter to ListMessagesQueryParams, FindMessageQueryParams, ListThreadsQueryParams, FindThreadQueryParams, ListContactsQueryParams, FindContactsQueryParams, ListEventQueryParams, FindEventQueryParams, ListCalendersQueryParams, FindCalendarQueryParams, and FindAttachmentQueryParams
- Create new FindFolderQueryParams, FindThreadQueryParams, and FindCalendarQueryParams classes
- Update Folders, Threads, and Calendars resources to accept query parameters in find methods
- Make model properties (grantId, id, etc.) optional in Message, Contact, Event, Thread, Folder, and Calendar models to support select functionality
- Add comprehensive tests ensuring backward compatibility
- Update examples to demonstrate select parameter usage

Fixes issue where grant_id wasn't included in responses when using select parameter, preventing model deserialization errors.
- Add SelectParameterDeserializationTests to verify models handle missing fields correctly
- Add SelectParameterIntegrationTests to verify query parameter handling
- Add comprehensive SelectParameterExample demonstrating usage across all endpoints
- Fix nullable field access in EventsTests to prevent compilation errors
- Update CHANGELOG.md with test coverage and examples information

All specified endpoints already have select parameter support and work correctly.
The reported grant_id issue appears to be resolved as deserialization properly
handles missing fields when using select parameter.
Copy link

playerzero-ai bot commented Sep 2, 2025

Pull Request Summary

This pull request introduces several changes aimed at improving the flexibility and performance of the Nylas SDK by allowing clients to request only specific fields in API responses, thereby reducing payload size and latency. Here are the key changes:

  • Introduction of "select" Query Parameter:

    • Added a new optional "select" parameter to various query parameter classes (e.g., FindThreadQueryParams, ListMessagesQueryParams, FindAttachmentQueryParams, etc.).
    • The "select" parameter allows clients to specify a comma-separated list of fields to be returned in API responses, enabling more efficient data retrieval.
  • Data Class and Builder Enhancements:

    • New data classes and builder patterns have been introduced or updated to support the "select" parameter, allowing for fluent construction of query parameters.
    • Builders now include methods to set the "select" parameter, enhancing usability and flexibility.
  • Nullable Fields:

    • Several model classes (e.g., Contact, Message, Event, Calendar, Thread, Folder) have been updated to make certain fields nullable instead of using default values.
    • This change aligns with the API's behavior of omitting fields when they are not present, improving data accuracy and representation.
  • Method Signature Updates:

    • Methods in resource classes (e.g., Threads, Calendars, Folders) have been updated to accept optional query parameters, including the new "select" parameter.
    • These changes allow for more granular control over API requests and responses.
  • Testing and Examples:

    • New tests have been added to ensure the correct handling and propagation of the "select" parameter in API requests.
    • Example files have been updated or added to demonstrate the use of the "select" parameter across various endpoints.
  • Backward Compatibility Considerations:

    • While the changes are mostly backward-compatible, some updates (e.g., nullable fields) may require client code to handle null values where defaults were previously assumed.
    • The insertion of query parameters before existing method arguments may affect Java clients relying on specific argument ordering.

Overall, these changes aim to enhance the SDK's performance and flexibility by allowing clients to tailor API responses to their specific needs, reducing unnecessary data transfer and processing.

Files Changed

File Name Summary
src/main/kotlin/com/nylas/models/FindThreadQueryParams.kt New data class FindThreadQueryParams (implements IQueryParams) with nullable select:String? (JSON "select") and a Builder for fluent construction — lets callers request specific thread fields.
src/main/kotlin/com/nylas/models/ListMessagesQueryParams.kt Added optional select:String? (JSON "select") and Builder.select(...) to let list-messages return only chosen fields; select is nullable (declared var).
src/main/kotlin/com/nylas/models/FindAttachmentQueryParams.kt Added nullable select:String? (JSON "select") with Builder support and KDoc — enables field-level selection when finding attachments.
src/main/kotlin/com/nylas/models/FindCalendarQueryParams.kt New FindCalendarQueryParams (implements IQueryParams) with nullable select:String? and Builder — allows selecting specific calendar fields.
src/main/kotlin/com/nylas/models/ListEventQueryParams.kt Added nullable var select:String? (JSON "select") and Builder.select(...) to request partial event fields for list-events calls.
examples/src/main/kotlin/com/nylas/examples/KotlinFoldersExample.kt Safer CLI printing: folder.name and folder.id print "N/A" when null; added comment about select causing omitted fields. No API change.
src/test/kotlin/com/nylas/resources/FoldersTests.kt New tests covering select/partial-folder responses and ensuring find forwards query params correctly to the client.
src/main/kotlin/com/nylas/resources/Threads.kt find(...) signature extended to accept optional queryParams: FindThreadQueryParams? and forwards it to findResource, allowing query-string options when fetching a thread.
src/main/kotlin/com/nylas/models/FindContactQueryParams.kt Added nullable select:String? (JSON "select"), KDoc, and a Builder (profilePicture + select) so find-contact can request partial fields.
src/main/kotlin/com/nylas/models/Contact.kt Made id, grantId, displayName nullable (String? = null) instead of non-null empty-string defaults to represent missing fields accurately.
src/main/kotlin/com/nylas/models/ListThreadsQueryParams.kt Added nullable var select:String? (JSON "select") with Builder.select(...) to let list-threads return only specified fields.
src/main/kotlin/com/nylas/models/Message.kt Made grantId nullable (String? = null) so Message can be deserialized/constructed when grant_id is omitted.
src/main/kotlin/com/nylas/resources/Calendars.kt find(...) now accepts optional queryParams: FindCalendarQueryParams? and forwards it to findResource; @jvmoverloads preserves default usage.
src/test/kotlin/com/nylas/models/SelectParameterDeserializationTests.kt New unit tests verifying partial/selected JSON responses deserialize safely and omitted fields become null across many models.
src/main/kotlin/com/nylas/models/Folder.kt Changed id and grantId to nullable (String? = null) so Folder tolerates responses that omit those fields.
src/main/kotlin/com/nylas/models/FindFolderQueryParams.kt New FindFolderQueryParams (implements IQueryParams) with nullable select:String? and Builder — supports field selection for folder find calls.
src/test/kotlin/com/nylas/resources/EventsTests.kt Updated assertions to use null-safe access for participants (avoid NPEs), aligning tests with nullable Event fields.
examples/src/main/kotlin/com/nylas/examples/SelectParameterExample.kt New example showing use of select across endpoints (folders, contacts, messages, threads, events, calendars, attachments); demonstrates building query params and notes omitted fields will be null.
src/main/kotlin/com/nylas/resources/Folders.kt find(...) signature extended to accept optional queryParams: FindFolderQueryParams? and forwards to findResource so single-folder GETs can include query params. Note: inserting queryParams before overrides can be a Java compatibility risk.
src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt Added nullable select:String? (JSON "select") with Builder support to allow field selection when finding a message; select is opt-in (defaults to null).
src/main/kotlin/com/nylas/models/Event.kt Many Event properties made nullable (id, grantId, when, busy, calendarId, hideParticipants, participants, readOnly, visibility); getWhen() now can return null — models now represent absent data as null instead of defaults (caller code must handle nulls).
src/main/kotlin/com/nylas/models/ListCalendersQueryParams.kt Added nullable var select:String? (JSON "select") and Builder.select(...) so list-calendars can request specific fields; opt-in and backward compatible.
src/main/kotlin/com/nylas/models/FindEventQueryParams.kt New nullable select:String? (JSON "select") and Builder.select(...) enabling field selection for find-event calls.
src/main/kotlin/com/nylas/models/Calendar.kt Made several Calendar properties nullable (id, grantId, name, timezone, readOnly, isOwnedByUser, isPrimary) to reflect missing data as null instead of sentinel defaults; callers must handle nulls.
src/test/kotlin/com/nylas/resources/SelectParameterIntegrationTests.kt New integration-style tests verifying select query parameter is passed through to executeGet for list/find calls and correct paths are used.
src/main/kotlin/com/nylas/models/ListContactsQueryParams.kt Added nullable select:String? (JSON "select") with Builder.select(...) so list-contacts can return only specified fields; opt-in and backward compatible.
src/main/kotlin/com/nylas/models/Thread.kt Made Thread.id and Thread.grantId nullable (String? = null) so Thread objects can be created/deserialized when those fields are missing.

View more in PlayerZero
updated: Sep 02 @ 01:32 PM UTC

Copy link

playerzero-ai bot commented Sep 26, 2025

nylas + PlayerZero

View more in PlayerZero
updated: Sep 26 @ 07:29 PM UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant