Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions resend/api_keys/_api_key.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

from typing_extensions import TypedDict


Expand All @@ -14,3 +16,7 @@ class ApiKey(TypedDict):
"""
The API key creation date
"""
last_used_at: Optional[str]
"""
The date and time the API key was last used, or None if never used
"""
21 changes: 21 additions & 0 deletions tests/api_keys_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_api_keys_list(self) -> None:
"id": "91f3200a-df72-4654-b0cd-f202395f5354",
"name": "Production",
"created_at": "2023-04-08T00:11:13.110779+00:00",
"last_used_at": "2023-04-08T12:00:00.000000+00:00",
}
],
}
Expand All @@ -50,6 +51,26 @@ def test_api_keys_list(self) -> None:
assert key["id"] == "91f3200a-df72-4654-b0cd-f202395f5354"
assert key["name"] == "Production"
assert key["created_at"] == "2023-04-08T00:11:13.110779+00:00"
assert key["last_used_at"] == "2023-04-08T12:00:00.000000+00:00"

def test_api_keys_list_last_used_at_none(self) -> None:
self.set_mock_json(
{
"object": "list",
"has_more": False,
"data": [
{
"id": "91f3200a-df72-4654-b0cd-f202395f5354",
"name": "Production",
"created_at": "2023-04-08T00:11:13.110779+00:00",
"last_used_at": None,
}
],
}
)

keys: resend.ApiKeys.ListResponse = resend.ApiKeys.list()
assert keys["data"][0]["last_used_at"] is None

def test_should_list_api_key_raise_exception_when_no_content(self) -> None:
self.set_mock_json(None)
Expand Down
Loading