Skip to content

Commit b4b83f2

Browse files
committed
chore: lint
1 parent ebe53b4 commit b4b83f2

14 files changed

Lines changed: 301 additions & 249 deletions

examples/async/automations_async.py

Lines changed: 85 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,39 @@
1010
async def main() -> None:
1111
# Create and publish a template to use in the automation
1212
print("--- Create and publish template ---")
13-
tpl: resend.Templates.CreateResponse = await resend.Templates.create_async({
14-
"name": "welcome-email",
15-
"subject": "Welcome!",
16-
"html": "<strong>Welcome to our service!</strong>",
17-
})
13+
tpl: resend.Templates.CreateResponse = await resend.Templates.create_async(
14+
{
15+
"name": "welcome-email",
16+
"subject": "Welcome!",
17+
"html": "<strong>Welcome to our service!</strong>",
18+
}
19+
)
1820
await resend.Templates.publish_async(tpl["id"])
1921
print(f"Template: {tpl['id']}")
2022

2123
# --- Create a simple automation (trigger → send_email) ---
2224
print("\n--- Create automation ---")
23-
simple: resend.Automations.CreateResponse = await resend.Automations.create_async({
24-
"name": "Welcome Flow",
25-
"status": "disabled",
26-
"steps": [
27-
{
28-
"key": "trigger_1",
29-
"type": "trigger",
30-
"config": {"event_name": "user.created"},
31-
},
32-
{
33-
"key": "send_1",
34-
"type": "send_email",
35-
"config": {"template": {"id": tpl["id"]}},
36-
},
37-
],
38-
"connections": [
39-
{"from": "trigger_1", "to": "send_1"},
40-
],
41-
})
25+
simple: resend.Automations.CreateResponse = await resend.Automations.create_async(
26+
{
27+
"name": "Welcome Flow",
28+
"status": "disabled",
29+
"steps": [
30+
{
31+
"key": "trigger_1",
32+
"type": "trigger",
33+
"config": {"event_name": "user.created"},
34+
},
35+
{
36+
"key": "send_1",
37+
"type": "send_email",
38+
"config": {"template": {"id": tpl["id"]}},
39+
},
40+
],
41+
"connections": [
42+
{"from": "trigger_1", "to": "send_1"},
43+
],
44+
}
45+
)
4246
automation_id = simple["id"]
4347
print(f"Created automation: {automation_id}")
4448

@@ -51,10 +55,12 @@ async def main() -> None:
5155

5256
# --- Update automation ---
5357
print("\n--- Update automation ---")
54-
updated: resend.Automations.UpdateResponse = await resend.Automations.update_async({
55-
"automation_id": automation_id,
56-
"status": "enabled",
57-
})
58+
updated: resend.Automations.UpdateResponse = await resend.Automations.update_async(
59+
{
60+
"automation_id": automation_id,
61+
"status": "enabled",
62+
}
63+
)
5864
print(f"Updated: {updated['id']}")
5965

6066
# --- List automations ---
@@ -64,54 +70,62 @@ async def main() -> None:
6470

6571
# --- Stop automation ---
6672
print("\n--- Stop automation ---")
67-
stopped: resend.Automations.StopResponse = await resend.Automations.stop_async(automation_id)
73+
stopped: resend.Automations.StopResponse = await resend.Automations.stop_async(
74+
automation_id
75+
)
6876
print(f"Stopped: {stopped['id']}, status: {stopped['status']}")
6977

7078
# --- List runs ---
7179
print("\n--- List runs ---")
72-
runs: resend.Automations.Runs.ListResponse = await resend.Automations.Runs.list_async(automation_id)
80+
runs: resend.Automations.Runs.ListResponse = (
81+
await resend.Automations.Runs.list_async(automation_id)
82+
)
7383
print(f"Total runs: {len(runs['data'])}")
7484
if runs["data"]:
7585
run_id = runs["data"][0]["id"]
76-
run: resend.AutomationRun = await resend.Automations.Runs.get_async(automation_id, run_id)
86+
run: resend.AutomationRun = await resend.Automations.Runs.get_async(
87+
automation_id, run_id
88+
)
7789
print(f"Run status: {run['status']}")
7890

7991
# --- Multi-step automation: delay + wait_for_event ---
8092
print("\n--- Create multi-step automation (delay + wait_for_event) ---")
81-
multi: resend.Automations.CreateResponse = await resend.Automations.create_async({
82-
"name": "Onboarding Flow",
83-
"status": "disabled",
84-
"steps": [
85-
{
86-
"key": "trigger_1",
87-
"type": "trigger",
88-
"config": {"event_name": "user.created"},
89-
},
90-
{
91-
"key": "delay_1",
92-
"type": "delay",
93-
# duration is a human-readable string; "seconds" (int) is also accepted
94-
"config": {"duration": "30 minutes"},
95-
},
96-
{
97-
"key": "wait_1",
98-
"type": "wait_for_event",
99-
# timeout is a human-readable string; timeout_seconds is NOT supported
100-
"config": {"event_name": "user.verified", "timeout": "1 hour"},
101-
},
102-
{
103-
"key": "send_1",
104-
"type": "send_email",
105-
"config": {"template": {"id": tpl["id"]}},
106-
},
107-
],
108-
"connections": [
109-
{"from": "trigger_1", "to": "delay_1"},
110-
{"from": "delay_1", "to": "wait_1"},
111-
{"from": "wait_1", "to": "send_1", "type": "event_received"},
112-
{"from": "wait_1", "to": "send_1", "type": "timeout"},
113-
],
114-
})
93+
multi: resend.Automations.CreateResponse = await resend.Automations.create_async(
94+
{
95+
"name": "Onboarding Flow",
96+
"status": "disabled",
97+
"steps": [
98+
{
99+
"key": "trigger_1",
100+
"type": "trigger",
101+
"config": {"event_name": "user.created"},
102+
},
103+
{
104+
"key": "delay_1",
105+
"type": "delay",
106+
# duration is a human-readable string; "seconds" (int) is also accepted
107+
"config": {"duration": "30 minutes"},
108+
},
109+
{
110+
"key": "wait_1",
111+
"type": "wait_for_event",
112+
# timeout is a human-readable string; timeout_seconds is NOT supported
113+
"config": {"event_name": "user.verified", "timeout": "1 hour"},
114+
},
115+
{
116+
"key": "send_1",
117+
"type": "send_email",
118+
"config": {"template": {"id": tpl["id"]}},
119+
},
120+
],
121+
"connections": [
122+
{"from": "trigger_1", "to": "delay_1"},
123+
{"from": "delay_1", "to": "wait_1"},
124+
{"from": "wait_1", "to": "send_1", "type": "event_received"},
125+
{"from": "wait_1", "to": "send_1", "type": "timeout"},
126+
],
127+
}
128+
)
115129
multi_id = multi["id"]
116130
print(f"Created: {multi_id}")
117131

@@ -121,9 +135,13 @@ async def main() -> None:
121135

122136
# --- Cleanup ---
123137
print("\n--- Cleanup ---")
124-
del1: resend.Automations.DeleteResponse = await resend.Automations.remove_async(automation_id)
138+
del1: resend.Automations.DeleteResponse = await resend.Automations.remove_async(
139+
automation_id
140+
)
125141
print(f"Deleted automation {del1['id']}: {del1['deleted']}")
126-
del2: resend.Automations.DeleteResponse = await resend.Automations.remove_async(multi_id)
142+
del2: resend.Automations.DeleteResponse = await resend.Automations.remove_async(
143+
multi_id
144+
)
127145
print(f"Deleted automation {del2['id']}: {del2['deleted']}")
128146
await resend.Templates.remove_async(tpl["id"])
129147
print(f"Deleted template {tpl['id']}")

examples/async/events_async.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@
1010
async def main() -> None:
1111
# Create a contact to use with event sends
1212
print("--- Create contact ---")
13-
contact: resend.Contacts.CreateContactResponse = await resend.Contacts.create_async({
14-
"email": "test-events-async@example.com",
15-
"first_name": "Test",
16-
"last_name": "User",
17-
})
13+
contact: resend.Contacts.CreateContactResponse = await resend.Contacts.create_async(
14+
{
15+
"email": "test-events-async@example.com",
16+
"first_name": "Test",
17+
"last_name": "User",
18+
}
19+
)
1820
contact_id = contact["id"]
1921
print(f"Contact: {contact_id}")
2022

2123
# --- Create event ---
2224
print("\n--- Create event ---")
23-
created: resend.Events.CreateResponse = await resend.Events.create_async({
24-
"name": "user.signed_up",
25-
"schema": {
26-
"plan": "string",
27-
"trial_days": "number",
28-
"is_enterprise": "boolean",
29-
"upgraded_at": "date",
30-
},
31-
})
25+
created: resend.Events.CreateResponse = await resend.Events.create_async(
26+
{
27+
"name": "user.signed_up",
28+
"schema": {
29+
"plan": "string",
30+
"trial_days": "number",
31+
"is_enterprise": "boolean",
32+
"upgraded_at": "date",
33+
},
34+
}
35+
)
3236
event_id = created["id"]
3337
print(f"Created event: {event_id}")
3438

@@ -44,27 +48,33 @@ async def main() -> None:
4448

4549
# --- Update event schema ---
4650
print("\n--- Update event schema ---")
47-
updated: resend.Events.UpdateResponse = await resend.Events.update_async({
48-
"identifier": "user.signed_up",
49-
"schema": {"plan": "string", "source": "string"},
50-
})
51+
updated: resend.Events.UpdateResponse = await resend.Events.update_async(
52+
{
53+
"identifier": "user.signed_up",
54+
"schema": {"plan": "string", "source": "string"},
55+
}
56+
)
5157
print(f"Updated event: {updated['id']}")
5258

5359
# --- Send event with contact_id ---
5460
print("\n--- Send event with contact_id ---")
55-
sent: resend.Events.SendResponse = await resend.Events.send_async({
56-
"event": "user.signed_up",
57-
"contact_id": contact_id,
58-
"payload": {"plan": "pro"},
59-
})
61+
sent: resend.Events.SendResponse = await resend.Events.send_async(
62+
{
63+
"event": "user.signed_up",
64+
"contact_id": contact_id,
65+
"payload": {"plan": "pro"},
66+
}
67+
)
6068
print(f"Sent event: {sent['event']}")
6169

6270
# --- Send event with email ---
6371
print("\n--- Send event with email ---")
64-
sent_email: resend.Events.SendResponse = await resend.Events.send_async({
65-
"event": "user.signed_up",
66-
"email": "test-events-async@example.com",
67-
})
72+
sent_email: resend.Events.SendResponse = await resend.Events.send_async(
73+
{
74+
"event": "user.signed_up",
75+
"email": "test-events-async@example.com",
76+
}
77+
)
6878
print(f"Sent event: {sent_email['event']}")
6979

7080
# --- List events ---

examples/async/receiving_email_async.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ async def main() -> None:
7979
print("No attachments")
8080

8181
print("\n--- Listing All Received Emails ---")
82-
all_emails: EmailsReceiving.ListResponse = await resend.Emails.Receiving.list_async()
82+
all_emails: EmailsReceiving.ListResponse = (
83+
await resend.Emails.Receiving.list_async()
84+
)
8385

8486
print(f"Total emails in this batch: {len(all_emails['data'])}")
8587
print(f"Has more emails: {all_emails['has_more']}")
@@ -138,7 +140,9 @@ async def main() -> None:
138140
first_attachment = received_email["attachments"][0]
139141
attachment_id = first_attachment["id"]
140142

141-
print(f"\n--- Retrieving Attachment Details: {first_attachment['filename']} ---")
143+
print(
144+
f"\n--- Retrieving Attachment Details: {first_attachment['filename']} ---"
145+
)
142146

143147
attachment_details: resend.EmailAttachmentDetails = (
144148
await resend.Emails.Receiving.Attachments.get_async(

0 commit comments

Comments
 (0)