Writing an integration
The contract itself is documented for everyone in Writing an integration. This page is the checklist for adding a built-in one to the repository.
Checklist
- Classes. Add
lib/messengerr/integrations/<name>.rb,lib/messengerr/setups/<name>.rbandlib/messengerr/sending_options/<name>.rb. Same class name in each parallel namespace. If the file name does not map to the constant (likeclicksendtoClickSend), add an inflection inlib/messengerr.rb. - Formats. Plain text is the default. If the provider can send HTML, declare
def self.formats = [ :text, :html ]and senddelivery.bodyas the HTML field whendelivery.html?: one body per message, never both. - Results. Return one
ResultperDelivery. Mark failuresuncertain: trueunless the provider definitely rejected the message. UseUncertainErrorfor batch-level uncertainty.yieldeach result if you send one at a time. - Timeouts and errors. Set explicit timeouts. Translate network exceptions into
IntegrationErrororUncertainErroras described in STYLE.md. Never put a secret in a message. - Specs. Under
spec/messengerr/integrations/,setups/andsending_options/. Stub every HTTP call with WebMock. Cover:verify!success and failure.- A sent result with its
provider_id, and a provider rejection. - Every uncertain and definite case: 4xx, 5xx, timeouts, a dropped connection, an unreadable body, a missing per-message status.
- That secrets never appear in
reasonstrings.
- End to end. Add a spec in
spec/messengerr/cli/send_command_spec.rbthat runs the real CLI with your real integration class and stubbed HTTP, as the Postmark one does. - Descriptions. Add a
DocsIntegrations::DESCRIPTIONSentry for each new sending option inrakelib/docs_integrations.rb. - Docs.
bundle exec rake docs:integrations, then commitdocs/integrations.md. Update the Limitations page if the integration changes what is possible. - Changelog. Add a line to
CHANGELOG.md. - Verify by hand. Revert a key behaviour (for example, treat a 5xx as definite) and confirm a spec fails.
The wizard and the contact validators support two delivery methods, email and sms. A provider for a new kind of channel needs changes in SendCommand and ContactValidator as well.