Open asherber opened 8 years ago
I went ahead and did the versioned MailgunMessage
thing in my feature/apifields-versioned
branch, if you want to take a look. If you like that version, I can issue the PR from there instead.
I actually now also have inline attachments working. When you have decided whether you prefer the versioned or unversioned MailgunMessage
(I think I prefer the versioned), I'll add inline attachments to that branch.
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.