pub struct SmsDev { /* private fields */ }Expand description
The primary entry-point for interacting with the SMSDev API.
§Example
use smsdev::{SmsDev, models::SendSmsRequest};
#[tokio::main]
async fn main() -> smsdev::Result<()> {
let client = SmsDev::new("YOUR_API_KEY");
let req = SendSmsRequest::new("YOUR_API_KEY", 5511988887777, "Hello from Rust!");
let results = client.send_sms(vec![req]).await?;
for r in &results {
println!("Sent! Message ID: {}", r.id);
}
Ok(())
}Implementations§
Source§impl SmsDev
impl SmsDev
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Create a new SmsDev client with the given API key.
Sourcepub async fn send_sms(
&self,
messages: Vec<SendSmsRequest>,
) -> Result<Vec<SendSmsResponse>>
pub async fn send_sms( &self, messages: Vec<SendSmsRequest>, ) -> Result<Vec<SendSmsResponse>>
Send one or more SMS messages.
Each element in messages targets a single recipient. The API
accepts batches, so you can pass as many as needed in one call.
Returns one SendSmsResponse per message, in the same order.
§Example
let client = SmsDev::new("YOUR_API_KEY");
let messages = vec![
SendSmsRequest::new("YOUR_API_KEY", 5511988887777, "Hello Alice!"),
SendSmsRequest::new("YOUR_API_KEY", 5521977776666, "Hello Bob!"),
];
let results = client.send_sms(messages).await?;
for r in results {
println!("id={} status={}", r.id, r.status);
}Sourcepub async fn send_one(&self, message: SendSmsRequest) -> Result<SendSmsResponse>
pub async fn send_one(&self, message: SendSmsRequest) -> Result<SendSmsResponse>
Send a single SMS message (convenience wrapper around [send_sms]).
§Example
let client = SmsDev::new("YOUR_API_KEY");
let req = SendSmsRequest::new("YOUR_API_KEY", 5511988887777, "Hi!")
.refer("order-42")
.schedule_date("25/12/2025")
.schedule_time("09:00");
let result = client.send_one(req).await?;
println!("Queued with id={}", result.id);Sourcepub async fn cancel(&self, ids: Vec<u64>) -> Result<Vec<CancelResponse>>
pub async fn cancel(&self, ids: Vec<u64>) -> Result<Vec<CancelResponse>>
Cancel one or more scheduled messages.
§Example
let client = SmsDev::new("YOUR_API_KEY");
let results = client.cancel(vec![637849052, 637849053]).await?;
for r in results {
println!("Cancelled id={}: {}", r.id, r.description);
}Sourcepub async fn inbox(&self, req: InboxRequest) -> Result<Vec<InboxMessage>>
pub async fn inbox(&self, req: InboxRequest) -> Result<Vec<InboxMessage>>
Query the inbox for received (MO) messages.
§Example – fetch only new messages
let client = SmsDev::new("YOUR_API_KEY");
let inbox = client.inbox(InboxRequest::new("YOUR_API_KEY")).await?;
for msg in inbox {
println!("[{}] {}: {}", msg.data_read, msg.phone, msg.description);
}Sourcepub async fn dlr(&self, ids: Vec<u64>) -> Result<Vec<DlrResponse>>
pub async fn dlr(&self, ids: Vec<u64>) -> Result<Vec<DlrResponse>>
Query delivery status (DLR) for one or more sent messages.
§Example
let client = SmsDev::new("YOUR_API_KEY");
let statuses = client.dlr(vec![637849052]).await?;
for s in statuses {
println!("operator={:?} status={}", s.operator, s.description);
}Sourcepub async fn balance(&self) -> Result<BalanceResponse>
pub async fn balance(&self) -> Result<BalanceResponse>
Retrieve the account’s current SMS credit balance.
§Example
let client = SmsDev::new("YOUR_API_KEY");
let balance = client.balance().await?;
println!("Credits remaining: {}", balance.sms_balance);Sourcepub async fn report(&self, req: ReportRequest) -> Result<ReportResponse>
pub async fn report(&self, req: ReportRequest) -> Result<ReportResponse>
Fetch a total usage report, optionally filtered by date range.
§Example
let client = SmsDev::new("YOUR_API_KEY");
let report = client
.report(
ReportRequest::new("YOUR_API_KEY")
.date_from("01/01/2025")
.date_to("31/01/2025"),
)
.await?;
println!(
"Sent={} Received={} Credits={}",
report.sent, report.received, report.credits_used
);Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SmsDev
impl !UnwindSafe for SmsDev
impl Freeze for SmsDev
impl Send for SmsDev
impl Sync for SmsDev
impl Unpin for SmsDev
impl UnsafeUnpin for SmsDev
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more