mailgun/mailgun-ruby — pull request #19 by brightcommerce (2014-10-14 06:44:26+00:00)
Title: Added set_message_id method, tests and documentation

Using `add_custom_parameter("h:Message-Id", "<20141014000000.11111.11111@example.com>")` to set the Message-Id results in the Message-Id being added as an array. This doesn't overwrite the Message-Id header, but creates a strange `Message-Id[]` key with the value provided.

The HTTP API allows for setting the Message-Id by passing the header, but this gem mangles the hash key. The result is that Mailgun backend creates a new Message-Id in addition to the one we've passed in. Since we cannot use the simple_setter or complex_setter methods to write the header key correctly (because they deal with an array), we need to write the key and value outside of the `add_custom_parameters` (and `set_custom_data`) methods.

This pull requests adds a `set_message_id` method that accepts a Message-Id. It will write whatever you pass so be careful as no validation is provided. If you want to clear the existing Message-Id pass nil or an empty string, and if the `h:Message-Id` key exists, the key and value will be deleted from the message hash. The addition of the `set_message_id` method leaves everything else intact, so there are no breaking changes to existing functionality, it simply adds a new feature.

I have included additional examples to test the new method, and updated the `Message.md`, `MessageBuilder.md` and `Snippets.md` markdown documents. I has tested the changes against my Mailgun account and everything is working as advertised.

This pull request should be linked to support ticket `155404`.