Skip to content

Conversation

@mqasimca
Copy link

Add comprehensive Nylas API v3 integration to the notify library, enabling email notifications through Nylas's communication platform. This implementation uses direct REST API calls to Nylas v3 endpoints, as there is no official Go SDK available for v3.

New Files

  • service/nylas/nylas.go - Core service implementation with full v3 API support
  • service/nylas/doc.go - Package documentation with usage examples
  • service/nylas/nylas_test.go - Comprehensive test suite with mock HTTP client
  • service/nylas/compile_check.go - Compile-time interface verification
  • service/nylas/example_test.go - Example usage demonstrations

Features

  • ✓ Direct REST API integration with Nylas v3 (no external SDK dependencies)
  • ✓ Multiple recipient support via AddReceivers()
  • ✓ HTML and plain text email formatting (BodyFormat())
  • ✓ Regional API support (US/EU) via WithBaseURL()
  • ✓ Custom HTTP client injection for testing (WithHTTPClient())
  • ✓ Context-aware operations with proper cancellation support
  • ✓ Production-ready timeout configuration (150s for Exchange servers)
  • ✓ Comprehensive error handling with detailed Nylas API error messages
  • ✓ Grant ID-based authentication (Nylas v3 authentication model)

Testing

  • 7 comprehensive test cases covering all scenarios
  • Mock HTTP client for isolated unit testing
  • Tests for success cases, error handling, context cancellation
  • All tests passing with full coverage of core functionality
  • Successfully tested with live Nylas API v3 endpoint

Implementation Details

The service follows the established notify library patterns:

  • Implements the notify.Notifier interface
  • Consistent API design matching other services (SendGrid, Mailgun)
  • No breaking changes to existing code
  • Zero external dependencies beyond Go standard library

API Reference

https://developer.nylas.com/docs/v3/email/send-email/

Closes integration gap for Nylas API v3 support in the notify ecosystem.

Description

Motivation and Context

How Has This Been Tested?

Screenshots / Output (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Add comprehensive Nylas API v3 integration to the notify library,
enabling email notifications through Nylas's communication platform.
This implementation uses direct REST API calls to Nylas v3 endpoints,
as there is no official Go SDK available for v3.

## New Files

- service/nylas/nylas.go - Core service implementation with full v3 API support
- service/nylas/doc.go - Package documentation with usage examples
- service/nylas/nylas_test.go - Comprehensive test suite with mock HTTP client
- service/nylas/compile_check.go - Compile-time interface verification
- service/nylas/example_test.go - Example usage demonstrations

## Features

- ✓ Direct REST API integration with Nylas v3 (no external SDK dependencies)
- ✓ Multiple recipient support via AddReceivers()
- ✓ HTML and plain text email formatting (BodyFormat())
- ✓ Regional API support (US/EU) via WithBaseURL()
- ✓ Custom HTTP client injection for testing (WithHTTPClient())
- ✓ Context-aware operations with proper cancellation support
- ✓ Production-ready timeout configuration (150s for Exchange servers)
- ✓ Comprehensive error handling with detailed Nylas API error messages
- ✓ Grant ID-based authentication (Nylas v3 authentication model)

## Testing

- 7 comprehensive test cases covering all scenarios
- Mock HTTP client for isolated unit testing
- Tests for success cases, error handling, context cancellation
- All tests passing with full coverage of core functionality
- Successfully tested with live Nylas API v3 endpoint

## Implementation Details

The service follows the established notify library patterns:
- Implements the notify.Notifier interface
- Consistent API design matching other services (SendGrid, Mailgun)
- No breaking changes to existing code
- Zero external dependencies beyond Go standard library

## API Reference

https://developer.nylas.com/docs/v3/email/send-email/

Closes integration gap for Nylas API v3 support in the notify ecosystem.
@mqasimca mqasimca marked this pull request as ready for review January 17, 2026 16:06
…tion

Add support for Nylas API regional endpoints (US and EU) with a new
NewWithRegion constructor that provides type-safe region selection.

Changes:
- Add Region type with RegionUS and RegionEU constants
- Add NewWithRegion() constructor for region-specific initialization
- Define BaseURLUS and BaseURLEU constants for regional endpoints
- Default to US region for backward compatibility
- Add comprehensive README.md with setup guide and usage examples
- Update doc.go with regional configuration examples
- Add test coverage for NewWithRegion with all region variants

The README includes:
- Step-by-step Nylas account setup instructions
- Grant ID creation and authentication flow explanation
- Usage examples for all features (basic, HTML/plain text, regions)
- Troubleshooting guide for common issues
- Environment variable recommendations for security

This improves the developer experience by providing clear documentation
for getting started with Nylas v3 API and enables users in the EU region
to use the appropriate API endpoint with a clean, type-safe API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant