use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendSmsRequest {
pub key: String,
#[serde(rename = "type")]
pub service_type: u8,
pub number: u64,
pub msg: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub refer: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub jobdate: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub jobtime: Option<String>,
}
impl SendSmsRequest {
pub fn new(key: impl Into<String>, number: u64, msg: impl Into<String>) -> Self {
Self {
key: key.into(),
service_type: 9,
number,
msg: msg.into(),
refer: None,
jobdate: None,
jobtime: None,
}
}
pub fn refer(mut self, refer: impl Into<String>) -> Self {
self.refer = Some(refer.into());
self
}
pub fn schedule_date(mut self, date: impl Into<String>) -> Self {
self.jobdate = Some(date.into());
self
}
pub fn schedule_time(mut self, time: impl Into<String>) -> Self {
self.jobtime = Some(time.into());
self
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct SendSmsResponse {
#[serde(rename = "situacao")]
pub status: String,
#[serde(rename = "codigo")]
pub code: String,
pub id: String,
#[serde(rename = "descricao")]
pub description: String,
}
impl SendSmsResponse {
pub fn is_ok(&self) -> bool {
self.status.eq_ignore_ascii_case("ok")
}
}