Skip to content

Commit c039510

Browse files
committed
Hold the email templates deprecation and rename to paginated_templates
- Remove the DeprecationWarning on email_templates_api.templates and the README "deprecated" label. /api/templates is still experimental, and the public spec still calls /api/email_templates the stable surface. - Rename the account_templates modules and AccountTemplatesApi to paginated_templates and PaginatedTemplatesApi. The old surface is just as account-scoped; the paginated data-envelope contract is what differs. - Document that get_list returns one page and that the next page needs the same per_page.
1 parent 05c1d03 commit c039510

12 files changed

Lines changed: 51 additions & 70 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ The same situation applies to both `client.batch_send()` and `client.sending_api
239239
- Contact Imports – [`contacts/contact_imports.py`](examples/contacts/contact_imports.py)
240240

241241
### Email Templates API:
242-
- Templates (experimental, `/api/templates`) – [`account_templates/templates.py`](examples/account_templates/templates.py)
243-
- Templates management (deprecated, use Templates above) – [`email_templates/templates.py`](examples/email_templates/templates.py)
242+
- Templates (experimental, `/api/templates`) – [`paginated_templates/templates.py`](examples/paginated_templates/templates.py)
243+
- Templates management – [`email_templates/templates.py`](examples/email_templates/templates.py)
244244

245245
### Sending Domains API:
246246
- Sending Domains – [`sending_domains/sending_domains.py`](examples/sending_domains/sending_domains.py)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from typing import Optional
33

44
import mailtrap as mt
5-
from mailtrap.models.account_templates import Template
6-
from mailtrap.models.account_templates import TemplateListResponse
75
from mailtrap.models.common import DeletedObject
6+
from mailtrap.models.paginated_templates import Template
7+
from mailtrap.models.paginated_templates import TemplateListResponse
88

99
API_KEY = os.environ["MAILTRAP_API_KEY"]
1010
ACCOUNT_ID = os.environ["MAILTRAP_ACCOUNT_ID"]

‎mailtrap/__init__.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
from .exceptions import AuthorizationError
66
from .exceptions import ClientConfigurationError
77
from .exceptions import MailtrapError
8-
from .models.account_templates import CreateTemplateParams
9-
from .models.account_templates import Template
10-
from .models.account_templates import TemplateListParams
11-
from .models.account_templates import TemplateListResponse
12-
from .models.account_templates import UpdateTemplateParams
138
from .models.accounts import AccountAccessFilterParams
149
from .models.api_tokens import ApiTokenResource
1510
from .models.api_tokens import CreateApiTokenParams
@@ -63,6 +58,11 @@
6358
from .models.mail import MailFromTemplate
6459
from .models.messages import UpdateEmailMessageParams
6560
from .models.organizations import CreateSubAccountParams
61+
from .models.paginated_templates import CreateTemplateParams
62+
from .models.paginated_templates import Template
63+
from .models.paginated_templates import TemplateListParams
64+
from .models.paginated_templates import TemplateListResponse
65+
from .models.paginated_templates import UpdateTemplateParams
6666
from .models.permissions import PermissionResourceParams
6767
from .models.projects import ProjectParams
6868
from .models.sending_domains import CreateSendingDomainParams
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from mailtrap.api.resources.account_templates import AccountTemplatesApi
1+
from mailtrap.api.resources.paginated_templates import PaginatedTemplatesApi
22
from mailtrap.http import HttpClient
33

44

@@ -8,5 +8,5 @@ def __init__(self, client: HttpClient, account_id: str) -> None:
88
self._client = client
99

1010
@property
11-
def templates(self) -> AccountTemplatesApi:
12-
return AccountTemplatesApi(account_id=self._account_id, client=self._client)
11+
def templates(self) -> PaginatedTemplatesApi:
12+
return PaginatedTemplatesApi(account_id=self._account_id, client=self._client)

mailtrap/api/resources/account_templates.py renamed to mailtrap/api/resources/paginated_templates.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from typing import Optional
22

33
from mailtrap.http import HttpClient
4-
from mailtrap.models.account_templates import CreateTemplateParams
5-
from mailtrap.models.account_templates import Template
6-
from mailtrap.models.account_templates import TemplateListParams
7-
from mailtrap.models.account_templates import TemplateListResponse
8-
from mailtrap.models.account_templates import TemplateResponse
9-
from mailtrap.models.account_templates import UpdateTemplateParams
104
from mailtrap.models.common import DeletedObject
5+
from mailtrap.models.paginated_templates import CreateTemplateParams
6+
from mailtrap.models.paginated_templates import Template
7+
from mailtrap.models.paginated_templates import TemplateListParams
8+
from mailtrap.models.paginated_templates import TemplateListResponse
9+
from mailtrap.models.paginated_templates import TemplateResponse
10+
from mailtrap.models.paginated_templates import UpdateTemplateParams
1111

1212

13-
class AccountTemplatesApi:
13+
class PaginatedTemplatesApi:
1414
"""
1515
Templates API. The ``/api/templates`` endpoints are experimental: their
1616
request and response shapes may change before general availability.
@@ -24,8 +24,10 @@ def get_list(
2424
self, params: Optional[TemplateListParams] = None
2525
) -> TemplateListResponse:
2626
"""
27-
List email templates in the account. ``params`` paginates the result;
28-
omit it for the first page with API defaults.
27+
List email templates in the account, one page at a time. Unlike the
28+
``email_templates_api`` list, it does not return every template: pass
29+
``pagination.next_token`` with the same ``per_page`` to get the next
30+
page. Omit ``params`` for the first page with API defaults.
2931
"""
3032
query_params = params.api_query_params if params else None
3133
response = self._client.get(self._api_path(), params=query_params or None)

‎mailtrap/api/templates.py‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
from mailtrap.api.resources.templates import TemplatesApi
42
from mailtrap.http import HttpClient
53

@@ -11,13 +9,4 @@ def __init__(self, client: HttpClient, account_id: str) -> None:
119

1210
@property
1311
def templates(self) -> TemplatesApi:
14-
"""
15-
Deprecated: use ``MailtrapClient.templates_api.templates``, which
16-
serves the paginated ``/api/templates`` endpoints.
17-
"""
18-
warnings.warn(
19-
"EmailTemplatesApi is deprecated; use MailtrapClient.templates_api.templates",
20-
DeprecationWarning,
21-
stacklevel=2,
22-
)
2312
return TemplatesApi(account_id=self._account_id, client=self._client)

‎mailtrap/client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
from pydantic import TypeAdapter
88

9-
from mailtrap.api.account_templates import TemplatesBaseApi
109
from mailtrap.api.company_info import CompanyInfoBaseApi
1110
from mailtrap.api.contacts import ContactsBaseApi
1211
from mailtrap.api.email_campaigns import EmailCampaignsBaseApi
1312
from mailtrap.api.email_logs import EmailLogsBaseApi
1413
from mailtrap.api.general import GeneralApi
1514
from mailtrap.api.inbound import InboundBaseApi
1615
from mailtrap.api.organizations import OrganizationsBaseApi
16+
from mailtrap.api.paginated_templates import TemplatesBaseApi
1717
from mailtrap.api.resources.stats import StatsApi
1818
from mailtrap.api.sending import SendingApi
1919
from mailtrap.api.sending_domains import SendingDomainsBaseApi

‎tests/unit/api/email_templates/test_deprecation.py‎

Lines changed: 0 additions & 12 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)