3 unstable releases

0.3.0 Mar 22, 2020
0.2.1 Feb 2, 2019
0.2.0 Feb 2, 2019

#6 in #twilio

Download history 909/week @ 2024-01-28 804/week @ 2024-02-04 644/week @ 2024-02-11 370/week @ 2024-02-18 963/week @ 2024-02-25 1188/week @ 2024-03-03 1278/week @ 2024-03-10 1355/week @ 2024-03-17 934/week @ 2024-03-24 884/week @ 2024-03-31 821/week @ 2024-04-07 813/week @ 2024-04-14 853/week @ 2024-04-21 1121/week @ 2024-04-28 861/week @ 2024-05-05 852/week @ 2024-05-12

3,691 downloads per month
Used in twilio-async

MIT license

23KB
672 lines

TwiML

   #[test]
    fn twiml_response() {
        let resp = Response::new()
            .say("Hello World")
            .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());
    }

    #[test]
    fn twiml_resp_build() {
        let resp = Response::new()
            .say(Say::new("Hello World").lang("de").voice(Voice::alice))
            .play("https://api.twilio.com/Cowbell.mp3")
            .build();
        let s = "<Response><Say voice=\"alice\" language=\"de\" loop=\"1\">Hello World</Say><Play loop=\"1\">https://api.twilio.com/Cowbell.mp3</Play></Response>";
        assert_eq!(resp.unwrap(), s.to_string());
    }

    #[test]
    fn twiml_say() {
        let say = Say::new("Hello World")
            .lang("de")
            .voice(Voice::alice)
            .build();
        let s = "<Say voice=\"alice\" language=\"de\" loop=\"1\">Hello World</Say>";
        assert_eq!(say.unwrap(), s.to_string());
    }

    #[test]
    fn twiml_play() {
        let play = Play::new("https://api.twilio.com/Cowbell.mp3")
            .count(3)
            .build();
        let s = "<Play loop=\"3\">https://api.twilio.com/Cowbell.mp3</Play>";
        assert_eq!(play.unwrap(), s.to_string());
    }

    #[test]
    fn twiml_response_dial() {
        let resp = Response::new().dial("415-123-4567").build();
        let s = "<Response><Dial method=\"POST\" timeout=\"30\" record=\"do-not-record\">415-123-4567</Dial></Response>";
        assert_eq!(resp.unwrap(), s.to_string());
    }

    #[test]
    fn twiml_response_hangup() {
        let resp = Response::new().hangup().build();
        let s = "<Response><Hangup /></Response>";
        assert_eq!(resp.unwrap(), s.to_string());
    }

Dependencies

~255KB