mikermcneil / machinepack-mandrill

Node.js machines for use with the Mandrill API
http://node-machine.org/machinepack-mandrill
5 stars 7 forks source link

added input for merge tags #3

Closed jondcallahan closed 9 years ago

jondcallahan commented 9 years ago

Was trying to use template_content for merge tags, but it only supported one. I added the merge_vars field to allow users to input multiple unique merge tags and content.

sgress454 commented 9 years ago

This is almost there but needs a couple of tweaks:

  1. Remove typeclass: "array" from the mergeVars input definition
  2. Change the example for mergeVars to only have one item in the array (i.e. one object with "name" and "content" keys instead of two)

Then you can test that the machine works with your changes. Normally you can do that by installing the machinepack runner (npm install machinepack) and running mp exec on the command line, but in this case it might be easier to write a little script since the mergeVars input is JSON. Something like:

require('./').sendTemplateEmail({
   apiKey: "theapikey",
   toEmail: "john@doe.com",
   templateName: "Welcome",
   mergeVars: [{'name': 'foo', 'content': 'bar'}]
}).exec(console.log);

then save it as test.js and run on the command line with node test.js

jondcallahan commented 9 years ago

Thanks for the feedback. I've changed the file, successfully tested, and recommitted with the changes.

alexlenail commented 9 years ago

You should consider adding merge vars to sendPlaintextEmail as well while you're at it, and perhaps even global merge vars. Either way, well done on the PR.

sgress454 commented 9 years ago

Sorry about the delay on this, taking a look now.