Add MailgunMessage with most API fields #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I see that previous mods have leveraged the
MailMessage.Headers
in order to get tags and vars working. I took a slightly different approach. I created a newMailgunMessage
class which is a descendant ofMailMessage
and which has fields for most of the things supported by the API – including Tags, Vars, CustomHeaders, DeliveryTime, etc.FormPartsBuilder
now knows how to iterate over these new properties and supply the appropriate form parts to the API call. All of this is backwards-compatible; you can still just useMailMessage
if you want, and you can still use the other methods of adding tags and vars.The only API fields I have not added are
inline
, because it deals with attachments and is tricky when you don't have file-based attachments, and thehtmlonly
option foro:tracking-clicks
.This could be extensible in the future – could add
MailgunMessageV3_1
orMailgunMessageV4
as new fields are introduced by new API versions. In fact, I thought about makingMailgunMessage
an abstract base class and calling the current classMailgunMessageV3
; let me know if you'd like me to make this change.