Skip to content

Commit bef78db

Browse files
committed
fix: wrong fields on TemplateListItem
1 parent f8cb7ae commit bef78db

2 files changed

Lines changed: 39 additions & 19 deletions

File tree

resend/templates/_template.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,31 @@ class TemplateListItem(TypedDict):
103103
104104
Attributes:
105105
id (str): The Template ID.
106-
object (str): The object type (always "template").
107106
name (str): The name of the template.
108-
html (str): The HTML version of the template.
107+
status (Literal["draft", "published"]): The status of the template.
108+
published_at (str | None): The timestamp when the template was published, or None if not published.
109109
created_at (str): The timestamp when the template was created.
110+
updated_at (str): The timestamp when the template was last updated.
111+
alias (str): The alias of the template.
110112
"""
111113

112114
id: str
113115
"""The Template ID."""
114116

115-
object: str
116-
"""The object type (always "template")."""
117-
118117
name: str
119118
"""The name of the template."""
120119

121-
html: str
122-
"""The HTML version of the template."""
120+
status: Literal["draft", "published"]
121+
"""The status of the template."""
122+
123+
published_at: Union[str, None]
124+
"""The timestamp when the template was published, or None if not published."""
123125

124126
created_at: str
125127
"""The timestamp when the template was created."""
128+
129+
updated_at: str
130+
"""The timestamp when the template was last updated."""
131+
132+
alias: str
133+
"""The alias of the template."""

tests/templates_test.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,21 @@ def test_templates_list(self) -> None:
169169
"data": [
170170
{
171171
"id": "template-1",
172-
"object": "template",
173172
"name": "welcome-email",
174-
"html": "<strong>Welcome!</strong>",
173+
"status": "published",
174+
"published_at": "2024-01-15T11:00:00.000Z",
175175
"created_at": "2024-01-15T10:30:00.000Z",
176+
"updated_at": "2024-01-15T10:30:00.000Z",
177+
"alias": "welcome",
176178
},
177179
{
178180
"id": "template-2",
179-
"object": "template",
180181
"name": "goodbye-email",
181-
"html": "<strong>Goodbye!</strong>",
182+
"status": "draft",
183+
"published_at": None,
182184
"created_at": "2024-01-16T10:30:00.000Z",
185+
"updated_at": "2024-01-16T10:30:00.000Z",
186+
"alias": "goodbye",
183187
},
184188
],
185189
}
@@ -192,17 +196,21 @@ def test_templates_list(self) -> None:
192196

193197
template = templates["data"][0]
194198
assert template["id"] == "template-1"
195-
assert template["object"] == "template"
196199
assert template["name"] == "welcome-email"
197-
assert template["html"] == "<strong>Welcome!</strong>"
200+
assert template["status"] == "published"
201+
assert template["published_at"] == "2024-01-15T11:00:00.000Z"
198202
assert template["created_at"] == "2024-01-15T10:30:00.000Z"
203+
assert template["updated_at"] == "2024-01-15T10:30:00.000Z"
204+
assert template["alias"] == "welcome"
199205

200206
template = templates["data"][1]
201207
assert template["id"] == "template-2"
202-
assert template["object"] == "template"
203208
assert template["name"] == "goodbye-email"
204-
assert template["html"] == "<strong>Goodbye!</strong>"
209+
assert template["status"] == "draft"
210+
assert template["published_at"] is None
205211
assert template["created_at"] == "2024-01-16T10:30:00.000Z"
212+
assert template["updated_at"] == "2024-01-16T10:30:00.000Z"
213+
assert template["alias"] == "goodbye"
206214

207215
def test_templates_list_with_pagination_params(self) -> None:
208216
self.set_mock_json(
@@ -212,10 +220,12 @@ def test_templates_list_with_pagination_params(self) -> None:
212220
"data": [
213221
{
214222
"id": "template-1",
215-
"object": "template",
216223
"name": "welcome-email",
217-
"html": "<strong>Welcome!</strong>",
224+
"status": "published",
225+
"published_at": "2024-01-15T11:00:00.000Z",
218226
"created_at": "2024-01-15T10:30:00.000Z",
227+
"updated_at": "2024-01-15T10:30:00.000Z",
228+
"alias": "welcome",
219229
}
220230
],
221231
}
@@ -239,10 +249,12 @@ def test_templates_list_with_before_param(self) -> None:
239249
"data": [
240250
{
241251
"id": "template-3",
242-
"object": "template",
243252
"name": "password-reset",
244-
"html": "<strong>Reset your password</strong>",
253+
"status": "draft",
254+
"published_at": None,
245255
"created_at": "2024-01-14T10:30:00.000Z",
256+
"updated_at": "2024-01-14T10:30:00.000Z",
257+
"alias": "password-reset",
246258
}
247259
],
248260
}

0 commit comments

Comments
 (0)