This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP add script for sending pathfinders commissioning email
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import argparse | ||
import io | ||
import os | ||
|
||
from notifications_python_client.notifications import NotificationsAPIClient | ||
|
||
from app.main.notify import prepare_upload | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Send commissioning email for Pathfinders (via Notify)") | ||
|
||
parser.add_argument( | ||
"-e", | ||
"--email-file", | ||
dest="environment", | ||
default="emails.txt", | ||
help="Path to file containing line separated list of users to email", | ||
) | ||
|
||
|
||
def send_notify( | ||
file_buffer: io.BytesIO, | ||
api_key: str = os.getenv("NOTIFY_API_KEY"), | ||
template_id: str = "c32ecc1e-0c17-4fef-b159-617948869daf", | ||
email_address: str = "test@example.com", | ||
): | ||
if not api_key: | ||
raise KeyError("Notify API key is required to send email") | ||
notifications_client = NotificationsAPIClient(api_key) | ||
notifications_client.send_email_notification( | ||
email_address=email_address, | ||
template_id=template_id, | ||
personalisation={ | ||
"link_to_file": prepare_upload( | ||
file_buffer, | ||
filename="Pathfinder Reporting Template v0.2.xslx", | ||
), | ||
}, | ||
) |