Skip to content

Commit

Permalink
fix: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
drish committed Apr 15, 2024
1 parent 588b15e commit e134a7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions examples/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
if not os.environ["RESEND_API_KEY"]:
raise EnvironmentError("RESEND_API_KEY is missing")

create_params: resend.ApiKeys.CreateParams = {
"name": "example.com",
}

key = resend.ApiKeys.create({"name": "asda"})
key = resend.ApiKeys.create(params = create_params)
print("Created new api key")
print(f'Key id: {key.id} and token: {key.token}')

Expand All @@ -16,7 +19,5 @@
print(key.name)
print(key.created_at)

try:
resend.ApiKeys.remove(keys[0].id)
except resend.exceptions.ResendError as e:
print(e)
if len(keys) > 0:
resend.ApiKeys.remove(api_key_id= keys[0].id)
12 changes: 6 additions & 6 deletions resend/api_keys/_api_keys.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
from typing import List, Any, Dict, Optional, cast
from typing import List, Any, Dict, cast

from typing_extensions import TypedDict
from typing_extensions import TypedDict, NotRequired

from resend import request
from resend.api_keys._api_key import ApiKey


class ApiKeys:

class CreateApiKeyRequestParams(TypedDict):
class CreateParams(TypedDict):
name: str
"""
The API key name.
"""
permission: Optional[str]
permission: NotRequired[str]
"""
The API key can have full access to Resend's API or be only
restricted to send emails. * full_access: Can create, delete, get,
and update any resource. * sending_access: Can only send emails.
"""
domain_id: Optional[str]
domain_id: NotRequired[str]
"""
Restrict an API key to send emails only from a specific domain.
This is only used when the permission is set to sending_access.
"""

@classmethod
def create(cls, params: "CreateApiKeyRequestParams") -> ApiKey:
def create(cls, params: CreateParams) -> ApiKey:
"""
Add a new API key to authenticate communications with Resend.
see more: https://resend.com/docs/api-reference/api-keys/create-api-key
Expand Down
2 changes: 1 addition & 1 deletion tests/api_keys_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def mock_json():
m.json = mock_json
mock.return_value = m

params = {
params: resend.ApiKeys.CreateParams = {
"name": "prod",
}
key = resend.ApiKeys.create(params)
Expand Down

0 comments on commit e134a7a

Please sign in to comment.