twilio_rust_openapi/apis/
api20100401_participant_api.rs

1/*
2 * Twilio - Api
3 *
4 * This is the public Twilio REST API.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: support@twilio.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`create_participant`]
18#[derive(Clone, Debug)]
19pub struct CreateParticipantParams {
20    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource.
21    pub account_sid: String,
22    /// The SID of the participant's conference.
23    pub conference_sid: String,
24    /// The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `from` must also be a phone number. If `to` is sip address, this value of `from` should be a username portion to be used to populate the P-Asserted-Identity header that is passed to the SIP endpoint.
25    pub from: String,
26    /// The phone number, SIP address, or Client identifier that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `sip:name@company.com`. Client identifiers are formatted `client:name`. [Custom parameters](https://www.twilio.com/docs/voice/api/conference-participant-resource#custom-parameters) may also be specified.
27    pub to: String,
28    /// The URL we should call using the `status_callback_method` to send status information to your application.
29    pub status_callback: Option<String>,
30    /// The HTTP method we should use to call `status_callback`. Can be: `GET` and `POST` and defaults to `POST`.
31    pub status_callback_method: Option<String>,
32    /// The conference state changes that should generate a call to `status_callback`. Can be: `initiated`, `ringing`, `answered`, and `completed`. Separate multiple values with a space. The default value is `completed`.
33    pub status_callback_event: Option<Vec<String>>,
34    /// A label for this participant. If one is supplied, it may subsequently be used to fetch, update or delete the participant.
35    pub label: Option<String>,
36    /// The number of seconds that we should allow the phone to ring before assuming there is no answer. Can be an integer between `5` and `600`, inclusive. The default value is `60`. We always add a 5-second timeout buffer to outgoing calls, so  value of 10 would result in an actual timeout that was closer to 15 seconds.
37    pub timeout: Option<i32>,
38    /// Whether to record the participant and their conferences, including the time between conferences. Can be `true` or `false` and the default is `false`.
39    pub record: Option<bool>,
40    /// Whether the agent is muted in the conference. Can be `true` or `false` and the default is `false`.
41    pub muted: Option<bool>,
42    /// Whether to play a notification beep to the conference when the participant joins. Can be: `true`, `false`, `onEnter`, or `onExit`. The default value is `true`.
43    pub beep: Option<String>,
44    /// Whether to start the conference when the participant joins, if it has not already started. Can be: `true` or `false` and the default is `true`. If `false` and the conference has not started, the participant is muted and hears background music until another participant starts the conference.
45    pub start_conference_on_enter: Option<bool>,
46    /// Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`.
47    pub end_conference_on_exit: Option<bool>,
48    /// The URL we should call using the `wait_method` for the music to play while participants are waiting for the conference to start. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic).
49    pub wait_url: Option<String>,
50    /// The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file.
51    pub wait_method: Option<String>,
52    /// Whether to allow an agent to hear the state of the outbound call, including ringing or disconnect messages. Can be: `true` or `false` and defaults to `true`.
53    pub early_media: Option<bool>,
54    /// The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`.
55    pub max_participants: Option<i32>,
56    /// Whether to record the conference the participant is joining. Can be: `true`, `false`, `record-from-start`, and `do-not-record`. The default value is `false`.
57    pub conference_record: Option<String>,
58    /// Whether to trim leading and trailing silence from the conference recording. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`.
59    pub conference_trim: Option<String>,
60    /// The URL we should call using the `conference_status_callback_method` when the conference events in `conference_status_callback_event` occur. Only the value set by the first participant to join the conference is used. Subsequent `conference_status_callback` values are ignored.
61    pub conference_status_callback: Option<String>,
62    /// The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
63    pub conference_status_callback_method: Option<String>,
64    /// The conference state changes that should generate a call to `conference_status_callback`. Can be: `start`, `end`, `join`, `leave`, `mute`, `hold`, `modify`, `speaker`, and `announcement`. Separate multiple values with a space. Defaults to `start end`.
65    pub conference_status_callback_event: Option<Vec<String>>,
66    /// The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`.
67    pub recording_channels: Option<String>,
68    /// The URL that we should call using the `recording_status_callback_method` when the recording status changes.
69    pub recording_status_callback: Option<String>,
70    /// The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
71    pub recording_status_callback_method: Option<String>,
72    /// The SIP username used for authentication.
73    pub sip_auth_username: Option<String>,
74    /// The SIP password for authentication.
75    pub sip_auth_password: Option<String>,
76    /// The [region](https://support.twilio.com/hc/en-us/articles/223132167-How-global-low-latency-routing-and-region-selection-work-for-conferences-and-Client-calls) where we should mix the recorded audio. Can be:`us1`, `ie1`, `de1`, `sg1`, `br1`, `au1`, or `jp1`.
77    pub region: Option<String>,
78    /// The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available.
79    pub conference_recording_status_callback: Option<String>,
80    /// The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
81    pub conference_recording_status_callback_method: Option<String>,
82    /// The recording state changes that should generate a call to `recording_status_callback`. Can be: `started`, `in-progress`, `paused`, `resumed`, `stopped`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`.
83    pub recording_status_callback_event: Option<Vec<String>>,
84    /// The conference recording state changes that generate a call to `conference_recording_status_callback`. Can be: `in-progress`, `completed`, `failed`, and `absent`. Separate multiple values with a space, ex: `'in-progress completed failed'`
85    pub conference_recording_status_callback_event: Option<Vec<String>>,
86    /// Whether the participant is coaching another call. Can be: `true` or `false`. If not present, defaults to `false` unless `call_sid_to_coach` is defined. If `true`, `call_sid_to_coach` must be defined.
87    pub coaching: Option<bool>,
88    /// The SID of the participant who is being `coached`. The participant being coached is the only participant who can hear the participant who is `coaching`.
89    pub call_sid_to_coach: Option<String>,
90    /// Jitter buffer size for the connecting participant. Twilio will use this setting to apply Jitter Buffer before participant's audio is mixed into the conference. Can be: `off`, `small`, `medium`, and `large`. Default to `large`.
91    pub jitter_buffer_size: Option<String>,
92    /// The SID of a BYOC (Bring Your Own Carrier) trunk to route this call with. Note that `byoc` is only meaningful when `to` is a phone number; it will otherwise be ignored. (Beta)
93    pub byoc: Option<String>,
94    /// The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `callerId` must also be a phone number. If `to` is sip address, this value of `callerId` should be a username portion to be used to populate the From header that is passed to the SIP endpoint.
95    pub caller_id: Option<String>,
96    /// The Reason for the outgoing call. Use it to specify the purpose of the call that is presented on the called party's phone. (Branded Calls Beta)
97    pub call_reason: Option<String>,
98    /// The audio track to record for the call. Can be: `inbound`, `outbound` or `both`. The default is `both`. `inbound` records the audio that is received by Twilio. `outbound` records the audio that is sent from Twilio. `both` records the audio that is received and sent by Twilio.
99    pub recording_track: Option<String>,
100    /// The maximum duration of the call in seconds. Constraints depend on account and configuration.
101    pub time_limit: Option<i32>,
102    /// Whether to detect if a human, answering machine, or fax has picked up the call. Can be: `Enable` or `DetectMessageEnd`. Use `Enable` if you would like us to return `AnsweredBy` as soon as the called party is identified. Use `DetectMessageEnd`, if you would like to leave a message on an answering machine. For more information, see [Answering Machine Detection](https://www.twilio.com/docs/voice/answering-machine-detection).
103    pub machine_detection: Option<String>,
104    /// The number of seconds that we should attempt to detect an answering machine before timing out and sending a voice request with `AnsweredBy` of `unknown`. The default timeout is 30 seconds.
105    pub machine_detection_timeout: Option<i32>,
106    /// The number of milliseconds that is used as the measuring stick for the length of the speech activity, where durations lower than this value will be interpreted as a human and longer than this value as a machine. Possible Values: 1000-6000. Default: 2400.
107    pub machine_detection_speech_threshold: Option<i32>,
108    /// The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200.
109    pub machine_detection_speech_end_threshold: Option<i32>,
110    /// The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000.
111    pub machine_detection_silence_timeout: Option<i32>,
112    /// The URL that we should call using the `amd_status_callback_method` to notify customer application whether the call was answered by human, machine or fax.
113    pub amd_status_callback: Option<String>,
114    /// The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`.
115    pub amd_status_callback_method: Option<String>,
116    /// Whether to trim any leading and trailing silence from the participant recording. Can be: `trim-silence` or `do-not-trim` and the default is `trim-silence`.
117    pub trim: Option<String>,
118    /// A token string needed to invoke a forwarded call. A call_token is generated when an incoming call is received on a Twilio number. Pass an incoming call's call_token value to a forwarded call via the call_token parameter when creating a new call. A forwarded call should bear the same CallerID of the original incoming call.
119    pub call_token: Option<String>
120}
121
122/// struct for passing parameters to the method [`delete_participant`]
123#[derive(Clone, Debug)]
124pub struct DeleteParticipantParams {
125    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to delete.
126    pub account_sid: String,
127    /// The SID of the conference with the participants to delete.
128    pub conference_sid: String,
129    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID or label of the participant to delete. Non URL safe characters in a label must be percent encoded, for example, a space character is represented as %20.
130    pub call_sid: String
131}
132
133/// struct for passing parameters to the method [`fetch_participant`]
134#[derive(Clone, Debug)]
135pub struct FetchParticipantParams {
136    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resource to fetch.
137    pub account_sid: String,
138    /// The SID of the conference with the participant to fetch.
139    pub conference_sid: String,
140    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID or label of the participant to fetch. Non URL safe characters in a label must be percent encoded, for example, a space character is represented as %20.
141    pub call_sid: String
142}
143
144/// struct for passing parameters to the method [`list_participant`]
145#[derive(Clone, Debug)]
146pub struct ListParticipantParams {
147    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to read.
148    pub account_sid: String,
149    /// The SID of the conference with the participants to read.
150    pub conference_sid: String,
151    /// Whether to return only participants that are muted. Can be: `true` or `false`.
152    pub muted: Option<bool>,
153    /// Whether to return only participants that are on hold. Can be: `true` or `false`.
154    pub hold: Option<bool>,
155    /// Whether to return only participants who are coaching another call. Can be: `true` or `false`.
156    pub coaching: Option<bool>,
157    /// How many resources to return in each list page. The default is 50, and the maximum is 1000.
158    pub page_size: Option<i32>,
159    /// The page index. This value is simply for client state.
160    pub page: Option<i32>,
161    /// The page token. This is provided by the API.
162    pub page_token: Option<String>
163}
164
165/// struct for passing parameters to the method [`update_participant`]
166#[derive(Clone, Debug)]
167pub struct UpdateParticipantParams {
168    /// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to update.
169    pub account_sid: String,
170    /// The SID of the conference with the participant to update.
171    pub conference_sid: String,
172    /// The [Call](https://www.twilio.com/docs/voice/api/call-resource) SID or label of the participant to update. Non URL safe characters in a label must be percent encoded, for example, a space character is represented as %20.
173    pub call_sid: String,
174    /// Whether the participant should be muted. Can be `true` or `false`. `true` will mute the participant, and `false` will un-mute them. Anything value other than `true` or `false` is interpreted as `false`.
175    pub muted: Option<bool>,
176    /// Whether the participant should be on hold. Can be: `true` or `false`. `true` puts the participant on hold, and `false` lets them rejoin the conference.
177    pub hold: Option<bool>,
178    /// The URL we call using the `hold_method` for music that plays when the participant is on hold. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
179    pub hold_url: Option<String>,
180    /// The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`.
181    pub hold_method: Option<String>,
182    /// The URL we call using the `announce_method` for an announcement to the participant. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs.
183    pub announce_url: Option<String>,
184    /// The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`.
185    pub announce_method: Option<String>,
186    /// The URL we call using the `wait_method` for the music to play while participants are waiting for the conference to start. The URL may return an MP3 file, a WAV file, or a TwiML document that contains `<Play>`, `<Say>`, `<Pause>`, or `<Redirect>` verbs. The default value is the URL of our standard hold music. [Learn more about hold music](https://www.twilio.com/labs/twimlets/holdmusic).
187    pub wait_url: Option<String>,
188    /// The HTTP method we should use to call `wait_url`. Can be `GET` or `POST` and the default is `POST`. When using a static audio file, this should be `GET` so that we can cache the file.
189    pub wait_method: Option<String>,
190    /// Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`.
191    pub beep_on_exit: Option<bool>,
192    /// Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`.
193    pub end_conference_on_exit: Option<bool>,
194    /// Whether the participant is coaching another call. Can be: `true` or `false`. If not present, defaults to `false` unless `call_sid_to_coach` is defined. If `true`, `call_sid_to_coach` must be defined.
195    pub coaching: Option<bool>,
196    /// The SID of the participant who is being `coached`. The participant being coached is the only participant who can hear the participant who is `coaching`.
197    pub call_sid_to_coach: Option<String>
198}
199
200
201/// struct for typed errors of method [`create_participant`]
202#[derive(Debug, Clone, Serialize, Deserialize)]
203#[serde(untagged)]
204pub enum CreateParticipantError {
205    UnknownValue(serde_json::Value),
206}
207
208/// struct for typed errors of method [`delete_participant`]
209#[derive(Debug, Clone, Serialize, Deserialize)]
210#[serde(untagged)]
211pub enum DeleteParticipantError {
212    UnknownValue(serde_json::Value),
213}
214
215/// struct for typed errors of method [`fetch_participant`]
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum FetchParticipantError {
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`list_participant`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum ListParticipantError {
226    UnknownValue(serde_json::Value),
227}
228
229/// struct for typed errors of method [`update_participant`]
230#[derive(Debug, Clone, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum UpdateParticipantError {
233    UnknownValue(serde_json::Value),
234}
235
236
237/// 
238pub async fn create_participant(configuration: &configuration::Configuration, params: CreateParticipantParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConferencePeriodParticipant, Error<CreateParticipantError>> {
239    let local_var_configuration = configuration;
240
241    // unbox the parameters
242    let account_sid = params.account_sid;
243    let conference_sid = params.conference_sid;
244    let from = params.from;
245    let to = params.to;
246    let status_callback = params.status_callback;
247    let status_callback_method = params.status_callback_method;
248    let status_callback_event = params.status_callback_event;
249    let label = params.label;
250    let timeout = params.timeout;
251    let record = params.record;
252    let muted = params.muted;
253    let beep = params.beep;
254    let start_conference_on_enter = params.start_conference_on_enter;
255    let end_conference_on_exit = params.end_conference_on_exit;
256    let wait_url = params.wait_url;
257    let wait_method = params.wait_method;
258    let early_media = params.early_media;
259    let max_participants = params.max_participants;
260    let conference_record = params.conference_record;
261    let conference_trim = params.conference_trim;
262    let conference_status_callback = params.conference_status_callback;
263    let conference_status_callback_method = params.conference_status_callback_method;
264    let conference_status_callback_event = params.conference_status_callback_event;
265    let recording_channels = params.recording_channels;
266    let recording_status_callback = params.recording_status_callback;
267    let recording_status_callback_method = params.recording_status_callback_method;
268    let sip_auth_username = params.sip_auth_username;
269    let sip_auth_password = params.sip_auth_password;
270    let region = params.region;
271    let conference_recording_status_callback = params.conference_recording_status_callback;
272    let conference_recording_status_callback_method = params.conference_recording_status_callback_method;
273    let recording_status_callback_event = params.recording_status_callback_event;
274    let conference_recording_status_callback_event = params.conference_recording_status_callback_event;
275    let coaching = params.coaching;
276    let call_sid_to_coach = params.call_sid_to_coach;
277    let jitter_buffer_size = params.jitter_buffer_size;
278    let byoc = params.byoc;
279    let caller_id = params.caller_id;
280    let call_reason = params.call_reason;
281    let recording_track = params.recording_track;
282    let time_limit = params.time_limit;
283    let machine_detection = params.machine_detection;
284    let machine_detection_timeout = params.machine_detection_timeout;
285    let machine_detection_speech_threshold = params.machine_detection_speech_threshold;
286    let machine_detection_speech_end_threshold = params.machine_detection_speech_end_threshold;
287    let machine_detection_silence_timeout = params.machine_detection_silence_timeout;
288    let amd_status_callback = params.amd_status_callback;
289    let amd_status_callback_method = params.amd_status_callback_method;
290    let trim = params.trim;
291    let call_token = params.call_token;
292
293
294    let local_var_client = &local_var_configuration.client;
295
296    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid));
297    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
298
299    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
300        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
301    }
302    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
303        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
304    };
305    let mut local_var_form_params = std::collections::HashMap::new();
306    local_var_form_params.insert("From", from.to_string());
307    local_var_form_params.insert("To", to.to_string());
308    if let Some(local_var_param_value) = status_callback {
309        local_var_form_params.insert("StatusCallback", local_var_param_value.to_string());
310    }
311    if let Some(local_var_param_value) = status_callback_method {
312        local_var_form_params.insert("StatusCallbackMethod", local_var_param_value.to_string());
313    }
314    if let Some(local_var_param_value) = status_callback_event {
315        local_var_form_params.insert("StatusCallbackEvent", local_var_param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
316    }
317    if let Some(local_var_param_value) = label {
318        local_var_form_params.insert("Label", local_var_param_value.to_string());
319    }
320    if let Some(local_var_param_value) = timeout {
321        local_var_form_params.insert("Timeout", local_var_param_value.to_string());
322    }
323    if let Some(local_var_param_value) = record {
324        local_var_form_params.insert("Record", local_var_param_value.to_string());
325    }
326    if let Some(local_var_param_value) = muted {
327        local_var_form_params.insert("Muted", local_var_param_value.to_string());
328    }
329    if let Some(local_var_param_value) = beep {
330        local_var_form_params.insert("Beep", local_var_param_value.to_string());
331    }
332    if let Some(local_var_param_value) = start_conference_on_enter {
333        local_var_form_params.insert("StartConferenceOnEnter", local_var_param_value.to_string());
334    }
335    if let Some(local_var_param_value) = end_conference_on_exit {
336        local_var_form_params.insert("EndConferenceOnExit", local_var_param_value.to_string());
337    }
338    if let Some(local_var_param_value) = wait_url {
339        local_var_form_params.insert("WaitUrl", local_var_param_value.to_string());
340    }
341    if let Some(local_var_param_value) = wait_method {
342        local_var_form_params.insert("WaitMethod", local_var_param_value.to_string());
343    }
344    if let Some(local_var_param_value) = early_media {
345        local_var_form_params.insert("EarlyMedia", local_var_param_value.to_string());
346    }
347    if let Some(local_var_param_value) = max_participants {
348        local_var_form_params.insert("MaxParticipants", local_var_param_value.to_string());
349    }
350    if let Some(local_var_param_value) = conference_record {
351        local_var_form_params.insert("ConferenceRecord", local_var_param_value.to_string());
352    }
353    if let Some(local_var_param_value) = conference_trim {
354        local_var_form_params.insert("ConferenceTrim", local_var_param_value.to_string());
355    }
356    if let Some(local_var_param_value) = conference_status_callback {
357        local_var_form_params.insert("ConferenceStatusCallback", local_var_param_value.to_string());
358    }
359    if let Some(local_var_param_value) = conference_status_callback_method {
360        local_var_form_params.insert("ConferenceStatusCallbackMethod", local_var_param_value.to_string());
361    }
362    if let Some(local_var_param_value) = conference_status_callback_event {
363        local_var_form_params.insert("ConferenceStatusCallbackEvent", local_var_param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
364    }
365    if let Some(local_var_param_value) = recording_channels {
366        local_var_form_params.insert("RecordingChannels", local_var_param_value.to_string());
367    }
368    if let Some(local_var_param_value) = recording_status_callback {
369        local_var_form_params.insert("RecordingStatusCallback", local_var_param_value.to_string());
370    }
371    if let Some(local_var_param_value) = recording_status_callback_method {
372        local_var_form_params.insert("RecordingStatusCallbackMethod", local_var_param_value.to_string());
373    }
374    if let Some(local_var_param_value) = sip_auth_username {
375        local_var_form_params.insert("SipAuthUsername", local_var_param_value.to_string());
376    }
377    if let Some(local_var_param_value) = sip_auth_password {
378        local_var_form_params.insert("SipAuthPassword", local_var_param_value.to_string());
379    }
380    if let Some(local_var_param_value) = region {
381        local_var_form_params.insert("Region", local_var_param_value.to_string());
382    }
383    if let Some(local_var_param_value) = conference_recording_status_callback {
384        local_var_form_params.insert("ConferenceRecordingStatusCallback", local_var_param_value.to_string());
385    }
386    if let Some(local_var_param_value) = conference_recording_status_callback_method {
387        local_var_form_params.insert("ConferenceRecordingStatusCallbackMethod", local_var_param_value.to_string());
388    }
389    if let Some(local_var_param_value) = recording_status_callback_event {
390        local_var_form_params.insert("RecordingStatusCallbackEvent", local_var_param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
391    }
392    if let Some(local_var_param_value) = conference_recording_status_callback_event {
393        local_var_form_params.insert("ConferenceRecordingStatusCallbackEvent", local_var_param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());
394    }
395    if let Some(local_var_param_value) = coaching {
396        local_var_form_params.insert("Coaching", local_var_param_value.to_string());
397    }
398    if let Some(local_var_param_value) = call_sid_to_coach {
399        local_var_form_params.insert("CallSidToCoach", local_var_param_value.to_string());
400    }
401    if let Some(local_var_param_value) = jitter_buffer_size {
402        local_var_form_params.insert("JitterBufferSize", local_var_param_value.to_string());
403    }
404    if let Some(local_var_param_value) = byoc {
405        local_var_form_params.insert("Byoc", local_var_param_value.to_string());
406    }
407    if let Some(local_var_param_value) = caller_id {
408        local_var_form_params.insert("CallerId", local_var_param_value.to_string());
409    }
410    if let Some(local_var_param_value) = call_reason {
411        local_var_form_params.insert("CallReason", local_var_param_value.to_string());
412    }
413    if let Some(local_var_param_value) = recording_track {
414        local_var_form_params.insert("RecordingTrack", local_var_param_value.to_string());
415    }
416    if let Some(local_var_param_value) = time_limit {
417        local_var_form_params.insert("TimeLimit", local_var_param_value.to_string());
418    }
419    if let Some(local_var_param_value) = machine_detection {
420        local_var_form_params.insert("MachineDetection", local_var_param_value.to_string());
421    }
422    if let Some(local_var_param_value) = machine_detection_timeout {
423        local_var_form_params.insert("MachineDetectionTimeout", local_var_param_value.to_string());
424    }
425    if let Some(local_var_param_value) = machine_detection_speech_threshold {
426        local_var_form_params.insert("MachineDetectionSpeechThreshold", local_var_param_value.to_string());
427    }
428    if let Some(local_var_param_value) = machine_detection_speech_end_threshold {
429        local_var_form_params.insert("MachineDetectionSpeechEndThreshold", local_var_param_value.to_string());
430    }
431    if let Some(local_var_param_value) = machine_detection_silence_timeout {
432        local_var_form_params.insert("MachineDetectionSilenceTimeout", local_var_param_value.to_string());
433    }
434    if let Some(local_var_param_value) = amd_status_callback {
435        local_var_form_params.insert("AmdStatusCallback", local_var_param_value.to_string());
436    }
437    if let Some(local_var_param_value) = amd_status_callback_method {
438        local_var_form_params.insert("AmdStatusCallbackMethod", local_var_param_value.to_string());
439    }
440    if let Some(local_var_param_value) = trim {
441        local_var_form_params.insert("Trim", local_var_param_value.to_string());
442    }
443    if let Some(local_var_param_value) = call_token {
444        local_var_form_params.insert("CallToken", local_var_param_value.to_string());
445    }
446    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
447
448    let local_var_req = local_var_req_builder.build()?;
449    let local_var_resp = local_var_client.execute(local_var_req).await?;
450
451    let local_var_status = local_var_resp.status();
452    let local_var_content = local_var_resp.text().await?;
453
454    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
455        serde_json::from_str(&local_var_content).map_err(Error::from)
456    } else {
457        let local_var_entity: Option<CreateParticipantError> = serde_json::from_str(&local_var_content).ok();
458        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
459        Err(Error::ResponseError(local_var_error))
460    }
461}
462
463/// Kick a participant from a given conference
464pub async fn delete_participant(configuration: &configuration::Configuration, params: DeleteParticipantParams) -> Result<(), Error<DeleteParticipantError>> {
465    let local_var_configuration = configuration;
466
467    // unbox the parameters
468    let account_sid = params.account_sid;
469    let conference_sid = params.conference_sid;
470    let call_sid = params.call_sid;
471
472
473    let local_var_client = &local_var_configuration.client;
474
475    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), CallSid=crate::apis::urlencode(call_sid));
476    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
477
478    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
479        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
480    }
481    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
482        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
483    };
484
485    let local_var_req = local_var_req_builder.build()?;
486    let local_var_resp = local_var_client.execute(local_var_req).await?;
487
488    let local_var_status = local_var_resp.status();
489    let local_var_content = local_var_resp.text().await?;
490
491    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
492        Ok(())
493    } else {
494        let local_var_entity: Option<DeleteParticipantError> = serde_json::from_str(&local_var_content).ok();
495        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
496        Err(Error::ResponseError(local_var_error))
497    }
498}
499
500/// Fetch an instance of a participant
501pub async fn fetch_participant(configuration: &configuration::Configuration, params: FetchParticipantParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConferencePeriodParticipant, Error<FetchParticipantError>> {
502    let local_var_configuration = configuration;
503
504    // unbox the parameters
505    let account_sid = params.account_sid;
506    let conference_sid = params.conference_sid;
507    let call_sid = params.call_sid;
508
509
510    let local_var_client = &local_var_configuration.client;
511
512    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), CallSid=crate::apis::urlencode(call_sid));
513    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
514
515    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
516        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
517    }
518    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
519        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
520    };
521
522    let local_var_req = local_var_req_builder.build()?;
523    let local_var_resp = local_var_client.execute(local_var_req).await?;
524
525    let local_var_status = local_var_resp.status();
526    let local_var_content = local_var_resp.text().await?;
527
528    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
529        serde_json::from_str(&local_var_content).map_err(Error::from)
530    } else {
531        let local_var_entity: Option<FetchParticipantError> = serde_json::from_str(&local_var_content).ok();
532        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
533        Err(Error::ResponseError(local_var_error))
534    }
535}
536
537/// Retrieve a list of participants belonging to the account used to make the request
538pub async fn list_participant(configuration: &configuration::Configuration, params: ListParticipantParams) -> Result<models::ListParticipantResponse, Error<ListParticipantError>> {
539    let local_var_configuration = configuration;
540
541    // unbox the parameters
542    let account_sid = params.account_sid;
543    let conference_sid = params.conference_sid;
544    let muted = params.muted;
545    let hold = params.hold;
546    let coaching = params.coaching;
547    let page_size = params.page_size;
548    let page = params.page;
549    let page_token = params.page_token;
550
551
552    let local_var_client = &local_var_configuration.client;
553
554    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid));
555    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
556
557    if let Some(ref local_var_str) = muted {
558        local_var_req_builder = local_var_req_builder.query(&[("Muted", &local_var_str.to_string())]);
559    }
560    if let Some(ref local_var_str) = hold {
561        local_var_req_builder = local_var_req_builder.query(&[("Hold", &local_var_str.to_string())]);
562    }
563    if let Some(ref local_var_str) = coaching {
564        local_var_req_builder = local_var_req_builder.query(&[("Coaching", &local_var_str.to_string())]);
565    }
566    if let Some(ref local_var_str) = page_size {
567        local_var_req_builder = local_var_req_builder.query(&[("PageSize", &local_var_str.to_string())]);
568    }
569    if let Some(ref local_var_str) = page {
570        local_var_req_builder = local_var_req_builder.query(&[("Page", &local_var_str.to_string())]);
571    }
572    if let Some(ref local_var_str) = page_token {
573        local_var_req_builder = local_var_req_builder.query(&[("PageToken", &local_var_str.to_string())]);
574    }
575    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
576        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
577    }
578    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
579        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
580    };
581
582    let local_var_req = local_var_req_builder.build()?;
583    let local_var_resp = local_var_client.execute(local_var_req).await?;
584
585    let local_var_status = local_var_resp.status();
586    let local_var_content = local_var_resp.text().await?;
587
588    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
589        serde_json::from_str(&local_var_content).map_err(Error::from)
590    } else {
591        let local_var_entity: Option<ListParticipantError> = serde_json::from_str(&local_var_content).ok();
592        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
593        Err(Error::ResponseError(local_var_error))
594    }
595}
596
597/// Update the properties of the participant
598pub async fn update_participant(configuration: &configuration::Configuration, params: UpdateParticipantParams) -> Result<models::ApiPeriodV2010PeriodAccountPeriodConferencePeriodParticipant, Error<UpdateParticipantError>> {
599    let local_var_configuration = configuration;
600
601    // unbox the parameters
602    let account_sid = params.account_sid;
603    let conference_sid = params.conference_sid;
604    let call_sid = params.call_sid;
605    let muted = params.muted;
606    let hold = params.hold;
607    let hold_url = params.hold_url;
608    let hold_method = params.hold_method;
609    let announce_url = params.announce_url;
610    let announce_method = params.announce_method;
611    let wait_url = params.wait_url;
612    let wait_method = params.wait_method;
613    let beep_on_exit = params.beep_on_exit;
614    let end_conference_on_exit = params.end_conference_on_exit;
615    let coaching = params.coaching;
616    let call_sid_to_coach = params.call_sid_to_coach;
617
618
619    let local_var_client = &local_var_configuration.client;
620
621    let local_var_uri_str = format!("{}/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json", local_var_configuration.base_path, AccountSid=crate::apis::urlencode(account_sid), ConferenceSid=crate::apis::urlencode(conference_sid), CallSid=crate::apis::urlencode(call_sid));
622    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
623
624    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
625        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
626    }
627    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
628        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
629    };
630    let mut local_var_form_params = std::collections::HashMap::new();
631    if let Some(local_var_param_value) = muted {
632        local_var_form_params.insert("Muted", local_var_param_value.to_string());
633    }
634    if let Some(local_var_param_value) = hold {
635        local_var_form_params.insert("Hold", local_var_param_value.to_string());
636    }
637    if let Some(local_var_param_value) = hold_url {
638        local_var_form_params.insert("HoldUrl", local_var_param_value.to_string());
639    }
640    if let Some(local_var_param_value) = hold_method {
641        local_var_form_params.insert("HoldMethod", local_var_param_value.to_string());
642    }
643    if let Some(local_var_param_value) = announce_url {
644        local_var_form_params.insert("AnnounceUrl", local_var_param_value.to_string());
645    }
646    if let Some(local_var_param_value) = announce_method {
647        local_var_form_params.insert("AnnounceMethod", local_var_param_value.to_string());
648    }
649    if let Some(local_var_param_value) = wait_url {
650        local_var_form_params.insert("WaitUrl", local_var_param_value.to_string());
651    }
652    if let Some(local_var_param_value) = wait_method {
653        local_var_form_params.insert("WaitMethod", local_var_param_value.to_string());
654    }
655    if let Some(local_var_param_value) = beep_on_exit {
656        local_var_form_params.insert("BeepOnExit", local_var_param_value.to_string());
657    }
658    if let Some(local_var_param_value) = end_conference_on_exit {
659        local_var_form_params.insert("EndConferenceOnExit", local_var_param_value.to_string());
660    }
661    if let Some(local_var_param_value) = coaching {
662        local_var_form_params.insert("Coaching", local_var_param_value.to_string());
663    }
664    if let Some(local_var_param_value) = call_sid_to_coach {
665        local_var_form_params.insert("CallSidToCoach", local_var_param_value.to_string());
666    }
667    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
668
669    let local_var_req = local_var_req_builder.build()?;
670    let local_var_resp = local_var_client.execute(local_var_req).await?;
671
672    let local_var_status = local_var_resp.status();
673    let local_var_content = local_var_resp.text().await?;
674
675    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
676        serde_json::from_str(&local_var_content).map_err(Error::from)
677    } else {
678        let local_var_entity: Option<UpdateParticipantError> = serde_json::from_str(&local_var_content).ok();
679        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
680        Err(Error::ResponseError(local_var_error))
681    }
682}
683