-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
1,083 additions
and
426 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
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
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
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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import os | ||
from typing import List | ||
|
||
import resend | ||
|
||
if not os.environ["RESEND_API_KEY"]: | ||
raise EnvironmentError("RESEND_API_KEY is missing") | ||
|
||
|
||
params = [ | ||
params: List[resend.Emails.SendParams] = [ | ||
{ | ||
"from": "[email protected]", | ||
"to": ["[email protected]"], | ||
"sender": "[email protected]", | ||
"to": ["[email protected]"], | ||
"subject": "hey", | ||
"html": "<strong>hello, world!</strong>", | ||
}, | ||
{ | ||
"from": "[email protected]", | ||
"to": ["[email protected]"], | ||
"sender": "[email protected]", | ||
"to": ["[email protected]"], | ||
"subject": "hello", | ||
"html": "<strong>hello, world!</strong>", | ||
}, | ||
] | ||
|
||
emails = resend.Batch.send(params) | ||
print(emails) | ||
for email in emails: | ||
print(f"Email sent with id: {email.id}") |
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 |
---|---|---|
|
@@ -5,41 +5,48 @@ | |
if not os.environ["RESEND_API_KEY"]: | ||
raise EnvironmentError("RESEND_API_KEY is missing") | ||
|
||
# replace with some audience id | ||
audience_id: str = "ca4e37c5-a82a-4199-a3b8-bf912a6472aa" | ||
|
||
audience_id = "78b8d3bc-a55a-45a3-aee6-6ec0a5e13d7e" | ||
|
||
contact = resend.Contacts.create( | ||
{ | ||
"audience_id": audience_id, | ||
"email": "[email protected]", | ||
"first_name": "Steve", | ||
"last_name": "Wozniak", | ||
"unsubscribed": True, | ||
} | ||
) | ||
print("created contact !") | ||
print(contact) | ||
|
||
update_params = { | ||
create_params: resend.Contacts.CreateParams = { | ||
"audience_id": audience_id, | ||
"id": contact["id"], | ||
"last_name": "Updated", | ||
"email": "[email protected]", | ||
"first_name": "Steve", | ||
"last_name": "Wozniak", | ||
"unsubscribed": False, | ||
} | ||
|
||
contact = resend.Contacts.create(create_params) | ||
print(f"Created contact with ID: {contact.id}") | ||
|
||
update_params: resend.Contacts.UpdateParams = { | ||
"audience_id": audience_id, | ||
"id": contact.id, | ||
"unsubscribed": False, | ||
"first_name": "Steve1", | ||
} | ||
|
||
updated = resend.Contacts.update(update_params) | ||
print("updated contact !") | ||
print(updated) | ||
|
||
cont = resend.Contacts.get(audience_id=audience_id, id=contact["id"]) | ||
print(cont) | ||
cont = resend.Contacts.get(audience_id=audience_id, id=contact.id) | ||
print("Retrieved contact") | ||
print(cont.id) | ||
print(cont.email) | ||
print(cont.first_name) | ||
print(cont.last_name) | ||
|
||
contacts = resend.Contacts.list(audience_id=audience_id) | ||
print(contacts) | ||
print("List of contacts") | ||
for contact in contacts: | ||
print( | ||
f"ID: {contact.id}, Email: {contact.email}, First Name: {contact.first_name}, Last Name: {contact.last_name}, Created At: {contact.created_at}, Unsubscribed: {contact.unsubscribed}" | ||
) | ||
|
||
# remove by email | ||
rmed = resend.Contacts.remove(audience_id=audience_id, email="[email protected]") | ||
# rmed = resend.Contacts.remove(audience_id=audience_id, email=cont.email) | ||
|
||
# remove by id | ||
# rmed = resend.Contacts.remove(audience_id=audience_id, id=contact["id"]) | ||
print(rmed) | ||
rmed = resend.Contacts.remove(audience_id=audience_id, id=cont.id) | ||
print(f"Removed contact - ID: {rmed.id} Deleted: {rmed.deleted}") |
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
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 |
---|---|---|
|
@@ -5,10 +5,9 @@ | |
if not os.environ["RESEND_API_KEY"]: | ||
raise EnvironmentError("RESEND_API_KEY is missing") | ||
|
||
|
||
params = { | ||
"from": "[email protected]", | ||
"to": ["[email protected]"], | ||
params: resend.Emails.SendParams = { | ||
"sender": "[email protected]", | ||
"to": ["[email protected]"], | ||
"subject": "hi", | ||
"html": "<strong>hello, world!</strong>", | ||
"reply_to": "[email protected]", | ||
|
@@ -21,7 +20,8 @@ | |
} | ||
|
||
email = resend.Emails.send(params) | ||
print(email) | ||
print(f"Email sent with id: {email.id}") | ||
|
||
email_resp = resend.Emails.get(email_id=email["id"]) | ||
print(email_resp) | ||
email_resp = resend.Emails.get(email_id=email.id) | ||
print(f"Retrieved email: {email_resp.id}") | ||
print(email_resp.__dict__) |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
requests==2.31.0 | ||
requests==2.31.0 | ||
typing_extensions |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.