Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`templates list|get|create|update|delete` now use the account-scoped
`/api/accounts/{id}/templates` endpoints.
- `templates list` takes `--per-page` and `--token`, prints a
"Next page: --token N" footer, and `--output json` returns the full
`{data, pagination}` object
- get, create and update print the template from the `data` envelope, so JSON
output keeps every field the API returns
- Request bodies are flat; `create` sends `category: "General"` when
`--category` is not set, and `update` requires at least one attribute flag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Mailtrap now serves a conventions-compliant templates API at
/api/templates(and/api/accounts/{account_id}/templates): every response is wrapped in adataenvelope, the list is paginated withtoken/per_page, and write bodies are flat. The existing/api/email_templatessurface keeps its published shape and stays live, but it is scheduled for removal once the new one leaves experimental status.This adds the new surface as a sibling resource rather than widening the existing one, because widening would change every return type for current callers. The old methods are deprecated and point at the replacement.
The CLI is a user surface rather than a library, so its
templatescommands move to the new endpoints in place instead of gaining a sibling command group.Changes
templates listcalls/api/accounts/{id}/templatesand gains--per-page/--token; table output ends with aNext page: --token Nhint and--output jsonprints the full{data, pagination}objecttemplates get|create|updateunwrap thedataenvelope and print the whole template in JSON (previously a typed subset droppedbody_html,body_textandupdated_at)create/updatesend flat bodies;--categoryoncreatedefaults toGeneral;updatesends only the flags that were set and requires at least oneHow to test
You'll need
MAILTRAP_API_TOKENandMAILTRAP_ACCOUNT_ID.mailtrap templates list --per-page 1prints one row andNext page: --token 2when more exist;--token 2prints the next page;--output jsonprints{ "data": [...], "pagination": {...} }mailtrap templates create --name W --subject Hi --body-html '<h1>Hi</h1>'prints the template with categoryGeneral; with--category Onboardingthat value is keptget --id N --output jsonincludesbody_htmlandupdated_at;update --id N --subject Hellochanges only the subject;update --id Nwith no attribute flag errors;delete --id Nprints the success linetemplates listwithout flags still lists templates (first page of 50)