Conversation
- New `client.templates_api.templates` targets /api/accounts/{id}/templates; list returns the `{data, pagination}` object, single-template calls return the unwrapped `Template`.
- Internal names use `account_templates` because `TemplatesApi` and `EmailTemplatesApi` already belong to the /api/email_templates resource.
- Request bodies are flat (no `email_template` wrap key) and update uses PATCH with the same "at least one field" check as before.
- `client.email_templates_api.templates` now emits a DeprecationWarning pointing at `templates_api`; its behavior is unchanged.
|
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 |
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.
Changes
client.templates_api.templates(AccountTemplatesApi) for/api/accounts/{id}/templates:get_list(TemplateListParams(per_page, token))returnsTemplateListResponse(data+pagination), get/create/update returnTemplate, delete returnsDeletedObject; bodies are flatPaginationis reused frommailtrap.models.commonclient.email_templates_api.templatesnow emits aDeprecationWarningpointing attemplates_api; behaviour unchangedexamples/account_templates/templates.pyand README rowsHow to test
You'll need an account API token and the account id.
client.templates_api.templates.get_list(mt.TemplateListParams(per_page=1))returns one item in.dataand.pagination.next_tokenwhen more exist;get_list(mt.TemplateListParams(token=2))returns the next pagecreate(mt.CreateTemplateParams(name=, subject=, category=, body_html=))returns aTemplatewith anid;get_by_id,update(id, mt.UpdateTemplateParams(subject=...))anddeletefollow;get_by_idafter delete raisesAPIErrormt.UpdateTemplateParams()raisesValueErrorclient.email_templates_api.templateswarns once and still returns a bare list