fax_receive/
fax_receive.rs1use twiml_rust::{
9 fax::{ReceiveAttributes, ReceiveMediaType, ReceivePageSize},
10 FaxResponse, TwiML,
11};
12
13fn main() {
14 println!("=== TwiML Fax Examples ===\n");
15
16 println!("1. Simple Fax Receive:");
18 simple_receive();
19
20 println!("\n2. Fax Receive with PDF Storage:");
22 receive_as_pdf();
23
24 println!("\n3. Fax Receive with All Options:");
26 receive_with_all_options();
27
28 println!("\n4. Fax Receive without Storage:");
30 receive_no_storage();
31}
32
33fn simple_receive() {
35 let response = FaxResponse::new().receive(Some(ReceiveAttributes::new()));
36
37 println!("{}", response.to_xml());
38}
39
40fn receive_as_pdf() {
42 let response = FaxResponse::new().receive(Some(
43 ReceiveAttributes::new()
44 .action("https://example.com/fax-received")
45 .media_type(ReceiveMediaType::ApplicationPdf),
46 ));
47
48 println!("{}", response.to_xml());
49}
50
51fn receive_with_all_options() {
53 let response = FaxResponse::new().receive(Some(
54 ReceiveAttributes::new()
55 .action("https://example.com/fax-received")
56 .method("POST")
57 .media_type(ReceiveMediaType::ApplicationPdf)
58 .page_size(ReceivePageSize::Letter)
59 .store_media(true),
60 ));
61
62 println!("{}", response.to_xml());
63}
64
65fn receive_no_storage() {
67 let response = FaxResponse::new().receive(Some(
68 ReceiveAttributes::new()
69 .action("https://example.com/fax-metadata")
70 .store_media(false),
71 ));
72
73 println!("{}", response.to_xml());
74}