Skip to content

Mailing Lists - Add Mailgun::MailingLists wrapper - #401

Merged
alex-leb merged 3 commits into
masterfrom
feature/mailing-lists
Oct 14, 2026
Merged

alex-leb merged 3 commits into
masterfrom
feature/mailing-lists

Conversation

@alex-leb

@alex-leb alex-leb commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Adds a Mailgun::MailingLists wrapper for the v3 Mailing Lists API. Until now the gem only had the double opt-in helper, so managing lists and members meant calling the raw client.

Methods

Area Methods
Lists list, list_pages, create, get, update, remove
Members list_members, list_members_pages, get_member, create_member, update_member, remove_member
Bulk upload create_members (JSON, up to 1,000 members), import_members (CSV file path or IO)
  • Return values follow Domains and Templates: list methods return items, create/update return the response hash, remove methods return a boolean.
  • Member vars and bulk member lists can be passed as Ruby hashes and arrays; they are JSON-encoded for the API.
  • Addresses keep @ and + in the path; / ? # % and whitespace are percent-encoded.
  • All methods require a v3 client and raise ParameterError when a list or member address is missing.
  • Usage is documented in docs/MailingLists.md, linked from the README.

Testing

All 14 operations are covered by VCR integration specs; there are no unit specs.

  • The list and list member specs now go through the wrapper and replay the existing mailing_list and list_members cassettes (9 operations).
  • A new mailing_lists spec, recorded against the live API, covers list_pages, list_members, list_members_pages, create_members and import_members. It also checks a member address with a + and that vars sent as a Hash come back as a Hash.
  • The recording confirms create_members works with members sent as a form field, as Mailgun's guides do (the OpenAPI spec lists it as a query parameter).
  • The new cassette is scrubbed like the existing ones (API key, auth header, test domain). Its X-Mailgun-Key-Id header value is replaced with a placeholder as well.
  • Full suite, run without credentials: 413 examples, 0 failures; line coverage 96.3%; RuboCop clean.

- Add Mailgun::MailingLists covering all 14 v3 mailing list endpoints:
  lists (list, list_pages, create, get, update, remove), members
  (list_members, list_members_pages, get_member, create_member,
  update_member, remove_member) and bulk uploads (create_members for
  JSON, import_members for CSV)
- Member vars and bulk members can be passed as Ruby objects; they are
  JSON-encoded for the API
- Addresses keep @ and + in the path; characters that would break it
  (/ ? # % and whitespace) are percent-encoded
- Methods require a v3 client and raise ParameterError on a missing
  list or member address
- Switch the list and list member integration specs to the wrapper,
  replaying the existing cassettes; add unit specs for the endpoints
  without recordings (paging, member listing, bulk uploads)
- Add docs/MailingLists.md and link it from the README
- Cover list_pages, list_members, list_members_pages, create_members
  and import_members with a new integration spec recorded against the
  live API (cassette mailing_lists); remove the unit specs
- The recording also checks a member address with a plus sign and that
  vars sent as a Hash come back as a Hash
- Argument and API version checks move into the integration spec
- Docs: a bulk upload response reports members_count from before the
  upload
- The cassette is scrubbed like the existing ones (key, auth header,
  test domain); the X-Mailgun-Key-Id header value is replaced too
@alex-leb alex-leb self-assigned this Oct 14, 2026
Keep one name per operation, as in Domains and AnalyticsTags: drop
get_lists, delete, add_member and delete_member.
@alex-leb
alex-leb merged commit fa32b95 into master Oct 14, 2026
8 checks passed
@alex-leb
alex-leb deleted the feature/mailing-lists branch October 14, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant