#twilio #api #api-bindings

twiml

Twilio TwiML 的类型安全构建

3个不稳定版本

0.3.0 2020年3月22日
0.2.1 2019年2月2日
0.2.0 2019年2月2日

#5#twilio

Download history 1495/week @ 2024-03-13 1012/week @ 2024-03-20 885/week @ 2024-03-27 911/week @ 2024-04-03 929/week @ 2024-04-10 652/week @ 2024-04-17 1147/week @ 2024-04-24 804/week @ 2024-05-01 1079/week @ 2024-05-08 592/week @ 2024-05-15 813/week @ 2024-05-22 827/week @ 2024-05-29 793/week @ 2024-06-05 756/week @ 2024-06-12 617/week @ 2024-06-19 451/week @ 2024-06-26

2,778 每月下载量
twilio-async 中使用

MIT 许可证

23KB
672

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());
    }

依赖项

~255KB