Skip to content

Commit

Permalink
fix: move PersonalizationData to sendgrid_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
samderanova committed Dec 14, 2023
1 parent eec11fe commit 7db88a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
11 changes: 9 additions & 2 deletions apps/api/src/services/sendgrid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
# https://github.com/sendgrid/sendgrid-python
import os
from logging import getLogger
from typing import Iterable, Tuple, Union
from typing import Iterable, Tuple, TypedDict, Union
from typing_extensions import NotRequired

import aiosendgrid
from httpx import HTTPStatusError
from sendgrid.helpers.mail import Email, Mail, Personalization
from utils.PersonalizationData import PersonalizationData

log = getLogger(__name__)

SENDGRID_API_KEY = os.getenv("SENDGRID_API_KEY")


class PersonalizationData(TypedDict):
email: str
first_name: NotRequired[str]
last_name: NotRequired[str]
passphrase: NotRequired[str]


async def send_email(
template_id: str,
sender_email: Tuple[str, str],
Expand Down
9 changes: 0 additions & 9 deletions apps/api/src/utils/PersonalizationData.py

This file was deleted.

2 changes: 1 addition & 1 deletion apps/api/src/utils/email_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pydantic import EmailStr

from services import sendgrid_handler
from utils.PersonalizationData import PersonalizationData
from services.sendgrid_handler import PersonalizationData

IH_SENDER = ("[email protected]", "IrvineHacks 2024 Applications")

Expand Down
2 changes: 1 addition & 1 deletion apps/api/tests/test_sendgrid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from httpx import HTTPStatusError, Request, Response

from services import sendgrid_handler
from utils.PersonalizationData import PersonalizationData
from services.sendgrid_handler import PersonalizationData

SAMPLE_SENDER = ("[email protected]", "No Reply IrvineHacks")
SAMPLE_RECIPIENTS: list[PersonalizationData] = [
Expand Down

0 comments on commit 7db88a4

Please sign in to comment.