Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toJSON() and toMap() support to AccountOwnedModel superclass #150

Merged
merged 5 commits into from
Feb 13, 2023

Conversation

mrashed-dev
Copy link
Collaborator

Description

This PR adds a new helper feature that allows all classes that extend AccountOwnedModel to serialize to either a JSON string or a Map representation of the object's fields.

Usage

public class NylasExample {
  public static void main(String[] args) throws Exception {
    NylasClient client = new NylasClient();
    NylasApplication application = client.application("CLIENT_ID", "CLIENT_SECRET");
    Event event = application.events().get("EVENT_ID");

    // Convert Event to JSON
    String eventJSON = event.toJSON();

    // Convert Event to Map
    Map<String, Event> eventMap = event.toMap();
  }
}

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.

These models have an `object` key that allows us to determine what to deserialize the object to
Job Statuses' object field is polymorphic and represents the object the status belongs to, so we have to deserialize it differently.
@mrashed-dev mrashed-dev merged commit ca7dbca into main Feb 13, 2023
@mrashed-dev mrashed-dev deleted the TW-1986-java-sdk-add-to-json-support branch February 13, 2023 21:10
@mrashed-dev mrashed-dev mentioned this pull request Feb 14, 2023
mrashed-dev added a commit that referenced this pull request Feb 14, 2023
# Description
New Nylas Java SDK release contains the following additions:
### Added

* Added missing `content_disposition` field in `File` (#149)
* Added toJSON() and toMap() support to account owned models (#150)
* Added scheduler support for the EU region (#151)

### Fixed

* Fixed NullPointerException sporadically occurring when calling
`Message.toString()` (#149)

# 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.
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.

2 participants