Giter VIP home page Giter VIP logo

twilio-async's Introduction

twilio-async

Example Usage

An async and ergonomic wrapper around Twilio API & TwiML.

All types can run run() or a similar function. They return a value that implements Deserialize.

The examples/ dir has up to date working example code.

Messages:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let twilio = Twilio::new(account_sid, token)?;
    // sending a message
    twilio.send_msg("from", "to", "Hello World").run().await?;
    // sending a body-less message with media
    twilio
        .send_msg("from", "to", "body")
        .media("http://i0.kym-cdn.com/photos/images/newsfeed/000/377/946/0b9.jpg")
        .run().await?;
    // get details about a message
    twilio.msg("messagesid").run().await?;
    // redact a message
    twilio.msg("messagesid").redact().await?;
    // get a msg media url
    twilio.msg("messagesid").media().await?;
    // delete a msg
    twilio.msg("messagesid").delete().await?;
    // get all messages
    twilio.msgs().run().await?;
    // get all messages between some time
    twilio.msgs().between("start date", "end date").run().await?;
    // get all messages on a specific date
    twilio.msgs().on("date").run().await?;
}

Calls:

let twilio = Twilio::new(env::var("TWILIO_SID")?, env::var("TWILIO_TOKEN")?)?;
let (status, resp) = twilio
    .call("from", "to", "http://demo.twilio.com/docs/voice.xml")
    .run().await?;

Twiml:

use twilio_async::twiml::Response;

let resp = Response::new()
    .say("Hello World") // builder pattern also supports say(Say::new("Hello World").lang("de")...)
    .play("https://api.twilio.com/Cowbell.mp3")
    .build();
let s = "<Response><Say voice=\"man\" language=\"en\" loop=\"1\">Hello World</Say><Play loop=\"1\">https://api.twilio.com/Cowbell.mp3</Play></Response>";
assert_eq!(resp.unwrap(), s.to_string());

Contributing

There is untested code for conferences/recordings.

The TwiML work is complete and has some test coverage.

PRs and suggestions are welcome.

twilio-async's People

Contributors

leshow avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.