Fix send email request body
This commit is contained in:
@@ -32,8 +32,12 @@ impl EmailClient {
|
||||
) -> Result<(), reqwest::Error> {
|
||||
let url = self.base_url.join("v1/email").unwrap();
|
||||
let request_body = SendEmailRequest {
|
||||
from: self.sender.as_ref(),
|
||||
to: vec![recipient.as_ref()],
|
||||
from: EmailField {
|
||||
email: self.sender.as_ref(),
|
||||
},
|
||||
to: vec![EmailField {
|
||||
email: recipient.as_ref(),
|
||||
}],
|
||||
subject,
|
||||
text: text_content,
|
||||
html: html_content,
|
||||
@@ -56,13 +60,18 @@ impl EmailClient {
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct SendEmailRequest<'a> {
|
||||
from: &'a str,
|
||||
to: Vec<&'a str>,
|
||||
from: EmailField<'a>,
|
||||
to: Vec<EmailField<'a>>,
|
||||
subject: &'a str,
|
||||
text: &'a str,
|
||||
html: &'a str,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct EmailField<'a> {
|
||||
email: &'a str,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
Reference in New Issue
Block a user