ebkalderon / vonage-rs

Vonage (formerly Nexmo) API bindings for Rust. Work in progress.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vonage-rs

Vonage (formerly Nexmo) API bindings for Rust.

This library (vonage-rs) is intended to be an idiomatic Rust equivalent of vonage-node-sdk. It enables you to quickly add communications functionality to your application, including sending SMS messages, making voice calls, text-to-speech, gathering phone number insights, two-factor authentication, and more.

To use this library, a Vonage account is required. If you don't have an account, you can always sign up for free.

See developer.nexmo.com for upstream documentation.

Example

use std::error::Error;
use std::io::BufRead;
use std::time::Duration;

use vonage::verify::{Code, CodeLength};
use vonage::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let client = Client::new("<api_key>", "<api_secret>");
    let mut pending = client
        .verify("+1 555-555-555".parse()?, "vonage-rs")?
        .code_length(CodeLength::Six)
        .pin_expiry(Duration::from_secs(5 * 60))
        .send()
        .await?;

    let stdin = std::io::stdin();
    let mut lines = stdin.lock().lines();

    let matched = loop {
        let code = lines.next().unwrap()?;
        match pending.check(&code).await? {
            Code::Match(matched) => break matched,
            Code::Mismatch(p) => pending = p,
        }
    };

    println!("Code matches! {:?}", matched);

    Ok(())
}

Product support

Below are the non-beta products that vonage-rs aims to support, at minimum:

Below are the non-beta nice-to-have products that vonage-rs may support later:

License

vonage-rs is free and open source software distributed under the terms of either the MIT or the Apache 2.0 license, at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Vonage (formerly Nexmo) API bindings for Rust. Work in progress.

License:Apache License 2.0


Languages

Language:Rust 100.0%