use reqwest::Method;
use serde::Deserialize;
use crate::{client::Sendry, error::Error, Page, PaginationParams};
#[derive(Debug, Clone)]
pub struct TestEmails {
client: Sendry,
}
impl TestEmails {
pub(crate) fn new(client: Sendry) -> Self {
Self { client }
}
pub async fn list(
&self,
params: PaginationParams,
) -> Result<Page<TestEmailSummary>, Error> {
let q = params.to_query();
self.client
.request(
self.client
.build::<()>(Method::GET, "/v1/test-emails", &q, None),
)
.await
}
pub async fn get(&self, id: &str) -> Result<TestEmail, Error> {
self.client
.request(self.client.build::<()>(
Method::GET,
&format!("/v1/test-emails/{id}"),
&[],
None,
))
.await
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct TestEmailSummary {
pub id: String,
pub from: String,
pub to: Vec<String>,
pub subject: String,
pub message_type: String,
pub created_at: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TestEmail {
pub id: String,
pub from: String,
pub to: Vec<String>,
pub cc: Option<Vec<String>>,
pub subject: String,
pub html: Option<String>,
pub text: Option<String>,
pub message_type: String,
pub created_at: String,
}