1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use hyper::{self, Method};
use serde;
use {Execute, Twilio, TwilioErr, TwilioRequest, TwilioResp};
#[derive(Debug, Default)]
pub struct Recording<'a> {
sid: &'a str,
}
impl<'a> Recording<'a> {
pub fn new(sid: &'a str) -> Recording<'a> {
Recording { sid }
}
}
pub struct GetRecording<'a> {
pub recording: Recording<'a>,
pub client: &'a Twilio,
}
execute!(GetRecording);
impl<'a> TwilioRequest for GetRecording<'a> {
type Resp = RecordingResp;
fn run(self) -> TwilioResp<Self::Resp> {
let url = format!("Recordings/{}.json", self.recording.sid);
self.execute(Method::Get, url, None)
}
}
impl<'a> GetRecording<'a> {
pub fn delete(self) -> TwilioResp<Option<bool>> {
let url = format!("Recordings/{}.json", self.recording.sid);
self.execute(Method::Delete, url, None)
}
}
pub struct Recordings<'a> {
pub client: &'a Twilio,
}
execute!(Recordings);
impl<'a> TwilioRequest for Recordings<'a> {
type Resp = ListRecordingResp;
fn run(self) -> TwilioResp<Self::Resp> {
self.execute(Method::Get, "Recordings.json", None)
}
}
impl<'a> Recordings<'a> {
pub fn for_call(self, call_sid: &'a str) -> TwilioResp<ListRecordingResp> {
let url = format!("Recordings.json?CallSid={}", call_sid);
self.execute(Method::Get, url, None)
}
pub fn created(self, date_created: &'a str) -> TwilioResp<ListRecordingResp> {
let url = format!("Recordings.json?DateCreated={}", date_created);
self.execute(Method::Get, url, None)
}
pub fn range(self, before: &'a str, after: &'a str) -> TwilioResp<ListRecordingResp> {
let url = format!(
"Recordings.json?DateCreatedBefore={}&DateCreatedAfter={}",
before, after
);
self.execute(Method::Get, url, None)
}
}
#[derive(Deserialize, Debug)]
pub struct ListRecordingResp {
pub recordings: Vec<RecordingResp>,
pub end: usize,
pub account_sid: String,
pub start: usize,
pub page: usize,
pub page_size: usize,
}
#[derive(Deserialize, Debug)]
pub struct RecordingResp {
pub account_sid: String,
pub call_sid: String,
pub channels: String,
pub conference_sid: String,
pub date_created: String,
pub date_updated: String,
pub end_time: String,
pub start_time: String,
pub price: String,
pub price_unit: String,
pub duration: String,
pub encryption_details: EncryptionDetails,
pub error_code: String,
pub uri: String,
pub status: RecordingStatus,
}
#[derive(Deserialize, Debug)]
pub struct EncryptionDetails {
pub encryption_public_key_sid: String,
pub encryption_cek: String,
pub encryption_iv: String,
}
#[derive(Deserialize, Debug)]
#[allow(non_camel_case_types)]
pub enum RecordingStatus {
#[serde(rename = "in-progress")]
inprogress,
paused,
stopped,
processing,
completed,
failed,
}