1818 "html" : "<strong>Hello, world!</strong>" ,
1919}
2020
21- print ("=" * 60 )
22- print ("Example 1: Without type annotations" )
23- print ("=" * 60 )
21+ resp : resend .Emails .SendResponse = resend .Emails .send (params )
22+ print (f"Email sent! ID: { resp ['id' ]} " )
2423
25- response = resend .Emails .send (params )
26- print (f"Email sent! ID: { response ['id' ]} " )
27- print (f"Request ID: { response ['headers' ].get ('x-request-id' )} " )
28- print (f"Rate limit: { response ['headers' ].get ('x-ratelimit-limit' )} " )
29- print (f"Rate limit remaining: { response ['headers' ].get ('x-ratelimit-remaining' )} " )
30- print (f"Rate limit reset: { response ['headers' ].get ('x-ratelimit-reset' )} " )
24+ if "headers" in resp :
25+ print (f"Request ID: { resp ['headers' ].get ('x-request-id' )} " )
26+ print (f"Rate limit: { resp ['headers' ].get ('x-ratelimit-limit' )} " )
27+ print (f"Rate limit remaining: { resp ['headers' ].get ('x-ratelimit-remaining' )} " )
28+ print (f"Rate limit reset: { resp ['headers' ].get ('x-ratelimit-reset' )} " )
3129
32- print ("\n " + "=" * 60 )
33- print ("Example 2: With type annotations" )
34- print ("=" * 60 )
35-
36- typed_response : resend .Emails .SendResponse = resend .Emails .send (params )
37- print (f"Email sent! ID: { typed_response ['id' ]} " )
38-
39- if "headers" in typed_response :
40- print (f"Request ID: { typed_response ['headers' ].get ('x-request-id' )} " )
41- print (f"Rate limit: { typed_response ['headers' ].get ('x-ratelimit-limit' )} " )
42- print (
43- f"Rate limit remaining: { typed_response ['headers' ].get ('x-ratelimit-remaining' )} "
44- )
45- print (f"Rate limit reset: { typed_response ['headers' ].get ('x-ratelimit-reset' )} " )
46-
47- print ("\n " + "=" * 60 )
30+ print ("\n " )
4831print ("Example 3: Rate limit tracking" )
49- print ("=" * 60 )
5032
5133
5234def send_with_rate_limit_check (params : resend .Emails .SendParams ) -> str :
@@ -61,7 +43,7 @@ def send_with_rate_limit_check(params: resend.Emails.SendParams) -> str:
6143 if remaining and limit :
6244 print (f"Rate limit usage: { int (limit ) - int (remaining )} /{ limit } " )
6345 if int (remaining ) < 10 :
64- print ("⚠️ Warning: Approaching rate limit!" )
46+ print ("Warning: Approaching rate limit!" )
6547
6648 return response ["id" ]
6749
0 commit comments