typesafe / mnailgun

A simple .Net wrapper library for the Mailgun API that allows you to send messages, create web hooks, manage mailboxes, etc. with minimal effort.
Other
35 stars 25 forks source link

Add MailgunMessage with most API fields #25

Open asherber opened 8 years ago

asherber commented 8 years ago

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 new MailgunMessage class which is a descendant of MailMessage 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 use MailMessage 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 the htmlonly option for o:tracking-clicks.

This could be extensible in the future – could add MailgunMessageV3_1 or MailgunMessageV4 as new fields are introduced by new API versions. In fact, I thought about making MailgunMessage an abstract base class and calling the current class MailgunMessageV3; let me know if you'd like me to make this change.

asherber commented 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.

asherber commented 8 years ago

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.