#sms #messagebird

messagebird-async

Wrapper around the message bird SMS API

1 unstable release

0.0.0 Sep 12, 2018
Download history 27/week @ 2018-09-16 36/week @ 2018-09-23 32/week @ 2018-09-30 14/week @ 2018-10-07 14/week @ 2018-10-14 115/week @ 2018-10-21 5/week @ 2018-10-28 50/week @ 2018-11-04 42/week @ 2018-11-11

1 downloads per month

MIT/Apache

74KB
2K SLoC

messagebird-async

Build Status Crates.io docs.rs License

MessageBird is a service for sending SMS at its core https://www.messagebird.com/

Example

Send a SMS Message

Sending a sms to a specified target is implemented in examples/send.rs:

export MESSAGEBIRD_ACCESSKEY=abio8usad..dfahdk
export SMS_RECIPIENT=1234556

The SMS_RECIPIENT should NOT contain leading zeros nor the +. The countrycode is still necessary.

cargo run --example send

or copy & paste:

#[macro_use]
extern crate log;
extern crate env_logger;
extern crate futures;
extern crate messagebird_async;
extern crate tokio_core;

use futures::future::Future;
use messagebird_async::errors::*;
use messagebird_async::sms;
use messagebird_async::sms::*;

fn main() -> Result<(), MessageBirdError> {
    env_logger::init();

    let msisdn_str = std::env::var("SMS_RECIPIENT".to_string())
        .expect("SMS_RECIPIENT should contain the number without prefix");
    let msisdn: Msisdn = Msisdn::from_str(msisdn_str.as_str())
        .expect("SMS_RECIPIENT did not contain a valid number");

    info!("example: sending a message");
    let sendable = sms::send::SendParameters::builder()
        .payload(
            PayloadType::Sms,
            Payload::Text("fun".to_string()),
            PayloadEncoding::Auto,
        )
        .origin(AlphaNumeric("inbox".to_string()).into())
        .add_recipient(msisdn.into())
        //.add_recipient(Recipient::new())
        .build();

    let accesskey = AccessKey::from_env()?;
    let fut = RequestSend::new(&sendable, &accesskey);
    let fut = fut.and_then(|sent_msg: Message| {
        info!("{:?}", sent_msg);
        futures::future::ok(())
    });
    let mut core = tokio_core::reactor::Core::new().unwrap();
    core.run(fut.map(|_| ()))
}

Features

Currently the planned features only include to send SMS and query SMS stati.

RoadMap

  • serde impl for all relevant datatypes
  • roundtrip decode encode tests
  • use crate serde_plain for trait ToString and trait FromStr for objects which are used in query filters and payload www urlencode
  • future for SMS sending and retrieval based on hyper.rs
  • send SMS example using tokio as executor
  • future for listing SMS
  • listing SMS examples using tokio as executor
  • write proper documentation
  • future for callback on SMS reception
  • callback example using tokio as executor

MessageBird APIs

* = not planned, unless external contributors step up

License

MIT or Apache-2.0

If neither of those works for you, feel free to request so via a github issue.

Donations

Since I am not affiliated with MessageBird in any kind (other than being their customer) I'd be delighted if you'd leave a tipp

LiberaPayButton

Dependencies

~22MB
~556K SLoC