Skip to content

Conversation

@AaronDDM
Copy link
Contributor

What did oyu do?

  • Add is_plaintext property to CreateDraftRequest and SendMessageRequest models

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.

@playerzero-ai
Copy link

playerzero-ai bot commented Aug 28, 2025

Pull Request Summary

  • New Feature Addition: Introduced an is_plaintext field in the CreateDraftRequest and SendMessageRequest classes to allow users to specify if messages should be sent as plain text or HTML.
  • User Experience Enhancement: Provides users with more control over email formatting, catering to preferences for plain text or HTML emails.
  • Documentation and Demonstration: Added documentation and a new example script to demonstrate the use of the is_plaintext field, including setup instructions and examples of sending messages and creating drafts in both formats.
  • Backward Compatibility: Ensures that messages and drafts can still be sent without explicitly setting is_plaintext, defaulting to the API's existing behavior.
  • Testing: Added tests for both drafts and messages to verify correct handling of plain text and HTML formats, ensuring reliability and functionality across different scenarios.

Functional Tests

  • Verify that messages can be sent as plain text when is_plaintext is set to True.
  • Verify that messages can be sent as HTML when is_plaintext is set to False.
  • Ensure that drafts can be created and updated as plain text when is_plaintext is set to True.
  • Ensure that drafts can be created and updated as HTML when is_plaintext is set to False.
  • Test backward compatibility by sending messages and creating drafts without specifying is_plaintext, ensuring default behavior is maintained.
  • Check that the example script correctly demonstrates the use of is_plaintext for both sending messages and creating drafts.
  • Validate that the new tests in test_drafts.py and test_messages.py accurately cover all scenarios for is_plaintext settings.
  • Confirm that the is_plaintext field in CreateDraftRequest and SendMessageRequest classes functions as expected, allowing user control over email format.

Files Changed

File Name Summary
nylas/models/drafts.py Added optional is_plaintext field to draft and send message requests to specify plain text or HTML format. Documented the field for clarity.
examples/is_plaintext_demo/is_plaintext_example.py New demo script showing how to use is_plaintext when sending messages and creating/updating drafts, with setup instructions and commented API calls.
tests/resources/test_drafts.py Added tests for draft creation with is_plaintext set to True, False, and unspecified for backward compatibility.
tests/resources/test_messages.py Added tests for sending messages with various is_plaintext settings, verifying correct API calls and message formats.

View more in PlayerZero
updated: Aug 28 @ 05:17 PM UTC

…dpoints

- Add is_plaintext property to CreateDraftRequest and SendMessageRequest models
- Property defaults to false (HTML) for backwards compatibility
- When true, sends message body as plain text without HTML in MIME data
- When false, sends message body as HTML with full MIME formatting
- Include comprehensive test coverage for both endpoints
- Add example demonstrating usage in examples/is_plaintext_demo/
- Update CHANGELOG.md with new feature
@AaronDDM AaronDDM merged commit bf0f8eb into main Aug 28, 2025
5 checks passed
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.

3 participants