A typed MoonBit SDK for Resend with a moonfetch HTTP adapter
///|
let client = @resend.Client::new("re_xxxxxxxxx").unwrap()
///|
let email = @resend.SendEmailParams::new(
"Acme <onboarding@example.com>",
["user@example.com"],
"Welcome",
html="<strong>It works!</strong>",
text="It works!",
)
///|
let request = client
.send_request(email, idempotency_key="welcome-user-42")
.unwrap()///|
async fn send_welcome(api_key : String) -> Unit {
let client = @resend.Client::new(api_key).unwrap()
let email = @resend.SendEmailParams::new(
"Acme <onboarding@example.com>",
["user@example.com"],
"Welcome",
html="<strong>It works!</strong>",
text="It works!",
)
match @adapter.send(client, email, idempotency_key="welcome-user-42") {
Ok(sent) => println("sent: " + sent.id())
Err(_) => println("send failed")
}
}$env:RESEND_API_KEY = "re_..."
$env:RESEND_FROM = "Demo <demo@your-verified-domain.example>"
$env:RESEND_TO = "you@example.com"
moon run cmd/send-live --target nativemoon check
moon test
moon info
moon fmtpub struct ApiError {
status : Int
name : String
message : String
raw_body : String
}pub struct Attachment {
content : String
filename : String
content_type : String?
content_id : String?
}fn Attachment::new(content : String, filename : String, content_type? : String, content_id? : String) -> Attachmentpub struct Client {
api_key : String
base_url : String
}fn Client::batch_send_request(self : Client, emails : Array[SendEmailParams], idempotency_key? : String) -> Result[HttpRequest, ResendError]fn Client::parse_batch_response(_self : Client, response : HttpResponse) -> Result[BatchEmailIds, ResendError]fn Client::parse_id_response(_self : Client, response : HttpResponse) -> Result[EmailId, ResendError]fn Client::parse_retrieve_response(_self : Client, response : HttpResponse) -> Result[RetrievedEmail, ResendError]fn Client::send_request(self : Client, params : SendEmailParams, idempotency_key? : String) -> Result[HttpRequest, ResendError]fn Client::update_request(self : Client, id : String, params : UpdateEmailParams) -> Result[HttpRequest, ResendError]pub struct EmailId {
id : String
}pub struct HttpRequest {
verb : String
url : String
headers : Array[(String, String)]
body : String?
}fn HttpRequest::new(verb : String, url : String, headers? : Array[(String, String)], body? : String) -> HttpRequestfn HttpResponse::new(status : Int, body : String, headers? : Array[(String, String)]) -> HttpResponsepub enum ResendError {
InvalidInput(String)
Api(ApiError)
InvalidResponse(String)
Transport(String)
}fn SendEmailParams::new(from : String, to : Array[String], subject : String, html? : String, text? : String, cc? : Array[String], bcc? : Array[String], reply_to? : Array[String], attachments? : Array[Attachment], tags? : Array[(String, String)], scheduled_at? : String) -> SendEmailParamspub struct UpdateEmailParams {
scheduled_at : String
}Install
Download zipA typed MoonBit SDK for Resend with a moonfetch HTTP adapter