alphagov / notifications-net-client

.NET client for the GOV.UK Notify API
https://www.nuget.org/packages/GovukNotify/
MIT License
25 stars 20 forks source link

Add a method to send pre-compiled letters #53

Closed allait closed 6 years ago

allait commented 6 years ago

Make NotificationResponse.Equals work with pre-compiled responses

We use NotificationResponse.Equals in our tests to compare actual and expected responses. This works for existing methods, but since pre-compiled responses don't contain template or content existing .Equals implementation fails when trying to compare attributes of null.

We could get rid of the .Equals and compare attributes with expected values in tests, but the methods are already part of the public interface and removing them is a breaking change.

Alternatively, we could add another response class for pre-compiled letters, but it's hard to fit it into existing class hierarchy (since it defines fewer fields than NotificationResponse it should either be a base class for it or both should derive from a common base class).

To avoid these changes we move the comparison logic to underlying attribute classes and use both == (to compare null values) and .Equals when comparing attributes. This keeps the existing behaviour of NotificationResponse.Equals while allowing us to instantiate LetterNotificationResponse with only pre-compiled fields set.

Add a sendPrecompiledLetterNotification method

The method accepts an array of bytes instead of a stream/file-like object since the easiest way to read an entire file in .NET seems to be File.ReadAllBytes, which returns byte[].

Add documentation for SendPrecompiledLetter

Add CHANGELOG record for new changes

Checklist