Skip to content

Commit 90afd93

Browse files
authored
feat(api-keys): add last_used_at field to API key response (#190)
1 parent acfccc1 commit 90afd93

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

resend/api_keys/_api_key.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from typing_extensions import TypedDict
24

35

@@ -14,3 +16,7 @@ class ApiKey(TypedDict):
1416
"""
1517
The API key creation date
1618
"""
19+
last_used_at: Optional[str]
20+
"""
21+
The date and time the API key was last used, or None if never used
22+
"""

resend/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.23.0"
1+
__version__ = "2.24.0"
22

33

44
def get_version() -> str:

tests/api_keys_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_api_keys_list(self) -> None:
3838
"id": "91f3200a-df72-4654-b0cd-f202395f5354",
3939
"name": "Production",
4040
"created_at": "2023-04-08T00:11:13.110779+00:00",
41+
"last_used_at": "2023-04-08T12:00:00.000000+00:00",
4142
}
4243
],
4344
}
@@ -50,6 +51,26 @@ def test_api_keys_list(self) -> None:
5051
assert key["id"] == "91f3200a-df72-4654-b0cd-f202395f5354"
5152
assert key["name"] == "Production"
5253
assert key["created_at"] == "2023-04-08T00:11:13.110779+00:00"
54+
assert key["last_used_at"] == "2023-04-08T12:00:00.000000+00:00"
55+
56+
def test_api_keys_list_last_used_at_none(self) -> None:
57+
self.set_mock_json(
58+
{
59+
"object": "list",
60+
"has_more": False,
61+
"data": [
62+
{
63+
"id": "91f3200a-df72-4654-b0cd-f202395f5354",
64+
"name": "Production",
65+
"created_at": "2023-04-08T00:11:13.110779+00:00",
66+
"last_used_at": None,
67+
}
68+
],
69+
}
70+
)
71+
72+
keys: resend.ApiKeys.ListResponse = resend.ApiKeys.list()
73+
assert keys["data"][0]["last_used_at"] is None
5374

5475
def test_should_list_api_key_raise_exception_when_no_content(self) -> None:
5576
self.set_mock_json(None)

0 commit comments

Comments
 (0)